Make one of the icon sets a wildcard set.
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 7 Sep 2013 05:12:59 +0000 (07:12 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 7 Sep 2013 05:17:33 +0000 (07:17 +0200)
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.

src/ui/gui/psppire.c

index d22e2895289806be3f77057b788f20dcf67531b5..bdf5064ef0576e86dc790ce0fedf4738a931eb7e 100644 (file)
@@ -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);