X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire.c;h=512239e92a4eb1a8fa038691ef2d23c841b9b0c0;hb=2fd4306b04da6c8fc982d81beacc1f2e3573307b;hp=d22e2895289806be3f77057b788f20dcf67531b5;hpb=ccf2a6f74f2c42ced981c1577e6f6402e9f75361;p=pspp diff --git a/src/ui/gui/psppire.c b/src/ui/gui/psppire.c index d22e289528..512239e92a 100644 --- a/src/ui/gui/psppire.c +++ b/src/ui/gui/psppire.c @@ -189,16 +189,32 @@ 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 GtkIconSize toolbar[] = {GTK_ICON_SIZE_LARGE_TOOLBAR}; + -static const struct icon_size sizes[] = { - {16, GTK_ICON_SIZE_MENU}, - {24, GTK_ICON_SIZE_LARGE_TOOLBAR} +/* We currently have three icon sets viz: 16x16, 24x24 and 32x32 + We use the 16x16 for menus, the 32x32 for the toolbar and + the 24x24 for everything else. + + Exactly one element of the following array should have its 2nd and 3rd + argument as zero. +*/ +static const struct icon_size sizemap[] = +{ + {16, sizeof (menus) / sizeof (GtkIconSize), menus}, + {24, 0, 0}, + {32, sizeof (toolbar) / sizeof (GtkIconSize), toolbar} }; @@ -207,29 +223,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);