]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkiconfactory.c
Apply a cleanup patch by Kjartan Maraas (#341812)
[~andy/gtk] / gtk / gtkiconfactory.c
index b7b5521fa240f25ec5f8d9768d62888836eb67af..0cc2cb1132d6252341ddb34f733ebd786af9af06 100644 (file)
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#include <config.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
 #include <pango/pango-utils.h> /* For pango_scan_* */
 #include "gtkiconfactory.h"
-#include "stock-icons/gtkstockpixbufs.h"
+#include "gtkiconcache.h"
 #include "gtkdebug.h"
 #include "gtkicontheme.h"
 #include "gtksettings.h"
 #include "gtkstock.h"
 #include "gtkwidget.h"
 #include "gtkintl.h"
+#include "gtkalias.h"
+
 
 static GSList *all_icon_factories = NULL;
 
 typedef enum {
   GTK_ICON_SOURCE_EMPTY,
   GTK_ICON_SOURCE_ICON_NAME,
+  GTK_ICON_SOURCE_STATIC_ICON_NAME,
   GTK_ICON_SOURCE_FILENAME,
   GTK_ICON_SOURCE_PIXBUF
 } GtkIconSourceType;
@@ -55,7 +59,7 @@ struct _GtkIconSource
     gchar *filename;
     GdkPixbuf *pixbuf;
   } source;
-  
+
   GdkPixbuf *filename_pixbuf;
 
   GtkTextDirection direction;
@@ -69,12 +73,16 @@ struct _GtkIconSource
   guint any_direction : 1;
   guint any_state : 1;
   guint any_size : 1;
+
+#ifdef G_OS_WIN32
+  /* System codepage version of filename, for DLL ABI backward
+   * compatibility functions.
+   */
+  gchar *cp_filename;
+#endif
 };
 
-static gpointer parent_class = NULL;
 
-static void gtk_icon_factory_init       (GtkIconFactory      *icon_factory);
-static void gtk_icon_factory_class_init (GtkIconFactoryClass *klass);
 static void gtk_icon_factory_finalize   (GObject             *object);
 static void get_default_icons           (GtkIconFactory      *icon_factory);
 static void icon_source_clear           (GtkIconSource       *source);
@@ -88,33 +96,7 @@ static GtkIconSize icon_size_register_intern (const gchar *name,
    0, 0, 0,                                                            \
    any_direction, any_state, any_size }
 
-GType
-gtk_icon_factory_get_type (void)
-{
-  static GType icon_factory_type = 0;
-
-  if (!icon_factory_type)
-    {
-      static const GTypeInfo icon_factory_info =
-      {
-        sizeof (GtkIconFactoryClass),
-        NULL,          /* base_init */
-        NULL,          /* base_finalize */
-        (GClassInitFunc) gtk_icon_factory_class_init,
-        NULL,           /* class_finalize */
-        NULL,           /* class_data */
-        sizeof (GtkIconFactory),
-        0,              /* n_preallocs */
-        (GInstanceInitFunc) gtk_icon_factory_init,
-      };
-      
-      icon_factory_type =
-       g_type_register_static (G_TYPE_OBJECT, "GtkIconFactory",
-                               &icon_factory_info, 0);
-    }
-  
-  return icon_factory_type;
-}
+G_DEFINE_TYPE (GtkIconFactory, gtk_icon_factory, G_TYPE_OBJECT)
 
 static void
 gtk_icon_factory_init (GtkIconFactory *factory)
@@ -128,8 +110,6 @@ gtk_icon_factory_class_init (GtkIconFactoryClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   
-  parent_class = g_type_class_peek_parent (klass);
-
   object_class->finalize = gtk_icon_factory_finalize;
 }
 
@@ -151,7 +131,7 @@ gtk_icon_factory_finalize (GObject *object)
   
   g_hash_table_destroy (factory->icons);
   
-  G_OBJECT_CLASS (parent_class)->finalize (object);
+  G_OBJECT_CLASS (gtk_icon_factory_parent_class)->finalize (object);
 }
 
 /**
@@ -294,8 +274,8 @@ gtk_icon_factory_remove_default (GtkIconFactory  *factory)
   g_object_unref (factory);
 }
 
-static void
-ensure_default_icons (void)
+void
+_gtk_icon_factory_ensure_default_icons (void)
 {
   if (gtk_default_icons == NULL)
     {
@@ -338,7 +318,7 @@ gtk_icon_factory_lookup_default (const gchar *stock_id)
       tmp_list = g_slist_next (tmp_list);
     }
 
-  ensure_default_icons ();
+  _gtk_icon_factory_ensure_default_icons ();
   
   return gtk_icon_factory_lookup (gtk_default_icons, stock_id);
 }
@@ -350,7 +330,7 @@ register_stock_icon (GtkIconFactory *factory,
   GtkIconSet *set = gtk_icon_set_new ();
   GtkIconSource source = GTK_ICON_SOURCE_INIT (TRUE, TRUE, TRUE);
 
-  source.type = GTK_ICON_SOURCE_ICON_NAME;
+  source.type = GTK_ICON_SOURCE_STATIC_ICON_NAME;
   source.source.icon_name = (gchar *)stock_id;
   gtk_icon_set_add_source (set, &source);
   
@@ -367,12 +347,12 @@ register_bidi_stock_icon (GtkIconFactory *factory,
   GtkIconSet *set = gtk_icon_set_new ();
   GtkIconSource source = GTK_ICON_SOURCE_INIT (FALSE, TRUE, TRUE);
 
-  source.type = GTK_ICON_SOURCE_ICON_NAME;
+  source.type = GTK_ICON_SOURCE_STATIC_ICON_NAME;
   source.source.icon_name = (gchar *)stock_id_ltr;
   source.direction = GTK_TEXT_DIR_LTR;
   gtk_icon_set_add_source (set, &source);
   
-  source.type = GTK_ICON_SOURCE_ICON_NAME;
+  source.type = GTK_ICON_SOURCE_STATIC_ICON_NAME;
   source.source.icon_name = (gchar *)stock_id_rtl;
   source.direction = GTK_TEXT_DIR_RTL;
   gtk_icon_set_add_source (set, &source);
@@ -381,329 +361,157 @@ register_bidi_stock_icon (GtkIconFactory *factory,
   gtk_icon_set_unref (set);
 }
 
-static void
-add_default_image (const gchar  *stock_id,
-                  gint          size,
-                  const guchar *inline_data)
-{
-  GdkPixbuf *pixbuf = gdk_pixbuf_new_from_inline (-1, inline_data, FALSE, NULL);
-  g_assert (pixbuf);
-
-  gtk_icon_theme_add_builtin_icon (stock_id, size, pixbuf);
-  
-  g_object_unref (pixbuf);
-}
-
-static void
-add_icon (GtkIconFactory *factory,
-         const gchar    *stock_id,
-         gint            size,
-         const guchar   *inline_data)
-{
-  register_stock_icon (factory, stock_id);
-
-  add_default_image (stock_id, size, inline_data);
-}
-
-static void
-add_icon2 (GtkIconFactory *factory,
-          const gchar    *stock_id,
-          gint            size1,
-          const guchar   *inline_data1,
-          gint            size2,
-          const guchar   *inline_data2)
-{
-  register_stock_icon (factory, stock_id);
-  
-  add_default_image (stock_id, size1, inline_data1);
-  add_default_image (stock_id, size2, inline_data2);
-}
-
-static void
-add_icon_bidi2 (GtkIconFactory *factory,
-               const gchar    *stock_id,
-               gint            size1,
-               const guchar   *inline_data_ltr1,
-               const guchar   *inline_data_rtl1,
-               gint            size2,
-               const guchar   *inline_data_ltr2,
-               const guchar   *inline_data_rtl2)
-{
-  gchar *stock_id_ltr = g_strconcat (stock_id, "-ltr", NULL);
-  gchar *stock_id_rtl = g_strconcat (stock_id, "-rtl", NULL);
-  
-  register_bidi_stock_icon (factory, stock_id,
-                           stock_id_ltr, stock_id_rtl);
-  
-  add_default_image (stock_id_ltr, size1, inline_data_ltr1);
-  add_default_image (stock_id_ltr, size2, inline_data_ltr2);
-
-  add_default_image (stock_id_rtl, size1, inline_data_rtl1);
-  add_default_image (stock_id_rtl, size2, inline_data_rtl2);
-  
-  g_free (stock_id_ltr);
-  g_free (stock_id_rtl);
-}
-
 static void
 get_default_icons (GtkIconFactory *factory)
 {
   /* KEEP IN SYNC with gtkstock.c */
 
-  /* Have dialog size */
-  add_icon (factory, GTK_STOCK_DIALOG_AUTHENTICATION, 48, stock_dialog_authentication_48);
-  add_icon (factory, GTK_STOCK_DIALOG_ERROR, 48, stock_dialog_error_48);
-  add_icon (factory, GTK_STOCK_DIALOG_INFO, 48, stock_dialog_info_48);
-  add_icon (factory, GTK_STOCK_DIALOG_QUESTION, 48, stock_dialog_question_48);
-  add_icon (factory, GTK_STOCK_DIALOG_WARNING, 48, stock_dialog_warning_48);
-  
-  /* Have dnd size */
-  add_icon (factory, GTK_STOCK_DND, 32, stock_dnd_32);
-  add_icon (factory, GTK_STOCK_DND_MULTIPLE, 32, stock_dnd_multiple_32);
-  
-  /* Have button sizes */
-  add_icon (factory, GTK_STOCK_APPLY, 20, stock_apply_20);
-  add_icon (factory, GTK_STOCK_CANCEL, 20, stock_cancel_20);
-  add_icon (factory, GTK_STOCK_NO, 20, stock_no_20);
-  add_icon (factory, GTK_STOCK_OK, 20, stock_ok_20);
-  add_icon (factory, GTK_STOCK_YES, 20, stock_yes_20);
-
-  /* Generic + button sizes */
-  add_icon2 (factory, GTK_STOCK_CLOSE,
-            20, stock_close_20,
-            24, stock_close_24);
-
-  /* Generic + menu sizes */  
-  add_icon2 (factory, GTK_STOCK_ADD,
-            16, stock_add_16,
-            24, stock_add_24);
-
-  add_icon2 (factory, GTK_STOCK_JUSTIFY_CENTER,
-            16, stock_align_center_16,
-            24, stock_align_center_24);
-
-  add_icon2 (factory, GTK_STOCK_JUSTIFY_FILL,
-            16, stock_align_justify_16,
-            24, stock_align_justify_24);
-
-  add_icon2 (factory, GTK_STOCK_JUSTIFY_LEFT,
-            16, stock_align_left_16,
-            24, stock_align_left_24);
-            
-  add_icon2 (factory, GTK_STOCK_JUSTIFY_RIGHT,
-            16, stock_align_right_16,
-            24, stock_align_right_24);
-
-  add_icon2 (factory, GTK_STOCK_GOTO_BOTTOM,
-            16, stock_bottom_16,
-            24, stock_bottom_24);
-            
-  add_icon2 (factory, GTK_STOCK_CDROM,
-            16, stock_cdrom_16,
-            24, stock_cdrom_24);
-
-  add_icon2 (factory, GTK_STOCK_CONVERT,
-            16, stock_convert_16,
-            24, stock_convert_24);
-
-  add_icon2 (factory, GTK_STOCK_COPY,
-            16, stock_copy_16,
-            24, stock_copy_24);
-
-  add_icon2 (factory, GTK_STOCK_CUT,
-            16, stock_cut_16,
-            24, stock_cut_24);
-
-  add_icon2 (factory, GTK_STOCK_GO_DOWN,
-            16, stock_down_arrow_16,
-            24, stock_down_arrow_24);
-
-  add_icon2 (factory, GTK_STOCK_EXECUTE,
-            16, stock_exec_16,
-            24, stock_exec_24);
-
-  add_icon2 (factory, GTK_STOCK_QUIT,
-            16, stock_exit_16,
-            24, stock_exit_24);
-
-  add_icon_bidi2 (factory, GTK_STOCK_GOTO_FIRST,
-                 16, stock_first_16, stock_last_16,
-                 24, stock_first_24, stock_last_24);
-
-  add_icon2 (factory, GTK_STOCK_SELECT_FONT,
-            16, stock_font_16,
-            24, stock_font_24);
-
-  add_icon2 (factory, GTK_STOCK_HARDDISK,
-            16, stock_harddisk_16,
-            24, stock_harddisk_24);
-
-  add_icon2 (factory, GTK_STOCK_HELP,
-            16, stock_help_16,
-            24, stock_help_24);
-
-  add_icon2 (factory, GTK_STOCK_HOME,
-            16, stock_home_16,
-            24, stock_home_24);
-
-  add_icon_bidi2 (factory, GTK_STOCK_JUMP_TO,
-                 16, stock_jump_to_16, stock_jump_to_rtl_16,
-                 24, stock_jump_to_24, stock_jump_to_rtl_24);
-
-  add_icon_bidi2 (factory, GTK_STOCK_GOTO_LAST,
-                 16, stock_last_16, stock_first_16,
-                 24, stock_last_24, stock_first_24);
-
-  add_icon_bidi2 (factory, GTK_STOCK_GO_BACK,
-                 16, stock_left_arrow_16, stock_right_arrow_16,
-                 24, stock_left_arrow_24, stock_right_arrow_24);
-
-  add_icon2 (factory, GTK_STOCK_MISSING_IMAGE,
-            16, stock_missing_image_16,
-            24, stock_missing_image_24);
-
-  add_icon2 (factory, GTK_STOCK_NETWORK,
-            16, stock_network_16,
-            24, stock_network_24);
-
-  add_icon2 (factory, GTK_STOCK_NEW,
-            16, stock_new_16,
-            24, stock_new_24);
-
-  add_icon2 (factory, GTK_STOCK_OPEN,
-            16, stock_open_16,
-            24, stock_open_24);
-
-  add_icon2 (factory, GTK_STOCK_PASTE,
-            16, stock_paste_16,
-            24, stock_paste_24);
-
-  add_icon2 (factory, GTK_STOCK_PREFERENCES,
-            16, stock_preferences_16,
-            24, stock_preferences_24);
-
-  add_icon2 (factory, GTK_STOCK_PRINT,
-            16, stock_print_16,
-            24, stock_print_24);
-
-  add_icon2 (factory, GTK_STOCK_PRINT_PREVIEW,
-            16, stock_print_preview_16,
-            24, stock_print_preview_24);
-
-  add_icon2 (factory, GTK_STOCK_PROPERTIES,
-            16, stock_properties_16,
-            24, stock_properties_24);
-  
-  add_icon_bidi2 (factory, GTK_STOCK_REDO,
-                 16, stock_redo_16, stock_redo_rtl_16,
-                 24, stock_redo_24, stock_redo_rtl_24);
-
-  add_icon2 (factory, GTK_STOCK_REMOVE,
-            16, stock_remove_16,
-            24, stock_remove_24);
-
-  add_icon2 (factory, GTK_STOCK_REFRESH,
-            16, stock_refresh_16,
-            24, stock_refresh_24);
-
-  add_icon_bidi2 (factory, GTK_STOCK_REVERT_TO_SAVED,
-                 16, stock_revert_16, stock_revert_rtl_16,
-                 24, stock_revert_24, stock_revert_rtl_24);
-
-  add_icon_bidi2 (factory, GTK_STOCK_GO_FORWARD,
-                 16, stock_right_arrow_16, stock_left_arrow_16,
-                 24, stock_right_arrow_24, stock_left_arrow_24);
-
-  add_icon2 (factory, GTK_STOCK_SAVE,
-            16, stock_save_16,
-            24, stock_save_24);
-
-  add_icon2 (factory, GTK_STOCK_FLOPPY,
-            16, stock_save_16,
-            24, stock_save_24);
-
-  add_icon2 (factory, GTK_STOCK_SAVE_AS,
-            16, stock_save_as_16,
-            24, stock_save_as_24);
-
-  add_icon2 (factory, GTK_STOCK_FIND,
-            16, stock_search_16,
-            24, stock_search_24);
-
-  add_icon2 (factory, GTK_STOCK_FIND_AND_REPLACE,
-            16, stock_search_replace_16,
-            24, stock_search_replace_24);
-
-  add_icon2 (factory, GTK_STOCK_SORT_DESCENDING,
-            16, stock_sort_descending_16,
-            24, stock_sort_descending_24);
-
-  add_icon2 (factory, GTK_STOCK_SORT_ASCENDING,
-            16, stock_sort_ascending_16,
-            24, stock_sort_ascending_24);
-
-  add_icon2 (factory, GTK_STOCK_SPELL_CHECK,
-            16, stock_spellcheck_16,
-            24, stock_spellcheck_24);
-
-  add_icon2 (factory, GTK_STOCK_STOP,
-            16, stock_stop_16,
-            24, stock_stop_24);
-
-  add_icon2 (factory, GTK_STOCK_BOLD,
-            16, stock_text_bold_16,
-            24, stock_text_bold_24);
-
-  add_icon2 (factory, GTK_STOCK_ITALIC,
-            16, stock_text_italic_16,
-            24, stock_text_italic_24);
-
-  add_icon2 (factory, GTK_STOCK_STRIKETHROUGH,
-            16, stock_text_strikethrough_16,
-            24, stock_text_strikethrough_24);
-
-  add_icon2 (factory, GTK_STOCK_UNDERLINE,
-            16, stock_text_underline_16,
-            24, stock_text_underline_24);
-
-  add_icon2 (factory, GTK_STOCK_INDENT,
-            16, stock_text_indent_16,
-            24, stock_text_indent_24);
-
-  add_icon2 (factory, GTK_STOCK_UNINDENT,
-            16, stock_text_unindent_16,
-            24, stock_text_unindent_24);
-
-  add_icon2 (factory, GTK_STOCK_GOTO_TOP,
-            16, stock_top_16,
-            24, stock_top_24);
-
-  add_icon2 (factory, GTK_STOCK_DELETE,
-            16, stock_trash_16,
-            24, stock_trash_24);
-
-  add_icon_bidi2 (factory, GTK_STOCK_UNDELETE,
-                 16, stock_undelete_16, stock_undelete_rtl_16,
-                 24, stock_undelete_24, stock_undelete_rtl_24);
-
-  add_icon_bidi2 (factory, GTK_STOCK_UNDO,
-                 16, stock_undo_16, stock_undo_rtl_16,
-                 24, stock_undo_24, stock_undo_rtl_24);
-
-  add_icon2 (factory, GTK_STOCK_GO_UP,
-            16, stock_up_arrow_16,
-            24, stock_up_arrow_24);
-
-  /* Generic size only */
-
-  add_icon (factory, GTK_STOCK_CLEAR, 24, stock_clear_24);
-  add_icon (factory, GTK_STOCK_SELECT_COLOR, 24, stock_colorselector_24);
-  add_icon (factory, GTK_STOCK_COLOR_PICKER, 25, stock_color_picker_25);
-  add_icon (factory, GTK_STOCK_INDEX, 24, stock_index_24);
-  add_icon (factory, GTK_STOCK_ZOOM_100, 24, stock_zoom_1_24);
-  add_icon (factory, GTK_STOCK_ZOOM_FIT, 24, stock_zoom_fit_24);
-  add_icon (factory, GTK_STOCK_ZOOM_IN, 24, stock_zoom_in_24);
-  add_icon (factory, GTK_STOCK_ZOOM_OUT, 24, stock_zoom_out_24);
+  register_stock_icon (factory, GTK_STOCK_DIALOG_AUTHENTICATION);
+  register_stock_icon (factory, GTK_STOCK_DIALOG_ERROR);
+  register_stock_icon (factory, GTK_STOCK_DIALOG_INFO);
+  register_stock_icon (factory, GTK_STOCK_DIALOG_QUESTION);
+  register_stock_icon (factory, GTK_STOCK_DIALOG_WARNING);
+  register_stock_icon (factory, GTK_STOCK_DND);
+  register_stock_icon (factory, GTK_STOCK_DND_MULTIPLE);
+  register_stock_icon (factory, GTK_STOCK_APPLY);
+  register_stock_icon (factory, GTK_STOCK_CANCEL);
+  register_stock_icon (factory, GTK_STOCK_NO);
+  register_stock_icon (factory, GTK_STOCK_OK);
+  register_stock_icon (factory, GTK_STOCK_YES);
+  register_stock_icon (factory, GTK_STOCK_CLOSE);
+  register_stock_icon (factory, GTK_STOCK_ADD);
+  register_stock_icon (factory, GTK_STOCK_JUSTIFY_CENTER);
+  register_stock_icon (factory, GTK_STOCK_JUSTIFY_FILL);
+  register_stock_icon (factory, GTK_STOCK_JUSTIFY_LEFT);
+  register_stock_icon (factory, GTK_STOCK_JUSTIFY_RIGHT);
+  register_stock_icon (factory, GTK_STOCK_GOTO_BOTTOM);
+  register_stock_icon (factory, GTK_STOCK_CDROM);
+  register_stock_icon (factory, GTK_STOCK_CONVERT);
+  register_stock_icon (factory, GTK_STOCK_COPY);
+  register_stock_icon (factory, GTK_STOCK_CUT);
+  register_stock_icon (factory, GTK_STOCK_GO_DOWN);
+  register_stock_icon (factory, GTK_STOCK_EXECUTE);
+  register_stock_icon (factory, GTK_STOCK_QUIT);
+  register_bidi_stock_icon (factory,  
+                           GTK_STOCK_GOTO_FIRST, 
+                           GTK_STOCK_GOTO_FIRST "-ltr", 
+                           GTK_STOCK_GOTO_FIRST "-rtl");
+  register_stock_icon (factory, GTK_STOCK_SELECT_FONT);
+  register_stock_icon (factory, GTK_STOCK_FULLSCREEN);
+  register_stock_icon (factory, GTK_STOCK_LEAVE_FULLSCREEN);
+  register_stock_icon (factory, GTK_STOCK_HARDDISK);
+  register_stock_icon (factory, GTK_STOCK_HELP);
+  register_stock_icon (factory, GTK_STOCK_HOME);
+  register_stock_icon (factory, GTK_STOCK_INFO);
+  register_bidi_stock_icon (factory, 
+                           GTK_STOCK_JUMP_TO,
+                           GTK_STOCK_JUMP_TO "-ltr",
+                           GTK_STOCK_JUMP_TO "-rtl");
+  register_bidi_stock_icon (factory, 
+                           GTK_STOCK_GOTO_LAST,
+                           GTK_STOCK_GOTO_LAST "-ltr",
+                           GTK_STOCK_GOTO_LAST "-rtl");
+  register_bidi_stock_icon (factory, 
+                           GTK_STOCK_GO_BACK,
+                           GTK_STOCK_GO_BACK "-ltr",
+                           GTK_STOCK_GO_BACK "-rtl");
+  register_stock_icon (factory, GTK_STOCK_MISSING_IMAGE);
+  register_stock_icon (factory, GTK_STOCK_NETWORK);
+  register_stock_icon (factory, GTK_STOCK_NEW);
+  register_stock_icon (factory, GTK_STOCK_OPEN);
+  register_stock_icon (factory, GTK_STOCK_ORIENTATION_PORTRAIT);
+  register_stock_icon (factory, GTK_STOCK_ORIENTATION_LANDSCAPE);
+  register_stock_icon (factory, GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT);
+  register_stock_icon (factory, GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE);
+  register_stock_icon (factory, GTK_STOCK_PASTE);
+  register_stock_icon (factory, GTK_STOCK_PREFERENCES);
+  register_stock_icon (factory, GTK_STOCK_PRINT);
+  register_stock_icon (factory, GTK_STOCK_PRINT_PREVIEW);
+  register_stock_icon (factory, GTK_STOCK_PROPERTIES);
+  register_bidi_stock_icon (factory, 
+                           GTK_STOCK_REDO,
+                           GTK_STOCK_REDO "-ltr",
+                           GTK_STOCK_REDO "-rtl");
+  register_stock_icon (factory, GTK_STOCK_REMOVE);
+  register_stock_icon (factory, GTK_STOCK_REFRESH);
+  register_bidi_stock_icon (factory, 
+                           GTK_STOCK_REVERT_TO_SAVED,
+                           GTK_STOCK_REVERT_TO_SAVED "-ltr",
+                           GTK_STOCK_REVERT_TO_SAVED "-rtl");
+  register_bidi_stock_icon (factory, 
+                           GTK_STOCK_GO_FORWARD,
+                           GTK_STOCK_GO_FORWARD "-ltr",
+                           GTK_STOCK_GO_FORWARD "-rtl");
+  register_stock_icon (factory, GTK_STOCK_SAVE);
+  register_stock_icon (factory, GTK_STOCK_FLOPPY);
+  register_stock_icon (factory, GTK_STOCK_SAVE_AS);
+  register_stock_icon (factory, GTK_STOCK_FIND);
+  register_stock_icon (factory, GTK_STOCK_FIND_AND_REPLACE);
+  register_stock_icon (factory, GTK_STOCK_SORT_DESCENDING);
+  register_stock_icon (factory, GTK_STOCK_SORT_ASCENDING);
+  register_stock_icon (factory, GTK_STOCK_SPELL_CHECK);
+  register_stock_icon (factory, GTK_STOCK_STOP);
+  register_stock_icon (factory, GTK_STOCK_BOLD);
+  register_stock_icon (factory, GTK_STOCK_ITALIC);
+  register_stock_icon (factory, GTK_STOCK_STRIKETHROUGH);
+  register_stock_icon (factory, GTK_STOCK_UNDERLINE);
+  register_bidi_stock_icon (factory, 
+                           GTK_STOCK_INDENT,
+                           GTK_STOCK_INDENT "-ltr",
+                           GTK_STOCK_INDENT "-rtl");
+  register_bidi_stock_icon (factory, 
+                           GTK_STOCK_UNINDENT,
+                           GTK_STOCK_UNINDENT "-ltr",
+                           GTK_STOCK_UNINDENT "-rtl");
+  register_stock_icon (factory, GTK_STOCK_GOTO_TOP);
+  register_stock_icon (factory, GTK_STOCK_DELETE);
+  register_bidi_stock_icon (factory, 
+                           GTK_STOCK_UNDELETE,
+                           GTK_STOCK_UNDELETE "-ltr",
+                           GTK_STOCK_UNDELETE "-rtl");
+  register_bidi_stock_icon (factory, 
+                           GTK_STOCK_UNDO,
+                           GTK_STOCK_UNDO "-ltr",
+                           GTK_STOCK_UNDO "-rtl");
+  register_stock_icon (factory, GTK_STOCK_GO_UP);
+  register_stock_icon (factory, GTK_STOCK_FILE);
+  register_stock_icon (factory, GTK_STOCK_DIRECTORY);
+  register_stock_icon (factory, GTK_STOCK_ABOUT);
+  register_stock_icon (factory, GTK_STOCK_CONNECT);
+  register_stock_icon (factory, GTK_STOCK_DISCONNECT);
+  register_stock_icon (factory, GTK_STOCK_EDIT);
+  register_bidi_stock_icon (factory, 
+                           GTK_STOCK_MEDIA_FORWARD,
+                           GTK_STOCK_MEDIA_FORWARD "-ltr",
+                           GTK_STOCK_MEDIA_FORWARD "-rtl");
+  register_bidi_stock_icon (factory, 
+                           GTK_STOCK_MEDIA_NEXT,
+                           GTK_STOCK_MEDIA_NEXT "-ltr",
+                           GTK_STOCK_MEDIA_NEXT "-rtl");
+  register_stock_icon (factory, GTK_STOCK_MEDIA_PAUSE);
+  register_bidi_stock_icon (factory, 
+                           GTK_STOCK_MEDIA_PLAY,
+                           GTK_STOCK_MEDIA_PLAY "-ltr",
+                           GTK_STOCK_MEDIA_PLAY "-rtl");
+  register_bidi_stock_icon (factory, 
+                           GTK_STOCK_MEDIA_PREVIOUS,
+                           GTK_STOCK_MEDIA_PREVIOUS "-ltr",
+                           GTK_STOCK_MEDIA_PREVIOUS "-rtl");
+  register_stock_icon (factory, GTK_STOCK_MEDIA_RECORD);
+  register_bidi_stock_icon (factory, 
+                           GTK_STOCK_MEDIA_REWIND,
+                           GTK_STOCK_MEDIA_REWIND "-ltr",
+                           GTK_STOCK_MEDIA_REWIND "-rtl");
+  register_stock_icon (factory, GTK_STOCK_MEDIA_STOP);
+  register_stock_icon (factory, GTK_STOCK_INDEX);
+  register_stock_icon (factory, GTK_STOCK_ZOOM_100);
+  register_stock_icon (factory, GTK_STOCK_ZOOM_IN);
+  register_stock_icon (factory, GTK_STOCK_ZOOM_OUT);
+  register_stock_icon (factory, GTK_STOCK_ZOOM_FIT);
+  register_stock_icon (factory, GTK_STOCK_SELECT_ALL);
+  register_stock_icon (factory, GTK_STOCK_CLEAR);
+  register_stock_icon (factory, GTK_STOCK_SELECT_COLOR);
+  register_stock_icon (factory, GTK_STOCK_COLOR_PICKER);
 }
 
 /************************************************************
@@ -1212,7 +1020,7 @@ gtk_icon_size_register_alias (const gchar *alias,
   init_icon_sizes ();
 
   if (!icon_size_lookup_intern (NULL, target, NULL, NULL))
-    g_warning ("gtk_icon_size_register_alias: Icon size %d does not exist", target);
+    g_warning ("gtk_icon_size_register_alias: Icon size %u does not exist", target);
 
   ia = g_hash_table_lookup (icon_aliases, alias);
   if (ia)
@@ -1440,7 +1248,7 @@ gtk_icon_set_get_type (void)
   static GType our_type = 0;
   
   if (our_type == 0)
-    our_type = g_boxed_type_register_static ("GtkIconSet",
+    our_type = g_boxed_type_register_static (I_("GtkIconSet"),
                                             (GBoxedCopyFunc) gtk_icon_set_ref,
                                             (GBoxedFreeFunc) gtk_icon_set_unref);
 
@@ -1590,11 +1398,12 @@ render_icon_name_pixbuf (GtkIconSource    *icon_source,
   GtkIconTheme *icon_theme;
   GtkSettings *settings;
   gint width, height, pixel_size;
+  gint *sizes, *s, dist;
   GError *error = NULL;
   
   if (widget && gtk_widget_has_screen (widget))
     screen = gtk_widget_get_screen (widget);
-  else if (style->colormap)
+  else if (style && style->colormap)
     screen = gdk_colormap_get_screen (style->colormap);
   else
     {
@@ -1608,8 +1417,45 @@ render_icon_name_pixbuf (GtkIconSource    *icon_source,
 
   if (!gtk_icon_size_lookup_for_settings (settings, size, &width, &height))
     {
-      g_warning ("Invalid icon size %d\n", size);
-      width = height = 24;
+      if (size == -1)
+       {
+         /* Find an available size close to 48 
+          */
+         sizes = gtk_icon_theme_get_icon_sizes (icon_theme, icon_source->source.icon_name);
+         dist = 1000;
+         width = height = 48;
+         for (s = sizes; *s; s++)
+           {
+             if (*s == -1)
+               {
+                 width = height = 48;
+                 break;
+               }
+             if (*s < 48)
+               {
+                 if (48 - *s < dist)
+                   {
+                     width = height = *s;
+                     dist = 48 - *s;
+                   }
+               }
+             else 
+               {
+                 if (*s - 48 < dist)
+                   {
+                     width = height = *s;
+                     dist = *s - 48;
+                   }
+               }
+           }
+         
+         g_free (sizes);
+       }
+      else
+       {
+         g_warning ("Invalid icon size %u\n", size);
+         width = height = 24;
+       }
     }
 
   pixel_size = MIN (width, height);
@@ -1688,6 +1534,7 @@ find_and_render_icon_source (GtkIconSet       *icon_set,
            }
          break;
        case GTK_ICON_SOURCE_ICON_NAME:
+       case GTK_ICON_SOURCE_STATIC_ICON_NAME:
          pixbuf = render_icon_name_pixbuf (source, style,
                                            direction, state, size,
                                            widget, detail);
@@ -1704,6 +1551,8 @@ find_and_render_icon_source (GtkIconSet       *icon_set,
   return pixbuf;
 }
 
+extern GtkIconCache *_builtin_cache;
+
 static GdkPixbuf*
 render_fallback_image (GtkStyle          *style,
                        GtkTextDirection   direction,
@@ -1717,7 +1566,13 @@ render_fallback_image (GtkStyle          *style,
 
   if (fallback_source.type == GTK_ICON_SOURCE_EMPTY)
     {
-      GdkPixbuf *pixbuf = gdk_pixbuf_new_from_inline (-1, stock_missing_image_24, FALSE, NULL);
+      GdkPixbuf *pixbuf;
+
+      _gtk_icon_theme_ensure_builtin_cache ();
+
+      pixbuf = _gtk_icon_cache_get_icon (_builtin_cache,
+                                        GTK_STOCK_MISSING_IMAGE,
+                                        "24");
       gtk_icon_source_set_pixbuf (&fallback_source, pixbuf);
       g_object_unref (pixbuf);
     }
@@ -1737,7 +1592,8 @@ render_fallback_image (GtkStyle          *style,
  * @style: a #GtkStyle associated with @widget, or %NULL
  * @direction: text direction
  * @state: widget state
- * @size: icon size
+ * @size: icon size. A size of (GtkIconSize)-1
+ *        means render at the size of the source and don't scale.
  * @widget: widget that will display the icon, or %NULL.
  *          The only use that is typically made of this
  *          is to determine the appropriate #GdkScreen.
@@ -1766,7 +1622,7 @@ gtk_icon_set_render_icon (GtkIconSet        *icon_set,
   GdkPixbuf *icon;
   
   g_return_val_if_fail (icon_set != NULL, NULL);
-  g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
+  g_return_val_if_fail (style == NULL || GTK_IS_STYLE (style), NULL);
 
   if (icon_set->sources == NULL)
     return render_fallback_image (style, direction, state, size, widget, detail);
@@ -2027,12 +1883,16 @@ gtk_icon_source_copy (const GtkIconSource *source)
   switch (copy->type)
     {
     case GTK_ICON_SOURCE_EMPTY:
+    case GTK_ICON_SOURCE_STATIC_ICON_NAME:
       break;
     case GTK_ICON_SOURCE_ICON_NAME:
       copy->source.icon_name = g_strdup (copy->source.icon_name);
       break;
     case GTK_ICON_SOURCE_FILENAME:
       copy->source.filename = g_strdup (copy->source.filename);
+#ifdef G_OS_WIN32
+      copy->cp_filename = g_strdup (copy->cp_filename);
+#endif
       if (copy->filename_pixbuf)
        g_object_ref (copy->filename_pixbuf);
       break;
@@ -2084,12 +1944,19 @@ icon_source_clear (GtkIconSource *source)
       break;
     case GTK_ICON_SOURCE_ICON_NAME:
       g_free (source->source.icon_name);
+      /* fall thru */
+    case GTK_ICON_SOURCE_STATIC_ICON_NAME:
       source->source.icon_name = NULL;
       break;
     case GTK_ICON_SOURCE_FILENAME:
       g_free (source->source.filename);
       source->source.filename = NULL;
-      g_free (source->filename_pixbuf);
+#ifdef G_OS_WIN32
+      g_free (source->cp_filename);
+      source->cp_filename = NULL;
+#endif
+      if (source->filename_pixbuf) 
+       g_object_unref (source->filename_pixbuf);
       source->filename_pixbuf = NULL;
       break;
     case GTK_ICON_SOURCE_PIXBUF:
@@ -2128,6 +1995,9 @@ gtk_icon_source_set_filename (GtkIconSource *source,
     {
       source->type = GTK_ICON_SOURCE_FILENAME;
       source->source.filename = g_strdup (filename);
+#ifdef G_OS_WIN32
+      source->cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
+#endif
     }
 }
 
@@ -2223,7 +2093,8 @@ gtk_icon_source_get_icon_name (const GtkIconSource *source)
 {
   g_return_val_if_fail (source != NULL, NULL);
 
-  if (source->type == GTK_ICON_SOURCE_ICON_NAME)
+  if (source->type == GTK_ICON_SOURCE_ICON_NAME ||
+     source->type == GTK_ICON_SOURCE_STATIC_ICON_NAME)
     return source->source.icon_name;
   else
     return NULL;
@@ -2597,7 +2468,7 @@ add_to_cache (GtkIconSet      *icon_set,
   CachedIcon *icon;
 
   ensure_cache_up_to_date (icon_set);
-  
+
   g_object_ref (pixbuf);
 
   /* We have to ref the style, since if the style was finalized
@@ -2607,10 +2478,10 @@ add_to_cache (GtkIconSet      *icon_set,
   
   if (style)
     g_object_ref (style);
-  
 
   icon = g_new (CachedIcon, 1);
   icon_set->cache = g_slist_prepend (icon_set->cache, icon);
+  icon_set->cache_size++;
 
   icon->style = style;
   icon->direction = direction;
@@ -2624,7 +2495,6 @@ add_to_cache (GtkIconSet      *icon_set,
   if (icon_set->cache_size >= NUM_CACHED_ICONS)
     {
       /* Remove oldest item in the cache */
-      
       GSList *tmp_list;
       
       tmp_list = icon_set->cache;
@@ -2652,10 +2522,13 @@ static void
 clear_cache (GtkIconSet *icon_set,
              gboolean    style_detach)
 {
-  GSList *tmp_list;
+  GSList *cache, *tmp_list;
   GtkStyle *last_style = NULL;
 
-  tmp_list = icon_set->cache;
+  cache = icon_set->cache;
+  icon_set->cache = NULL;
+  icon_set->cache_size = 0;
+  tmp_list = cache;
   while (tmp_list != NULL)
     {
       CachedIcon *icon = tmp_list->data;
@@ -2679,9 +2552,7 @@ clear_cache (GtkIconSet *icon_set,
       tmp_list = g_slist_next (tmp_list);
     }
 
-  g_slist_free (icon_set->cache);
-  icon_set->cache = NULL;
-  icon_set->cache_size = 0;
+  g_slist_free (cache);
 }
 
 static GSList*
@@ -2702,7 +2573,10 @@ copy_cache (GtkIconSet *icon_set,
       *icon_copy = *icon;
 
       if (icon_copy->style)
-        attach_to_style (copy_recipient, icon_copy->style);
+       {
+         attach_to_style (copy_recipient, icon_copy->style);
+         g_object_ref (icon_copy->style);
+       }
         
       g_object_ref (icon_copy->pixbuf);
 
@@ -2819,7 +2693,7 @@ _gtk_icon_factory_list_ids (void)
 
   ids = NULL;
 
-  ensure_default_icons ();
+  _gtk_icon_factory_ensure_default_icons ();
   
   tmp_list = all_icon_factories;
   while (tmp_list != NULL)
@@ -2837,3 +2711,38 @@ _gtk_icon_factory_list_ids (void)
 
   return ids;
 }
+
+#ifdef G_OS_WIN32
+
+/* DLL ABI stability backward compatibility versions */
+
+#undef gtk_icon_source_set_filename
+
+void
+gtk_icon_source_set_filename (GtkIconSource *source,
+                             const gchar   *filename)
+{
+  gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
+
+  gtk_icon_source_set_filename_utf8 (source, utf8_filename);
+
+  g_free (utf8_filename);
+}
+
+#undef gtk_icon_source_get_filename
+
+G_CONST_RETURN gchar*
+gtk_icon_source_get_filename (const GtkIconSource *source)
+{
+  g_return_val_if_fail (source != NULL, NULL);
+
+  if (source->type == GTK_ICON_SOURCE_FILENAME)
+    return source->cp_filename;
+  else
+    return NULL;
+}
+
+#endif
+
+#define __GTK_ICON_FACTORY_C__
+#include "gtkaliasdef.c"