From 37ccdcbafdd5e97bb985eaf26fa3fa9f881b3b06 Mon Sep 17 00:00:00 2001 From: Andrzej Date: Tue, 17 Jan 2012 23:16:49 +0900 Subject: [PATCH] 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