]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkiconfactory.c
GtkColorChooserWidget: deselect swatch before removing palettes
[~andy/gtk] / gtk / gtkiconfactory.c
index c95b46c7578ecf54d946c712b85c2f39b8506244..b40267335b0a78c0a1ec613de399e2a2422de375 100644 (file)
@@ -367,7 +367,6 @@ gtk_icon_factory_lookup (GtkIconFactory *factory,
   return g_hash_table_lookup (priv->icons, stock_id);
 }
 
-static GtkIconFactory *gtk_default_icons = NULL;
 static GSList *default_factories = NULL;
 
 /**
@@ -409,15 +408,32 @@ gtk_icon_factory_remove_default (GtkIconFactory  *factory)
   g_object_unref (factory);
 }
 
-void
-_gtk_icon_factory_ensure_default_icons (void)
+static GtkIconFactory *
+_gtk_icon_factory_get_default_icons (void)
 {
-  if (gtk_default_icons == NULL)
-    {
-      gtk_default_icons = gtk_icon_factory_new ();
+  static GtkIconFactory *default_icons = NULL;
+  GtkIconFactory *icons = NULL;
+  GdkScreen *screen = gdk_screen_get_default ();
+
+  if (screen)
+    icons = g_object_get_data (G_OBJECT (screen), "gtk-default-icons");
 
-      get_default_icons (gtk_default_icons);
+  if (icons == NULL)
+    {
+      if (default_icons == NULL)
+        {
+          default_icons = gtk_icon_factory_new ();
+          get_default_icons (default_icons);
+        }
+      if (screen)
+        g_object_set_data_full (G_OBJECT (screen),
+                                I_("gtk-default-icons"),
+                                default_icons,
+                                g_object_unref);
+      icons = default_icons;
     }
+
+  return icons;
 }
 
 /**
@@ -436,6 +452,7 @@ GtkIconSet *
 gtk_icon_factory_lookup_default (const gchar *stock_id)
 {
   GSList *tmp_list;
+  GtkIconFactory *default_icons;
 
   g_return_val_if_fail (stock_id != NULL, NULL);
 
@@ -452,9 +469,11 @@ gtk_icon_factory_lookup_default (const gchar *stock_id)
       tmp_list = g_slist_next (tmp_list);
     }
 
-  _gtk_icon_factory_ensure_default_icons ();
-
-  return gtk_icon_factory_lookup (gtk_default_icons, stock_id);
+  default_icons = _gtk_icon_factory_get_default_icons ();
+  if (default_icons)
+    return gtk_icon_factory_lookup (default_icons, stock_id);
+  else
+    return NULL;
 }
 
 static void
@@ -1550,7 +1569,7 @@ render_icon_name_pixbuf (GtkIconSource    *icon_source,
       if (info)
         {
           tmp_pixbuf = gtk_icon_info_load_icon (info, &error);
-          gtk_icon_info_free (info);
+          g_object_unref (info);
         }
       else
         tmp_pixbuf = NULL;
@@ -1712,7 +1731,9 @@ gtk_icon_set_render_icon_pixbuf (GtkIconSet        *icon_set,
   else
     state = GTK_STATE_NORMAL;
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
   direction = gtk_style_context_get_direction (context);
+G_GNUC_END_IGNORE_DEPRECATIONS;
 
   if (icon_set->sources)
     {
@@ -1807,7 +1828,9 @@ gtk_icon_set_render_icon (GtkIconSet        *icon_set,
     }
 
   gtk_style_context_set_state (context, flags);
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
   gtk_style_context_set_direction (context, direction);
+G_GNUC_END_IGNORE_DEPRECATIONS;
 
   icon = gtk_icon_set_render_icon_pixbuf (icon_set, context, size);
 
@@ -2800,7 +2823,7 @@ _gtk_icon_factory_list_ids (void)
 
   ids = NULL;
 
-  _gtk_icon_factory_ensure_default_icons ();
+  _gtk_icon_factory_get_default_icons ();
 
   tmp_list = all_icon_factories;
   while (tmp_list != NULL)