]> Pileus Git - ~andy/gtk/commitdiff
Insert cast to fix warning. Assign something to old_value to quiet gcc
authorSoeren Sandmann <sandmann@daimi.au.dk>
Thu, 3 Jul 2003 01:02:04 +0000 (01:02 +0000)
committerSøren Sandmann Pedersen <ssp@src.gnome.org>
Thu, 3 Jul 2003 01:02:04 +0000 (01:02 +0000)
Thu Jul  3 03:13:20 2003  Soeren Sandmann  <sandmann@daimi.au.dk>

* gtk/gtkpaned.c (gtk_paned_set_child_property): Insert cast to
fix warning. Assign something to old_value to quiet gcc

* gtk/gtkcalendar.c
(start_spinning): gtk_timeout_add->g_timeout_add

* gtk/gtkicontheme.c
(theme_lookup_icon): Make it compile (remove double semicolon)

* gtk/gtktoolbutton.c
(gtk_tool_button_class_init): Long comment about properties.
(gtk_tool_button_class_init): Improve text for "use_underline"
property
(gtk_tool_button_create_menu_proxy): Fix up to use_mnemonic based
on whether the passed-in label has use_mnemonic set
(gtk_tool_button_create_menu_proxy): Split image cloning out in
new function. Make that function also handle image with pixbuf
storage.
(gtk_tool_button_construct_contents): Use gtk_widget_destroy()
instead of gtk_container_remove().
(gtk_tool_button_construct_contents): Fix eliding bug

* gtk/gtktoolbar.c
(gtk_toolbar_finalize): New function. Unref tooltips, pointed out
by Morten Welinder
(gtk_toolbar_button_press): Make popup_context_menu signal provide
coordinates and button number

* tests/testtoolbar.c (main): Add new pixbuf toolbutton

* tests/apple-red.png: new file

13 files changed:
ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkcalendar.c
gtk/gtkicontheme.c
gtk/gtkpaned.c
gtk/gtktoolbar.c
gtk/gtktoolbar.h
gtk/gtktoolbutton.c
tests/apple-red.png [new file with mode: 0644]
tests/testtoolbar.c

index 4f48f4211927738af22d78d04ea4e294d9bfb7f2..62c2689ebc3b432ba9924f2686d8b24b610bc090 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,37 @@
+Thu Jul  3 03:13:20 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtkpaned.c (gtk_paned_set_child_property): Insert cast to
+       fix warning. Assign something to old_value to quiet gcc
+
+       * gtk/gtkcalendar.c 
+       (start_spinning): gtk_timeout_add->g_timeout_add
+
+       * gtk/gtkicontheme.c 
+       (theme_lookup_icon): Make it compile (remove double semicolon)
+
+       * gtk/gtktoolbutton.c
+       (gtk_tool_button_class_init): Long comment about properties.
+       (gtk_tool_button_class_init): Improve text for "use_underline"
+       property
+       (gtk_tool_button_create_menu_proxy): Fix up to use_mnemonic based
+       on whether the passed-in label has use_mnemonic set
+       (gtk_tool_button_create_menu_proxy): Split image cloning out in
+       new function. Make that function also handle image with pixbuf
+       storage.
+       (gtk_tool_button_construct_contents): Use gtk_widget_destroy()
+       instead of gtk_container_remove().
+       (gtk_tool_button_construct_contents): Fix eliding bug
+
+       * gtk/gtktoolbar.c
+       (gtk_toolbar_finalize): New function. Unref tooltips, pointed out
+       by Morten Welinder
+       (gtk_toolbar_button_press): Make popup_context_menu signal provide
+       coordinates and button number
+
+       * tests/testtoolbar.c (main): Add new pixbuf toolbutton
+
+       * tests/apple-red.png: new file
+
 Wed Jul  2 18:00:56 2003  Owen Taylor  <otaylor@redhat.com>
         
         * gtk/gtkicontheme.[ch]: Implement a loader for
index 4f48f4211927738af22d78d04ea4e294d9bfb7f2..62c2689ebc3b432ba9924f2686d8b24b610bc090 100644 (file)
@@ -1,3 +1,37 @@
+Thu Jul  3 03:13:20 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtkpaned.c (gtk_paned_set_child_property): Insert cast to
+       fix warning. Assign something to old_value to quiet gcc
+
+       * gtk/gtkcalendar.c 
+       (start_spinning): gtk_timeout_add->g_timeout_add
+
+       * gtk/gtkicontheme.c 
+       (theme_lookup_icon): Make it compile (remove double semicolon)
+
+       * gtk/gtktoolbutton.c
+       (gtk_tool_button_class_init): Long comment about properties.
+       (gtk_tool_button_class_init): Improve text for "use_underline"
+       property
+       (gtk_tool_button_create_menu_proxy): Fix up to use_mnemonic based
+       on whether the passed-in label has use_mnemonic set
+       (gtk_tool_button_create_menu_proxy): Split image cloning out in
+       new function. Make that function also handle image with pixbuf
+       storage.
+       (gtk_tool_button_construct_contents): Use gtk_widget_destroy()
+       instead of gtk_container_remove().
+       (gtk_tool_button_construct_contents): Fix eliding bug
+
+       * gtk/gtktoolbar.c
+       (gtk_toolbar_finalize): New function. Unref tooltips, pointed out
+       by Morten Welinder
+       (gtk_toolbar_button_press): Make popup_context_menu signal provide
+       coordinates and button number
+
+       * tests/testtoolbar.c (main): Add new pixbuf toolbutton
+
+       * tests/apple-red.png: new file
+
 Wed Jul  2 18:00:56 2003  Owen Taylor  <otaylor@redhat.com>
         
         * gtk/gtkicontheme.[ch]: Implement a loader for
index 4f48f4211927738af22d78d04ea4e294d9bfb7f2..62c2689ebc3b432ba9924f2686d8b24b610bc090 100644 (file)
@@ -1,3 +1,37 @@
+Thu Jul  3 03:13:20 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtkpaned.c (gtk_paned_set_child_property): Insert cast to
+       fix warning. Assign something to old_value to quiet gcc
+
+       * gtk/gtkcalendar.c 
+       (start_spinning): gtk_timeout_add->g_timeout_add
+
+       * gtk/gtkicontheme.c 
+       (theme_lookup_icon): Make it compile (remove double semicolon)
+
+       * gtk/gtktoolbutton.c
+       (gtk_tool_button_class_init): Long comment about properties.
+       (gtk_tool_button_class_init): Improve text for "use_underline"
+       property
+       (gtk_tool_button_create_menu_proxy): Fix up to use_mnemonic based
+       on whether the passed-in label has use_mnemonic set
+       (gtk_tool_button_create_menu_proxy): Split image cloning out in
+       new function. Make that function also handle image with pixbuf
+       storage.
+       (gtk_tool_button_construct_contents): Use gtk_widget_destroy()
+       instead of gtk_container_remove().
+       (gtk_tool_button_construct_contents): Fix eliding bug
+
+       * gtk/gtktoolbar.c
+       (gtk_toolbar_finalize): New function. Unref tooltips, pointed out
+       by Morten Welinder
+       (gtk_toolbar_button_press): Make popup_context_menu signal provide
+       coordinates and button number
+
+       * tests/testtoolbar.c (main): Add new pixbuf toolbutton
+
+       * tests/apple-red.png: new file
+
 Wed Jul  2 18:00:56 2003  Owen Taylor  <otaylor@redhat.com>
         
         * gtk/gtkicontheme.[ch]: Implement a loader for
index 4f48f4211927738af22d78d04ea4e294d9bfb7f2..62c2689ebc3b432ba9924f2686d8b24b610bc090 100644 (file)
@@ -1,3 +1,37 @@
+Thu Jul  3 03:13:20 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtkpaned.c (gtk_paned_set_child_property): Insert cast to
+       fix warning. Assign something to old_value to quiet gcc
+
+       * gtk/gtkcalendar.c 
+       (start_spinning): gtk_timeout_add->g_timeout_add
+
+       * gtk/gtkicontheme.c 
+       (theme_lookup_icon): Make it compile (remove double semicolon)
+
+       * gtk/gtktoolbutton.c
+       (gtk_tool_button_class_init): Long comment about properties.
+       (gtk_tool_button_class_init): Improve text for "use_underline"
+       property
+       (gtk_tool_button_create_menu_proxy): Fix up to use_mnemonic based
+       on whether the passed-in label has use_mnemonic set
+       (gtk_tool_button_create_menu_proxy): Split image cloning out in
+       new function. Make that function also handle image with pixbuf
+       storage.
+       (gtk_tool_button_construct_contents): Use gtk_widget_destroy()
+       instead of gtk_container_remove().
+       (gtk_tool_button_construct_contents): Fix eliding bug
+
+       * gtk/gtktoolbar.c
+       (gtk_toolbar_finalize): New function. Unref tooltips, pointed out
+       by Morten Welinder
+       (gtk_toolbar_button_press): Make popup_context_menu signal provide
+       coordinates and button number
+
+       * tests/testtoolbar.c (main): Add new pixbuf toolbutton
+
+       * tests/apple-red.png: new file
+
 Wed Jul  2 18:00:56 2003  Owen Taylor  <otaylor@redhat.com>
         
         * gtk/gtkicontheme.[ch]: Implement a loader for
index 4f48f4211927738af22d78d04ea4e294d9bfb7f2..62c2689ebc3b432ba9924f2686d8b24b610bc090 100644 (file)
@@ -1,3 +1,37 @@
+Thu Jul  3 03:13:20 2003  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtkpaned.c (gtk_paned_set_child_property): Insert cast to
+       fix warning. Assign something to old_value to quiet gcc
+
+       * gtk/gtkcalendar.c 
+       (start_spinning): gtk_timeout_add->g_timeout_add
+
+       * gtk/gtkicontheme.c 
+       (theme_lookup_icon): Make it compile (remove double semicolon)
+
+       * gtk/gtktoolbutton.c
+       (gtk_tool_button_class_init): Long comment about properties.
+       (gtk_tool_button_class_init): Improve text for "use_underline"
+       property
+       (gtk_tool_button_create_menu_proxy): Fix up to use_mnemonic based
+       on whether the passed-in label has use_mnemonic set
+       (gtk_tool_button_create_menu_proxy): Split image cloning out in
+       new function. Make that function also handle image with pixbuf
+       storage.
+       (gtk_tool_button_construct_contents): Use gtk_widget_destroy()
+       instead of gtk_container_remove().
+       (gtk_tool_button_construct_contents): Fix eliding bug
+
+       * gtk/gtktoolbar.c
+       (gtk_toolbar_finalize): New function. Unref tooltips, pointed out
+       by Morten Welinder
+       (gtk_toolbar_button_press): Make popup_context_menu signal provide
+       coordinates and button number
+
+       * tests/testtoolbar.c (main): Add new pixbuf toolbutton
+
+       * tests/apple-red.png: new file
+
 Wed Jul  2 18:00:56 2003  Owen Taylor  <otaylor@redhat.com>
         
         * gtk/gtkicontheme.[ch]: Implement a loader for
index 29a3d991a757bcd98d0119a8a035455babe87b7c..5faa39c3efe9a226354d99c9209024718179e010 100644 (file)
@@ -2496,9 +2496,10 @@ arrow_action (GtkCalendar *calendar,
     }
 }
 
-static gint
-calendar_timer (GtkCalendar *calendar)
+static gboolean
+calendar_timer (gpointer data)
 {
+  GtkCalendar *calendar = data;
   GtkCalendarPrivateData *private_data = GTK_CALENDAR_PRIVATE_DATA (calendar);
   gboolean retval = FALSE;
   
@@ -2535,9 +2536,9 @@ start_spinning (GtkWidget *widget,
   if (!private_data->timer)
     {
       private_data->need_timer = TRUE;
-      private_data->timer = gtk_timeout_add (CALENDAR_INITIAL_TIMER_DELAY, 
-                                            (GtkFunction) calendar_timer,
-                                            (gpointer) widget);
+      private_data->timer = g_timeout_add (CALENDAR_INITIAL_TIMER_DELAY, 
+                                          calendar_timer,
+                                          (gpointer) widget);
     }
 }
 
index eca45e39a0a2a1ee9f310da79df2009a4d86cff2..143640d5444edc85d4e6a8bd4c4e4ef96bb00667 100644 (file)
@@ -1517,7 +1517,7 @@ theme_lookup_icon (IconTheme          *theme,
   IconThemeDir *dir, *min_dir;
   char *file;
   int min_difference, difference;
-  BuiltinIcon *closest_builtin = NULL;;
+  BuiltinIcon *closest_builtin = NULL;
   gboolean smaller, has_larger;
   IconSuffix suffix;
 
index c271f1a6c1e1d55234eb88dffcc81545ae91fab4..58dfd9ed2f2fb25e808a5fbe2e2abef9f4d8825a 100644 (file)
@@ -547,10 +547,11 @@ gtk_paned_set_child_property (GtkContainer    *container,
       break;
     default:
       GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
+      old_value = -1; /* quiet gcc */
       break;
     }
   if (old_value != new_value)
-    gtk_widget_queue_resize (container);    
+    gtk_widget_queue_resize (GTK_WIDGET (container));
 }
 
 static void
index aeff39f8505fa359d8555fc7caa14ff442e270e1..393526b14c846737014000abecf5431e7d7005a1 100644 (file)
@@ -131,6 +131,8 @@ static void    gtk_toolbar_get_child_property (GtkContainer    *container,
                                               guint            property_id,
                                               GValue          *value,
                                               GParamSpec      *pspec);
+static void gtk_toolbar_finalize (GObject *object);
+
 
 static void  gtk_toolbar_add        (GtkContainer *container,
                                     GtkWidget    *widget);
@@ -281,6 +283,7 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
   
   gobject_class->set_property = gtk_toolbar_set_property;
   gobject_class->get_property = gtk_toolbar_get_property;
+  gobject_class->finalize = gtk_toolbar_finalize;
 
   widget_class->button_press_event = gtk_toolbar_button_press;
   widget_class->expose_event = gtk_toolbar_expose;
@@ -332,7 +335,7 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
                  G_SIGNAL_RUN_FIRST,
                  G_STRUCT_OFFSET (GtkToolbarClass, popup_context_menu),
                  NULL, NULL,
-                 g_cclosure_marshal_VOID__VOID,
+                 _gtk_marshal_VOID__INT_INT_INT,
                  G_TYPE_NONE, 0);
   toolbar_signals[MOVE_FOCUS] =
     _gtk_binding_signal_new ("move_focus",
@@ -1983,7 +1986,10 @@ gtk_toolbar_button_press (GtkWidget      *toolbar,
                          GdkEventButton *event)
 {
   if (event->button == 3)
-    g_signal_emit (toolbar, toolbar_signals[POPUP_CONTEXT_MENU], 0, NULL);
+    {
+      g_signal_emit (toolbar, toolbar_signals[POPUP_CONTEXT_MENU], 0,
+                    (int)event->x_root, (int)event->y_root, event->button, NULL);
+    }
 
   return FALSE;
 }
@@ -2762,3 +2768,14 @@ gtk_toolbar_internal_insert_element (GtkToolbar          *toolbar,
 
   return child->widget;
 }
+
+static void
+gtk_toolbar_finalize (GObject *object)
+{
+  GtkToolbar *toolbar = GTK_TOOLBAR (object);
+
+  if (toolbar->tooltips)
+    g_object_unref (toolbar->tooltips);
+  
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
index 49162e30115c781b3509c1b31cc941d0defbe9d4..b8170705c963167a8806bb02443dc3a0402288db 100644 (file)
@@ -121,7 +121,10 @@ struct _GtkToolbarClass
                                GtkOrientation    orientation);
   void (* style_changed)       (GtkToolbar       *toolbar,
                                GtkToolbarStyle   style);
-  void (* popup_context_menu)  (GtkToolbar       *toolbar);
+  void (* popup_context_menu)  (GtkToolbar       *toolbar,
+                               gint               x,
+                               gint               y,
+                               gint               button_number);
 
   /* Padding for future expansion */
   void (*_gtk_reserved1) (void);
index 6deab67e4cf140e32a7f9d48d9b48bf00fecb6ad..0a6141faf0f332265a656d79a2f07f7f01d341a1 100644 (file)
@@ -31,6 +31,7 @@
 #include "gtkvbox.h"
 #include "gtkintl.h"
 #include "gtktoolbar.h"
+#include "gtkiconfactory.h"
 
 #include <string.h>
 
@@ -129,6 +130,37 @@ gtk_tool_button_class_init (GtkToolButtonClass *klass)
   
   klass->button_type = GTK_TYPE_BUTTON;
 
+  /* Properties are interpreted like this:
+   *
+   *          - if the tool button has an icon_widget, then that widget
+   *            will be used as the icon. Otherwise, if the tool button
+   *            has a stock id, the corresponding stock icon will be
+   *            used. Otherwise, the tool button will not have an icon.
+   *
+   *          - if the tool button has a label_widget then that widget
+   *            will be used as the label. Otherwise, if the tool button
+   *            has a label text, that text will be used as label. Otherwise,
+   *            if the toolbutton has a stock id, the corresponding text
+   *            will be used as label. Otherwise, the toolbutton will
+   *            have an empty label.
+   *
+   *         - The use_underline property only has an effect when the label
+   *            on the toolbutton comes from the label property (ie. not from
+   *            label_widget or from stock_id).
+   *
+   *            In that case, if use_underline is set,
+   *
+   *                   - underscores are removed from the label text before
+   *                      the label is shown on the toolbutton unless the
+   *                      underscore is followed by another underscore
+   *
+   *                   - an underscore indicates that the next character when
+   *                      used in the overflow menu should be used as a mnemonic.
+   *
+   *           In short: use_underline = TRUE means that the label text has
+   *            the form "_Open" and the toolbar should take appropriate action.
+   */
+
   g_object_class_install_property (object_class,
                                   PROP_LABEL,
                                   g_param_spec_string ("label",
@@ -140,7 +172,7 @@ gtk_tool_button_class_init (GtkToolButtonClass *klass)
                                   PROP_USE_UNDERLINE,
                                   g_param_spec_boolean ("use_underline",
                                                         _("Use underline"),
-                                                        _("Interpret underlines in the item label"),
+                                                        _("If set, an underline in the label property indicates that the next character should be used for the mnemonic accelerator key in the overflow menu"),
                                                         FALSE,
                                                         G_PARAM_READWRITE));
   g_object_class_install_property (object_class,
@@ -277,8 +309,10 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
 
   if (GTK_BIN (button->button)->child)
     {
-      gtk_container_remove (GTK_CONTAINER (button->button),
-                           GTK_BIN (button->button)->child);
+      /* Note: we are not destroying the label_widget or icon_widget
+       * here because they were removed from their containers above
+       */
+      gtk_widget_destroy (GTK_BIN (button->button)->child);
     }
 
   style = gtk_tool_item_get_toolbar_style (GTK_TOOL_ITEM (button));
@@ -298,7 +332,7 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
       else
        {
          GtkStockItem stock_item;
-         gboolean elide = TRUE;
+         gboolean elide;
          gchar *label_text;
 
          if (button->label_text)
@@ -307,9 +341,15 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
              elide = button->use_underline;
            }
          else if (button->stock_id && gtk_stock_lookup (button->stock_id, &stock_item))
-           label_text = stock_item.label;
+           {
+             label_text = stock_item.label;
+             elide = TRUE;
+           }
          else
-           label_text = "";
+           {
+             label_text = "";
+             elide = FALSE;
+           }
 
          if (elide)
            label_text = _gtk_toolbar_elide_underscores (label_text);
@@ -333,25 +373,9 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
          
          if (GTK_IS_IMAGE (icon))
            {
-             GtkImage *image = GTK_IMAGE (icon);
-             GtkImageType storage_type = gtk_image_get_storage_type (image);
-             
-             if (storage_type == GTK_IMAGE_STOCK)
-               {
-                 gchar *stock_id;
-                 gtk_image_get_stock (image, &stock_id, NULL);
-
-                 icon = gtk_image_new_from_stock (stock_id, icon_size);
-                 gtk_widget_show (icon);
-               }
-             else if (storage_type == GTK_IMAGE_ICON_SET)
-               {
-                 GtkIconSet *icon_set;
-                 gtk_image_get_icon_set (image, &icon_set, NULL);
-                 
-                 icon = gtk_image_new_from_icon_set (icon_set, icon_size);
-                 gtk_widget_show (icon);
-               }
+             g_object_set (G_OBJECT (button->icon_widget),
+                           "icon-size", icon_size,
+                           NULL);
            }
        }
       else if (button->stock_id)
@@ -467,6 +491,44 @@ gtk_tool_button_finalize (GObject *object)
   parent_class->finalize (object);
 }
 
+static GtkWidget *
+clone_image_menu_size (GtkImage *image, GtkSettings *settings)
+{
+  GtkImageType storage_type = gtk_image_get_storage_type (image);
+
+  if (storage_type == GTK_IMAGE_STOCK)
+    {
+      gchar *stock_id;
+      gtk_image_get_stock (image, &stock_id, NULL);
+      return gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
+    }
+  else if (storage_type == GTK_IMAGE_ICON_SET)
+    {
+      GtkIconSet *icon_set;
+      gtk_image_get_icon_set (image, &icon_set, NULL);
+      return gtk_image_new_from_icon_set (icon_set, GTK_ICON_SIZE_MENU);
+    }
+  else if (storage_type == GTK_IMAGE_PIXBUF)
+    {
+      gint width, height;
+      
+      if (settings &&
+         gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU,
+                                            &width, &height))
+       {
+         GdkPixbuf *src_pixbuf, *dest_pixbuf;
+
+         src_pixbuf = gtk_image_get_pixbuf (image);
+         dest_pixbuf = gdk_pixbuf_scale_simple (src_pixbuf, width, height,
+                                                GDK_INTERP_BILINEAR);
+
+         return gtk_image_new_from_pixbuf (dest_pixbuf);
+       }
+    }
+
+  return NULL;
+}
+      
 static gboolean
 gtk_tool_button_create_menu_proxy (GtkToolItem *item)
 {
@@ -475,17 +537,28 @@ gtk_tool_button_create_menu_proxy (GtkToolItem *item)
   GtkWidget *menu_image = NULL;
   GtkStockItem stock_item;
   gboolean use_mnemonic = TRUE;
-  const char *label = "";
+  const char *label;
 
   if (button->label_widget && GTK_IS_LABEL (button->label_widget))
-    label = gtk_label_get_label (GTK_LABEL (button->label_widget));
+    {
+      label = gtk_label_get_label (GTK_LABEL (button->label_widget));
+      use_mnemonic = gtk_label_get_use_underline (GTK_LABEL (button->label_widget));
+    }
   else if (button->label_text)
     {
       label = button->label_text;
       use_mnemonic = button->use_underline;
     }
   else if (button->stock_id && gtk_stock_lookup (button->stock_id, &stock_item))
-    label = stock_item.label;
+    {
+      label = stock_item.label;
+      use_mnemonic = FALSE;
+    }
+  else
+    {
+      label = "";
+      use_mnemonic = FALSE;
+    }
   
   if (use_mnemonic)
     menu_item = gtk_image_menu_item_new_with_mnemonic (label);
@@ -494,21 +567,8 @@ gtk_tool_button_create_menu_proxy (GtkToolItem *item)
 
   if (button->icon_widget && GTK_IS_IMAGE (button->icon_widget))
     {
-      GtkImage *image = GTK_IMAGE (button->icon_widget);
-      GtkImageType storage_type = gtk_image_get_storage_type (image);
-      
-      if (storage_type == GTK_IMAGE_STOCK)
-       {
-         gchar *stock_id;
-         gtk_image_get_stock (image, &stock_id, NULL);
-         menu_image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
-       }
-      else if (storage_type == GTK_IMAGE_ICON_SET)
-       {
-         GtkIconSet *icon_set;
-         gtk_image_get_icon_set (image, &icon_set, NULL);
-         menu_image = gtk_image_new_from_icon_set (icon_set, GTK_ICON_SIZE_MENU);
-       }
+      menu_image = clone_image_menu_size (GTK_IMAGE (button->icon_widget),
+                                         gtk_widget_get_settings (GTK_WIDGET (button)));
     }
   else if (button->stock_id)
     {
diff --git a/tests/apple-red.png b/tests/apple-red.png
new file mode 100644 (file)
index 0000000..8d0f458
Binary files /dev/null and b/tests/apple-red.png differ
index 6ad3b8e8486241f4585d5c0276f7f41754e49627..6d8b92c2afde96131293f55b41a6f9299d0337e6 100644 (file)
@@ -532,15 +532,19 @@ main (gint argc, gchar **argv)
   
   item = gtk_radio_tool_button_new_from_stock (group, GTK_STOCK_JUSTIFY_CENTER);  make_prop_editor (G_OBJECT (item));
 
-  group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (item));  
+  group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (item));
   add_item_to_list (store, item, "Center");
   gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
 
   item = gtk_radio_tool_button_new_from_stock (group, GTK_STOCK_JUSTIFY_RIGHT);
-  
   add_item_to_list (store, item, "Right");
   gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
 
+  item = gtk_tool_button_new ("_Apple", gtk_image_new_from_file ("apple-red.png"));
+  add_item_to_list (store, item, "Apple");
+  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+  gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (item), TRUE);
+  
   hbox = gtk_hbox_new (FALSE, 5);
   gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
   gtk_table_attach (GTK_TABLE (table), hbox,