Index: gtk/gtkimagemenuitem.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkimagemenuitem.c,v
retrieving revision 1.25
diff -u -p -r1.25 gtkimagemenuitem.c
--- gtk/gtkimagemenuitem.c	9 Aug 2004 16:59:52 -0000	1.25
+++ gtk/gtkimagemenuitem.c	14 Nov 2004 06:07:59 -0000
@@ -33,18 +33,12 @@
 #include "gtkiconfactory.h"
 #include "gtkimage.h"
 
-typedef struct _GtkImageMenuItemPrivate GtkImageMenuItemPrivate;
-
-struct _GtkImageMenuItemPrivate 
-{
-  GtkSettings *settings;
-  guint        show_image_connection;
-};
-
-#define GTK_IMAGE_MENU_ITEM_GET_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_IMAGE_MENU_ITEM, GtkImageMenuItemPrivate))
+static GHashTable *all_image_menu_items = NULL;
 
 static void gtk_image_menu_item_class_init           (GtkImageMenuItemClass *klass);
 static void gtk_image_menu_item_init                 (GtkImageMenuItem      *image_menu_item);
+static void gtk_image_menu_item_finalize             (GObject          *object);
+
 static void gtk_image_menu_item_size_request         (GtkWidget        *widget,
                                                       GtkRequisition   *requisition);
 static void gtk_image_menu_item_size_allocate        (GtkWidget        *widget,
@@ -130,6 +124,7 @@ gtk_image_menu_item_class_init (GtkImage
   
   menu_item_class->toggle_size_request = gtk_image_menu_item_toggle_size_request;
 
+  gobject_class->finalize = gtk_image_menu_item_finalize;
   gobject_class->set_property = gtk_image_menu_item_set_property;
   gobject_class->get_property = gtk_image_menu_item_get_property;
   
@@ -146,14 +141,26 @@ gtk_image_menu_item_class_init (GtkImage
 						       P_("Whether images should be shown in menus"),
 						       TRUE,
 						       G_PARAM_READWRITE));
-
-  g_type_class_add_private (gobject_class, sizeof (GtkImageMenuItemPrivate));  
+  
+  if (all_image_menu_items == NULL)
+    all_image_menu_items = g_hash_table_new (NULL, NULL);
 }
 
 static void
 gtk_image_menu_item_init (GtkImageMenuItem *image_menu_item)
 {
   image_menu_item->image = NULL;
+
+  g_hash_table_insert (all_image_menu_items, 
+		       image_menu_item, image_menu_item);
+}
+
+static void
+gtk_image_menu_item_finalize (GObject *object)
+{
+  g_hash_table_remove (all_image_menu_items, object);
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
 static void
@@ -551,44 +558,48 @@ gtk_image_menu_item_remove (GtkContainer
 static void 
 show_image_change_notify (GtkImageMenuItem *image_menu_item)
 {
-  if (image_menu_item->image) 
-    g_object_set (image_menu_item->image, "visible", show_image (image_menu_item), NULL);
+  if (image_menu_item->image)
+    {
+      if (show_image (image_menu_item))
+	gtk_widget_show (image_menu_item->image);
+      else
+	gtk_widget_hide (image_menu_item->image);
+    }
+}
+
+static void
+gtk_image_menu_item_setting_changed (GtkSettings *settings)
+{
+  g_hash_table_foreach (all_image_menu_items, 
+			(GHFunc)show_image_change_notify, NULL);
 }
 
 static void
 gtk_image_menu_item_screen_changed (GtkWidget *widget,
 				    GdkScreen *previous_screen)
 {
-  GtkImageMenuItemPrivate *priv = GTK_IMAGE_MENU_ITEM_GET_PRIVATE (widget);
   GtkSettings *settings;
+  guint show_image_connection;
 
-  if (gtk_widget_has_screen (widget))
-    settings = gtk_widget_get_settings (widget);
-  else
-    settings = NULL;
-
-  if (settings == priv->settings)
+  if (!gtk_widget_has_screen (widget))
     return;
 
-  if (priv->settings)
-    {
-      g_signal_handler_disconnect (priv->settings, priv->show_image_connection);
-      g_object_unref (priv->settings);
-    }
-
-  if (settings)
-    {
-      priv->show_image_connection =
-	g_signal_connect_swapped (settings,
-				  "notify::gtk-menu-images",
-				  G_CALLBACK (show_image_change_notify),
-				  widget);
+  settings = gtk_widget_get_settings (widget);
+  
+  show_image_connection = 
+    GPOINTER_TO_INT (g_object_get_data (G_OBJECT (settings), 
+					"gtk-image-menu-item-connection"));
+  
+  if (show_image_connection)
+    return;
 
-      g_object_ref (settings);
-      priv->settings = settings;
-    }
-  else
-    priv->settings = NULL;
+  show_image_connection =
+    g_signal_connect (settings, "notify::gtk-menu-images",
+		      G_CALLBACK (gtk_image_menu_item_setting_changed), 0);
+  g_object_set_data (G_OBJECT (settings), 
+		     "gtk-image-menu-item-connection",
+		     GINT_TO_POINTER (show_image_connection));
 
   show_image_change_notify (GTK_IMAGE_MENU_ITEM (widget));
 }
+
Index: gtk/gtkbutton.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkbutton.c,v
retrieving revision 1.112
diff -u -p -r1.112 gtkbutton.c
--- gtk/gtkbutton.c	26 Sep 2004 05:47:11 -0000	1.112
+++ gtk/gtkbutton.c	14 Nov 2004 06:07:59 -0000
@@ -72,18 +72,19 @@ enum {
 #define GTK_BUTTON_GET_PRIVATE(o)       (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_BUTTON, GtkButtonPrivate))
 typedef struct _GtkButtonPrivate GtkButtonPrivate;
 
+static GHashTable *all_image_buttons = NULL;
+
 struct _GtkButtonPrivate
 {
   gfloat       xalign;
   gfloat       yalign;
-  GtkSettings *settings;
-  guint        show_image_connection;
   GtkWidget   *image;
   guint        align_set : 1;
 };
 
 static void gtk_button_class_init     (GtkButtonClass   *klass);
 static void gtk_button_init           (GtkButton        *button);
+static void gtk_button_finalize       (GObject          *object);
 static void gtk_button_destroy        (GtkObject        *object);
 static void gtk_button_set_property   (GObject         *object,
                                        guint            prop_id,
@@ -183,6 +184,7 @@ gtk_button_class_init (GtkButtonClass *k
   parent_class = g_type_class_peek_parent (klass);
 
   gobject_class->constructor = gtk_button_constructor;
+  gobject_class->finalize = gtk_button_finalize;
   gobject_class->set_property = gtk_button_set_property;
   gobject_class->get_property = gtk_button_get_property;
 
@@ -405,6 +407,9 @@ gtk_button_class_init (GtkButtonClass *k
 						       G_PARAM_READWRITE));
   
   g_type_class_add_private (gobject_class, sizeof (GtkButtonPrivate));  
+
+  if (all_image_buttons == NULL)
+    all_image_buttons = g_hash_table_new (NULL, NULL);
 }
 
 static void
@@ -446,6 +451,14 @@ gtk_button_destroy (GtkObject *object)
   (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
 }
 
+static void
+gtk_button_finalize (GObject *object)
+{
+  g_hash_table_remove (all_image_buttons, object);
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
 static GObject*
 gtk_button_constructor (GType                  type,
 			guint                  n_construct_properties,
@@ -650,6 +663,8 @@ gtk_button_construct_child (GtkButton *b
       gtk_container_add (GTK_CONTAINER (align), hbox);
       gtk_widget_show_all (align);
 
+      g_hash_table_insert (all_image_buttons, button, button);
+
       return;
     }
 
@@ -1613,43 +1628,47 @@ show_image_change_notify (GtkButton *but
   GtkButtonPrivate *priv = GTK_BUTTON_GET_PRIVATE (button);
 
   if (priv->image) 
-    g_object_set (priv->image, "visible", show_image (button), NULL);
+    {
+      if (show_image (button))
+	gtk_widget_show (priv->image);
+      else
+	gtk_widget_hide (priv->image);
+    }
+}
+
+static void
+gtk_button_setting_changed (GtkSettings *settings)
+{
+  g_hash_table_foreach (all_image_buttons, 
+			(GHFunc)show_image_change_notify, NULL);
 }
 
+
 static void
 gtk_button_screen_changed (GtkWidget *widget,
 			   GdkScreen *previous_screen)
 {
-  GtkButtonPrivate *priv = GTK_BUTTON_GET_PRIVATE (widget);
   GtkSettings *settings;
+  guint show_image_connection;
 
-  if (gtk_widget_has_screen (widget))
-    settings = gtk_widget_get_settings (widget);
-  else
-    settings = NULL;
-
-  if (settings == priv->settings)
+  if (!gtk_widget_has_screen (widget))
     return;
 
-  if (priv->settings)
-    {
-      g_signal_handler_disconnect (priv->settings, priv->show_image_connection);
-      g_object_unref (priv->settings);
-    }
+  settings = gtk_widget_get_settings (widget);
 
-  if (settings)
-    {
-      priv->show_image_connection =
-	g_signal_connect_swapped (settings,
-				  "notify::gtk-button-images",
-				  G_CALLBACK (show_image_change_notify),
-				  widget);
+  show_image_connection = 
+    GPOINTER_TO_INT (g_object_get_data (G_OBJECT (settings), 
+					"gtk-button-connection"));
+  
+  if (show_image_connection)
+    return;
 
-      g_object_ref (settings);
-      priv->settings = settings;
-    }
-  else
-    priv->settings = NULL;
+  show_image_connection =
+    g_signal_connect (settings, "notify::gtk-button-images",
+		      G_CALLBACK (gtk_button_setting_changed), 0);
+  g_object_set_data (G_OBJECT (settings), 
+		     "gtk-button-connection",
+		     GINT_TO_POINTER (show_image_connection));
 
   show_image_change_notify (GTK_BUTTON (widget));
 }
