static void register_stock_icon_bidi (GtkIconFactory * icon_factory, const char * stock_id, const char * icon_name_ltr, const char * icon_name_rtl) { GtkIconSource *source; GtkIconSet *set; set = gtk_icon_set_new (); source = gtk_icon_source_new (); gtk_icon_source_set_icon_name (source, icon_name_ltr); gtk_icon_source_set_direction (source, GTK_TEXT_DIR_LTR); gtk_icon_source_set_direction_wildcarded (source, FALSE); gtk_icon_set_add_source (set, source); gtk_icon_source_free (source); source = gtk_icon_source_new (); gtk_icon_source_set_icon_name (source, icon_name_rtl); gtk_icon_source_set_direction (source, GTK_TEXT_DIR_RTL); gtk_icon_source_set_direction_wildcarded (source, FALSE); gtk_icon_set_add_source (set, source); gtk_icon_source_free (source); gtk_icon_factory_add (icon_factory, stock_id, set); gtk_icon_set_unref (set); }
void fr_stock_init (void) { GtkIconFactory *factory; GtkIconSource *source; int i; if (stock_initialized) return; stock_initialized = TRUE; gtk_stock_add_static (stock_items, G_N_ELEMENTS (stock_items)); factory = gtk_icon_factory_new (); gtk_icon_factory_add_default (factory); source = gtk_icon_source_new (); for (i = 0; i < G_N_ELEMENTS (stock_icons); i++) { GtkIconSet *set; gtk_icon_source_set_icon_name (source, stock_icons [i].icon); set = gtk_icon_set_new (); gtk_icon_set_add_source (set, source); gtk_icon_factory_add (factory, stock_icons [i].stock_id, set); gtk_icon_set_unref (set); } gtk_icon_source_free (source); g_object_unref (factory); }
/** * ev_stock_icons_init: * * Creates a new icon factory, adding the base stock icons to it. */ void ev_stock_icons_init (void) { GtkIconFactory *factory; GtkIconSource *source; gint i; ev_icons_path = g_build_filename (ATRILDATADIR, "icons", NULL); factory = gtk_icon_factory_new (); gtk_icon_factory_add_default (factory); source = gtk_icon_source_new (); for (i = 0; i < G_N_ELEMENTS (stock_icons); i++) { GtkIconSet *set; gtk_icon_source_set_icon_name (source, stock_icons [i].icon); set = gtk_icon_set_new (); gtk_icon_set_add_source (set, source); gtk_icon_factory_add (factory, stock_icons [i].stock_id, set); gtk_icon_set_unref (set); } gtk_icon_source_free (source); g_object_unref (G_OBJECT (factory)); ev_stock_icons_add_icons_path_for_screen (gdk_screen_get_default ()); }
MidoriExtension* extension_init (void) { GtkIconFactory* factory; GtkIconSource* icon_source; GtkIconSet* icon_set; static GtkStockItem items[] = { { STOCK_PAGE_HOLDER, N_("_Pageholder"), 0, 0, NULL }, }; factory = gtk_icon_factory_new (); gtk_stock_add (items, G_N_ELEMENTS (items)); icon_set = gtk_icon_set_new (); icon_source = gtk_icon_source_new (); gtk_icon_source_set_icon_name (icon_source, GTK_STOCK_ORIENTATION_PORTRAIT); gtk_icon_set_add_source (icon_set, icon_source); gtk_icon_source_free (icon_source); gtk_icon_factory_add (factory, STOCK_PAGE_HOLDER, icon_set); gtk_icon_set_unref (icon_set); gtk_icon_factory_add_default (factory); g_object_unref (factory); MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION, "name", _("Pageholder"), "description", "", "version", "0.1", "authors", "Christian Dywan <*****@*****.**>", NULL); g_signal_connect (extension, "activate", G_CALLBACK (page_holder_activate_cb), NULL); return extension; }
static void add_stock_item(void) { GtkIconSet *icon_set; GtkIconFactory *factory = gtk_icon_factory_new(); GtkIconTheme *theme = gtk_icon_theme_get_default(); GtkStockItem item = { (gchar*)(GEANYSENDMAIL_STOCK_MAIL), (gchar*)(N_("Mail")), 0, 0, (gchar*)(GETTEXT_PACKAGE) }; if (gtk_icon_theme_has_icon(theme, "mail-message-new")) { GtkIconSource *icon_source = gtk_icon_source_new(); icon_set = gtk_icon_set_new(); gtk_icon_source_set_icon_name(icon_source, "mail-message-new"); gtk_icon_set_add_source(icon_set, icon_source); gtk_icon_source_free(icon_source); } else { GdkPixbuf *pb = gdk_pixbuf_new_from_xpm_data(mail_icon); icon_set = gtk_icon_set_new_from_pixbuf(pb); g_object_unref(pb); } gtk_icon_factory_add(factory, item.stock_id, icon_set); gtk_stock_add(&item, 1); gtk_icon_factory_add_default(factory); g_object_unref(factory); gtk_icon_set_unref(icon_set); }
void RenderThemeGtk::initMediaButtons() { static bool iconsInitialized = false; if (iconsInitialized) return; GRefPtr<GtkIconFactory> iconFactory = adoptGRef(gtk_icon_factory_new()); GtkIconSource* iconSource = gtk_icon_source_new(); const char* icons[] = { "audio-volume-high", "audio-volume-muted" }; gtk_icon_factory_add_default(iconFactory.get()); for (size_t i = 0; i < G_N_ELEMENTS(icons); ++i) { gtk_icon_source_set_icon_name(iconSource, icons[i]); GtkIconSet* iconSet = gtk_icon_set_new(); gtk_icon_set_add_source(iconSet, iconSource); gtk_icon_factory_add(iconFactory.get(), icons[i], iconSet); gtk_icon_set_unref(iconSet); } gtk_icon_source_free(iconSource); iconsInitialized = true; }
/** * thunar_stock_init: * * Initializes the stock icons used by the Thunar * file manager. **/ void thunar_stock_init (void) { GtkIconFactory *icon_factory; GtkIconSource *icon_source; GtkIconSet *icon_set; guint n; /* allocate a new icon factory for the thunar stock icons */ icon_factory = gtk_icon_factory_new (); /* allocate an icon source */ icon_source = gtk_icon_source_new (); /* register our stock icons */ for (n = 0; n < G_N_ELEMENTS (thunar_stock_icons); ++n) { /* setup the icon set */ icon_set = gtk_icon_set_new (); gtk_icon_source_set_icon_name (icon_source, thunar_stock_icons[n].icon); gtk_icon_set_add_source (icon_set, icon_source); gtk_icon_factory_add (icon_factory, thunar_stock_icons[n].name, icon_set); gtk_icon_set_unref (icon_set); } /* register our icon factory as default */ gtk_icon_factory_add_default (icon_factory); /* cleanup */ g_object_unref (G_OBJECT (icon_factory)); gtk_icon_source_free (icon_source); }
void camorama_stock_init(void) { GtkIconFactory* factory = gtk_icon_factory_new(); GtkIconSet * set = gtk_icon_set_new (); GtkIconSource * source = gtk_icon_source_new(); gtk_stock_add_static(camorama_items, G_N_ELEMENTS(camorama_items)); gtk_icon_source_set_size_wildcarded(source, TRUE); gtk_icon_source_set_direction_wildcarded(source, TRUE); gtk_icon_source_set_state_wildcarded(source, TRUE); gtk_icon_source_set_icon_name(source, CAMORAMA_STOCK_WEBCAM); gtk_icon_set_add_source(set, source); gtk_icon_factory_add(factory, CAMORAMA_STOCK_WEBCAM, set); add_default_image(CAMORAMA_STOCK_WEBCAM, 16, camorama_webcam_16); add_default_image(CAMORAMA_STOCK_WEBCAM, 24, camorama_webcam_24); gtk_icon_factory_add_default(factory); gtk_icon_set_unref(set); gtk_icon_source_free(source); }
nsresult nsIconChannel::Init(nsIURI* aURI) { nsCOMPtr<nsIMozIconURI> iconURI = do_QueryInterface(aURI); NS_ASSERTION(iconURI, "URI is not an nsIMozIconURI"); nsCAutoString stockIcon; iconURI->GetStockIcon(stockIcon); if (stockIcon.IsEmpty()) { #ifdef MOZ_ENABLE_GNOMEUI return InitWithGnome(iconURI); #else return NS_ERROR_NOT_AVAILABLE; #endif } nsCAutoString iconSizeString; iconURI->GetIconSize(iconSizeString); nsCAutoString iconStateString; iconURI->GetIconState(iconStateString); GtkIconSize icon_size = moz_gtk_icon_size(iconSizeString.get()); ensure_stock_image_widget(); gboolean sensitive = strcmp(iconStateString.get(), "disabled"); gtk_widget_set_sensitive (gStockImageWidget, sensitive); GdkPixbuf *icon = gtk_widget_render_icon(gStockImageWidget, stockIcon.get(), icon_size, NULL); #if GTK_CHECK_VERSION(2,4,0) if (!icon) { ensure_icon_factory(); GtkIconSet *icon_set = gtk_icon_set_new(); GtkIconSource *icon_source = gtk_icon_source_new(); gtk_icon_source_set_icon_name(icon_source, stockIcon.get()); gtk_icon_set_add_source(icon_set, icon_source); gtk_icon_factory_add(gIconFactory, stockIcon.get(), icon_set); gtk_icon_set_unref(icon_set); gtk_icon_source_free(icon_source); icon = gtk_widget_render_icon(gStockImageWidget, stockIcon.get(), icon_size, NULL); } #endif if (!icon) return NS_ERROR_NOT_AVAILABLE; nsresult rv = moz_gdk_pixbuf_to_channel(icon, iconURI, getter_AddRefs(mRealChannel)); g_object_unref(icon); return rv; }
static void register_screenshooter_icon (GtkIconFactory * factory) { GtkIconSource *source; GtkIconSet *icon_set; source = gtk_icon_source_new (); gtk_icon_source_set_icon_name (source, SCREENSHOOTER_ICON); icon_set = gtk_icon_set_new (); gtk_icon_set_add_source (icon_set, source); gtk_icon_factory_add (factory, SCREENSHOOTER_ICON, icon_set); gtk_icon_set_unref (icon_set); gtk_icon_source_free (source); }
static void register_stock_icon (GtkIconFactory * icon_factory, const char * stock_id, const char * icon_name) { GtkIconSource *source; GtkIconSet *set; set = gtk_icon_set_new (); source = gtk_icon_source_new (); gtk_icon_source_set_icon_name (source, icon_name); gtk_icon_set_add_source (set, source); gtk_icon_source_free (source); gtk_icon_factory_add (icon_factory, stock_id, set); gtk_icon_set_unref (set); }
static GtkIconSource* make_theme_source (const gchar *icon, GtkIconSize size) { GtkIconSource *source; source = gtk_icon_source_new (); gtk_icon_source_set_icon_name (source, icon); gtk_icon_source_set_direction_wildcarded (source, TRUE); gtk_icon_source_set_state_wildcarded (source, TRUE); if (size == -1) { gtk_icon_source_set_size_wildcarded (source, TRUE); } else { gtk_icon_source_set_size_wildcarded (source, FALSE); gtk_icon_source_set_size (source, size); } return source; }
static void register_stock_icon (GtkIconFactory *factory, const gchar *stock_id, const gchar *icon_name) { GtkIconSet *set = gtk_icon_set_new (); GtkIconSource *source = gtk_icon_source_new (); gtk_icon_source_set_direction_wildcarded (source, TRUE); gtk_icon_source_set_size_wildcarded (source, TRUE); gtk_icon_source_set_state_wildcarded (source, TRUE); gtk_icon_source_set_icon_name (source, icon_name); gtk_icon_set_add_source (set, source); gtk_icon_source_free (source); gtk_icon_factory_add (factory, stock_id, set); gtk_icon_set_unref (set); }
static void panel_init_stock_icons (GtkIconFactory *factory) { GtkIconSource *source; int i; source = gtk_icon_source_new (); for (i = 0; i < G_N_ELEMENTS (stock_icons); i++) { GtkIconSet *set; gtk_icon_source_set_icon_name (source, stock_icons [i].icon); set = gtk_icon_set_new (); gtk_icon_set_add_source (set, source); gtk_icon_factory_add (factory, stock_icons [i].stock_id, set); gtk_icon_set_unref (set); } gtk_icon_source_free (source); }
MidoriExtension* extension_init (void) { GtkIconFactory* factory; GtkIconSource* icon_source; GtkIconSet* icon_set; static GtkStockItem items[] = { { STOCK_TAB_PANEL, N_("T_ab Panel"), 0, 0, NULL }, }; MidoriExtension* extension; factory = gtk_icon_factory_new (); gtk_stock_add (items, G_N_ELEMENTS (items)); icon_set = gtk_icon_set_new (); icon_source = gtk_icon_source_new (); gtk_icon_source_set_icon_name (icon_source, GTK_STOCK_INDEX); gtk_icon_set_add_source (icon_set, icon_source); gtk_icon_source_free (icon_source); gtk_icon_factory_add (factory, STOCK_TAB_PANEL, icon_set); gtk_icon_set_unref (icon_set); gtk_icon_factory_add_default (factory); g_object_unref (factory); extension = g_object_new (MIDORI_TYPE_EXTENSION, "name", _("Tab Panel"), "description", _("Show tabs in a vertical panel"), "version", "0.1", "authors", "Christian Dywan <*****@*****.**>", NULL); g_signal_connect (extension, "activate", G_CALLBACK (tab_panel_activate_cb), NULL); return extension; }
int main (int argc, char **argv) { GtkWidget *window, *grid; GtkWidget *label, *image, *box; GtkIconTheme *theme; GdkPixbuf *pixbuf; GtkIconSet *iconset; GtkIconSource *iconsource; gchar *icon_name = "gnome-terminal"; gchar *anim_filename = NULL; GIcon *icon; GFile *file; gtk_init (&argc, &argv); if (argc > 1) icon_name = argv[1]; if (argc > 2) anim_filename = argv[2]; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); grid = gtk_grid_new (); gtk_container_add (GTK_CONTAINER (window), grid); label = gtk_label_new ("symbolic size"); gtk_grid_attach (GTK_GRID (grid), label, 1, 0, 1, 1); label = gtk_label_new ("fixed size"); gtk_grid_attach (GTK_GRID (grid), label, 2, 0, 1, 1); label = gtk_label_new ("GTK_IMAGE_PIXBUF"); gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1); theme = gtk_icon_theme_get_default (); pixbuf = gtk_icon_theme_load_icon (theme, icon_name, 48, 0, NULL); image = gtk_image_new_from_pixbuf (pixbuf); box = gtk_event_box_new (); gtk_container_add (GTK_CONTAINER (box), image); gtk_grid_attach (GTK_GRID (grid), box, 2, 1, 1, 1); gtk_drag_source_set (box, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY); gtk_drag_source_add_image_targets (box); g_signal_connect (box, "drag_begin", G_CALLBACK (drag_begin), image); g_signal_connect (box, "drag_data_get", G_CALLBACK (drag_data_get), image); gtk_drag_dest_set (box, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, NULL, 0, GDK_ACTION_COPY); gtk_drag_dest_add_image_targets (box); g_signal_connect (box, "drag_data_received", G_CALLBACK (drag_data_received), image); label = gtk_label_new ("GTK_IMAGE_STOCK"); gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1); image = gtk_image_new_from_stock (GTK_STOCK_REDO, GTK_ICON_SIZE_DIALOG); gtk_grid_attach (GTK_GRID (grid), image, 1, 2, 1, 1); label = gtk_label_new ("GTK_IMAGE_ICON_SET"); gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 1, 1); iconsource = gtk_icon_source_new (); gtk_icon_source_set_icon_name (iconsource, icon_name); iconset = gtk_icon_set_new (); gtk_icon_set_add_source (iconset, iconsource); image = gtk_image_new_from_icon_set (iconset, GTK_ICON_SIZE_DIALOG); gtk_grid_attach (GTK_GRID (grid), image, 1, 3, 1, 1); label = gtk_label_new ("GTK_IMAGE_ICON_NAME"); gtk_grid_attach (GTK_GRID (grid), label, 0, 4, 1, 1); image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG); gtk_grid_attach (GTK_GRID (grid), image, 1, 4, 1, 1); image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG); gtk_image_set_pixel_size (GTK_IMAGE (image), 30); gtk_grid_attach (GTK_GRID (grid), image, 2, 4, 1, 1); label = gtk_label_new ("GTK_IMAGE_GICON"); gtk_grid_attach (GTK_GRID (grid), label, 0, 5, 1, 1); icon = g_themed_icon_new_with_default_fallbacks ("folder-remote"); image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG); g_object_unref (icon); gtk_grid_attach (GTK_GRID (grid), image, 1, 5, 1, 1); file = g_file_new_for_path ("apple-red.png"); icon = g_file_icon_new (file); image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG); g_object_unref (icon); gtk_image_set_pixel_size (GTK_IMAGE (image), 30); gtk_grid_attach (GTK_GRID (grid), image, 2, 5, 1, 1); if (anim_filename) { label = gtk_label_new ("GTK_IMAGE_ANIMATION (from file)"); gtk_grid_attach (GTK_GRID (grid), label, 0, 6, 1, 1); image = gtk_image_new_from_file (anim_filename); gtk_image_set_pixel_size (GTK_IMAGE (image), 30); gtk_grid_attach (GTK_GRID (grid), image, 2, 6, 1, 1); /* produce high load */ g_signal_connect_after (image, "draw", G_CALLBACK (anim_image_draw), NULL); } gtk_widget_show_all (window); gtk_main (); return 0; }
/** * pixbuf_cache_register_stocks: register galeon icons with the gnome stock * system so people can theme our icons */ void gul_pixbuf_cache_register_stocks (void) { static gboolean done = FALSE; GtkIconFactory *factory; GtkIconSet *icon_set; GtkIconSource *icon_source; gint i; GtkStockItem items[] = { { GALEON_STOCK_SEPARATOR ,"_Separator", 0, 0, NULL }, { GALEON_STOCK_FOLDER ,"_Folder", 0, 0, NULL }, { GALEON_STOCK_DEFAULT ,"_Default", 0, 0, NULL }, { GALEON_STOCK_HISTORY ,"_History", 0, 0, NULL }, { GALEON_STOCK_FILTER ,"_Filter", 0, 0, NULL }, { GALEON_STOCK_POPUP_BLOCKED ,"_Popup blocked", 0, 0, NULL }, { GALEON_STOCK_SECURE ,"_Secure", 0, 0, NULL }, { GALEON_STOCK_INSECURE ,"_Insecure", 0, 0, NULL }, { GALEON_STOCK_DOWNLOAD ,"_Download", 0, 0, NULL }, { GALEON_STOCK_ENTRY ,"_Entry", 0, 0, NULL } }; const char * icon_theme_items[] = { STOCK_ZOOM, STOCK_NEW_TAB, STOCK_FULLSCREEN, STOCK_VIEW_SOURCE, STOCK_SEND_MAIL, STOCK_ADD_BOOKMARK, STOCK_SPINNER_REST, STOCK_SELECT_ALL, STOCK_EDIT_BOOKMARK, STOCK_CONNECT, STOCK_DISCONNECT, STOCK_LOCK_BROKEN }; if (done) { return; } done = TRUE; gtk_stock_add (items, G_N_ELEMENTS (items)); factory = gtk_icon_factory_new (); gtk_icon_factory_add_default (factory); for (i = 0; i < (gint) G_N_ELEMENTS (items); i++) { GdkPixbuf *pixbuf; gchar *fn; fn = g_strconcat (items[i].stock_id, ".png", NULL); pixbuf = gul_pixbuf_cache_get (fn); g_free (fn); icon_set = gtk_icon_set_new_from_pixbuf (pixbuf); gtk_icon_factory_add (factory, items[i].stock_id, icon_set); gtk_icon_set_unref (icon_set); 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); gtk_icon_source_free (icon_source); } g_object_unref (G_OBJECT (factory)); }
nsresult nsIconChannel::Init(nsIURI* aURI) { nsCOMPtr<nsIMozIconURI> iconURI = do_QueryInterface(aURI); NS_ASSERTION(iconURI, "URI is not an nsIMozIconURI"); nsAutoCString stockIcon; iconURI->GetStockIcon(stockIcon); if (stockIcon.IsEmpty()) { #ifdef MOZ_ENABLE_GNOMEUI return InitWithGnome(iconURI); #else #ifdef MOZ_ENABLE_GIO return InitWithGIO(iconURI); #else return NS_ERROR_NOT_AVAILABLE; #endif #endif } // Search for stockIcon nsAutoCString iconSizeString; iconURI->GetIconSize(iconSizeString); nsAutoCString iconStateString; iconURI->GetIconState(iconStateString); GtkIconSize icon_size = moz_gtk_icon_size(iconSizeString.get()); GtkStateType state = iconStateString.EqualsLiteral("disabled") ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL; // First lookup the icon by stock id and text direction. GtkTextDirection direction = GTK_TEXT_DIR_NONE; if (StringEndsWith(stockIcon, NS_LITERAL_CSTRING("-ltr"))) { direction = GTK_TEXT_DIR_LTR; } else if (StringEndsWith(stockIcon, NS_LITERAL_CSTRING("-rtl"))) { direction = GTK_TEXT_DIR_RTL; } bool forceDirection = direction != GTK_TEXT_DIR_NONE; nsAutoCString stockID; bool useIconName = false; if (!forceDirection) { direction = gtk_widget_get_default_direction(); stockID = stockIcon; } else { // GTK versions < 2.22 use icon names from concatenating stock id with // -(rtl|ltr), which is how the moz-icon stock name is interpreted here. stockID = Substring(stockIcon, 0, stockIcon.Length() - 4); // However, if we lookup bidi icons by the stock name, then GTK versions // >= 2.22 will use a bidi lookup convention that most icon themes do not // yet follow. Therefore, we first check to see if the theme supports the // old icon name as this will have bidi support (if found). GtkIconTheme *icon_theme = gtk_icon_theme_get_default(); // Micking what gtk_icon_set_render_icon does with sizes, though it's not // critical as icons will be scaled to suit size. It just means we follow // the same pathes and so share caches. gint width, height; if (gtk_icon_size_lookup(icon_size, &width, &height)) { gint size = NS_MIN(width, height); // We use gtk_icon_theme_lookup_icon() without // GTK_ICON_LOOKUP_USE_BUILTIN instead of gtk_icon_theme_has_icon() so // we don't pick up fallback icons added by distributions for backward // compatibility. GtkIconInfo *icon = gtk_icon_theme_lookup_icon(icon_theme, stockIcon.get(), size, (GtkIconLookupFlags)0); if (icon) { useIconName = true; gtk_icon_info_free(icon); } } } ensure_stock_image_widget(); GtkStyle *style = gtk_widget_get_style(gStockImageWidget); GtkIconSet *icon_set = NULL; if (!useIconName) { icon_set = gtk_style_lookup_icon_set(style, stockID.get()); } if (!icon_set) { // Either we have choosen icon-name lookup for a bidi icon, or stockIcon is // not a stock id so we assume it is an icon name. useIconName = true; // Creating a GtkIconSet is a convenient way to allow the style to // render the icon, possibly with variations suitable for insensitive // states. icon_set = gtk_icon_set_new(); GtkIconSource *icon_source = gtk_icon_source_new(); gtk_icon_source_set_icon_name(icon_source, stockIcon.get()); gtk_icon_set_add_source(icon_set, icon_source); gtk_icon_source_free(icon_source); } GdkPixbuf *icon = gtk_icon_set_render_icon (icon_set, style, direction, state, icon_size, gStockImageWidget, NULL); if (useIconName) { gtk_icon_set_unref(icon_set); } // According to documentation, gtk_icon_set_render_icon() never returns // NULL, but it does return NULL when we have the problem reported here: // https://bugzilla.gnome.org/show_bug.cgi?id=629878#c13 if (!icon) return NS_ERROR_NOT_AVAILABLE; nsresult rv = moz_gdk_pixbuf_to_channel(icon, iconURI, getter_AddRefs(mRealChannel)); g_object_unref(icon); return rv; }
void browser_stock_icons_init (void) { GtkIconFactory *factory; GtkIconSet *icon_set; GtkIconSource *icon_source; int i; const char *icon_theme_items[] = { STOCK_NEW_WINDOW, STOCK_ADD_BOOKMARK, }; static const GtkStockItem items[] = { { BROWSER_STOCK_HISTORY, N_("History"), 0, 0, NULL }, { BROWSER_STOCK_BOOKMARKS, N_("Bookmarks"), 0, 0, NULL }, { BROWSER_STOCK_BEGIN, N_("Begin"), 0, 0, NULL }, { BROWSER_STOCK_COMMIT, N_("Commit"), 0, 0, NULL }, { BROWSER_STOCK_ROLLBACK, N_("Rollback"), 0, 0, NULL }, { BROWSER_STOCK_BUILDER, N_("Builder"), 0, 0, NULL }, { BROWSER_STOCK_LDAP_ENTRIES, N_("Ldap entries"), 0, 0, NULL }, { BROWSER_STOCK_TABLE_ADD, N_("Add table"), 0, 0, NULL}, { BROWSER_STOCK_GRID, N_("Grid"), 0, 0, NULL}, { BROWSER_STOCK_FORM, N_("Form"), 0, 0, NULL}, }; factory = gtk_icon_factory_new (); for (i = 0; i < (int) G_N_ELEMENTS (items); i++) { icon_source = gtk_icon_source_new (); gtk_icon_source_set_icon_name (icon_source, items[i].stock_id); icon_set = gtk_icon_set_new (); gtk_icon_set_add_source (icon_set, icon_source); gtk_icon_source_free (icon_source); gtk_icon_factory_add (factory, items[i].stock_id, icon_set); gtk_icon_set_unref (icon_set); } gtk_stock_add_static (items, G_N_ELEMENTS (items)); for (i = 0; i < (int) G_N_ELEMENTS (icon_theme_items); i++) { icon_source = gtk_icon_source_new (); gtk_icon_source_set_icon_name (icon_source, icon_theme_items[i]); icon_set = gtk_icon_set_new (); gtk_icon_set_add_source (icon_set, icon_source); gtk_icon_source_free (icon_source); gtk_icon_factory_add (factory, icon_theme_items[i], icon_set); gtk_icon_set_unref (icon_set); } gtk_icon_factory_add_default (factory); g_object_unref (factory); /* GtkIconTheme will then look in Browser custom hicolor dir * for icons as well as the standard search paths */ /* FIXME: multi-head! */ gchar *path; path = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, "icons", NULL); gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), path); g_free (path); }