[Xfce4-commits] <xfce4-panel:devel> Add insensitive state to the panel image.

Nick Schermer noreply at xfce.org
Thu Feb 25 18:16:01 CET 2010


Updating branch refs/heads/devel
         to 8dfb506bd8545367cf33eb5355c1736fce368006 (commit)
       from 711e7b39dc5fc2d24c194505d8f7b9789997ac3f (commit)

commit 8dfb506bd8545367cf33eb5355c1736fce368006
Author: Nick Schermer <nick at xfce.org>
Date:   Wed Feb 24 15:43:40 2010 +0100

    Add insensitive state to the panel image.

 libxfce4panel/xfce-panel-image.c |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/libxfce4panel/xfce-panel-image.c b/libxfce4panel/xfce-panel-image.c
index 00e5d18..f690821 100644
--- a/libxfce4panel/xfce-panel-image.c
+++ b/libxfce4panel/xfce-panel-image.c
@@ -416,8 +416,11 @@ xfce_panel_image_expose_event (GtkWidget      *widget,
   XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (widget)->priv;
   gint                   source_width, source_height;
   gint                   dest_x, dest_y;
+  GtkIconSource         *source;
+  GdkPixbuf             *rendered = NULL;
+  GdkPixbuf             *pixbuf = priv->cache;
 
-  if (G_LIKELY (priv->cache != NULL))
+  if (G_LIKELY (pixbuf != NULL))
     {
       /* get the size of the cache pixbuf */
       source_width = gdk_pixbuf_get_width (priv->cache);
@@ -427,14 +430,32 @@ xfce_panel_image_expose_event (GtkWidget      *widget,
       dest_x = widget->allocation.x + (priv->width - source_width) / 2;
       dest_y = widget->allocation.y + (priv->height - source_height) / 2;
 
+      if (GTK_WIDGET_STATE (widget) == GTK_STATE_INSENSITIVE)
+        {
+          source = gtk_icon_source_new ();
+          gtk_icon_source_set_pixbuf (source, pixbuf);
+
+          rendered = gtk_style_render_icon (widget->style,
+                                            source,
+                                            gtk_widget_get_direction (widget),
+                                            GTK_WIDGET_STATE (widget),
+                                            -1, widget, "xfce-panel-image");
+          gtk_icon_source_free (source);
+
+          if (G_LIKELY (rendered != NULL))
+            pixbuf = rendered;
+        }
+
       /* draw the pixbuf */
       gdk_draw_pixbuf (widget->window,
                        widget->style->black_gc,
-                       priv->cache,
-                       0, 0,
+                       pixbuf, 0, 0,
                        dest_x, dest_y,
                        source_width, source_height,
                        GDK_RGB_DITHER_NORMAL, 0, 0);
+
+      if (rendered != NULL)
+        g_object_unref (G_OBJECT (rendered));
     }
 
   return FALSE;



More information about the Xfce4-commits mailing list