[Xfce4-commits] <libxfcegui4:xfce-4.6> Revert "WIP: fix icon sizing for XfceAppMenuItem"

Nick Schermer noreply at xfce.org
Wed Jan 20 10:26:03 CET 2010


Updating branch refs/heads/xfce-4.6
         to bc960ebbcdfdf3835bd6ba5e881edb914eb04584 (commit)
       from 51bef833e35b29a3545f9f2fc969eabd0213c402 (commit)

commit bc960ebbcdfdf3835bd6ba5e881edb914eb04584
Author: Nick Schermer <nick at xfce.org>
Date:   Tue Jan 19 20:09:51 2010 +0100

    Revert "WIP: fix icon sizing for XfceAppMenuItem"
    
    This reverts commit 566ec31d14b78f0d13e21b7beed70ac27e4c5a90.

 libxfcegui4/xfce-appmenuitem.c |   61 ++++++++++-----------------------------
 1 files changed, 16 insertions(+), 45 deletions(-)

diff --git a/libxfcegui4/xfce-appmenuitem.c b/libxfcegui4/xfce-appmenuitem.c
index b72d30d..ffef48f 100644
--- a/libxfcegui4/xfce-appmenuitem.c
+++ b/libxfcegui4/xfce-appmenuitem.c
@@ -414,38 +414,6 @@ xfce_app_menu_item_finalize(GObject *object)
     G_OBJECT_CLASS(xfce_app_menu_item_parent_class)->finalize(object);
 }
 
-static void
-xfce_app_menu_item_update_icon(XfceAppMenuItem *app_menu_item)
-{
-    if(!GTK_WIDGET_REALIZED(app_menu_item))
-        return;
-
-    if(app_menu_item->priv->icon_name)
-        gtk_image_set_from_icon_name(GTK_IMAGE(img), app_menu_item->priv->icon_name);
-    else if(app_menu_item->priv->icon_path) {
-        GtkIconTheme *itheme = gtk_icon_theme_get_default();
-        GdkPixbuf *pix = gtk_icon_theme_load_icon(itheme, app_menu_item->priv->icon_path, 0, NULL);
-        if(pix) {
-            GtkWidget *img = gtk_image_menu_item_get_image(GTK_IMAGE_MENU_ITEM(app_menu_item));
-
-            if(!img) {
-                img = gtk_image_new();
-                gtk_widget_show(img);
-                gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(app_menu_item), img);
-            }
-
-            gtk_image_set_from_pixbuf(GTK_IMAGE(img), pix);
-            g_object_unref(G_OBJECT(pix));
-        }
-    } else {
-        GtkWidget *img = gtk_image_menu_item_get_image(GTK_IMAGE_MENU_ITEM(app_menu_item));
-        if(img) {
-            gtk_image_set_from_icon_name(GTK_IMAGE(img), NULL);
-            gtk_image_set_from_pixbuf(GTK_IMAGE(img), NULL);
-        }
-    }
-}
-
 /**
  * xfce_app_menu_item_new:
  * @returns: A new #XfceAppMenuItem.
@@ -718,19 +686,25 @@ void
 xfce_app_menu_item_set_icon_name(XfceAppMenuItem *app_menu_item,
         const gchar *filename)
 {
+    GtkWidget *img;
+    
     g_return_if_fail(XFCE_IS_APP_MENU_ITEM(app_menu_item));
 
-    g_free(app_menu_item->priv->icon_name);
-    app_menu_item->priv->icon_name = NULL;
-    g_free(app_menu_item->priv->icon_path);
-    app_menu_item->priv->icon_path = NULL;
+    if(app_menu_item->priv->icon_name)
+        g_free(app_menu_item->priv->icon_name);
 
-    if(!strstr(filename, G_DIR_SEPARATOR_S))
-        app_menu_item->priv->icon_name = g_strdup(filename);
-    else
-        app_menu_item->priv->icon_path = g_strdup(filename);
+    if(!filename) {
+        app_menu_item->priv->icon_name = NULL;
+        return;
+    }
 
-    xfce_app_menu_item_update_icon(app_menu_item);
+    app_menu_item->priv->icon_name = g_strdup(filename);
+    app_menu_item->priv->icon_path = xfce_themed_icon_lookup(filename,
+                                                _xfce_app_menu_item_icon_size);
+    
+    img = gtk_image_menu_item_get_image(GTK_IMAGE_MENU_ITEM(app_menu_item));
+    if(img)
+        gtk_image_set_from_pixbuf(GTK_IMAGE(img), NULL);
 }
 
 /**
@@ -823,10 +797,7 @@ xfce_app_menu_item_get_icon_name(XfceAppMenuItem *app_menu_item)
 {
     g_return_val_if_fail(XFCE_IS_APP_MENU_ITEM(app_menu_item), NULL);
     
-    if(app_menu_item->priv->icon_name)
-        return app_menu_item->priv->icon_name;
-    else
-        return app_menu_item->priv->icon_path;
+    return app_menu_item->priv->icon_name;
 }
 
 /**



More information about the Xfce4-commits mailing list