[Xfce4-commits] [xfce/xfce4-power-manager] 03/03: React to LXDE panel configuration change events

noreply at xfce.org noreply at xfce.org
Mon Jun 23 15:53:03 CEST 2014


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository xfce/xfce4-power-manager.

commit 3dd713c9d8e1b79cb990ef43176dac81cc2048fd
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Mon Jun 23 16:47:04 2014 +0300

    React to LXDE panel configuration change events
    
    This way the panel icon will increase with the LXDE icon_size
    changes.
---
 panel-plugins/battery/battery-button.c      |   10 ++++++++++
 panel-plugins/battery/battery-button.h      |   10 ++++++----
 panel-plugins/battery/lxde/battery-plugin.c |   23 ++++++++++++++++++++++-
 3 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/panel-plugins/battery/battery-button.c b/panel-plugins/battery/battery-button.c
index 4713900..e59f991 100644
--- a/panel-plugins/battery/battery-button.c
+++ b/panel-plugins/battery/battery-button.c
@@ -484,6 +484,16 @@ battery_button_set_icon (BatteryButton *button)
     return FALSE;
 }
 
+void
+battery_button_set_width (BatteryButton *button, gint width)
+{
+    g_return_if_fail (BATTERY_IS_BUTTON (button));
+
+    battery->priv->panel_icon_width = width;
+
+    battery_button_set_icon (button);
+}
+
 static gboolean
 battery_button_press_event (GtkWidget *widget, GdkEventButton *event)
 {
diff --git a/panel-plugins/battery/battery-button.h b/panel-plugins/battery/battery-button.h
index 5e35ef4..171ce9f 100644
--- a/panel-plugins/battery/battery-button.h
+++ b/panel-plugins/battery/battery-button.h
@@ -51,16 +51,18 @@ typedef struct
 
 } BatteryButtonClass;
 
-GType        			 battery_button_get_type        (void) G_GNUC_CONST;
+GType                    battery_button_get_type (void) G_GNUC_CONST;
 
 #ifdef XFCE_PLUGIN
-GtkWidget       		*battery_button_new             (XfcePanelPlugin *plugin);
+GtkWidget               *battery_button_new       (XfcePanelPlugin *plugin);
 #endif
 #ifdef LXDE_PLUGIN
-GtkWidget       		*battery_button_new             (Plugin *plugin);
+GtkWidget               *battery_button_new       (Plugin *plugin);
 #endif
 
-void                             battery_button_show            (BatteryButton *button);
+void                     battery_button_show      (BatteryButton *button);
+
+void                     battery_button_set_width (BatteryButton *button, gint width);
 
 G_END_DECLS
 
diff --git a/panel-plugins/battery/lxde/battery-plugin.c b/panel-plugins/battery/lxde/battery-plugin.c
index d1f9644..18de503 100644
--- a/panel-plugins/battery/lxde/battery-plugin.c
+++ b/panel-plugins/battery/lxde/battery-plugin.c
@@ -46,6 +46,7 @@ BatteryPlugin;
 
 /* prototypes */
 static int battery_plugin_construct (Plugin *p, char **fp);
+static void battery_plugin_configuration_changed(Plugin *p);
 
 PluginClass lxdebattery_plugin_class = {
     PLUGINCLASS_VERSIONING,
@@ -59,7 +60,7 @@ PluginClass lxdebattery_plugin_class = {
     destructor  : NULL,
     config : NULL,
     save : NULL,
-    panel_configuration_changed : NULL
+    panel_configuration_changed : battery_plugin_configuration_changed
 };
 
 
@@ -97,6 +98,26 @@ battery_plugin_construct (Plugin *plugin, char **fp)
 
     /* add the ebox to the panel */
     plugin->pwid = battery_plugin->ebox;
+    plugin->priv = battery_plugin;
 
     return 1;
 }
+
+static void
+battery_plugin_configuration_changed(Plugin *p)
+{
+    BatteryPlugin *battery_plugin = p->plugin;
+
+    /* Determine orientation and size */
+    GtkOrientation orientation = (p->panel->orientation == GTK_ORIENTATION_VERTICAL) ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL;
+
+    int size = (orientation == GTK_ORIENTATION_VERTICAL) ? p->panel->width : p->panel->height;
+
+    if ( orientation == GTK_ORIENTATION_HORIZONTAL )
+        gtk_widget_set_size_request (p->pwid, -1, size);
+    else
+        gtk_widget_set_size_request (p->pwid, size, -1);
+
+    /* update the button's width */
+    battery_button_set_width (battery_plugin->battery_button, p->panel->icon_size);
+}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list