emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/gtkutil.c,v


From: Jan Djärv
Subject: [Emacs-diffs] Changes to emacs/src/gtkutil.c,v
Date: Sun, 02 Sep 2007 16:47:18 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Jan Djärv <jhd>        07/09/02 16:47:18

Index: gtkutil.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/gtkutil.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -b -r1.114 -r1.115
--- gtkutil.c   31 Aug 2007 10:17:02 -0000      1.114
+++ gtkutil.c   2 Sep 2007 16:47:18 -0000       1.115
@@ -3346,6 +3346,10 @@
    the GtkImage with a new image.  */
 #define XG_TOOL_BAR_STOCK_NAME "emacs-tool-bar-stock-name"
 
+/* As above, but this is used for named theme widgets, as opposed to
+   stock items.  */
+#define XG_TOOL_BAR_ICON_NAME "emacs-tool-bar-icon-name"
+
 /* Callback function invoked when a tool bar item is pressed.
    W is the button widget in the tool bar that got pressed,
    CLIENT_DATA is an integer that is the index of the button in the
@@ -3809,6 +3813,7 @@
       Lisp_Object stock;
       GtkStockItem stock_item;
       char *stock_name = NULL;
+      char *icon_name = NULL;
       Lisp_Object rtl;
       GtkWidget *wbutton = NULL;
       GtkWidget *weventbox;
@@ -3834,14 +3839,34 @@
       if (EQ (Qt, Ffboundp (func))) 
         stock = call1 (func, file_for_image (image));
 
-      if (! NILP (stock) && STRINGP (stock)
-          && gtk_stock_lookup (SSDATA (stock), &stock_item))
+      if (! NILP (stock) && STRINGP (stock))
         {
           stock_name = SSDATA (stock);
+          if (stock_name[0] == 'n' && stock_name[1] == ':')
+            {
+              GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET 
(wtoolbar));
+              GtkIconTheme *icon_theme = gtk_icon_theme_get_for_screen 
(screen);
+
+              icon_name = stock_name + 2;
+              stock_name = NULL;
+              stock = Qnil;
+
+              if (! gtk_icon_theme_has_icon (icon_theme, icon_name))
+                icon_name = NULL;
+              else
           icon_size = gtk_toolbar_get_icon_size (wtoolbar);
         }
+          else if (gtk_stock_lookup (SSDATA (stock), &stock_item))
+              icon_size = gtk_toolbar_get_icon_size (wtoolbar);
       else
         {
+              stock = Qnil;
+              stock_name = NULL;
+            }
+        }
+
+      if (stock_name == NULL && icon_name == NULL)
+        {
           /* No stock image, or stock item not known.  Try regular image.  */
 
           /* If image is a vector, choose the image according to the
@@ -3905,6 +3930,13 @@
                                       (gpointer) xstrdup (stock_name),
                                       (GDestroyNotify) xfree);
             }
+          else if (icon_name) 
+            {
+              w = gtk_image_new_from_icon_name (icon_name, icon_size);
+              g_object_set_data_full (G_OBJECT (w), XG_TOOL_BAR_ICON_NAME,
+                                      (gpointer) xstrdup (icon_name),
+                                      (GDestroyNotify) xfree);
+            }
           else
             {
               w = xg_get_image_for_pixmap (f, img, x->widget, NULL);
@@ -3980,6 +4012,8 @@
                                                       XG_TOOL_BAR_IMAGE_DATA);
           gpointer old_stock_name = g_object_get_data (G_OBJECT (wimage),
                                                        XG_TOOL_BAR_STOCK_NAME);
+          gpointer old_icon_name = g_object_get_data (G_OBJECT (wimage),
+                                                      XG_TOOL_BAR_ICON_NAME);
           if (stock_name &&
               (! old_stock_name || strcmp (old_stock_name, stock_name) != 0))
             {
@@ -3990,6 +4024,20 @@
                                       (GDestroyNotify) xfree);
               g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA,
                                  NULL);
+              g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_ICON_NAME, 
NULL);
+            }
+          else if (icon_name &&
+                   (! old_icon_name || strcmp (old_icon_name, icon_name) != 0))
+            {
+              gtk_image_set_from_icon_name (GTK_IMAGE (wimage),
+                                            icon_name, icon_size);
+              g_object_set_data_full (G_OBJECT (wimage), XG_TOOL_BAR_ICON_NAME,
+                                      (gpointer) xstrdup (icon_name),
+                                      (GDestroyNotify) xfree);
+              g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA,
+                                 NULL);
+              g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_STOCK_NAME,
+                                 NULL);
             }
           else if (img && old_img != img->pixmap)
             {
@@ -3999,6 +4047,7 @@
 
               g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_STOCK_NAME,
                                  NULL);
+              g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_ICON_NAME, 
NULL);
             }
 
           gtk_misc_set_padding (GTK_MISC (wimage), hmargin, vmargin);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]