[Xfce4-commits] <xfce4-panel:devel> Implement fixed gtk-icon-sizes in the XfcePanelImage widget.

Nick Schermer noreply at xfce.org
Fri Sep 25 20:02:04 CEST 2009


Updating branch refs/heads/devel
         to 778f7b9b87d923f511a74759e3e51ee4637bab4a (commit)
       from ec6e5331f949718f3a5fc03f86d59f19904ce64d (commit)

commit 778f7b9b87d923f511a74759e3e51ee4637bab4a
Author: Nick Schermer <nick at xfce.org>
Date:   Thu Sep 24 20:10:27 2009 +0200

    Implement fixed gtk-icon-sizes in the XfcePanelImage widget.
    
    This allows icon sizes to clamp to fixed icon sizes, which
    will for example prevent fuzzy icons in the launcher on
    some panel sizes.

 docs/README.gtkrc-2.0            |   19 +++++++++++++++----
 libxfce4panel/xfce-panel-image.c |   33 ++++++++++++++++++++++-----------
 2 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/docs/README.gtkrc-2.0 b/docs/README.gtkrc-2.0
index 5bad4dd..ac1d482 100644
--- a/docs/README.gtkrc-2.0
+++ b/docs/README.gtkrc-2.0
@@ -3,7 +3,6 @@ The Xfce Panel .gtkrc-2.0 hacks
 
 XfceTasklist
 ---------------
-
 style "xfce-tasklist-style"
 {
   # The maximum length of a button before the label ellipsizes. 
@@ -25,10 +24,22 @@ class "XfceTasklist" style "xfce-tasklist-style"
 
 XfceLauncherPlugin
 ------------------
-
-style "xfce-launcher-style"
+style "xfce-launcher-plugin-style"
 {
   # Size of the icons of the menu, in pixels.
   XfceLauncherPlugin::menu-icon-size = 36
 }
-class "XfceLauncherPlugin" style "xfce-launcher-style"
+class "XfceLauncherPlugin" style "xfce-launcher-plugin-style"
+
+
+
+XfcePanelImage
+--------------
+style "xfce-panel-image-style"
+{
+  # Fix the panel images to a default gtk icon size, is only works for
+  # images below 32 pixels. You can for example use this when you have
+  # fuzzy launcher icons.
+  XfcePanelImage::force-gtk-icon-sizes = true
+}
+class "XfcePanelImage" style "xfce-panel-image-style"
diff --git a/libxfce4panel/xfce-panel-image.c b/libxfce4panel/xfce-panel-image.c
index ca7f325..f1952e1 100644
--- a/libxfce4panel/xfce-panel-image.c
+++ b/libxfce4panel/xfce-panel-image.c
@@ -82,16 +82,16 @@ static void       xfce_panel_image_set_property  (GObject         *object,
                                                   GParamSpec      *pspec);
 static void       xfce_panel_image_finalize      (GObject         *object);
 static void       xfce_panel_image_size_request  (GtkWidget       *widget,
-                                                   GtkRequisition  *requisition);
+                                                  GtkRequisition  *requisition);
 static void       xfce_panel_image_size_allocate (GtkWidget       *widget,
-                                                   GtkAllocation   *allocation);
+                                                  GtkAllocation   *allocation);
 static gboolean   xfce_panel_image_expose_event  (GtkWidget       *widget,
-                                                   GdkEventExpose  *event);
-static void       xfce_panel_image_style_set     (GtkWidget *widget,
-                                                  GtkStyle  *previous_style);
+                                                  GdkEventExpose  *event);
+static void       xfce_panel_image_style_set     (GtkWidget       *widget,
+                                                  GtkStyle        *previous_style);
 static GdkPixbuf *xfce_panel_image_scale_pixbuf  (GdkPixbuf       *source,
-                                                   gint             dest_width,
-                                                   gint             dest_height);
+                                                  gint             dest_width,
+                                                  gint             dest_height);
 
 
 
@@ -290,6 +290,7 @@ xfce_panel_image_size_allocate (GtkWidget     *widget,
   GdkPixbuf             *pixbuf = NULL;
   GdkScreen             *screen;
   GError                *error = NULL;
+  gint                   size;
 
   widget->allocation = *allocation;
 
@@ -327,14 +328,24 @@ xfce_panel_image_size_allocate (GtkWidget     *widget,
         }
       else
         {
-          /* get the screen */
           screen = gtk_widget_get_screen (widget);
 
+          size = MIN (priv->width, priv->height);
+          if (G_UNLIKELY (priv->force_icon_sizes && size < 32))
+            {
+              /* we use some hardcoded values here for convienence,
+               * above 32 pixels svg icons will kick in */
+              if (size > 16 && size < 22)
+                size = 16;
+              else if (size > 22 && size < 24)
+                size = 22;
+              else if (size > 24 && size < 32)
+                size = 24;
+            }
+
           /* get a pixbuf from the icon name */
           pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_for_screen (screen),
-                                             priv->source,
-                                             MIN (priv->width, priv->height),
-                                             0, NULL);
+                                             priv->source, size, 0, NULL);
 
           /* TODO more loading modes: try without extension and lower case */
         }



More information about the Xfce4-commits mailing list