From 37ccdcbafdd5e97bb985eaf26fa3fa9f881b3b06 Mon Sep 17 00:00:00 2001 From: Andrzej Date: Tue, 17 Jan 2012 23:16:49 +0900 Subject: [PATCH 1/2] Panel plugin: added support for changing orientation. New (4.9+) panel has two vertical modes, one with horizontal labels (deskbar mode) and one with vertical/rotated labels (vertical mode). This patch makes clock labels follow this convention. --- panel-plugin/xfce4-orageclock-plugin.c | 53 ++++++++++++++++++++++++++++++++ 1 files changed, 53 insertions(+), 0 deletions(-) diff --git a/panel-plugin/xfce4-orageclock-plugin.c b/panel-plugin/xfce4-orageclock-plugin.c index 4a6ad8f..7ab72a4 100644 --- a/panel-plugin/xfce4-orageclock-plugin.c +++ b/panel-plugin/xfce4-orageclock-plugin.c @@ -306,6 +306,28 @@ static void oc_update_size(Clock *clock, int size) } } +static void oc_update_orientation(Clock *clock, GtkOrientation orientation) +{ + ClockLine *line; + GList *tmp_list; + + for (tmp_list = g_list_first(clock->lines); + tmp_list; + tmp_list = g_list_next(tmp_list)) { + line = tmp_list->data; + if (orientation == GTK_ORIENTATION_VERTICAL) { + gtk_box_reorder_child(GTK_BOX(clock->vbox), line->label, -1); + } else { + gtk_box_reorder_child(GTK_BOX(clock->vbox), line->label, 0); + } + gtk_label_set_angle(GTK_LABEL(line->label), + orientation == GTK_ORIENTATION_VERTICAL ? + 0 : 270); + } + + gtk_orientable_set_orientation (GTK_ORIENTABLE (clock->vbox), orientation); +} + static gboolean popup_program(GtkWidget *widget, gchar *program, Clock *clock , guint event_time) { @@ -405,6 +427,20 @@ static gboolean oc_set_size(XfcePanelPlugin *plugin, int size, Clock *clock) return(TRUE); } +#if LIBXFCE4PANEL_CHECK_VERSION (4,9,0) +static void oc_set_mode(XfcePanelPlugin *plugin, XfcePanelPluginMode mode, Clock *clock) +{ + GtkOrientation orientation; + + orientation = + (mode == XFCE_PANEL_PLUGIN_MODE_VERTICAL) ? + GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL; + + oc_update_orientation(clock, orientation); + oc_update_size(clock, xfce_panel_plugin_get_size(plugin)); +} +#endif + static void oc_free_data(XfcePanelPlugin *plugin, Clock *clock) { GtkWidget *dlg = g_object_get_data(G_OBJECT(plugin), "dialog"); @@ -696,6 +732,10 @@ static void oc_construct(XfcePanelPlugin *plugin) { Clock *clock; +#if LIBXFCE4PANEL_CHECK_VERSION (4,9,0) + GtkOrientation orientation; +#endif + xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); clock = orage_oc_new(plugin); @@ -714,6 +754,14 @@ static void oc_construct(XfcePanelPlugin *plugin) oc_init_timer(clock); +#if LIBXFCE4PANEL_CHECK_VERSION (4,9,0) + orientation = + (xfce_panel_plugin_get_mode(plugin) == XFCE_PANEL_PLUGIN_MODE_VERTICAL) ? + GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL; + + oc_update_orientation(clock, orientation); +#endif + oc_update_size(clock, xfce_panel_plugin_get_size(XFCE_PANEL_PLUGIN(plugin))); @@ -727,6 +775,11 @@ static void oc_construct(XfcePanelPlugin *plugin) g_signal_connect(plugin, "size-changed", G_CALLBACK(oc_set_size), clock); +#if LIBXFCE4PANEL_CHECK_VERSION (4,9,0) + g_signal_connect(plugin, "mode-changed", + G_CALLBACK(oc_set_mode), clock); +#endif + g_signal_connect(plugin, "free-data", G_CALLBACK(oc_free_data), clock); -- 1.7.1 From 6fb1d0d76ce9407951375b30fbc5d9b770df81af Mon Sep 17 00:00:00 2001 From: Andrzej Date: Wed, 18 Jan 2012 01:22:11 +0900 Subject: [PATCH 2/2] Panel plugin: reducing spacing between lines in wide panels. Previously the plugin was spreading the labels evenly across the whole available space, which isn't very readable and pretty. This fix places the labels near the center line of the panel, preserving their spacing. --- panel-plugin/xfce4-orageclock-plugin.c | 8 +++++++- panel-plugin/xfce4-orageclock-plugin.h | 1 + 2 files changed, 8 insertions(+), 1 deletions(-) diff --git a/panel-plugin/xfce4-orageclock-plugin.c b/panel-plugin/xfce4-orageclock-plugin.c index 7ab72a4..a6a0ee1 100644 --- a/panel-plugin/xfce4-orageclock-plugin.c +++ b/panel-plugin/xfce4-orageclock-plugin.c @@ -326,6 +326,7 @@ static void oc_update_orientation(Clock *clock, GtkOrientation orientation) } gtk_orientable_set_orientation (GTK_ORIENTABLE (clock->vbox), orientation); + gtk_orientable_set_orientation (GTK_ORIENTABLE (clock->outer_vbox), orientation); } static gboolean popup_program(GtkWidget *widget, gchar *program, Clock *clock @@ -636,9 +637,14 @@ Clock *orage_oc_new(XfcePanelPlugin *plugin) gtk_container_add(GTK_CONTAINER(clock->ebox), clock->frame); gtk_widget_show(clock->frame); + clock->outer_vbox = gtk_vbox_new(TRUE, 0); + gtk_widget_show(clock->outer_vbox); + gtk_container_add(GTK_CONTAINER(clock->frame), clock->outer_vbox); + clock->vbox = gtk_vbox_new(TRUE, 0); gtk_widget_show(clock->vbox); - gtk_container_add(GTK_CONTAINER(clock->frame), clock->vbox); + gtk_box_pack_start(GTK_BOX(clock->outer_vbox), clock->vbox, + TRUE, FALSE, 0); clock->show_frame = TRUE; clock->fg_set = FALSE; diff --git a/panel-plugin/xfce4-orageclock-plugin.h b/panel-plugin/xfce4-orageclock-plugin.h index 7b923e7..16a6448 100644 --- a/panel-plugin/xfce4-orageclock-plugin.h +++ b/panel-plugin/xfce4-orageclock-plugin.h @@ -30,6 +30,7 @@ typedef struct _clock GtkWidget *ebox; GtkWidget *frame; + GtkWidget *outer_vbox; GtkWidget *vbox; gboolean show_frame; gboolean fg_set; -- 1.7.1