[Xfce4-commits] [xfce/xfce4-power-manager] 08/64: Change the panel icon back

noreply at xfce.org noreply at xfce.org
Mon May 26 06:00: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 918a3aecb83bc25f69c570ed79d126c250ad9135
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Thu May 1 17:31:18 2014 +0300

    Change the panel icon back
    
    Dynamically changing the icon in the panel itself looks horrible.
    Revert and improve it later.
---
 panel-plugins/battery/battery-button.c |   94 +++++++++-----------------------
 1 file changed, 26 insertions(+), 68 deletions(-)

diff --git a/panel-plugins/battery/battery-button.c b/panel-plugins/battery/battery-button.c
index d037363..4ef12e1 100644
--- a/panel-plugins/battery/battery-button.c
+++ b/panel-plugins/battery/battery-button.c
@@ -493,7 +493,6 @@ device_changed_cb (UpDevice *device, BatteryButton *button)
     const gchar *object_path = up_device_get_object_path(device);
     gchar *details, *icon_name;
     GdkPixbuf *pix;
-    guint type;
 
     TRACE("entering for %s", object_path);
 
@@ -517,30 +516,6 @@ device_changed_cb (UpDevice *device, BatteryButton *button)
 			-1);
 
     gtk_tree_iter_free (iter);
-
-    g_object_get (device,
-		  "kind", &type,
-		   NULL);
-
-    /* update the panel icon */
-    if (type == UP_DEVICE_KIND_LINE_POWER)
-    {
-	if ( g_strcmp0(icon_name, XFPM_AC_ADAPTER_ICON) == 0 )
-	{
-	    gtk_image_set_from_pixbuf (GTK_IMAGE (button->priv->image), pix);
-	}
-	else
-	{
-	    GdkPixbuf *tmp = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
-						       XFPM_BATTERY_ICON,
-						       48,
-						       GTK_ICON_LOOKUP_USE_BUILTIN,
-						       NULL);
-
-	    gtk_image_set_from_pixbuf (GTK_IMAGE (button->priv->image), tmp);
-	    g_object_unref (tmp);
-	}
-    }
 }
 
 static void
@@ -588,23 +563,6 @@ battery_button_add_device (UpDevice *device, BatteryButton *button)
     {
 	/* The PC's plugged in status shows up first */
 	gtk_list_store_prepend (list_store, &iter);
-
-	/* update the panel icon */
-	if ( g_strcmp0(icon_name, XFPM_AC_ADAPTER_ICON) == 0 )
-	{
-	    gtk_image_set_from_pixbuf (GTK_IMAGE (button->priv->image), pix);
-	}
-	else
-	{
-	    GdkPixbuf *tmp = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
-						       XFPM_BATTERY_ICON,
-						       48,
-						       GTK_ICON_LOOKUP_USE_BUILTIN,
-						       NULL);
-
-	    gtk_image_set_from_pixbuf (GTK_IMAGE (button->priv->image), tmp);
-	    g_object_unref (tmp);
-	}
     }
     else
     {
@@ -818,6 +776,28 @@ battery_button_new (XfcePanelPlugin *plugin)
     return GTK_WIDGET (button);
 }
 
+static gboolean
+battery_button_set_icon (BatteryButton *button, gint width)
+{
+    GdkPixbuf *pixbuf;
+    const gchar *icon_name = "xfpm-primary-100-charging";
+
+    pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                       icon_name,
+                                       width,
+                                       GTK_ICON_LOOKUP_FORCE_SIZE,
+                                       NULL);
+
+    if ( pixbuf )
+    {
+        gtk_image_set_from_pixbuf (GTK_IMAGE (button->priv->image), pixbuf);
+        g_object_unref (pixbuf);
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
 static void
 destroy_popup (BatteryButton *button)
 {
@@ -828,8 +808,11 @@ destroy_popup (BatteryButton *button)
 static gboolean
 battery_button_size_changed_cb (XfcePanelPlugin *plugin, gint size, BatteryButton *button)
 {
+    gint width = size -2 - 2* MAX(gtk_widget_get_style(GTK_WIDGET(button))->xthickness,
+                                  gtk_widget_get_style(GTK_WIDGET(button))->xthickness);
+
     gtk_widget_set_size_request (GTK_WIDGET(plugin), size, size);
-    return TRUE;
+    return battery_button_set_icon (button, width);
 }
 
 static void
@@ -849,9 +832,6 @@ help_cb (GtkMenuItem *menuitem, gpointer user_data)
 void battery_button_show (BatteryButton *button)
 {
     GtkWidget *mi;
-    GdkPixbuf *pix;
-    gboolean on_battery;
-    const gchar *icon_name;
 
     g_return_if_fail (BATTERY_IS_BUTTON (button));
 
@@ -860,28 +840,6 @@ void battery_button_show (BatteryButton *button)
     button->priv->image = gtk_image_new ();
     gtk_container_add (GTK_CONTAINER (button), button->priv->image);
 
-    g_object_get (button->priv->upower,
-                  "on-battery", &on_battery,
-		  NULL);
-
-    if ( on_battery )
-    {
-	icon_name = XFPM_BATTERY_ICON;
-    }
-    else
-    {
-	icon_name = XFPM_AC_ADAPTER_ICON;
-    }
-
-    pix = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
-				    icon_name,
-				    48,
-				    GTK_ICON_LOOKUP_USE_BUILTIN,
-				    NULL);
-
-    gtk_image_set_from_pixbuf (GTK_IMAGE (button->priv->image), pix);
-    g_object_unref (pix);
-
     /* help dialog */
     mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_HELP, NULL);
     gtk_widget_set_sensitive (mi, TRUE);

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


More information about the Xfce4-commits mailing list