]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkiconfactory.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / gtk / gtkiconfactory.c
index 4feff1087fd89b14dfa49b5f670e95405c4cc2e4..b40267335b0a78c0a1ec613de399e2a2422de375 100644 (file)
@@ -12,9 +12,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 /*
@@ -41,6 +39,7 @@
 #include "gtkbuildable.h"
 #include "gtkbuilderprivate.h"
 #include "gtktypebuiltins.h"
+#include "deprecated/gtkstyle.h"
 
 
 /**
@@ -368,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;
 
 /**
@@ -410,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 ();
 
-      get_default_icons (gtk_default_icons);
+  if (screen)
+    icons = g_object_get_data (G_OBJECT (screen), "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;
 }
 
 /**
@@ -437,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);
 
@@ -453,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
@@ -1166,12 +1184,13 @@ gtk_icon_size_from_name (const gchar *name)
 /**
  * gtk_icon_size_get_name:
  * @size: (type int): a #GtkIconSize.
- * @returns: the name of the given icon size.
  *
  * Gets the canonical name of the given icon size. The returned string
  * is statically allocated and should not be freed.
+ *
+ * Returns: the name of the given icon size.
  */
-G_CONST_RETURN gchar*
+const gchar*
 gtk_icon_size_get_name (GtkIconSize  size)
 {
   if (size >= icon_sizes_used)
@@ -1456,7 +1475,7 @@ ensure_filename_pixbuf (GtkIconSet    *icon_set,
          /* Remove this icon source so we don't keep trying to
           * load it.
           */
-         g_warning (_("Error loading icon: %s"), error->message);
+         g_warning ("Error loading icon: %s", error->message);
          g_error_free (error);
 
          icon_set->sources = g_slist_remove (icon_set->sources, source);
@@ -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;
@@ -1662,9 +1681,10 @@ render_fallback_image (GtkStyleContext   *context,
       _gtk_icon_theme_ensure_builtin_cache ();
 
       index = _gtk_icon_cache_get_directory_index (_builtin_cache, "24");
-      pixbuf = _gtk_icon_cache_get_icon (_builtin_cache,
-                                        GTK_STOCK_MISSING_IMAGE,
-                                        index);
+      pixbuf = _gtk_icon_cache_get_icon (_builtin_cache, "image-missing", index);
+
+      g_return_val_if_fail(pixbuf != NULL, NULL);
+
       gtk_icon_source_set_pixbuf (&fallback_source, pixbuf);
       g_object_unref (pixbuf);
     }
@@ -1711,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)
     {
@@ -1806,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);
 
@@ -2145,7 +2169,7 @@ gtk_icon_source_set_filename (GtkIconSource *source,
 }
 
 /**
- * gtk_icon_source_set_icon_name
+ * gtk_icon_source_set_icon_name:
  * @source: a #GtkIconSource
  * @icon_name: (allow-none): name of icon to use
  *
@@ -2210,7 +2234,7 @@ gtk_icon_source_set_pixbuf (GtkIconSource *source,
  * Return value: (type filename): image filename. This string must not
  * be modified or freed.
  */
-G_CONST_RETURN gchar*
+const gchar*
 gtk_icon_source_get_filename (const GtkIconSource *source)
 {
   g_return_val_if_fail (source != NULL, NULL);
@@ -2231,7 +2255,7 @@ gtk_icon_source_get_filename (const GtkIconSource *source)
  *
  * Return value: icon name. This string must not be modified or freed.
  */
-G_CONST_RETURN gchar*
+const gchar*
 gtk_icon_source_get_icon_name (const GtkIconSource *source)
 {
   g_return_val_if_fail (source != NULL, NULL);
@@ -2799,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)