summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog33
-rw-r--r--ChangeLog.pre-2-1033
-rw-r--r--gtk/Makefile.am236
-rw-r--r--gtk/gtkiconcache.c78
-rw-r--r--gtk/gtkiconcache.h4
-rw-r--r--gtk/gtkiconfactory.c563
-rw-r--r--gtk/gtkicontheme.c97
-rw-r--r--gtk/updateiconcache.c64
8 files changed, 661 insertions, 447 deletions
diff --git a/ChangeLog b/ChangeLog
index 057b0417f8..532906b2f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+2005-11-04 Matthias Clasen <mclasen@redhat.com>
+
+ Store builtin stock icons in an icon cache, instead of
+ populating a hash table with pixbufs at startup, to save both
+ memory and startup time.
+
+ * gtk/stock-icons/*: Reorganize the icons in a directory structure
+ suitable for gtk-update-icon-cache, and rename them to match the
+ stock ids.
+
+ * gtk/gtkiconcache.[hc]: Support non-mmapped icon caches, and
+ add _gtk_icon_cache_has_icon_in_directory().
+
+ * gtk/updateiconcache.c: Support a --source <VARIABLE> argument
+ to store the contents of the icon cache in a C header.
+
+ * gtk/gtkbuiltincache.h: Generated private header which contains
+ the icon cache for the builtin icons.
+
+ * gtk/gtkicontheme.c: Create a GtkIconCache for the builtin
+ icons, and use that in addition to the hash table whenever
+ builtin icons are searched.
+
+ * gtk/gtkiconfactory.c: Add GTK_ICON_SOURCE_STATIC_ICON_NAME and
+ use it for static stock ids.
+ (get_default_icons): Don't add the builtin
+ icons to the icon theme, just register the stock ids.
+ (render_fallback_image): Take the fallback image out of the
+ builtin icon cache.
+
+ * gtk/Makefile.am: Remove stock-icons from SUBDIRS and add
+ the necessary machinery to rebuild gtkbuiltincache.h.
+
2005-11-04 Michael Natterer <mitch@imendio.com>
* gtk/gtkrc.c (gtk_rc_reparse_all_for_settings): applied patch
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 057b0417f8..532906b2f9 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,36 @@
+2005-11-04 Matthias Clasen <mclasen@redhat.com>
+
+ Store builtin stock icons in an icon cache, instead of
+ populating a hash table with pixbufs at startup, to save both
+ memory and startup time.
+
+ * gtk/stock-icons/*: Reorganize the icons in a directory structure
+ suitable for gtk-update-icon-cache, and rename them to match the
+ stock ids.
+
+ * gtk/gtkiconcache.[hc]: Support non-mmapped icon caches, and
+ add _gtk_icon_cache_has_icon_in_directory().
+
+ * gtk/updateiconcache.c: Support a --source <VARIABLE> argument
+ to store the contents of the icon cache in a C header.
+
+ * gtk/gtkbuiltincache.h: Generated private header which contains
+ the icon cache for the builtin icons.
+
+ * gtk/gtkicontheme.c: Create a GtkIconCache for the builtin
+ icons, and use that in addition to the hash table whenever
+ builtin icons are searched.
+
+ * gtk/gtkiconfactory.c: Add GTK_ICON_SOURCE_STATIC_ICON_NAME and
+ use it for static stock ids.
+ (get_default_icons): Don't add the builtin
+ icons to the icon theme, just register the stock ids.
+ (render_fallback_image): Take the fallback image out of the
+ builtin icon cache.
+
+ * gtk/Makefile.am: Remove stock-icons from SUBDIRS and add
+ the necessary machinery to rebuild gtkbuiltincache.h.
+
2005-11-04 Michael Natterer <mitch@imendio.com>
* gtk/gtkrc.c (gtk_rc_reparse_all_for_settings): applied patch
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 9008066def..c567ae9550 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -1,6 +1,6 @@
# Makefile.am for gtk+/gtk
-SUBDIRS=stock-icons theme-bits
+SUBDIRS=theme-bits
if OS_UNIX
SUBDIRS += xdgmime
@@ -568,7 +568,8 @@ gtk_built_public_sources = \
# built sources that don't get installed
gtk_built_private_headers = \
gtkalias.h \
- gtkmarshalers.h
+ gtkmarshalers.h \
+ gtkbuiltincache.h
gtk_built_sources = \
gtkaliasdef.c \
@@ -734,20 +735,243 @@ gtk_query_immodules_2_0_LDADD = $(LDADDS)
gtk_query_immodules_2_0_SOURCES = queryimmodules.c
-
-gtk_update_icon_cache_DEPENDENCIES = $(DEPS)
-gtk_update_icon_cache_LDADD = $(LDADDS)
+gtk_update_icon_cache_LDADD = $(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la
gtk_update_icon_cache_SOURCES = updateiconcache.c
-.PHONY: files test test-debug
+.PHONY: files test test-debug icons
files:
@files=`ls $(DISTFILES) 2> /dev/null `; for p in $$files; do \
echo $$p; \
done
+STOCK_ICONS = \
+ stock-icons/16/gtk-about.png \
+ stock-icons/16/gtk-add.png \
+ stock-icons/16/gtk-cdrom.png \
+ stock-icons/16/gtk-connect.png \
+ stock-icons/16/gtk-convert.png \
+ stock-icons/16/gtk-copy.png \
+ stock-icons/16/gtk-cut.png \
+ stock-icons/16/gtk-delete.png \
+ stock-icons/16/gtk-directory.png \
+ stock-icons/16/gtk-disconnect.png \
+ stock-icons/16/gtk-edit.png \
+ stock-icons/16/gtk-execute.png \
+ stock-icons/16/gtk-file.png \
+ stock-icons/16/gtk-find-and-replace.png \
+ stock-icons/16/gtk-find.png \
+ stock-icons/16/gtk-floppy.png \
+ stock-icons/16/gtk-fullscreen.png \
+ stock-icons/16/gtk-go-back-ltr.png \
+ stock-icons/16/gtk-go-back-rtl.png \
+ stock-icons/16/gtk-go-down.png \
+ stock-icons/16/gtk-go-forward-ltr.png \
+ stock-icons/16/gtk-go-forward-rtl.png \
+ stock-icons/16/gtk-goto-bottom.png \
+ stock-icons/16/gtk-goto-first-ltr.png \
+ stock-icons/16/gtk-goto-first-rtl.png \
+ stock-icons/16/gtk-goto-last-ltr.png \
+ stock-icons/16/gtk-goto-last-rtl.png \
+ stock-icons/16/gtk-goto-top.png \
+ stock-icons/16/gtk-go-up.png \
+ stock-icons/16/gtk-harddisk.png \
+ stock-icons/16/gtk-help.png \
+ stock-icons/16/gtk-home.png \
+ stock-icons/16/gtk-indent.png \
+ stock-icons/16/gtk-index.png \
+ stock-icons/16/gtk-info.png \
+ stock-icons/16/gtk-jump-to-ltr.png \
+ stock-icons/16/gtk-jump-to-rtl.png \
+ stock-icons/16/gtk-justify-center.png \
+ stock-icons/16/gtk-justify-fill.png \
+ stock-icons/16/gtk-justify-left.png \
+ stock-icons/16/gtk-justify-right.png \
+ stock-icons/16/gtk-leave-fullscreen.png \
+ stock-icons/16/gtk-media-forward-ltr.png \
+ stock-icons/16/gtk-media-forward-rtl.png \
+ stock-icons/16/gtk-media-next-ltr.png \
+ stock-icons/16/gtk-media-next-rtl.png \
+ stock-icons/16/gtk-media-pause.png \
+ stock-icons/16/gtk-media-play-ltr.png \
+ stock-icons/16/gtk-media-play-rtl.png \
+ stock-icons/16/gtk-media-previous-ltr.png \
+ stock-icons/16/gtk-media-previous-rtl.png \
+ stock-icons/16/gtk-media-record.png \
+ stock-icons/16/gtk-media-rewind-ltr.png \
+ stock-icons/16/gtk-media-rewind-rtl.png \
+ stock-icons/16/gtk-media-stop.png \
+ stock-icons/16/gtk-missing-image.png \
+ stock-icons/16/gtk-network.png \
+ stock-icons/16/gtk-new.png \
+ stock-icons/16/gtk-open.png \
+ stock-icons/16/gtk-paste.png \
+ stock-icons/16/gtk-preferences.png \
+ stock-icons/16/gtk-print.png \
+ stock-icons/16/gtk-print-preview.png \
+ stock-icons/16/gtk-properties.png \
+ stock-icons/16/gtk-quit.png \
+ stock-icons/16/gtk-redo-ltr.png \
+ stock-icons/16/gtk-redo-rtl.png \
+ stock-icons/16/gtk-refresh.png \
+ stock-icons/16/gtk-remove.png \
+ stock-icons/16/gtk-revert-to-saved-ltr.png \
+ stock-icons/16/gtk-revert-to-saved-rtl.png \
+ stock-icons/16/gtk-save-as.png \
+ stock-icons/16/gtk-save.png \
+ stock-icons/16/gtk-select-all.png \
+ stock-icons/16/gtk-select-font.png \
+ stock-icons/16/gtk-sort-ascending.png \
+ stock-icons/16/gtk-sort-descending.png \
+ stock-icons/16/gtk-spell-check.png \
+ stock-icons/16/gtk-stop.png \
+ stock-icons/16/gtk-strikethrough.png \
+ stock-icons/16/gtk-font.png \
+ stock-icons/16/gtk-undelete-ltr.png \
+ stock-icons/16/gtk-undelete-rtl.png \
+ stock-icons/16/gtk-underline.png \
+ stock-icons/16/gtk-undo-ltr.png \
+ stock-icons/16/gtk-undo-rtl.png \
+ stock-icons/16/gtk-unindent.png \
+ stock-icons/16/gtk-zoom-100.png \
+ stock-icons/16/gtk-zoom-fit.png \
+ stock-icons/16/gtk-zoom-in.png \
+ stock-icons/16/gtk-zoom-out.png \
+ stock-icons/16/gtk-italic.png \
+ stock-icons/16/gtk-bold.png \
+ stock-icons/20/gtk-apply.png \
+ stock-icons/20/gtk-cancel.png \
+ stock-icons/20/gtk-close.png \
+ stock-icons/20/gtk-no.png \
+ stock-icons/20/gtk-ok.png \
+ stock-icons/20/gtk-yes.png \
+ stock-icons/24/gtk-about.png \
+ stock-icons/24/gtk-add.png \
+ stock-icons/24/gtk-bold.png \
+ stock-icons/24/gtk-cdrom.png \
+ stock-icons/24/gtk-clear.png \
+ stock-icons/24/gtk-close.png \
+ stock-icons/24/gtk-color-picker.png \
+ stock-icons/24/gtk-connect.png \
+ stock-icons/24/gtk-convert.png \
+ stock-icons/24/gtk-copy.png \
+ stock-icons/24/gtk-cut.png \
+ stock-icons/24/gtk-directory.png \
+ stock-icons/24/gtk-disconnect.png \
+ stock-icons/24/gtk-edit.png \
+ stock-icons/24/gtk-execute.png \
+ stock-icons/24/gtk-file.png \
+ stock-icons/24/gtk-find-and-replace.png \
+ stock-icons/24/gtk-find.png \
+ stock-icons/24/gtk-font.png \
+ stock-icons/24/gtk-fullscreen.png \
+ stock-icons/24/gtk-go-back-ltr.png \
+ stock-icons/24/gtk-goto-top.png \
+ stock-icons/24/gtk-go-down.png \
+ stock-icons/24/gtk-goto-bottom.png \
+ stock-icons/24/gtk-goto-first-ltr.png \
+ stock-icons/24/gtk-goto-first-rtl.png \
+ stock-icons/24/gtk-goto-last-ltr.png \
+ stock-icons/24/gtk-goto-last-rtl.png \
+ stock-icons/24/gtk-go-up.png \
+ stock-icons/24/gtk-harddisk.png \
+ stock-icons/24/gtk-help.png \
+ stock-icons/24/gtk-home.png \
+ stock-icons/24/gtk-indent.png \
+ stock-icons/24/gtk-index.png \
+ stock-icons/24/gtk-info.png \
+ stock-icons/24/gtk-italic.png \
+ stock-icons/24/gtk-jump-to-ltr.png \
+ stock-icons/24/gtk-jump-to-rtl.png \
+ stock-icons/24/gtk-justify-center.png \
+ stock-icons/24/gtk-justify-fill.png \
+ stock-icons/24/gtk-justify-left.png \
+ stock-icons/24/gtk-justify-right.png \
+ stock-icons/24/gtk-leave-fullscreen.png \
+ stock-icons/24/gtk-media-forward-ltr.png \
+ stock-icons/24/gtk-media-forward-rtl.png \
+ stock-icons/24/gtk-media-next-ltr.png \
+ stock-icons/24/gtk-media-next-rtl.png \
+ stock-icons/24/gtk-media-pause.png \
+ stock-icons/24/gtk-media-play-ltr.png \
+ stock-icons/24/gtk-media-play-rtl.png \
+ stock-icons/24/gtk-media-previous-ltr.png \
+ stock-icons/24/gtk-media-previous-rtl.png \
+ stock-icons/24/gtk-media-record.png \
+ stock-icons/24/gtk-media-rewind-ltr.png \
+ stock-icons/24/gtk-media-rewind-rtl.png \
+ stock-icons/24/gtk-media-stop.png \
+ stock-icons/24/gtk-missing-image.png \
+ stock-icons/24/gtk-network.png \
+ stock-icons/24/gtk-new.png \
+ stock-icons/24/gtk-open.png \
+ stock-icons/24/gtk-paste.png \
+ stock-icons/24/gtk-preferences.png \
+ stock-icons/24/gtk-print.png \
+ stock-icons/24/gtk-print-preview.png \
+ stock-icons/24/gtk-properties.png \
+ stock-icons/24/gtk-quit.png \
+ stock-icons/24/gtk-redo-ltr.png \
+ stock-icons/24/gtk-redo-rtl.png \
+ stock-icons/24/gtk-refresh.png \
+ stock-icons/24/gtk-remove.png \
+ stock-icons/24/gtk-revert-to-saved-ltr.png \
+ stock-icons/24/gtk-revert-to-saved-rtl.png \
+ stock-icons/24/gtk-select-font.png \
+ stock-icons/24/gtk-save-as.png \
+ stock-icons/24/gtk-floppy.png \
+ stock-icons/24/gtk-select-all.png \
+ stock-icons/24/gtk-select-color.png \
+ stock-icons/24/gtk-sort-ascending.png \
+ stock-icons/24/gtk-sort-descending.png \
+ stock-icons/24/gtk-spell-check.png \
+ stock-icons/24/gtk-stop.png \
+ stock-icons/24/gtk-strikethrough.png \
+ stock-icons/24/gtk-delete.png \
+ stock-icons/24/gtk-undelete-ltr.png \
+ stock-icons/24/gtk-undelete-rtl.png \
+ stock-icons/24/gtk-underline.png \
+ stock-icons/24/gtk-undo-ltr.png \
+ stock-icons/24/gtk-undo-rtl.png \
+ stock-icons/24/gtk-unindent.png \
+ stock-icons/24/gtk-zoom-100.png \
+ stock-icons/24/gtk-zoom-fit.png \
+ stock-icons/24/gtk-zoom-in.png \
+ stock-icons/24/gtk-zoom-out.png \
+ stock-icons/24/gtk-go-forward-ltr.png \
+ stock-icons/24/gtk-go-forward-rtl.png \
+ stock-icons/24/gtk-go-back-rtl.png \
+ stock-icons/24/gtk-save.png \
+ stock-icons/32/gtk-dnd-multiple.png \
+ stock-icons/32/gtk-dnd.png \
+ stock-icons/48/gtk-dialog-authentication.png \
+ stock-icons/48/gtk-dialog-error.png \
+ stock-icons/48/gtk-dialog-info.png \
+ stock-icons/48/gtk-dialog-question.png \
+ stock-icons/48/gtk-dialog-warning.png
+
+icons:
+ for i in 16 24; do \
+ (cd stock-icons/$$i \
+ $(LN_S) gtk-go-forward-ltr.png gtk-go-back-rtl.png \
+ $(LN_S) gtk-go-back-ltr.png gtk-go-forward-rtl.png \
+ $(LN_S) gtk-goto-first-ltr.png gtk-goto-last-rtl.png \
+ $(LN_S) gtk-goto-last-ltr.png gtk-goto-first-rtl.png \
+ $(LN_S) gtk-media-forward-ltr.png gtk-media-rewind-rtl.png \
+ $(LN_S) gtk-media-rewind-ltr.png gtk-media-forward-rtl.png \
+ $(LN_S) gtk-media-next-ltr.png gtk-media-previous-rtl.png \
+ $(LN_S) gtk-media-previous-ltr.png gtk-media-next-rtl.png \
+ $(LN_S) gtk-floppy.png gtk-save.png \
+ cd ../..) \
+ done
+
+gtkbuiltincache.h: @REBUILD@ gtk-update-icon-cache icons
+ ./gtk-update-icon-cache --force --ignore-theme-index \
+ --source builtin_icons stock-icons > gtkbuiltincache.h
+
EXTRA_DIST += \
+ $(STOCK_ICONS) \
line-arrow.xbm \
line-wrap.xbm \
tree_plus.xbm \
diff --git a/gtk/gtkiconcache.c b/gtk/gtkiconcache.c
index d6f685065b..23fe31d6da 100644
--- a/gtk/gtkiconcache.c
+++ b/gtk/gtkiconcache.c
@@ -70,7 +70,8 @@ _gtk_icon_cache_unref (GtkIconCache *cache)
GTK_NOTE (ICONTHEME,
g_print ("unmapping icon cache\n"));
- g_mapped_file_free (cache->map);
+ if (cache->map)
+ g_mapped_file_free (cache->map);
g_free (cache);
}
}
@@ -146,13 +147,26 @@ _gtk_icon_cache_new_for_path (const gchar *path)
return cache;
}
-static int
+GtkIconCache *
+_gtk_icon_cache_new (const gchar *data)
+{
+ GtkIconCache *cache;
+
+ cache = g_new0 (GtkIconCache, 1);
+ cache->ref_count = 1;
+ cache->map = NULL;
+ cache->buffer = (gchar *)data;
+
+ return cache;
+}
+
+static gint
get_directory_index (GtkIconCache *cache,
const gchar *directory)
{
guint32 dir_list_offset;
- int n_dirs;
- int i;
+ gint n_dirs;
+ gint i;
dir_list_offset = GET_UINT32 (cache->buffer, 8);
@@ -327,6 +341,62 @@ _gtk_icon_cache_has_icon (GtkIconCache *cache,
return FALSE;
}
+gboolean
+_gtk_icon_cache_has_icon_in_directory (GtkIconCache *cache,
+ const gchar *icon_name,
+ const gchar *directory)
+{
+ guint32 hash_offset;
+ guint32 n_buckets;
+ guint32 chain_offset;
+ gint hash;
+ gboolean found_icon = FALSE;
+ gint directory_index;
+
+ directory_index = get_directory_index (cache, directory);
+
+ if (directory_index == -1)
+ return FALSE;
+
+ hash_offset = GET_UINT32 (cache->buffer, 4);
+ n_buckets = GET_UINT32 (cache->buffer, hash_offset);
+
+ hash = icon_name_hash (icon_name) % n_buckets;
+
+ chain_offset = GET_UINT32 (cache->buffer, hash_offset + 4 + 4 * hash);
+ while (chain_offset != 0xffffffff)
+ {
+ guint32 name_offset = GET_UINT32 (cache->buffer, chain_offset + 4);
+ gchar *name = cache->buffer + name_offset;
+
+ if (strcmp (name, icon_name) == 0)
+ {
+ found_icon = TRUE;
+ break;
+ }
+
+ chain_offset = GET_UINT32 (cache->buffer, chain_offset);
+ }
+
+ if (found_icon)
+ {
+ guint32 image_list_offset = GET_UINT32 (cache->buffer, chain_offset + 8);
+ guint32 n_images = GET_UINT32 (cache->buffer, image_list_offset);
+ guint32 image_offset = image_list_offset + 4;
+ gint i;
+ for (i = 0; i < n_images; i++)
+ {
+ guint16 index = GET_UINT16 (cache->buffer, image_offset);
+
+ if (index == directory_index)
+ return TRUE;
+ image_offset += 8;
+ }
+ }
+
+ return FALSE;
+}
+
static void
pixbuf_destroy_cb (guchar *pixels,
gpointer data)
diff --git a/gtk/gtkiconcache.h b/gtk/gtkiconcache.h
index 134a3ab317..c404d16d7c 100644
--- a/gtk/gtkiconcache.h
+++ b/gtk/gtkiconcache.h
@@ -36,11 +36,15 @@ struct _GtkIconData
gchar *display_name;
};
+GtkIconCache *_gtk_icon_cache_new (const gchar *data);
GtkIconCache *_gtk_icon_cache_new_for_path (const gchar *path);
gboolean _gtk_icon_cache_has_directory (GtkIconCache *cache,
const gchar *directory);
gboolean _gtk_icon_cache_has_icon (GtkIconCache *cache,
const gchar *icon_name);
+gboolean _gtk_icon_cache_has_icon_in_directory (GtkIconCache *cache,
+ const gchar *icon_name,
+ const gchar *directory);
void _gtk_icon_cache_add_icons (GtkIconCache *cache,
const gchar *directory,
GHashTable *hash_table);
diff --git a/gtk/gtkiconfactory.c b/gtk/gtkiconfactory.c
index 26ee7dc1f3..b38d82c423 100644
--- a/gtk/gtkiconfactory.c
+++ b/gtk/gtkiconfactory.c
@@ -30,7 +30,7 @@
#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"
@@ -45,6 +45,7 @@ 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;
@@ -360,7 +361,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);
@@ -377,12 +378,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);
@@ -392,415 +393,146 @@ register_bidi_stock_icon (GtkIconFactory *factory,
}
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_FULLSCREEN,
- 16, stock_fullscreen_16,
- 24, stock_fullscreen_24);
-
- add_icon2 (factory, GTK_STOCK_LEAVE_FULLSCREEN,
- 16, stock_leave_fullscreen_16,
- 24, stock_leave_fullscreen_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_icon2 (factory, GTK_STOCK_INFO,
- 16, stock_info_16,
- 24, stock_info_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);
-
- add_icon2 (factory, GTK_STOCK_FILE,
- 16, stock_file_16,
- 24, stock_file_24);
-
- add_icon2 (factory, GTK_STOCK_DIRECTORY,
- 16, stock_directory_16,
- 24, stock_directory_24);
-
- add_icon2 (factory, GTK_STOCK_ABOUT,
- 16, stock_about_16,
- 24, stock_about_24);
-
- add_icon2 (factory, GTK_STOCK_CONNECT,
- 16, stock_connect_16,
- 24, stock_connect_24);
-
- add_icon2 (factory, GTK_STOCK_DISCONNECT,
- 16, stock_disconnect_16,
- 24, stock_disconnect_24);
-
- add_icon2 (factory, GTK_STOCK_EDIT,
- 16, stock_edit_16,
- 24, stock_edit_24);
-
- add_icon_bidi2 (factory, GTK_STOCK_MEDIA_FORWARD,
- 16, stock_media_forward_16, stock_media_rewind_16,
- 24, stock_media_forward_24, stock_media_rewind_24);
-
- add_icon_bidi2 (factory, GTK_STOCK_MEDIA_NEXT,
- 16, stock_media_next_16, stock_media_previous_16,
- 24, stock_media_next_24, stock_media_previous_24);
-
- add_icon2 (factory, GTK_STOCK_MEDIA_PAUSE,
- 16, stock_media_pause_16,
- 24, stock_media_pause_24);
-
- add_icon_bidi2 (factory, GTK_STOCK_MEDIA_PLAY,
- 16, stock_media_play_16, stock_media_play_rtl_16,
- 24, stock_media_play_24, stock_media_play_rtl_24);
-
- add_icon_bidi2 (factory, GTK_STOCK_MEDIA_PREVIOUS,
- 16, stock_media_previous_16, stock_media_next_16,
- 24, stock_media_previous_24, stock_media_next_24);
-
- add_icon2 (factory, GTK_STOCK_MEDIA_RECORD,
- 16, stock_media_record_16,
- 24, stock_media_record_24);
-
- add_icon_bidi2 (factory, GTK_STOCK_MEDIA_REWIND,
- 16, stock_media_rewind_16, stock_media_forward_16,
- 24, stock_media_rewind_24, stock_media_forward_24);
-
- add_icon2 (factory, GTK_STOCK_MEDIA_STOP,
- 16, stock_media_stop_16,
- 24, stock_media_stop_24);
-
- add_icon2 (factory, GTK_STOCK_INDEX,
- 16, stock_index_16,
- 24, stock_index_24);
-
- add_icon2 (factory, GTK_STOCK_ZOOM_100,
- 16, stock_zoom_1_16,
- 24, stock_zoom_1_24);
-
- add_icon2 (factory, GTK_STOCK_ZOOM_IN,
- 16, stock_zoom_in_16,
- 24, stock_zoom_in_24);
-
- add_icon2 (factory, GTK_STOCK_ZOOM_OUT,
- 16, stock_zoom_out_16,
- 24, stock_zoom_out_24);
-
- add_icon2 (factory, GTK_STOCK_ZOOM_FIT,
- 16, stock_zoom_fit_16,
- 24, stock_zoom_fit_24);
-
- add_icon2 (factory, GTK_STOCK_SELECT_ALL,
- 16, stock_select_all_16,
- 24, stock_select_all_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);
+ 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_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_stock_icon (factory, GTK_STOCK_INDENT);
+ register_stock_icon (factory, GTK_STOCK_UNINDENT);
+ 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);
}
/************************************************************
@@ -1823,6 +1555,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);
@@ -1839,6 +1572,8 @@ find_and_render_icon_source (GtkIconSet *icon_set,
return pixbuf;
}
+extern GtkIconCache *_builtin_cache;
+
static GdkPixbuf*
render_fallback_image (GtkStyle *style,
GtkTextDirection direction,
@@ -1852,7 +1587,9 @@ 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_cache_get_icon (_builtin_cache,
+ GTK_STOCK_MISSING_IMAGE,
+ "24");
gtk_icon_source_set_pixbuf (&fallback_source, pixbuf);
g_object_unref (pixbuf);
}
@@ -2163,6 +1900,7 @@ 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);
@@ -2223,6 +1961,8 @@ 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:
@@ -2370,7 +2110,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;
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 9a5d7f869c..3b439cc87e 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -38,12 +38,12 @@
#include "gtkicontheme.h"
#include "gtkiconfactory.h"
#include "gtkiconcache.h"
+#include "gtkbuiltincache.h"
#include "gtkintl.h"
#include "gtksettings.h"
#include "gtkprivate.h"
#include "gtkalias.h"
-
#define DEFAULT_THEME_NAME "hicolor"
typedef enum
@@ -111,8 +111,6 @@ struct _GtkIconInfo
*/
gchar *cp_filename;
#endif
- GdkPixbuf *builtin_pixbuf;
-
/* Cache pixbuf (if there is any) */
GdkPixbuf *cache_pixbuf;
@@ -226,7 +224,7 @@ static GtkIconInfo *icon_info_new_builtin (BuiltinIcon *icon);
static IconSuffix suffix_from_name (const char *name);
static BuiltinIcon *find_builtin_icon (const gchar *icon_name,
- gint size,
+ gint size,
gint *min_difference_p,
gboolean *has_larger_p);
@@ -236,6 +234,11 @@ static guint signal_changed = 0;
static GHashTable *icon_theme_builtin_icons;
+/* also used in gtkiconfactory.c */
+GtkIconCache *_builtin_cache = NULL;
+static GList *builtin_dirs = NULL;
+
+
GType
gtk_icon_theme_get_type (void)
{
@@ -1231,16 +1234,8 @@ gtk_icon_theme_lookup_icon (GtkIconTheme *icon_theme,
l = l->next;
}
- if (!found_default)
- {
- BuiltinIcon *builtin = find_builtin_icon (icon_name, size, NULL, NULL);
- if (builtin)
- {
- icon_info = icon_info_new_builtin (builtin);
- goto out;
- }
- }
-
+ g_assert (found_default);
+
unthemed_icon = g_hash_table_lookup (priv->unthemed_icons, icon_name);
if (unthemed_icon)
{
@@ -1411,6 +1406,10 @@ gtk_icon_theme_has_icon (GtkIconTheme *icon_theme,
icon_name, NULL, NULL))
return TRUE;
+ if (_builtin_cache &&
+ _gtk_icon_cache_has_icon (_builtin_cache, icon_name))
+ return TRUE;
+
if (icon_theme_builtin_icons &&
g_hash_table_lookup_extended (icon_theme_builtin_icons,
icon_name, NULL, NULL))
@@ -1812,6 +1811,40 @@ theme_dir_get_icon_suffix (IconThemeDir *dir,
return suffix;
}
+static void
+_gtk_icon_theme_ensure_builtin_cache (void)
+{
+ static gboolean initialized = FALSE;
+ IconThemeDir *dir;
+ gint sizes[5] = { 16, 20, 24, 32, 48 };
+ gint n_sizes = G_N_ELEMENTS (sizes);
+ gint i;
+
+ if (!initialized)
+ {
+ initialized = TRUE;
+
+ _builtin_cache = _gtk_icon_cache_new ((gchar *)builtin_icons);
+
+ for (i = 0; i < n_sizes; i++)
+ {
+ dir = g_new (IconThemeDir, 1);
+ dir->type = ICON_THEME_DIR_THRESHOLD;
+ dir->context = 0;
+ dir->size = sizes[i];
+ dir->min_size = sizes[i];
+ dir->max_size = sizes[i];
+ dir->threshold = 2;
+ dir->dir = NULL;
+ dir->icon_data = NULL;
+ dir->subdir = g_strdup_printf ("%d", sizes[i]);
+ dir->cache = _gtk_icon_cache_ref (_builtin_cache);
+
+ builtin_dirs = g_list_append (builtin_dirs, dir);
+ }
+ }
+}
+
static GtkIconInfo *
theme_lookup_icon (IconTheme *theme,
const char *icon_name,
@@ -1819,7 +1852,7 @@ theme_lookup_icon (IconTheme *theme,
gboolean allow_svg,
gboolean use_builtin)
{
- GList *l;
+ GList *dirs, *l;
IconThemeDir *dir, *min_dir;
char *file;
int min_difference, difference;
@@ -1834,17 +1867,24 @@ theme_lookup_icon (IconTheme *theme,
/* Builtin icons are logically part of the default theme and
* are searched before other subdirectories of the default theme.
*/
+ _gtk_icon_theme_ensure_builtin_cache ();
+
if (strcmp (theme->name, DEFAULT_THEME_NAME) == 0 && use_builtin)
{
- closest_builtin = find_builtin_icon (icon_name, size,
+ closest_builtin = find_builtin_icon (icon_name,
+ size,
&min_difference,
&has_larger);
if (min_difference == 0)
return icon_info_new_builtin (closest_builtin);
+
+ dirs = builtin_dirs;
}
+ else
+ dirs = theme->dirs;
- l = theme->dirs;
+ l = dirs;
while (l != NULL)
{
dir = l->data;
@@ -1885,6 +1925,12 @@ theme_lookup_icon (IconTheme *theme,
}
l = l->next;
+
+ if (l == NULL && dirs == builtin_dirs)
+ {
+ dirs = theme->dirs;
+ l = dirs;
+ }
}
if (closest_builtin)
@@ -2287,7 +2333,7 @@ icon_info_new_builtin (BuiltinIcon *icon)
{
GtkIconInfo *icon_info = icon_info_new ();
- icon_info->builtin_pixbuf = g_object_ref (icon->pixbuf);
+ icon_info->cache_pixbuf = g_object_ref (icon->pixbuf);
icon_info->dir_type = ICON_THEME_DIR_THRESHOLD;
icon_info->dir_size = icon->size;
icon_info->threshold = 2;
@@ -2313,8 +2359,8 @@ gtk_icon_info_copy (GtkIconInfo *icon_info)
g_return_val_if_fail (icon_info != NULL, NULL);
copy = g_memdup (icon_info, sizeof (GtkIconInfo));
- if (copy->builtin_pixbuf)
- g_object_ref (copy->builtin_pixbuf);
+ if (copy->cache_pixbuf)
+ g_object_ref (copy->cache_pixbuf);
if (copy->pixbuf)
g_object_ref (copy->pixbuf);
if (copy->load_error)
@@ -2348,8 +2394,6 @@ gtk_icon_info_free (GtkIconInfo *icon_info)
if (icon_info->cp_filename)
g_free (icon_info->cp_filename);
#endif
- if (icon_info->builtin_pixbuf)
- g_object_unref (icon_info->builtin_pixbuf);
if (icon_info->pixbuf)
g_object_unref (icon_info->pixbuf);
if (icon_info->cache_pixbuf)
@@ -2430,7 +2474,10 @@ gtk_icon_info_get_builtin_pixbuf (GtkIconInfo *icon_info)
{
g_return_val_if_fail (icon_info != NULL, NULL);
- return icon_info->builtin_pixbuf;
+ if (icon_info->filename)
+ return NULL;
+
+ return icon_info->cache_pixbuf;
}
static GdkPixbuf *
@@ -2540,9 +2587,7 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info,
/* At this point, we need to actually get the icon; either from the
* builting image or by loading the file
*/
- if (icon_info->builtin_pixbuf)
- source_pixbuf = g_object_ref (icon_info->builtin_pixbuf);
- else if (icon_info->cache_pixbuf)
+ if (icon_info->cache_pixbuf)
source_pixbuf = g_object_ref (icon_info->cache_pixbuf);
else
{
diff --git a/gtk/updateiconcache.c b/gtk/updateiconcache.c
index f3385b0547..31906f9524 100644
--- a/gtk/updateiconcache.c
+++ b/gtk/updateiconcache.c
@@ -42,6 +42,7 @@ static gboolean force_update = FALSE;
static gboolean ignore_theme_index = FALSE;
static gboolean quiet = FALSE;
static gboolean index_only = FALSE;
+static gchar *var_name = "-";
#define CACHE_NAME "icon-theme.cache"
@@ -1207,10 +1208,70 @@ build_cache (const gchar *path)
g_printerr ("Cache file created successfully.\n");
}
+void
+write_csource (const gchar *path)
+{
+ gchar *cache_path;
+ gchar *data;
+ guint8 d;
+ gsize len;
+ gint pos;
+ gint i;
+
+ cache_path = g_build_filename (path, CACHE_NAME, NULL);
+ if (!g_file_get_contents (cache_path, &data, &len, NULL))
+ exit (1);
+
+ g_printf ("#ifdef __SUNPRO_C\n");
+ g_printf ("#pragma align 4 (%s)\n", var_name);
+ g_printf ("#endif\n");
+
+ g_printf ("#ifdef __GNUC__\n");
+ g_printf ("static const guint8 %s[] __attribute__ ((__aligned__ (4))) = \n", var_name);
+ g_printf ("#else\n");
+ g_printf ("static const guint8 %s[] = \n", var_name);
+ g_printf ("#endif\n");
+ g_printf ("{ ""\n \"");
+
+ pos = 3;
+ for (i = 0; i < len; i++)
+ {
+ d = data[i];
+ if (pos > 70)
+ {
+ g_printf ("\"\n \"");
+ pos = 3;
+ }
+ if (d < 33 || d > 126 || d == '?')
+ {
+ g_printf ("\\%.3o", d);
+ pos += 4;
+ continue;
+ }
+ if (d == '\\')
+ {
+ g_printf ("\\\\");
+ pos += 2;
+ }
+ else if (d == '"')
+ {
+ g_printf ("\\\"");
+ pos += 2;
+ }
+ else
+ {
+ g_printf ("%c", d);
+ pos += 1;
+ }
+ }
+ g_printf ("\"};\n");
+}
+
static GOptionEntry args[] = {
{ "force", 'f', 0, G_OPTION_ARG_NONE, &force_update, "Overwrite an existing cache, even if uptodate", NULL },
{ "ignore-theme-index", 't', 0, G_OPTION_ARG_NONE, &ignore_theme_index, "Don't check for the existence of index.theme", NULL },
{ "index-only", 'i', 0, G_OPTION_ARG_NONE, &index_only, "Don't include image data in the cache", NULL },
+ { "source", 'c', 0, G_OPTION_ARG_STRING, &var_name, "Output a C header file", "NAME" },
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, "Turn off verbose output", NULL },
{ NULL }
};
@@ -1247,5 +1308,8 @@ main (int argc, char **argv)
g_type_init ();
build_cache (path);
+ if (strcmp (var_name, "-") != 0)
+ write_csource (path);
+
return 0;
}