From deff36e3da4763656a7456c6fb26f3a546827192 Mon Sep 17 00:00:00 2001 From: Andrzej Date: Fri, 27 Jan 2012 02:30:28 +0900 Subject: [PATCH] Icon size and label orientation to follow panel 4.9+ conventions. --- panel-plugin/xfce4-cpufreq-plugin.c | 48 ++++++++++++++++++++++++++++++++--- 1 files changed, 44 insertions(+), 4 deletions(-) diff --git a/panel-plugin/xfce4-cpufreq-plugin.c b/panel-plugin/xfce4-cpufreq-plugin.c index fd9788d..6d4512f 100644 --- a/panel-plugin/xfce4-cpufreq-plugin.c +++ b/panel-plugin/xfce4-cpufreq-plugin.c @@ -71,7 +71,11 @@ cpufreq_update_label (CpuInfo *cpu) if (strcmp(label,"")) { gtk_label_set_markup (GTK_LABEL(cpuFreq->label), label); +#if defined (LIBXFCE4PANEL_CHECK_VERSION) && LIBXFCE4PANEL_CHECK_VERSION (4,9,0) + if (xfce_panel_plugin_get_mode (cpuFreq->plugin) == XFCE_PANEL_PLUGIN_MODE_VERTICAL) +#else if (xfce_panel_plugin_get_orientation (cpuFreq->plugin) == GTK_ORIENTATION_VERTICAL) +#endif gtk_label_set_angle (GTK_LABEL(cpuFreq->label), -90); else gtk_label_set_angle (GTK_LABEL(cpuFreq->label), 0); @@ -140,12 +144,29 @@ cpufreq_restart_timeout (void) NULL); } +#if defined (LIBXFCE4PANEL_CHECK_VERSION) && LIBXFCE4PANEL_CHECK_VERSION (4,9,0) +static void +cpufreq_mode_changed (XfcePanelPlugin *plugin, XfcePanelPluginMode mode, CpuFreqPlugin *cpufreq) +{ + GtkOrientation orientation; + + orientation = + (mode == XFCE_PANEL_PLUGIN_MODE_HORIZONTAL) ? + GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL; + + gtk_orientable_set_orientation (GTK_ORIENTABLE (cpufreq->box), orientation); + cpufreq_update_plugin (); +} + +#else + static void cpufreq_orientation_changed (XfcePanelPlugin *plugin, GtkOrientation orientation, CpuFreqPlugin *cpufreq) { gtk_orientable_set_orientation (GTK_ORIENTABLE (cpufreq->box), orientation); cpufreq_update_plugin (); } +#endif void cpufreq_update_icon (CpuFreqPlugin *cpufreq) @@ -193,10 +214,13 @@ cpufreq_prepare_label (CpuFreqPlugin *cpufreq) static void cpufreq_widgets (void) { - GtkOrientation orientation; - - orientation = xfce_panel_plugin_get_orientation (cpuFreq->plugin); +#if defined (LIBXFCE4PANEL_CHECK_VERSION) && LIBXFCE4PANEL_CHECK_VERSION (4,9,0) + cpuFreq->icon_size = xfce_panel_plugin_get_size (cpuFreq->plugin); + cpuFreq->icon_size /= xfce_panel_plugin_get_nrows (cpuFreq->plugin); + cpuFreq->icon_size -=4; +#else cpuFreq->icon_size = xfce_panel_plugin_get_size (cpuFreq->plugin) - 4; +#endif cpuFreq->ebox = gtk_event_box_new (); xfce_panel_plugin_add_action_widget (cpuFreq->plugin, cpuFreq->ebox); @@ -219,7 +243,13 @@ cpufreq_widgets (void) g_signal_connect (cpuFreq->ebox, "button-press-event", G_CALLBACK (cpufreq_overview), cpuFreq); - cpufreq_orientation_changed (cpuFreq->plugin, orientation, cpuFreq); +#if defined (LIBXFCE4PANEL_CHECK_VERSION) && LIBXFCE4PANEL_CHECK_VERSION (4,9,0) + cpufreq_mode_changed + (cpuFreq->plugin, xfce_panel_plugin_get_mode (cpuFreq->plugin), cpuFreq); +#else + cpufreq_orientation_changed + (cpuFreq->plugin, xfce_panel_plugin_get_orientation (cpuFreq->plugin), cpuFreq); +#endif gtk_widget_show (cpuFreq->box); gtk_widget_show (cpuFreq->ebox); @@ -306,7 +336,12 @@ cpufreq_free (XfcePanelPlugin *plugin) static gboolean cpufreq_set_size (XfcePanelPlugin *plugin, gint size, CpuFreqPlugin *cpufreq) { +#if defined (LIBXFCE4PANEL_CHECK_VERSION) && LIBXFCE4PANEL_CHECK_VERSION (4,9,0) + cpuFreq->icon_size = size / xfce_panel_plugin_get_nrows (cpuFreq->plugin); + cpuFreq->icon_size -=4; +#else cpufreq->icon_size = size - 4; +#endif cpufreq_update_icon (cpufreq); cpufreq_update_plugin (); @@ -348,8 +383,13 @@ cpufreq_construct (XfcePanelPlugin *plugin) NULL); g_signal_connect (plugin, "size-changed", G_CALLBACK (cpufreq_set_size), cpuFreq); +#if defined (LIBXFCE4PANEL_CHECK_VERSION) && LIBXFCE4PANEL_CHECK_VERSION (4,9,0) + g_signal_connect (plugin, "mode-changed", + G_CALLBACK (cpufreq_mode_changed), cpuFreq); +#else g_signal_connect (plugin, "orientation-changed", G_CALLBACK (cpufreq_orientation_changed), cpuFreq); +#endif /* the configure and about menu items are hidden by default */ xfce_panel_plugin_menu_show_configure (plugin); -- 1.7.5.4