From: John Darrington Date: Sat, 7 Sep 2013 05:12:59 +0000 (+0200) Subject: Make one of the icon sets a wildcard set. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d7b15886cb3084395c167fbd993f082fa97feab9;p=pspp Make one of the icon sets a wildcard set. We currently have two icon sets: A 16x16 and a 24x24 set. Previously, we had been using the 16x16 set for menuitems and the 24x24 set for the toolbar. However it appeared that windows uses the symbol GTK_ICON_SIZE_SMALL_TOOLBAR instead of GTK_ICON_SIZE_LARGE_TOOLBAR, which meant no icons appeared in the toolbar. This change sets the 24x24 set as a "wildcard" set meaning it will be used for all purposes except menuitems. --- diff --git a/src/ui/gui/psppire.c b/src/ui/gui/psppire.c index d22e289528..bdf5064ef0 100644 --- a/src/ui/gui/psppire.c +++ b/src/ui/gui/psppire.c @@ -189,16 +189,25 @@ inject_renamed_icons (void) } } + struct icon_size { - int resolution; - GtkIconSize size; + int resolution; /* The dimension of the images which will be used */ + size_t n_sizes; /* The number of items in the array below. + This may be zero, in which case the iconset will be wildcarded + (used by default when no non-wildcarded set is available) */ + const GtkIconSize *usage; /* An array determining for what the icon set is used */ }; +static const GtkIconSize menus[] = {GTK_ICON_SIZE_MENU}; + -static const struct icon_size sizes[] = { - {16, GTK_ICON_SIZE_MENU}, - {24, GTK_ICON_SIZE_LARGE_TOOLBAR} +/* We currently have two icon sets viz: 16x16 and 24x24. + We use the 16x16 for menus, and the 24x24 for everything else. */ +static const struct icon_size sizemap[] = +{ + {16, sizeof (menus) / sizeof (GtkIconSize), menus}, + {24, 0, 0} }; @@ -207,29 +216,31 @@ create_icon_factory (void) { gint c; GtkIconFactory *factory = gtk_icon_factory_new (); - struct icon_context xx[2]; - xx[0] = action_icon_context; - xx[1] = category_icon_context; + struct icon_context ctx[2]; + ctx[0] = action_icon_context; + ctx[1] = category_icon_context; for (c = 0 ; c < 2 ; ++c) { - const struct icon_context *ic = &xx[c]; + const struct icon_context *ic = &ctx[c]; gint i; for (i = 0 ; i < ic->n_icons ; ++i) { GtkIconSet *icon_set = gtk_icon_set_new (); int r; - for (r = 0 ; r < sizeof (sizes) / sizeof (sizes[0]); ++r) + for (r = 0 ; r < sizeof (sizemap) / sizeof (sizemap[0]); ++r) { + int s; GtkIconSource *source = gtk_icon_source_new (); gchar *filename = g_strdup_printf ("%s/%s/%dx%d/%s.png", PKGDATADIR, ic->context_name, - sizes[r].resolution, sizes[r].resolution, + sizemap[r].resolution, sizemap[r].resolution, ic->icon_name[i]); const char *relocated_filename = relocate (filename); gtk_icon_source_set_filename (source, relocated_filename); - gtk_icon_source_set_size_wildcarded (source, FALSE); - gtk_icon_source_set_size (source, sizes[r].size); + gtk_icon_source_set_size_wildcarded (source, sizemap[r].n_sizes <= 0); + for (s = 0 ; s < sizemap[r].n_sizes ; ++s) + gtk_icon_source_set_size (source, sizemap[r].usage[s]); if (filename != relocated_filename) free (CONST_CAST (char *, relocated_filename)); g_free (filename);