Permalink
Browse files

Add our stock icons manually

Although GtkIconFactory implements GtkBuildable properly and works just
fine, Glade can't handle it and keeps removing it upon save.  So, drop
the automatic setup to a manual one so the UI description is editable
with Glade again, and which also has the small advantage of not
repeating the stock ID strings.
  • Loading branch information...
1 parent 17a7469 commit 1a5554c41cffce0c90252c1f6503aae369659b88 @b4n b4n committed Jan 10, 2014
Showing with 24 additions and 8 deletions.
  1. +0 −7 data/geany.glade
  2. +24 −1 src/ui_utils.c
View
@@ -3,13 +3,6 @@
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkAccelGroup" id="accelgroup1"/>
- <object class="GtkIconFactory" id="iconfactory1">
- <sources>
- <source stock-id="geany-build" icon-name="geany-build"/>
- <source stock-id="geany-close-all" icon-name="geany-close-all"/>
- <source stock-id="geany-save-all" icon-name="geany-save-all"/>
- </sources>
- </object>
<object class="GtkAdjustment" id="adjustment1">
<property name="lower">3</property>
<property name="upper">1000</property>
View
@@ -1886,6 +1886,28 @@ static void create_config_files_menu(void)
}
+/* adds factory icons with a named icon source using the stock items id */
+static void add_stock_icons(const GtkStockItem *items, gsize count)
+{
+ GtkIconFactory *factory = gtk_icon_factory_new();
+ GtkIconSource *source = gtk_icon_source_new();
+ gsize i;
+
+ for (i = 0; i < count; i++)
+ {
+ GtkIconSet *set = gtk_icon_set_new();
+
+ gtk_icon_source_set_icon_name(source, items[i].stock_id);
+ gtk_icon_set_add_source(set, source);
+ gtk_icon_factory_add(factory, items[i].stock_id, set);
+ gtk_icon_set_unref(set);
+ }
+ gtk_icon_source_free(source);
+ gtk_icon_factory_add_default(factory);
+ g_object_unref(factory);
+}
+
+
void ui_init_stock_items(void)
{
GtkStockItem items[] =
@@ -1895,7 +1917,8 @@ void ui_init_stock_items(void)
{ GEANY_STOCK_BUILD, N_("Build"), 0, 0, GETTEXT_PACKAGE }
};
- gtk_stock_add((GtkStockItem *) items, G_N_ELEMENTS(items));
+ gtk_stock_add(items, G_N_ELEMENTS(items));
+ add_stock_icons(items, G_N_ELEMENTS(items));
}

0 comments on commit 1a5554c

Please sign in to comment.