diff options
| -rw-r--r-- | shell/Makefile.am | 6 | ||||
| -rw-r--r-- | shell/clock.c | 376 | ||||
| -rw-r--r-- | shell/clock.h | 67 | ||||
| -rw-r--r-- | shell/favorites.c | 2 | ||||
| -rw-r--r-- | shell/launcher.c | 430 | ||||
| -rw-r--r-- | shell/launcher.h | 59 | ||||
| -rw-r--r-- | shell/maynard.c | 321 | ||||
| -rw-r--r-- | shell/panel.c | 189 | ||||
| -rw-r--r-- | shell/panel.h | 13 | ||||
| -rw-r--r-- | shell/shell-helper.c | 161 | ||||
| -rw-r--r-- | shell/style.css | 56 | ||||
| -rw-r--r-- | shell/vertical-clock.c | 132 | ||||
| -rw-r--r-- | shell/vertical-clock.h | 56 |
13 files changed, 10 insertions, 1858 deletions
diff --git a/shell/Makefile.am b/shell/Makefile.am index 770f9a7..c587c6e 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -7,18 +7,12 @@ maynard_SOURCES = \ maynard.c \ app-icon.c \ app-icon.h \ - clock.c \ - clock.h \ favorites.c \ favorites.h \ shell-app-system.c \ shell-app-system.h \ panel.c \ panel.h \ - vertical-clock.c \ - vertical-clock.h \ - launcher.c \ - launcher.h \ maynard-resources.c \ maynard-resources.h \ desktop-shell-client-protocol.h \ diff --git a/shell/clock.c b/shell/clock.c deleted file mode 100644 index 180f121..0000000 --- a/shell/clock.c +++ /dev/null @@ -1,376 +0,0 @@ -/* - * Copyright (C) 2014 Collabora Ltd. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - * - * Author: Jonny Lamb <jonny.lamb@collabora.co.uk> - */ - -#include "config.h" - -#include <alsa/asoundlib.h> -#define GNOME_DESKTOP_USE_UNSTABLE_API -#include <libgnome-desktop/gnome-wall-clock.h> - -#include "clock.h" - -enum { - VOLUME_CHANGED, - N_SIGNALS -}; -static guint signals[N_SIGNALS] = { 0 }; - -struct MaynardClockPrivate { - GtkWidget *revealer_clock; - GtkWidget *revealer_system; - GtkWidget *revealer_volume; - - GtkWidget *label; - - GtkWidget *volume_scale; - GtkWidget *volume_image; - - GnomeWallClock *wall_clock; - - snd_mixer_t *mixer_handle; - snd_mixer_elem_t *mixer; - glong min_volume, max_volume; -}; - -G_DEFINE_TYPE(MaynardClock, maynard_clock, GTK_TYPE_WINDOW) - -static void -maynard_clock_init (MaynardClock *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - MAYNARD_CLOCK_TYPE, - MaynardClockPrivate); -} - -static gdouble -alsa_volume_to_percentage (MaynardClock *self, - glong value) -{ - glong range; - - /* min volume isn't always zero unfortunately */ - range = self->priv->max_volume - self->priv->min_volume; - - value -= self->priv->min_volume; - - return (value / (gdouble) range) * 100; -} - -static glong -percentage_to_alsa_volume (MaynardClock *self, - gdouble value) -{ - glong range; - - /* min volume isn't always zero unfortunately */ - range = self->priv->max_volume - self->priv->min_volume; - - return (range * value / 100) + self->priv->min_volume; -} - -static void -volume_changed_cb (GtkRange *range, - MaynardClock *self) -{ - gdouble value; - const gchar *icon_name; - GtkWidget *box; - - value = gtk_range_get_value (range); - - if (self->priv->mixer != NULL) - { - snd_mixer_selem_set_playback_volume_all (self->priv->mixer, - percentage_to_alsa_volume (self, value)); - } - - /* update the icon */ - if (value > 75) - icon_name = "audio-volume-high-symbolic"; - else if (value > 30) - icon_name = "audio-volume-medium-symbolic"; - else if (value > 0) - icon_name = "audio-volume-low-symbolic"; - else - icon_name = "audio-volume-muted-symbolic"; - - box = gtk_widget_get_parent (self->priv->volume_image); - gtk_widget_destroy (self->priv->volume_image); - self->priv->volume_image = gtk_image_new_from_icon_name ( - icon_name, GTK_ICON_SIZE_LARGE_TOOLBAR); - gtk_box_pack_start (GTK_BOX (box), self->priv->volume_image, - FALSE, FALSE, 0); - gtk_widget_show (self->priv->volume_image); - - g_signal_emit (self, signals[VOLUME_CHANGED], 0, value, icon_name); -} - -static gboolean -volume_idle_cb (gpointer data) -{ - MaynardClock *self = MAYNARD_CLOCK (data); - glong volume; - - if (self->priv->mixer != NULL) - { - snd_mixer_selem_get_playback_volume (self->priv->mixer, - SND_MIXER_SCHN_MONO, &volume); - - gtk_range_set_value (GTK_RANGE (self->priv->volume_scale), - alsa_volume_to_percentage (self, volume)); - } - - return G_SOURCE_REMOVE; -} - -static GtkWidget * -create_system_box (MaynardClock *self) -{ - return gtk_label_new ("Not implemented"); -} - -static GtkWidget * -create_volume_box (MaynardClock *self) -{ - GtkWidget *box; - - box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - - self->priv->volume_image = gtk_image_new_from_icon_name ( - "audio-volume-muted-symbolic", - GTK_ICON_SIZE_LARGE_TOOLBAR); - gtk_box_pack_start (GTK_BOX (box), self->priv->volume_image, - FALSE, FALSE, 0); - - self->priv->volume_scale = gtk_scale_new_with_range ( - GTK_ORIENTATION_HORIZONTAL, 0, 100, 1); - gtk_scale_set_draw_value (GTK_SCALE (self->priv->volume_scale), FALSE); - gtk_widget_set_size_request (self->priv->volume_scale, 100, -1); - gtk_box_pack_end (GTK_BOX (box), self->priv->volume_scale, TRUE, TRUE, 0); - - g_signal_connect (self->priv->volume_scale, "value-changed", - G_CALLBACK (volume_changed_cb), self); - - /* set the initial value in an idle so ::volume-changed is emitted - * when other widgets are connected to the signal and can react - * accordingly. */ - g_idle_add (volume_idle_cb, self); - - return box; -} - -static void -wall_clock_notify_cb (GnomeWallClock *wall_clock, - GParamSpec *pspec, - MaynardClock *self) -{ - GDateTime *datetime; - gchar *str; - - datetime = g_date_time_new_now_local (); - - str = g_date_time_format (datetime, - "<span font=\"Droid Sans 32\">%H:%M</span>\n" - "<span font=\"Droid Sans 12\">%d/%m/%Y</span>"); - gtk_label_set_markup (GTK_LABEL (self->priv->label), str); - - g_free (str); - g_date_time_unref (datetime); -} - -static void -setup_mixer (MaynardClock *self) -{ - snd_mixer_selem_id_t *sid; - gint ret; - - /* this is all pretty specific to the rpi */ - - if ((ret = snd_mixer_open (&self->priv->mixer_handle, 0)) < 0) - goto error; - - if ((ret = snd_mixer_attach (self->priv->mixer_handle, "default")) < 0) - goto error; - - if ((ret = snd_mixer_selem_register (self->priv->mixer_handle, NULL, NULL)) < 0) - goto error; - - if ((ret = snd_mixer_load (self->priv->mixer_handle)) < 0) - goto error; - - snd_mixer_selem_id_alloca (&sid); - snd_mixer_selem_id_set_index (sid, 0); - snd_mixer_selem_id_set_name (sid, "PCM"); - self->priv->mixer = snd_mixer_find_selem (self->priv->mixer_handle, sid); - - /* fallback to mixer "Master" */ - if (self->priv->mixer == NULL) - { - snd_mixer_selem_id_set_name (sid, "Master"); - self->priv->mixer = snd_mixer_find_selem (self->priv->mixer_handle, sid); - if (self->priv->mixer == NULL) - goto error; - } - - if ((ret = snd_mixer_selem_get_playback_volume_range (self->priv->mixer, - &self->priv->min_volume, &self->priv->max_volume)) < 0) - goto error; - - return; - -error: - g_debug ("failed to setup mixer: %s", snd_strerror (ret)); - - if (self->priv->mixer_handle != NULL) - snd_mixer_close (self->priv->mixer_handle); - self->priv->mixer_handle = NULL; - self->priv->mixer = NULL; -} - -static void -maynard_clock_constructed (GObject *object) -{ - MaynardClock *self = MAYNARD_CLOCK (object); - GtkWidget *box, *system_box, *volume_box; - - G_OBJECT_CLASS (maynard_clock_parent_class)->constructed (object); - - self->priv->wall_clock = g_object_new (GNOME_TYPE_WALL_CLOCK, NULL); - g_signal_connect (self->priv->wall_clock, "notify::clock", - G_CALLBACK (wall_clock_notify_cb), self); - - gtk_window_set_title (GTK_WINDOW (self), "maynard"); - gtk_window_set_decorated (GTK_WINDOW (self), FALSE); - gtk_widget_realize (GTK_WIDGET (self)); - - gtk_style_context_add_class ( - gtk_widget_get_style_context (GTK_WIDGET (self)), - "maynard-clock"); - - /* the box for the revealers */ - box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_container_add (GTK_CONTAINER (self), box); - - /* volume */ - self->priv->revealer_volume = gtk_revealer_new (); - gtk_revealer_set_transition_type ( - GTK_REVEALER (self->priv->revealer_volume), - GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT); - gtk_revealer_set_reveal_child ( - GTK_REVEALER (self->priv->revealer_volume), FALSE); - gtk_box_pack_start (GTK_BOX (box), self->priv->revealer_volume, - TRUE, TRUE, 0); - - volume_box = create_volume_box (self); - gtk_container_add (GTK_CONTAINER (self->priv->revealer_volume), - volume_box); - - /* system */ - self->priv->revealer_system = gtk_revealer_new (); - gtk_revealer_set_transition_type ( - GTK_REVEALER (self->priv->revealer_system), - GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT); - gtk_revealer_set_reveal_child ( - GTK_REVEALER (self->priv->revealer_system), FALSE); - gtk_box_pack_start (GTK_BOX (box), self->priv->revealer_system, - TRUE, TRUE, 0); - - system_box = create_system_box (self); - gtk_container_add (GTK_CONTAINER (self->priv->revealer_system), - system_box); - - /* clock */ - self->priv->revealer_clock = gtk_revealer_new (); - gtk_revealer_set_transition_type ( - GTK_REVEALER (self->priv->revealer_clock), - GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT); - gtk_revealer_set_reveal_child ( - GTK_REVEALER (self->priv->revealer_clock), TRUE); - gtk_box_pack_start (GTK_BOX (box), self->priv->revealer_clock, - TRUE, TRUE, 0); - - self->priv->label = gtk_label_new (""); - gtk_label_set_justify (GTK_LABEL (self->priv->label), GTK_JUSTIFY_CENTER); - gtk_container_add (GTK_CONTAINER (self->priv->revealer_clock), - self->priv->label); - - /* TODO: work out how to fix the padding properly. this is added to - * fix the broken alignment where the clock appears to the right. */ - gtk_box_pack_start (GTK_BOX (box), gtk_revealer_new (), TRUE, TRUE, 0); - - setup_mixer (self); - - wall_clock_notify_cb (self->priv->wall_clock, NULL, self); -} - -static void -maynard_clock_dispose (GObject *object) -{ - MaynardClock *self = MAYNARD_CLOCK (object); - - g_clear_object (&self->priv->wall_clock); - - if (self->priv->mixer_handle != NULL) - snd_mixer_close (self->priv->mixer_handle); - self->priv->mixer_handle = NULL; - self->priv->mixer = NULL; - - G_OBJECT_CLASS (maynard_clock_parent_class)->dispose (object); -} - -static void -maynard_clock_class_init (MaynardClockClass *klass) -{ - GObjectClass *object_class = (GObjectClass *)klass; - - object_class->constructed = maynard_clock_constructed; - object_class->dispose = maynard_clock_dispose; - - signals[VOLUME_CHANGED] = g_signal_new ("volume-changed", - G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, - NULL, G_TYPE_NONE, 2, G_TYPE_DOUBLE, G_TYPE_STRING); - - g_type_class_add_private (object_class, sizeof (MaynardClockPrivate)); -} - -GtkWidget * -maynard_clock_new (void) -{ - return g_object_new (MAYNARD_CLOCK_TYPE, - NULL); -} - -void -maynard_clock_show_section (MaynardClock *self, - MaynardClockSection section) -{ - gtk_revealer_set_reveal_child ( - GTK_REVEALER (self->priv->revealer_clock), - section == MAYNARD_CLOCK_SECTION_CLOCK); - - gtk_revealer_set_reveal_child ( - GTK_REVEALER (self->priv->revealer_system), - section == MAYNARD_CLOCK_SECTION_SYSTEM); - - gtk_revealer_set_reveal_child ( - GTK_REVEALER (self->priv->revealer_volume), - section == MAYNARD_CLOCK_SECTION_VOLUME); -} diff --git a/shell/clock.h b/shell/clock.h deleted file mode 100644 index 8044a27..0000000 --- a/shell/clock.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2014 Collabora Ltd. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - * - * Author: Jonny Lamb <jonny.lamb@collabora.co.uk> - */ - -#ifndef __MAYNARD_CLOCK_H__ -#define __MAYNARD_CLOCK_H__ - -#include <gtk/gtk.h> - -#include "panel.h" - -#define MAYNARD_CLOCK_TYPE (maynard_clock_get_type ()) -#define MAYNARD_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAYNARD_CLOCK_TYPE, MaynardClock)) -#define MAYNARD_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAYNARD_CLOCK_TYPE, MaynardClockClass)) -#define MAYNARD_IS_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAYNARD_CLOCK_TYPE)) -#define MAYNARD_IS_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAYNARD_CLOCK_TYPE)) -#define MAYNARD_CLOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAYNARD_CLOCK_TYPE, MaynardClockClass)) - -typedef struct MaynardClock MaynardClock; -typedef struct MaynardClockClass MaynardClockClass; -typedef struct MaynardClockPrivate MaynardClockPrivate; - -struct MaynardClock -{ - GtkWindow parent; - - MaynardClockPrivate *priv; -}; - -struct MaynardClockClass -{ - GtkWindowClass parent_class; -}; - -#define MAYNARD_CLOCK_WIDTH (MAYNARD_PANEL_WIDTH * 2.6) -#define MAYNARD_CLOCK_HEIGHT (MAYNARD_PANEL_WIDTH * 2) - -typedef enum { - MAYNARD_CLOCK_SECTION_CLOCK, - MAYNARD_CLOCK_SECTION_SYSTEM, - MAYNARD_CLOCK_SECTION_VOLUME -} MaynardClockSection; - -GType maynard_clock_get_type (void) G_GNUC_CONST; - -GtkWidget * maynard_clock_new (void); - -void maynard_clock_show_section (MaynardClock *self, MaynardClockSection section); - -#endif /* __MAYNARD_CLOCK_H__ */ diff --git a/shell/favorites.c b/shell/favorites.c index 7f15e76..eaa2f77 100644 --- a/shell/favorites.c +++ b/shell/favorites.c @@ -155,6 +155,6 @@ GtkWidget * maynard_favorites_new (void) { return g_object_new (MAYNARD_TYPE_FAVORITES, - "orientation", GTK_ORIENTATION_VERTICAL, + "orientation", GTK_ORIENTATION_HORIZONTAL, NULL); } diff --git a/shell/launcher.c b/shell/launcher.c deleted file mode 100644 index bce7b9d..0000000 --- a/shell/launcher.c +++ /dev/null @@ -1,430 +0,0 @@ -/* - * Copyright (C) 2013-2014 Collabora Ltd. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - * - * Authors: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk> - * Jonny Lamb <jonny.lamb@collabora.co.uk> - */ - -#include "config.h" - -#include "launcher.h" - -#include "clock.h" -#include "panel.h" -#include "shell-app-system.h" - -enum { - PROP_0, - PROP_BACKGROUND, -}; - -enum { - APP_LAUNCHED, - N_SIGNALS -}; -static guint signals[N_SIGNALS] = { 0 }; - -struct MaynardLauncherPrivate { - /* background widget so we know the output size */ - GtkWidget *background; - ShellAppSystem *app_system; - GtkWidget *scrolled_window; - GtkWidget *grid; -}; - -G_DEFINE_TYPE(MaynardLauncher, maynard_launcher, GTK_TYPE_WINDOW) - -/* each grid item is 114x114 */ -#define GRID_ITEM_WIDTH 114 -#define GRID_ITEM_HEIGHT 114 - -static void -maynard_launcher_init (MaynardLauncher *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - MAYNARD_LAUNCHER_TYPE, - MaynardLauncherPrivate); -} - -static gint -sort_apps (gconstpointer a, - gconstpointer b) -{ - GAppInfo *info1 = G_APP_INFO (a); - GAppInfo *info2 = G_APP_INFO (b); - gchar *s1, *s2; - gint ret; - - s1 = g_utf8_casefold (g_app_info_get_display_name (info1), -1); - s2 = g_utf8_casefold (g_app_info_get_display_name (info2), -1); - - ret = g_strcmp0 (s1, s2); - - g_free (s1); - g_free (s2); - - return ret; -} - -static gboolean -get_child_position_cb (GtkOverlay *overlay, - GtkWidget *widget, - GdkRectangle *allocation, - gpointer user_data) -{ - GtkOverlayClass *klass = GTK_OVERLAY_GET_CLASS (overlay); - - klass->get_child_position (overlay, widget, allocation); - - /* use the same valign and halign properties, but given we have a - * border of 1px, respect it and don't draw the overlay widget over - * the border. */ - allocation->x += 1; - allocation->y -= 1; - allocation->width -= 2; - - return TRUE; -} - -static gboolean -app_launched_idle_cb (gpointer data) -{ - MaynardLauncher *self = data; - GtkAdjustment *adjustment; - - /* make the scrolled window go back to the top */ - - adjustment = gtk_scrolled_window_get_vadjustment ( - GTK_SCROLLED_WINDOW (self->priv->scrolled_window)); - - gtk_adjustment_set_value (adjustment, 0.0); - - return G_SOURCE_REMOVE; -} - -static void -clicked_cb (GtkWidget *widget, - GDesktopAppInfo *info) -{ - MaynardLauncher *self; - - g_app_info_launch (G_APP_INFO (info), NULL, NULL, NULL); - - self = g_object_get_data (G_OBJECT (widget), "launcher"); - g_assert (self); - g_signal_emit (self, signals[APP_LAUNCHED], 0); - - /* do this in an idle so it's not done so obviously onscreen */ - g_idle_add (app_launched_idle_cb, self); -} - -static gboolean -app_enter_cb (GtkWidget *widget, - GdkEvent *event, - GtkWidget *revealer) -{ - gtk_revealer_set_reveal_child (GTK_REVEALER (revealer), TRUE); - return FALSE; -} - -static gboolean -app_leave_cb (GtkWidget *widget, - GdkEvent *event, - GtkWidget *revealer) -{ - gtk_revealer_set_reveal_child (GTK_REVEALER (revealer), FALSE); - return FALSE; -} - -static GtkWidget * -app_launcher_new_from_desktop_info (MaynardLauncher *self, - GDesktopAppInfo *info) -{ - GIcon *icon; - GtkWidget *alignment; - GtkWidget *image; - GtkWidget *button; - GtkWidget *overlay; - GtkWidget *revealer; - GtkWidget *label; - GtkWidget *ebox; - - /* we need an ebox to catch enter and leave events */ - ebox = gtk_event_box_new (); - gtk_style_context_add_class (gtk_widget_get_style_context (ebox), - "maynard-grid-item"); - - /* we use an overlay so we can have the app icon showing but use a - * GtkRevealer to show a label of the app's name. */ - overlay = gtk_overlay_new (); - gtk_container_add (GTK_CONTAINER (ebox), overlay); - - /* ...but each item has a border of 1px and we don't want the - * revealer to paint into the border, so overload this function to - * know where to put it. */ - g_signal_connect (overlay, "get-child-position", - G_CALLBACK (get_child_position_cb), NULL); - - revealer = gtk_revealer_new (); - g_object_set (revealer, - "halign", GTK_ALIGN_FILL, /* all the width */ - "valign", GTK_ALIGN_END, /* only at the bottom */ - NULL); - gtk_revealer_set_transition_type (GTK_REVEALER (revealer), - GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP); - gtk_revealer_set_reveal_child (GTK_REVEALER (revealer), FALSE); - gtk_overlay_add_overlay (GTK_OVERLAY (overlay), revealer); - - /* app name */ - label = gtk_label_new (g_app_info_get_display_name (G_APP_INFO (info))); - gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); - gtk_style_context_add_class (gtk_widget_get_style_context (label), "maynard-grid-label"); - gtk_container_add (GTK_CONTAINER (revealer), label); - - /* icon button to load the app */ - alignment = gtk_alignment_new (0.5, 0.5, 1, 1); - gtk_container_add (GTK_CONTAINER (overlay), alignment); - - icon = g_app_info_get_icon (G_APP_INFO (info)); - image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG); - button = gtk_button_new (); - gtk_style_context_remove_class ( - gtk_widget_get_style_context (button), - "button"); - gtk_style_context_remove_class ( - gtk_widget_get_style_context (button), - "image-button"); - gtk_button_set_image (GTK_BUTTON (button), image); - g_object_set (image, - "margin", 30, - NULL); - gtk_container_add (GTK_CONTAINER (alignment), button); - - /* TODO: a bit ugly */ - g_object_set_data (G_OBJECT (button), "launcher", self); - g_signal_connect (button, "clicked", G_CALLBACK (clicked_cb), info); - - /* now we have set everything up, we can refernce the ebox and the - * revealer. enter will show the label and leave will hide the label. */ - g_signal_connect (ebox, "enter-notify-event", G_CALLBACK (app_enter_cb), revealer); - g_signal_connect (ebox, "leave-notify-event", G_CALLBACK (app_leave_cb), revealer); - - return ebox; -} - -static void -installed_changed_cb (ShellAppSystem *app_system, - MaynardLauncher *self) -{ - GHashTable *entries = shell_app_system_get_entries (app_system); - GList *l, *values; - - gint output_width, output_height; - guint cols; - guint left, top; - - /* remove all children first */ - gtk_container_foreach (GTK_CONTAINER (self->priv->grid), - (GtkCallback) gtk_widget_destroy, NULL); - - values = g_hash_table_get_values (entries); - values = g_list_sort (values, sort_apps); - - maynard_launcher_calculate (self, NULL, NULL, &cols); - cols--; /* because we start from zero here */ - - left = top = 0; - for (l = values; l; l = l->next) - { - GDesktopAppInfo *info = G_DESKTOP_APP_INFO (l->data); - GtkWidget *app = app_launcher_new_from_desktop_info (self, info); - - gtk_grid_attach (GTK_GRID (self->priv->grid), app, left++, top, 1, 1); - - if (left > cols) - { - left = 0; - top++; - } - } - - g_list_free (values); - - gtk_widget_show_all (self->priv->grid); -} - -static void -background_size_allocate_cb (GtkWidget *widget, - GdkRectangle *allocation, - MaynardLauncher *self) -{ - installed_changed_cb (self->priv->app_system, self); -} - -static void -maynard_launcher_constructed (GObject *object) -{ - MaynardLauncher *self = MAYNARD_LAUNCHER (object); - - G_OBJECT_CLASS (maynard_launcher_parent_class)->constructed (object); - - /* window properties */ - gtk_window_set_title (GTK_WINDOW (self), "maynard"); - gtk_window_set_decorated (GTK_WINDOW (self), FALSE); - gtk_widget_realize (GTK_WIDGET (self)); - - /* make it black and slightly alpha */ - gtk_style_context_add_class ( - gtk_widget_get_style_context (GTK_WIDGET (self)), - "maynard-grid"); - - /* scroll it */ - self->priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_container_add (GTK_CONTAINER (self), self->priv->scrolled_window); - - /* main grid for apps */ - self->priv->grid = gtk_grid_new (); - gtk_container_add (GTK_CONTAINER (self->priv->scrolled_window), - self->priv->grid); - - /* fill the grid with apps */ - self->priv->app_system = shell_app_system_get_default (); - g_signal_connect (self->priv->app_system, "installed-changed", - G_CALLBACK (installed_changed_cb), self); - - /* refill the grid if the background is changed */ - g_assert (self->priv->background != NULL); - g_signal_connect (self->priv->background, "size-allocate", - G_CALLBACK (background_size_allocate_cb), self); - - /* now actually fill the grid */ - installed_changed_cb (self->priv->app_system, self); -} - -static void -maynard_launcher_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - MaynardLauncher *self = MAYNARD_LAUNCHER (object); - - switch (param_id) - { - case PROP_BACKGROUND: - g_value_set_object (value, self->priv->background); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -static void -maynard_launcher_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - MaynardLauncher *self = MAYNARD_LAUNCHER (object); - - switch (param_id) - { - case PROP_BACKGROUND: - self->priv->background = g_value_get_object (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -static void -maynard_launcher_class_init (MaynardLauncherClass *klass) -{ - GObjectClass *object_class = (GObjectClass *)klass; - - object_class->constructed = maynard_launcher_constructed; - object_class->get_property = maynard_launcher_get_property; - object_class->set_property = maynard_launcher_set_property; - - g_object_class_install_property (object_class, PROP_BACKGROUND, - g_param_spec_object ("background", - "background", - "The #GtkWidget of the background of the output", - GTK_TYPE_WIDGET, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); - - signals[APP_LAUNCHED] = g_signal_new ("app-launched", - G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, - NULL, G_TYPE_NONE, 0); - - g_type_class_add_private (object_class, sizeof (MaynardLauncherPrivate)); -} - -GtkWidget * -maynard_launcher_new (GtkWidget *background_widget) -{ - return g_object_new (MAYNARD_LAUNCHER_TYPE, - "background", background_widget, - NULL); -} - -void -maynard_launcher_calculate (MaynardLauncher *self, - gint *grid_window_width, - gint *grid_window_height, - gint *grid_cols) -{ - gint output_width, output_height, panel_height; - gint usable_width, usable_height; - guint cols, rows; - guint num_apps; - guint scrollbar_width = 13; - - gtk_widget_get_size_request (self->priv->background, - &output_width, &output_height); - panel_height = output_height * MAYNARD_PANEL_HEIGHT_RATIO; - - usable_width = output_width - MAYNARD_PANEL_WIDTH - scrollbar_width; - /* don't go further down than the panel */ - usable_height = panel_height - MAYNARD_CLOCK_HEIGHT; - - /* try and fill half the screen, otherwise round down */ - cols = (int) ((usable_width / 2.0) / GRID_ITEM_WIDTH); - /* try to fit as many rows as possible in the panel height we have */ - rows = (int) (usable_height / GRID_ITEM_HEIGHT); - - /* we don't need to include the scrollbar if we already have enough - * space for all the apps. */ - num_apps = g_hash_table_size ( - shell_app_system_get_entries (self->priv->app_system)); - if ((cols * rows) >= num_apps) - scrollbar_width = 0; - - /* done! */ - - if (grid_window_width) - *grid_window_width = (cols * GRID_ITEM_WIDTH) + scrollbar_width; - - if (grid_window_height) - *grid_window_height = (rows * GRID_ITEM_HEIGHT); - - if (grid_cols) - *grid_cols = cols; -} diff --git a/shell/launcher.h b/shell/launcher.h deleted file mode 100644 index 225c6cb..0000000 --- a/shell/launcher.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2013-2014 Collabora Ltd. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - * - * Authors: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk> - * Jonny Lamb <jonny.lamb@collabora.co.uk> - */ - -#ifndef __MAYNARD_LAUNCHER_H__ -#define __MAYNARD_LAUNCHER_H__ - -#include <gtk/gtk.h> - -#define MAYNARD_LAUNCHER_TYPE (maynard_launcher_get_type ()) -#define MAYNARD_LAUNCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAYNARD_LAUNCHER_TYPE, MaynardLauncher)) -#define MAYNARD_LAUNCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAYNARD_LAUNCHER_TYPE, MaynardLauncherClass)) -#define MAYNARD_IS_LAUNCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAYNARD_LAUNCHER_TYPE)) -#define MAYNARD_IS_LAUNCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAYNARD_LAUNCHER_TYPE)) -#define MAYNARD_LAUNCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAYNARD_LAUNCHER_TYPE, MaynardLauncherClass)) - -typedef struct MaynardLauncher MaynardLauncher; -typedef struct MaynardLauncherClass MaynardLauncherClass; -typedef struct MaynardLauncherPrivate MaynardLauncherPrivate; - -struct MaynardLauncher -{ - GtkWindow parent; - - MaynardLauncherPrivate *priv; -}; - -struct MaynardLauncherClass -{ - GtkWindowClass parent_class; -}; - -GType maynard_launcher_get_type (void) G_GNUC_CONST; - -GtkWidget * maynard_launcher_new (GtkWidget *background_widget); - -void maynard_launcher_calculate (MaynardLauncher *self, - gint *grid_window_width, gint *grid_window_height, - gint *grid_cols); - -#endif /* __MAYNARD_LAUNCHER_H__ */ diff --git a/shell/maynard.c b/shell/maynard.c index 85da0fc..1939e34 100644 --- a/shell/maynard.c +++ b/shell/maynard.c @@ -34,15 +34,12 @@ #include "maynard-resources.h" #include "app-icon.h" -#include "clock.h" #include "favorites.h" -#include "launcher.h" #include "panel.h" -#include "vertical-clock.h" extern char **environ; /* defined by libc */ -#define DEFAULT_BACKGROUND "/usr/share/wallpapers/Hanami/contents/images/3872x2592.jpg" +#define DEFAULT_BACKGROUND "/usr/share/wallpapers/Golden_Ripples/contents/images/1920x1200.jpg" struct element { GtkWidget *window; @@ -61,46 +58,8 @@ struct desktop { struct element *background; struct element *panel; - struct element *launcher_grid; - struct element *clock; - - guint initial_panel_timeout_id; - guint hide_panel_idle_id; - - gboolean grid_visible; - gboolean system_visible; - gboolean volume_visible; }; -static gboolean panel_window_enter_cb (GtkWidget *widget, - GdkEventCrossing *event, struct desktop *desktop); -static gboolean panel_window_leave_cb (GtkWidget *widget, - GdkEventCrossing *event, struct desktop *desktop); - -static gboolean -connect_enter_leave_signals (gpointer data) -{ - struct desktop *desktop = data; - GList *l; - - g_signal_connect (desktop->panel->window, "enter-notify-event", - G_CALLBACK (panel_window_enter_cb), desktop); - g_signal_connect (desktop->panel->window, "leave-notify-event", - G_CALLBACK (panel_window_leave_cb), desktop); - - g_signal_connect (desktop->clock->window, "enter-notify-event", - G_CALLBACK (panel_window_enter_cb), desktop); - g_signal_connect (desktop->clock->window, "leave-notify-event", - G_CALLBACK (panel_window_leave_cb), desktop); - - g_signal_connect (desktop->launcher_grid->window, "enter-notify-event", - G_CALLBACK (panel_window_enter_cb), desktop); - g_signal_connect (desktop->launcher_grid->window, "leave-notify-event", - G_CALLBACK (panel_window_leave_cb), desktop); - - return G_SOURCE_REMOVE; -} - static void desktop_shell_configure (void *data, struct desktop_shell *desktop_shell, @@ -109,42 +68,14 @@ desktop_shell_configure (void *data, int32_t width, int32_t height) { struct desktop *desktop = data; - int window_height; - int grid_width, grid_height; gtk_widget_set_size_request (desktop->background->window, width, height); - /* TODO: make this height a little nicer */ - window_height = height * MAYNARD_PANEL_HEIGHT_RATIO; gtk_window_resize (GTK_WINDOW (desktop->panel->window), - MAYNARD_PANEL_WIDTH, window_height); - - maynard_launcher_calculate (MAYNARD_LAUNCHER (desktop->launcher_grid->window), - &grid_width, &grid_height, NULL); - gtk_widget_set_size_request (desktop->launcher_grid->window, - grid_width, grid_height); - - shell_helper_move_surface (desktop->helper, desktop->panel->surface, - 0, (height - window_height) / 2); - - gtk_window_resize (GTK_WINDOW (desktop->clock->window), - MAYNARD_CLOCK_WIDTH, MAYNARD_CLOCK_HEIGHT); - - shell_helper_move_surface (desktop->helper, desktop->clock->surface, - MAYNARD_PANEL_WIDTH, (height - window_height) / 2); - - shell_helper_move_surface (desktop->helper, - desktop->launcher_grid->surface, - - grid_width, - ((height - window_height) / 2) + MAYNARD_CLOCK_HEIGHT); + width, MAYNARD_PANEL_HEIGHT); desktop_shell_desktop_ready (desktop->shell); - - /* TODO: why does the panel signal leave on drawing for - * startup? we don't want to have to have this silly - * timeout. */ - g_timeout_add_seconds (1, connect_enter_leave_signals, desktop); } static void @@ -168,238 +99,9 @@ static const struct desktop_shell_listener listener = { }; static void -launcher_grid_toggle (GtkWidget *widget, - struct desktop *desktop) -{ - if (desktop->grid_visible) - { - shell_helper_slide_surface_back (desktop->helper, - desktop->launcher_grid->surface); - } - else - { - int width; - - gtk_widget_get_size_request (desktop->launcher_grid->window, - &width, NULL); - - shell_helper_slide_surface (desktop->helper, - desktop->launcher_grid->surface, - width + MAYNARD_PANEL_WIDTH, 0); - } - - desktop->grid_visible = !desktop->grid_visible; -} - -static void -launcher_grid_create (struct desktop *desktop) -{ - struct element *launcher_grid; - GdkWindow *gdk_window; - - launcher_grid = malloc (sizeof *launcher_grid); - memset (launcher_grid, 0, sizeof *launcher_grid); - - launcher_grid->window = maynard_launcher_new (desktop->background->window); - gdk_window = gtk_widget_get_window (launcher_grid->window); - launcher_grid->surface = gdk_wayland_window_get_wl_surface (gdk_window); - - gdk_wayland_window_set_use_custom_surface (gdk_window); - shell_helper_add_surface_to_layer (desktop->helper, - launcher_grid->surface, - desktop->panel->surface); - - g_signal_connect (launcher_grid->window, "app-launched", - G_CALLBACK (launcher_grid_toggle), desktop); - - gtk_widget_show_all (launcher_grid->window); - - desktop->launcher_grid = launcher_grid; -} - -static void -volume_changed_cb (MaynardClock *clock, - gdouble value, - const gchar *icon_name, - struct desktop *desktop) -{ - maynard_panel_set_volume_icon_name ( - MAYNARD_PANEL (desktop->panel->window), icon_name); -} - -static GtkWidget * -clock_create (struct desktop *desktop) -{ - struct element *clock; - GdkWindow *gdk_window; - - clock = malloc (sizeof *clock); - memset (clock, 0, sizeof *clock); - - clock->window = maynard_clock_new (); - - g_signal_connect (clock->window, "volume-changed", - G_CALLBACK (volume_changed_cb), desktop); - - gdk_window = gtk_widget_get_window (clock->window); - clock->surface = gdk_wayland_window_get_wl_surface (gdk_window); - - gdk_wayland_window_set_use_custom_surface (gdk_window); - shell_helper_add_surface_to_layer (desktop->helper, clock->surface, - desktop->panel->surface); - - gtk_widget_show_all (clock->window); - - desktop->clock = clock; -} - -static void -button_toggled_cb (struct desktop *desktop, - gboolean *visible, - gboolean *not_visible) -{ - *visible = !*visible; - *not_visible = FALSE; - - if (desktop->system_visible) - { - maynard_clock_show_section (MAYNARD_CLOCK (desktop->clock->window), - MAYNARD_CLOCK_SECTION_SYSTEM); - maynard_panel_show_previous (MAYNARD_PANEL (desktop->panel->window), - MAYNARD_PANEL_BUTTON_SYSTEM); - } - else if (desktop->volume_visible) - { - maynard_clock_show_section (MAYNARD_CLOCK (desktop->clock->window), - MAYNARD_CLOCK_SECTION_VOLUME); - maynard_panel_show_previous (MAYNARD_PANEL (desktop->panel->window), - MAYNARD_PANEL_BUTTON_VOLUME); - } - else - { - maynard_clock_show_section (MAYNARD_CLOCK (desktop->clock->window), - MAYNARD_CLOCK_SECTION_CLOCK); - maynard_panel_show_previous (MAYNARD_PANEL (desktop->panel->window), - MAYNARD_PANEL_BUTTON_NONE); - } -} - -static void -system_toggled_cb (GtkWidget *widget, - struct desktop *desktop) -{ - button_toggled_cb (desktop, - &desktop->system_visible, - &desktop->volume_visible); -} - -static void -volume_toggled_cb (GtkWidget *widget, - struct desktop *desktop) -{ - button_toggled_cb (desktop, - &desktop->volume_visible, - &desktop->system_visible); -} - -static gboolean -panel_window_enter_cb (GtkWidget *widget, - GdkEventCrossing *event, - struct desktop *desktop) -{ - if (desktop->initial_panel_timeout_id > 0) - { - g_source_remove (desktop->initial_panel_timeout_id); - desktop->initial_panel_timeout_id = 0; - } - - if (desktop->hide_panel_idle_id > 0) - { - g_source_remove (desktop->hide_panel_idle_id); - desktop->hide_panel_idle_id = 0; - return; - } - - shell_helper_slide_surface_back (desktop->helper, - desktop->panel->surface); - shell_helper_slide_surface_back (desktop->helper, - desktop->clock->surface); - - maynard_panel_set_expand (MAYNARD_PANEL (desktop->panel->window), TRUE); - - return FALSE; -} - -static gboolean -leave_panel_idle_cb (gpointer data) -{ - struct desktop *desktop = data; - gint width; - - desktop->hide_panel_idle_id = 0; - - gtk_window_get_size (GTK_WINDOW (desktop->clock->window), - &width, NULL); - - shell_helper_slide_surface (desktop->helper, - desktop->panel->surface, - MAYNARD_VERTICAL_CLOCK_WIDTH - MAYNARD_PANEL_WIDTH, 0); - shell_helper_slide_surface (desktop->helper, - desktop->clock->surface, - MAYNARD_VERTICAL_CLOCK_WIDTH - MAYNARD_PANEL_WIDTH - width, 0); - - maynard_panel_set_expand (MAYNARD_PANEL (desktop->panel->window), FALSE); - - maynard_clock_show_section (MAYNARD_CLOCK (desktop->clock->window), - MAYNARD_CLOCK_SECTION_CLOCK); - maynard_panel_show_previous (MAYNARD_PANEL (desktop->panel->window), - MAYNARD_PANEL_BUTTON_NONE); - desktop->system_visible = FALSE; - desktop->volume_visible = FALSE; - - return G_SOURCE_REMOVE; -} - -static gboolean -panel_window_leave_cb (GtkWidget *widget, - GdkEventCrossing *event, - struct desktop *desktop) -{ - if (desktop->initial_panel_timeout_id > 0) - { - g_source_remove (desktop->initial_panel_timeout_id); - desktop->initial_panel_timeout_id = 0; - } - - if (desktop->hide_panel_idle_id > 0) - return; - - if (desktop->grid_visible) - return; - - desktop->hide_panel_idle_id = g_idle_add (leave_panel_idle_cb, desktop); - - return FALSE; -} - -static gboolean -panel_hide_timeout_cb (gpointer data) -{ - struct desktop *desktop = data; - - panel_window_leave_cb (NULL, NULL, desktop); - - return G_SOURCE_REMOVE; -} - -static void favorite_launched_cb (MaynardPanel *panel, struct desktop *desktop) { - if (desktop->grid_visible) - launcher_grid_toggle (desktop->launcher_grid->window, desktop); - - panel_window_leave_cb (NULL, NULL, desktop); } static void @@ -413,18 +115,9 @@ panel_create (struct desktop *desktop) panel->window = maynard_panel_new (); - g_signal_connect (panel->window, "app-menu-toggled", - G_CALLBACK (launcher_grid_toggle), desktop); - g_signal_connect (panel->window, "system-toggled", - G_CALLBACK (system_toggled_cb), desktop); - g_signal_connect (panel->window, "volume-toggled", - G_CALLBACK (volume_toggled_cb), desktop); g_signal_connect (panel->window, "favorite-launched", G_CALLBACK (favorite_launched_cb), desktop); - desktop->initial_panel_timeout_id = - g_timeout_add_seconds (2, panel_hide_timeout_cb, desktop); - /* set it up as the panel */ gdk_window = gtk_widget_get_window (panel->window); gdk_wayland_window_set_use_custom_surface (gdk_window); @@ -433,7 +126,7 @@ panel_create (struct desktop *desktop) desktop_shell_set_user_data (desktop->shell, desktop); desktop_shell_set_panel (desktop->shell, desktop->output, panel->surface); desktop_shell_set_panel_position (desktop->shell, - DESKTOP_SHELL_PANEL_POSITION_LEFT); + DESKTOP_SHELL_PANEL_POSITION_TOP); shell_helper_set_panel (desktop->helper, panel->surface); gtk_widget_show_all (panel->window); @@ -646,18 +339,12 @@ main (int argc, return -1; } - desktop->grid_visible = FALSE; - desktop->system_visible = FALSE; - desktop->volume_visible = FALSE; - css_setup (desktop); background_create (desktop); - /* panel needs to be first so the clock and launcher grid can + /* panel needs to be first so everything else can * be added to its layer */ panel_create (desktop); - clock_create (desktop); - launcher_grid_create (desktop); gtk_main (); diff --git a/shell/panel.c b/shell/panel.c index 44ab5e3..ca6047f 100644 --- a/shell/panel.c +++ b/shell/panel.c @@ -25,12 +25,8 @@ #include "app-icon.h" #include "favorites.h" -#include "vertical-clock.h" enum { - APP_MENU_TOGGLED, - SYSTEM_TOGGLED, - VOLUME_TOGGLED, FAVORITE_LAUNCHED, N_SIGNALS }; @@ -38,15 +34,6 @@ static guint signals[N_SIGNALS] = { 0 }; struct MaynardPanelPrivate { gboolean hidden; - - GtkWidget *revealer_buttons; /* for the top buttons */ - GtkWidget *revealer_clock; /* for the vertical clock */ - - GtkWidget *system_button; - - gboolean volume_showing; - GtkWidget *volume_button; - gchar *volume_icon_name; }; G_DEFINE_TYPE(MaynardPanel, maynard_panel, GTK_TYPE_WINDOW) @@ -57,8 +44,6 @@ maynard_panel_init (MaynardPanel *self) self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MAYNARD_PANEL_TYPE, MaynardPanelPrivate); - - self->priv->volume_icon_name = g_strdup ("audio-volume-high-symbolic"); } static gboolean @@ -80,27 +65,6 @@ widget_connect_enter_signal (MaynardPanel *self, } static void -app_menu_button_clicked_cb (GtkButton *button, - MaynardPanel *self) -{ - g_signal_emit (self, signals[APP_MENU_TOGGLED], 0); -} - -static void -system_button_clicked_cb (GtkButton *button, - MaynardPanel *self) -{ - g_signal_emit (self, signals[SYSTEM_TOGGLED], 0); -} - -static void -volume_button_clicked_cb (GtkButton *button, - MaynardPanel *self) -{ - g_signal_emit (self, signals[VOLUME_TOGGLED], 0); -} - -static void favorite_launched_cb (MaynardFavorites *favorites, MaynardPanel *self) { @@ -129,91 +93,10 @@ maynard_panel_constructed (GObject *object) gtk_widget_get_style_context (GTK_WIDGET (self)), "maynard-panel"); - /* main vbox */ - main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); + /* main hbox */ + main_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_container_add (GTK_CONTAINER (self), main_box); - /* for the top buttons and vertical clock we have a few more - * boxes. the hbox has two cells. in each cell there is a - * GtkRevealer for hiding and showing the content. only one revealer - * is ever visibile at one point and transitions happen at the same - * time so the width stays constant (the animation duration is the - * same). the first revealer contains another box which has the two - * wifi and sound buttons. the second revealer has the vertical - * clock widget. - */ - - /* GtkBoxes seem to eat up enter/leave events, so let's use an event - * box for the entire thing. */ - ebox = gtk_event_box_new (); - gtk_box_pack_start (GTK_BOX (main_box), ebox, FALSE, FALSE, 0); - widget_connect_enter_signal (self, ebox); - - menu_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_container_add (GTK_CONTAINER (ebox), menu_box); - - /* revealer for the top buttons */ - self->priv->revealer_buttons = gtk_revealer_new (); - gtk_revealer_set_transition_type (GTK_REVEALER (self->priv->revealer_buttons), - GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT); - gtk_revealer_set_reveal_child (GTK_REVEALER (self->priv->revealer_buttons), - TRUE); - gtk_box_pack_start (GTK_BOX (menu_box), - self->priv->revealer_buttons, FALSE, FALSE, 0); - - /* the box for the top buttons */ - buttons_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - gtk_container_add (GTK_CONTAINER (self->priv->revealer_buttons), buttons_box); - - /* system button */ - ebox = gtk_event_box_new (); - gtk_box_pack_start (GTK_BOX (buttons_box), ebox, FALSE, FALSE, 0); - button = gtk_button_new_from_icon_name ("emblem-system-symbolic", - GTK_ICON_SIZE_LARGE_TOOLBAR); - gtk_style_context_add_class (gtk_widget_get_style_context (button), - "maynard-system"); - gtk_style_context_remove_class (gtk_widget_get_style_context (button), - "button"); - gtk_style_context_remove_class (gtk_widget_get_style_context (button), - "image-button"); - g_signal_connect (button, "clicked", - G_CALLBACK (system_button_clicked_cb), self); - gtk_container_add (GTK_CONTAINER (ebox), button); - widget_connect_enter_signal (self, ebox); - self->priv->system_button = button; - - /* sound button */ - ebox = gtk_event_box_new (); - gtk_box_pack_start (GTK_BOX (buttons_box), ebox, FALSE, FALSE, 0); - button = gtk_button_new_from_icon_name (self->priv->volume_icon_name, - GTK_ICON_SIZE_LARGE_TOOLBAR); - gtk_style_context_add_class (gtk_widget_get_style_context (button), - "maynard-audio"); - gtk_style_context_remove_class (gtk_widget_get_style_context (button), - "button"); - gtk_style_context_remove_class (gtk_widget_get_style_context (button), - "image-button"); - g_signal_connect (button, "clicked", - G_CALLBACK (volume_button_clicked_cb), self); - gtk_container_add (GTK_CONTAINER (ebox), button); - widget_connect_enter_signal (self, ebox); - self->priv->volume_button = button; - - /* revealer for the vertical clock */ - self->priv->revealer_clock = gtk_revealer_new (); - gtk_revealer_set_transition_type (GTK_REVEALER (self->priv->revealer_clock), - GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT); - gtk_revealer_set_reveal_child (GTK_REVEALER (self->priv->revealer_clock), - FALSE); - gtk_box_pack_start (GTK_BOX (menu_box), - self->priv->revealer_clock, FALSE, FALSE, 0); - - /* vertical clock */ - gtk_container_add (GTK_CONTAINER (self->priv->revealer_clock), - maynard_vertical_clock_new ()); - - /* end of the menu buttons and vertical clock */ - /* favorites */ ebox = gtk_event_box_new (); gtk_box_pack_start (GTK_BOX (main_box), ebox, FALSE, FALSE, 0); @@ -224,18 +107,8 @@ maynard_panel_constructed (GObject *object) g_signal_connect (favorites, "app-launched", G_CALLBACK (favorite_launched_cb), self); - /* bottom app menu button */ - ebox = gtk_event_box_new (); - gtk_box_pack_end (GTK_BOX (main_box), ebox, FALSE, FALSE, 0); - button = maynard_app_icon_new ("view-grid-symbolic"); - g_signal_connect (button, "clicked", - G_CALLBACK (app_menu_button_clicked_cb), self); - gtk_container_add (GTK_CONTAINER (ebox), button); - widget_connect_enter_signal (self, ebox); - /* done */ self->priv->hidden = FALSE; - self->priv->volume_showing = FALSE; } static void @@ -243,9 +116,6 @@ maynard_panel_dispose (GObject *object) { MaynardPanel *self = MAYNARD_PANEL (object); - g_free (self->priv->volume_icon_name); - self->priv->volume_icon_name = NULL; - G_OBJECT_CLASS (maynard_panel_parent_class)->dispose (object); } @@ -258,18 +128,6 @@ maynard_panel_class_init (MaynardPanelClass *klass) object_class->constructed = maynard_panel_constructed; object_class->dispose = maynard_panel_dispose; - signals[APP_MENU_TOGGLED] = g_signal_new ("app-menu-toggled", - G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, - NULL, G_TYPE_NONE, 0); - - signals[SYSTEM_TOGGLED] = g_signal_new ("system-toggled", - G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, - NULL, G_TYPE_NONE, 0); - - signals[VOLUME_TOGGLED] = g_signal_new ("volume-toggled", - G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, - NULL, G_TYPE_NONE, 0); - signals[FAVORITE_LAUNCHED] = g_signal_new ("favorite-launched", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0); @@ -284,14 +142,6 @@ maynard_panel_new (void) NULL); } -void -maynard_panel_set_expand (MaynardPanel *self, - gboolean expand) -{ - gtk_revealer_set_reveal_child (GTK_REVEALER (self->priv->revealer_buttons), expand); - gtk_revealer_set_reveal_child (GTK_REVEALER (self->priv->revealer_clock), !expand); -} - static void set_icon (GtkWidget *button, const gchar *icon_name) @@ -303,38 +153,3 @@ set_icon (GtkWidget *button, gtk_button_set_image (GTK_BUTTON (button), image); } - -void -maynard_panel_show_previous (MaynardPanel *self, - MaynardPanelButton button) -{ - switch (button) - { - case MAYNARD_PANEL_BUTTON_SYSTEM: - set_icon (self->priv->system_button, "go-previous-symbolic"); - set_icon (self->priv->volume_button, self->priv->volume_icon_name); - self->priv->volume_showing = FALSE; - break; - case MAYNARD_PANEL_BUTTON_VOLUME: - set_icon (self->priv->system_button, "emblem-system-symbolic"); - set_icon (self->priv->volume_button, "go-previous-symbolic"); - self->priv->volume_showing = TRUE; - break; - case MAYNARD_PANEL_BUTTON_NONE: - default: - set_icon (self->priv->system_button, "emblem-system-symbolic"); - set_icon (self->priv->volume_button, self->priv->volume_icon_name); - self->priv->volume_showing = FALSE; - } -} - -void -maynard_panel_set_volume_icon_name (MaynardPanel *self, - const gchar *icon_name) -{ - g_free (self->priv->volume_icon_name); - self->priv->volume_icon_name = g_strdup (icon_name); - - if (!self->priv->volume_showing) - set_icon (self->priv->volume_button, icon_name); -} diff --git a/shell/panel.h b/shell/panel.h index 957fd9d..2ec9e02 100644 --- a/shell/panel.h +++ b/shell/panel.h @@ -47,24 +47,15 @@ struct MaynardPanelClass GtkWindowClass parent_class; }; -#define MAYNARD_PANEL_WIDTH 56 -#define MAYNARD_PANEL_HEIGHT_RATIO 0.73 +#define MAYNARD_PANEL_HEIGHT 56 +#define MAYNARD_PANEL_WIDTH_RATIO 1 typedef enum { MAYNARD_PANEL_BUTTON_NONE, - MAYNARD_PANEL_BUTTON_SYSTEM, - MAYNARD_PANEL_BUTTON_VOLUME } MaynardPanelButton; GType maynard_panel_get_type (void) G_GNUC_CONST; GtkWidget * maynard_panel_new (void); -void maynard_panel_set_expand (MaynardPanel *self, gboolean expand); - -void maynard_panel_show_previous (MaynardPanel *self, MaynardPanelButton button); - -void maynard_panel_set_volume_icon_name (MaynardPanel *self, - const gchar *icon_name); - #endif /* __MAYNARD_PANEL_H__ */ diff --git a/shell/shell-helper.c b/shell/shell-helper.c index 111d483..5830379 100644 --- a/shell/shell-helper.c +++ b/shell/shell-helper.c @@ -32,8 +32,6 @@ struct shell_helper { struct wl_listener destroy_listener; struct weston_layer *panel_layer; - - struct wl_list slide_list; }; static void @@ -162,167 +160,10 @@ enum SlideRequest { SLIDE_REQUEST_BACK }; -struct slide { - struct weston_surface *surface; - struct weston_view *view; - int x; - int y; - - enum SlideState state; - enum SlideRequest request; - - struct weston_transform transform; - - struct wl_list link; -}; - -static void slide_back(struct slide *slide); - -static void -slide_done_cb(struct weston_view_animation *animation, void *data) -{ - struct slide *slide = data; - - slide->state = SLIDE_STATE_OUT; - - wl_list_insert(&slide->view->transform.position.link, - &slide->transform.link); - weston_matrix_init(&slide->transform.matrix); - weston_matrix_translate(&slide->transform.matrix, - slide->x, - slide->y, - 0); - - weston_view_geometry_dirty(slide->view); - weston_compositor_schedule_repaint(slide->surface->compositor); - - if (slide->request == SLIDE_REQUEST_BACK) { - slide->request = SLIDE_REQUEST_NONE; - slide_back(slide); - } -} - -static void -slide_out(struct slide *slide) -{ - assert(slide->state == SLIDE_STATE_NONE || slide->state == SLIDE_STATE_BACK); - - slide->state = SLIDE_STATE_SLIDING_OUT; - - weston_move_scale_run(slide->view, slide->x, slide->y, - 1.0, 1.0, 0, - slide_done_cb, slide); -} - -static void -slide_back_done_cb(struct weston_view_animation *animation, void *data) -{ - struct slide *slide = data; - - slide->state = SLIDE_STATE_BACK; - - wl_list_remove(&slide->transform.link); - weston_view_geometry_dirty(slide->view); - - if (slide->request == SLIDE_REQUEST_OUT) { - slide->request = SLIDE_REQUEST_NONE; - slide_out(slide); - } else { - wl_list_remove(&slide->link); - free(slide); - } -} - -static void -slide_back(struct slide *slide) -{ - assert(slide->state == SLIDE_STATE_OUT); - - slide->state = SLIDE_STATE_SLIDING_BACK; - - weston_move_scale_run(slide->view, -slide->x, -slide->y, - 1.0, 1.0, 0, - slide_back_done_cb, slide); -} - -static void -shell_helper_slide_surface(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *surface_resource, - int32_t x, - int32_t y) -{ - struct shell_helper *helper = wl_resource_get_user_data(resource); - struct weston_surface *surface = - wl_resource_get_user_data(surface_resource); - struct weston_view *view; - struct slide *slide; - - wl_list_for_each(slide, &helper->slide_list, link) { - if (slide->surface == surface) { - if (slide->state == SLIDE_STATE_SLIDING_BACK) - slide->request = SLIDE_REQUEST_OUT; - return; - } - } - - view = container_of(surface->views.next, struct weston_view, surface_link); - - if (!view) - return; - - slide = malloc(sizeof *slide); - if (!slide) - return; - - slide->surface = surface; - slide->view = view; - slide->x = x; - slide->y = y; - - slide->state = SLIDE_STATE_NONE; - slide->request = SLIDE_REQUEST_NONE; - - wl_list_insert(&helper->slide_list, - &slide->link); - - slide_out(slide); -} - -static void -shell_helper_slide_surface_back(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *surface_resource) -{ - struct shell_helper *helper = wl_resource_get_user_data(resource); - struct weston_surface *surface = - wl_resource_get_user_data(surface_resource); - struct weston_view *view; - int found = 0; - struct slide *slide; - - wl_list_for_each(slide, &helper->slide_list, link) { - if (slide->surface == surface) { - found = 1; - break; - } - } - - if (!found || slide->state == SLIDE_STATE_SLIDING_BACK) - return; - - if (slide->state == SLIDE_STATE_SLIDING_OUT) - slide->request = SLIDE_REQUEST_BACK; - else - slide_back(slide); -} - static const struct shell_helper_interface helper_implementation = { shell_helper_move_surface, shell_helper_add_surface_to_layer, shell_helper_set_panel, - shell_helper_slide_surface, - shell_helper_slide_surface_back }; static void @@ -359,8 +200,6 @@ module_init(struct weston_compositor *ec, helper->compositor = ec; helper->panel_layer = NULL; - wl_list_init(&helper->slide_list); - helper->destroy_listener.notify = helper_destroy; wl_signal_add(&ec->destroy_signal, &helper->destroy_listener); diff --git a/shell/style.css b/shell/style.css index 1501888..aaed96b 100644 --- a/shell/style.css +++ b/shell/style.css @@ -1,57 +1,3 @@ .maynard-panel { - background-color: alpha(black, 0.7); + background-color: alpha(black, 0.8); } - -.maynard-system { - background-color: #6d6d6d; - padding: 13px; - color: #fcfcfc; -} - -.maynard-system:hover { - background-color: alpha(#6d6d6d, 0.8); - color: white; -} - -.maynard-audio { - background-color: #b4b4b4; - color: #fcfcfc; - padding: 13px; -} - -.maynard-audio:hover { - background-color: alpha(#b4b4b4, 0.8); - color: white; -} - -.maynard-apps { - color: #bebebe; -} - -.maynard-apps:hover { - background-color: alpha(black, 0.2); - color: white; -} - -.maynard-clock { - background-color: #929292; - color: white; -} - -.maynard-grid { - background-color: alpha(black, 0.6); -} - -.maynard-grid-item { - background-color: alpha(black, 0.6); - color: white; - font: Droid Sans 12; - border-style: solid; - border-color: #6d6d6d; - border-width: 1px; - border-radius: 1px; -} - -.maynard-grid-label { - background-color: #929292; -}
\ No newline at end of file diff --git a/shell/vertical-clock.c b/shell/vertical-clock.c deleted file mode 100644 index ed9f9f0..0000000 --- a/shell/vertical-clock.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2014 Collabora Ltd. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - * - * Author: Jonny Lamb <jonny.lamb@collabora.co.uk> - */ - -#include "config.h" - -#include "vertical-clock.h" - -#define GNOME_DESKTOP_USE_UNSTABLE_API -#include <libgnome-desktop/gnome-wall-clock.h> - -#include "panel.h" - -struct MaynardVerticalClockPrivate { - GtkWidget *label; - - GnomeWallClock *wall_clock; -}; - -G_DEFINE_TYPE(MaynardVerticalClock, maynard_vertical_clock, GTK_TYPE_BOX) - -/* this widget takes up the entire width of the panel and displays - * padding for the first (panel width - vertical clock width) pixels, - * then shows the vertical clock itself. the idea is to put this into - * a GtkRevealer and only show it when appropriate. */ - -static void -maynard_vertical_clock_init (MaynardVerticalClock *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - MAYNARD_VERTICAL_CLOCK_TYPE, - MaynardVerticalClockPrivate); -} - -static void -wall_clock_notify_cb (GnomeWallClock *wall_clock, - GParamSpec *pspec, - MaynardVerticalClock *self) -{ - GDateTime *datetime; - gchar *str; - - datetime = g_date_time_new_now_local (); - - str = g_date_time_format (datetime, - "<span font=\"Droid Sans 12\">%H\n" - ":\n" - "%M</span>"); - gtk_label_set_markup (GTK_LABEL (self->priv->label), str); - - g_free (str); - g_date_time_unref (datetime); -} - -static void -maynard_vertical_clock_constructed (GObject *object) -{ - MaynardVerticalClock *self = MAYNARD_VERTICAL_CLOCK (object); - GtkWidget *padding; - gint width; - - G_OBJECT_CLASS (maynard_vertical_clock_parent_class)->constructed (object); - - self->priv->wall_clock = g_object_new (GNOME_TYPE_WALL_CLOCK, NULL); - g_signal_connect (self->priv->wall_clock, "notify::clock", - G_CALLBACK (wall_clock_notify_cb), self); - - gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_HORIZONTAL); - - /* a label just to pad things out to the correct width */ - width = MAYNARD_PANEL_WIDTH - MAYNARD_VERTICAL_CLOCK_WIDTH; - - padding = gtk_label_new (""); - gtk_style_context_add_class (gtk_widget_get_style_context (padding), - "maynard-clock"); - gtk_widget_set_size_request (padding, width, -1); - gtk_box_pack_start (GTK_BOX (self), padding, FALSE, FALSE, 0); - - /* the actual clock label */ - self->priv->label = gtk_label_new (""); - gtk_style_context_add_class (gtk_widget_get_style_context (self->priv->label), - "maynard-clock"); - gtk_label_set_justify (GTK_LABEL (self->priv->label), GTK_JUSTIFY_CENTER); - gtk_widget_set_size_request (self->priv->label, - MAYNARD_VERTICAL_CLOCK_WIDTH, -1); - gtk_box_pack_start (GTK_BOX (self), self->priv->label, FALSE, FALSE, 0); - - wall_clock_notify_cb (self->priv->wall_clock, NULL, self); -} - -static void -maynard_vertical_clock_dispose (GObject *object) -{ - MaynardVerticalClock *self = MAYNARD_VERTICAL_CLOCK (object); - - G_OBJECT_CLASS (maynard_vertical_clock_parent_class)->dispose (object); -} - -static void -maynard_vertical_clock_class_init (MaynardVerticalClockClass *klass) -{ - GObjectClass *object_class = (GObjectClass *)klass; - - object_class->constructed = maynard_vertical_clock_constructed; - object_class->dispose = maynard_vertical_clock_dispose; - - g_type_class_add_private (object_class, sizeof (MaynardVerticalClockPrivate)); -} - -GtkWidget * -maynard_vertical_clock_new (void) -{ - return g_object_new (MAYNARD_VERTICAL_CLOCK_TYPE, - NULL); -} diff --git a/shell/vertical-clock.h b/shell/vertical-clock.h deleted file mode 100644 index ca4d7e3..0000000 --- a/shell/vertical-clock.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2014 Collabora Ltd. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - * - * Author: Jonny Lamb <jonny.lamb@collabora.co.uk> - */ - -#ifndef __MAYNARD_VERTICAL_CLOCK_H__ -#define __MAYNARD_VERTICAL_CLOCK_H__ - -#include <gtk/gtk.h> - -#define MAYNARD_VERTICAL_CLOCK_TYPE (maynard_vertical_clock_get_type ()) -#define MAYNARD_VERTICAL_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAYNARD_VERTICAL_CLOCK_TYPE, MaynardVerticalClock)) -#define MAYNARD_VERTICAL_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAYNARD_VERTICAL_CLOCK_TYPE, MaynardVerticalClockClass)) -#define MAYNARD_IS_VERTICAL_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAYNARD_VERTICAL_CLOCK_TYPE)) -#define MAYNARD_IS_VERTICAL_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAYNARD_VERTICAL_CLOCK_TYPE)) -#define MAYNARD_VERTICAL_CLOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAYNARD_VERTICAL_CLOCK_TYPE, MaynardVerticalClockClass)) - -typedef struct MaynardVerticalClock MaynardVerticalClock; -typedef struct MaynardVerticalClockClass MaynardVerticalClockClass; -typedef struct MaynardVerticalClockPrivate MaynardVerticalClockPrivate; - -struct MaynardVerticalClock -{ - GtkBox parent; - - MaynardVerticalClockPrivate *priv; -}; - -struct MaynardVerticalClockClass -{ - GtkBoxClass parent_class; -}; - -#define MAYNARD_VERTICAL_CLOCK_WIDTH 25 - -GType maynard_vertical_clock_get_type (void) G_GNUC_CONST; - -GtkWidget * maynard_vertical_clock_new (void); - -#endif /* __MAYNARD_VERTICAL_CLOCK_H__ */ |
