summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2014-04-02 21:00:52 +0200
committerJonny Lamb <jonny.lamb@collabora.co.uk>2014-04-02 21:00:52 +0200
commitdea55fa3e757dd8e99594c4b19745af33bef73d6 (patch)
tree56501d335f5e0dbf716388b21cb08df398f0943d
parente41c9cacbd620d5cd94381a38b7e034c89055a6c (diff)
downloadgraynard-dea55fa3e757dd8e99594c4b19745af33bef73d6.tar.gz
graynard-dea55fa3e757dd8e99594c4b19745af33bef73d6.zip
clock: make system icon clickable and show not implemented message
-rw-r--r--shell/clock.c42
-rw-r--r--shell/clock.h9
-rw-r--r--shell/maynard.c55
-rw-r--r--shell/panel.c68
-rw-r--r--shell/panel.h8
-rw-r--r--shell/style.css2
6 files changed, 150 insertions, 34 deletions
diff --git a/shell/clock.c b/shell/clock.c
index 909ec90..afda643 100644
--- a/shell/clock.c
+++ b/shell/clock.c
@@ -35,6 +35,7 @@ static guint signals[N_SIGNALS] = { 0 };
struct MaynardClockPrivate {
GtkWidget *revealer_clock;
+ GtkWidget *revealer_system;
GtkWidget *revealer_volume;
GtkWidget *label;
@@ -141,6 +142,12 @@ volume_idle_cb (gpointer data)
}
static GtkWidget *
+create_system_box (MaynardClock *self)
+{
+ return gtk_label_new ("Not implemented yet!");
+}
+
+static GtkWidget *
create_volume_box (MaynardClock *self)
{
GtkWidget *box;
@@ -242,7 +249,7 @@ static void
maynard_clock_constructed (GObject *object)
{
MaynardClock *self = MAYNARD_CLOCK (object);
- GtkWidget *box, *volume_box;
+ GtkWidget *box, *system_box, *volume_box;
G_OBJECT_CLASS (maynard_clock_parent_class)->constructed (object);
@@ -276,6 +283,20 @@ maynard_clock_constructed (GObject *object)
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 (
@@ -291,6 +312,10 @@ maynard_clock_constructed (GObject *object)
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);
@@ -334,11 +359,18 @@ maynard_clock_new (void)
}
void
-maynard_clock_show_volume (MaynardClock *self,
- gboolean value)
+maynard_clock_show_section (MaynardClock *self,
+ MaynardClockSection section)
{
gtk_revealer_set_reveal_child (
- GTK_REVEALER (self->priv->revealer_volume), value);
+ 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_clock), !value);
+ GTK_REVEALER (self->priv->revealer_volume),
+ section == MAYNARD_CLOCK_SECTION_VOLUME);
}
diff --git a/shell/clock.h b/shell/clock.h
index a0803e8..8044a27 100644
--- a/shell/clock.h
+++ b/shell/clock.h
@@ -52,11 +52,16 @@ struct MaynardClockClass
#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_volume (MaynardClock *self,
- gboolean value);
+void maynard_clock_show_section (MaynardClock *self, MaynardClockSection section);
#endif /* __MAYNARD_CLOCK_H__ */
diff --git a/shell/maynard.c b/shell/maynard.c
index e5d60ea..81b1d37 100644
--- a/shell/maynard.c
+++ b/shell/maynard.c
@@ -68,6 +68,7 @@ struct desktop {
guint hide_panel_idle_id;
gboolean grid_visible;
+ gboolean system_visible;
gboolean volume_visible;
};
@@ -255,15 +256,47 @@ clock_create (struct desktop *desktop)
}
static void
-volume_toggled_cb (GtkWidget *widget,
+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)
{
- desktop->volume_visible = !desktop->volume_visible;
+ button_toggled_cb (desktop,
+ &desktop->system_visible,
+ &desktop->volume_visible);
+}
- maynard_clock_show_volume (MAYNARD_CLOCK (desktop->clock->window),
- desktop->volume_visible);
- maynard_panel_show_volume_previous (MAYNARD_PANEL (desktop->panel->window),
- 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
@@ -314,8 +347,11 @@ leave_panel_idle_cb (gpointer data)
maynard_panel_set_expand(MAYNARD_PANEL(desktop->panel->window),
FALSE);
- maynard_clock_show_volume (MAYNARD_CLOCK (desktop->clock->window), FALSE);
- maynard_panel_show_volume_previous (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;
@@ -365,6 +401,8 @@ panel_create(struct desktop *desktop)
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);
@@ -573,6 +611,7 @@ main(int argc, char *argv[])
wl_display_roundtrip (desktop->display);
desktop->grid_visible = FALSE;
+ desktop->system_visible = FALSE;
desktop->volume_visible = FALSE;
css_setup(desktop);
diff --git a/shell/panel.c b/shell/panel.c
index 7324c71..f4f17bf 100644
--- a/shell/panel.c
+++ b/shell/panel.c
@@ -29,6 +29,7 @@
enum {
APP_MENU_TOGGLED,
+ SYSTEM_TOGGLED,
VOLUME_TOGGLED,
N_SIGNALS
};
@@ -40,6 +41,8 @@ struct MaynardPanelPrivate {
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;
@@ -83,6 +86,13 @@ app_menu_button_clicked_cb (GtkButton *button,
}
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)
{
@@ -147,15 +157,25 @@ maynard_panel_constructed (GObject *object)
gtk_container_add (GTK_CONTAINER (self->priv->revealer_buttons), buttons_box);
/* system button */
- image = gtk_image_new_from_icon_name ("emblem-system-symbolic",
+ 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 (image),
+ gtk_style_context_add_class (gtk_widget_get_style_context (button),
"maynard-system");
- gtk_box_pack_start (GTK_BOX (buttons_box), image, FALSE, FALSE, 0);
+ 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_end (GTK_BOX (buttons_box), ebox, FALSE, FALSE, 0);
+ 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),
@@ -229,6 +249,10 @@ maynard_panel_class_init (MaynardPanelClass *klass)
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);
@@ -252,29 +276,39 @@ maynard_panel_set_expand (MaynardPanel *self,
}
static void
-set_volume_icon (MaynardPanel *self,
+set_icon (GtkWidget *button,
const gchar *icon_name)
{
GtkWidget *image;
image = gtk_image_new_from_icon_name (icon_name,
GTK_ICON_SIZE_LARGE_TOOLBAR);
- gtk_button_set_image (GTK_BUTTON (self->priv->volume_button),
+ gtk_button_set_image (GTK_BUTTON (button),
image);
}
void
-maynard_panel_show_volume_previous (MaynardPanel *self,
- gboolean status)
+maynard_panel_show_previous (MaynardPanel *self,
+ MaynardPanelButton button)
{
- const gchar *icon_name = self->priv->volume_icon_name;
-
- if (status)
- icon_name = "go-previous-symbolic";
-
- self->priv->volume_showing = !status;
-
- set_volume_icon (self, icon_name);
+ 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
@@ -285,5 +319,5 @@ maynard_panel_set_volume_icon_name (MaynardPanel *self,
self->priv->volume_icon_name = g_strdup (icon_name);
if (self->priv->volume_showing)
- set_volume_icon (self, icon_name);
+ set_icon (self->priv->volume_button, icon_name);
}
diff --git a/shell/panel.h b/shell/panel.h
index 5278e89..957fd9d 100644
--- a/shell/panel.h
+++ b/shell/panel.h
@@ -50,13 +50,19 @@ struct MaynardPanelClass
#define MAYNARD_PANEL_WIDTH 56
#define MAYNARD_PANEL_HEIGHT_RATIO 0.73
+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_volume_previous (MaynardPanel *self, gboolean status);
+void maynard_panel_show_previous (MaynardPanel *self, MaynardPanelButton button);
void maynard_panel_set_volume_icon_name (MaynardPanel *self,
const gchar *icon_name);
diff --git a/shell/style.css b/shell/style.css
index e63580d..b2078bc 100644
--- a/shell/style.css
+++ b/shell/style.css
@@ -5,7 +5,7 @@
.maynard-system {
background-color: #6d6d6d;
color: white;
- padding: 16px;
+ padding: 13px;
}
.maynard-audio {