From c371819f2c4fef7c069b69c3f4037a3e5276450e Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Fri, 21 Nov 2003 11:00:24 +0000 Subject: Pass a source based on filename instead of pixbuf for our own icon set, so 2003-11-21 Marco Pesenti Gritti * lib/ephy-stock-icons.c: (ephy_stock_icons_init): * lib/ephy-stock-icons.h: Pass a source based on filename instead of pixbuf for our own icon set, so that they are created only when necessary. Add code to insert icon theme icons in our icon set and use icon theme icons when possible. * src/ephy-window.c: Update icons id. --- lib/ephy-stock-icons.c | 35 ++++++++++++++++++++++++++--------- lib/ephy-stock-icons.h | 9 +++++---- 2 files changed, 31 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/ephy-stock-icons.c b/lib/ephy-stock-icons.c index 7f05f0248..22b2b6038 100644 --- a/lib/ephy-stock-icons.c +++ b/lib/ephy-stock-icons.c @@ -30,8 +30,18 @@ void ephy_stock_icons_init (void) { GtkIconFactory *factory; + GtkIconSet *icon_set; + GtkIconSource *icon_source; int i; + static const char *icon_theme_items[] = + { + STOCK_NEW_TAB, + STOCK_FULLSCREEN, + STOCK_VIEW_SOURCE, + STOCK_SEND_MAIL + }; + static const char *items[] = { EPHY_STOCK_SECURE, @@ -39,10 +49,6 @@ ephy_stock_icons_init (void) EPHY_STOCK_HISTORY, EPHY_STOCK_BOOKMARKS, EPHY_STOCK_BOOKMARK_PAGE, - EPHY_STOCK_FULLSCREEN, - EPHY_STOCK_NEW_TAB, - EPHY_STOCK_VIEWSOURCE, - EPHY_STOCK_SEND_LINK, EPHY_STOCK_ENTRY, EPHY_STOCK_DOWNLOAD }; @@ -52,19 +58,30 @@ ephy_stock_icons_init (void) for (i = 0; i < (int) G_N_ELEMENTS (items); i++) { - GtkIconSet *icon_set; - GdkPixbuf *pixbuf; char *fn; + icon_set = gtk_icon_set_new (); + icon_source = gtk_icon_source_new (); + fn = g_strconcat (items[i], ".png", NULL); - pixbuf = gdk_pixbuf_new_from_file (ephy_file (fn), NULL); + gtk_icon_source_set_filename (icon_source, ephy_file (fn)); g_free (fn); - icon_set = gtk_icon_set_new_from_pixbuf (pixbuf); + gtk_icon_set_add_source (icon_set, icon_source); gtk_icon_factory_add (factory, items[i], icon_set); gtk_icon_set_unref (icon_set); + g_free (icon_source); + } - g_object_unref (G_OBJECT (pixbuf)); + for (i = 0; i < (int) G_N_ELEMENTS (icon_theme_items); i++) + { + icon_set = gtk_icon_set_new (); + icon_source = gtk_icon_source_new (); + gtk_icon_source_set_icon_name (icon_source, icon_theme_items[i]); + gtk_icon_set_add_source (icon_set, icon_source); + gtk_icon_factory_add (factory, icon_theme_items[i], icon_set); + gtk_icon_set_unref (icon_set); + g_free (icon_source); } g_object_unref (G_OBJECT (factory)); diff --git a/lib/ephy-stock-icons.h b/lib/ephy-stock-icons.h index 85b878dc7..b41353b08 100644 --- a/lib/ephy-stock-icons.h +++ b/lib/ephy-stock-icons.h @@ -28,13 +28,14 @@ G_BEGIN_DECLS #define EPHY_STOCK_HISTORY "epiphany-history" #define EPHY_STOCK_BOOKMARKS "epiphany-bookmarks" #define EPHY_STOCK_BOOKMARK_PAGE "epiphany-bookmark-page" -#define EPHY_STOCK_NEW_TAB "epiphany-new-tab" -#define EPHY_STOCK_FULLSCREEN "epiphany-fullscreen" -#define EPHY_STOCK_VIEWSOURCE "epiphany-viewsource" -#define EPHY_STOCK_SEND_LINK "epiphany-send-link" #define EPHY_STOCK_ENTRY "epiphany-entry" #define EPHY_STOCK_DOWNLOAD "epiphany-download" +#define STOCK_NEW_TAB "stock_new-tab" +#define STOCK_FULLSCREEN "stock_fullscreen" +#define STOCK_VIEW_SOURCE "stock_view-html-source" +#define STOCK_SEND_MAIL "stock_mail_send" + void ephy_stock_icons_init (void); G_END_DECLS -- cgit v1.2.3