r2708 - in trunk/src/target/OM-2007.2/libraries/libmokoui2: . libmokoui

thomas at sita.openmoko.org thomas at sita.openmoko.org
Wed Aug 15 17:32:51 CEST 2007


Author: thomas
Date: 2007-08-15 17:32:50 +0200 (Wed, 15 Aug 2007)
New Revision: 2708

Modified:
   trunk/src/target/OM-2007.2/libraries/libmokoui2/ChangeLog
   trunk/src/target/OM-2007.2/libraries/libmokoui2/libmokoui/moko-stock.c
Log:
* libmokoui/moko-stock.c: (_moko_stock_add_icon): Add a hack to make sure we
at least have a version of the icons available at each possible GtkIconSize


Modified: trunk/src/target/OM-2007.2/libraries/libmokoui2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/libraries/libmokoui2/ChangeLog	2007-08-15 13:36:00 UTC (rev 2707)
+++ trunk/src/target/OM-2007.2/libraries/libmokoui2/ChangeLog	2007-08-15 15:32:50 UTC (rev 2708)
@@ -1,3 +1,8 @@
+2007-08-15  Thomas Wood  <thomas at openedhand.com>
+
+	* libmokoui/moko-stock.c: (_moko_stock_add_icon): Add a hack to make sure we
+	at least have a version of the icons available at each possible GtkIconSize
+
 2007-08-03  Holger Hans Peter Freyther  <zecke at selfish.org>
 
         Change GtkAdjustment handling to be the Gtk+ way. There is

Modified: trunk/src/target/OM-2007.2/libraries/libmokoui2/libmokoui/moko-stock.c
===================================================================
--- trunk/src/target/OM-2007.2/libraries/libmokoui2/libmokoui/moko-stock.c	2007-08-15 13:36:00 UTC (rev 2707)
+++ trunk/src/target/OM-2007.2/libraries/libmokoui2/libmokoui/moko-stock.c	2007-08-15 15:32:50 UTC (rev 2708)
@@ -69,37 +69,49 @@
 _moko_stock_add_icon (GtkIconFactory *factory, const GtkStockItem *item)
 {
   static GtkIconTheme *theme = NULL;
-  GtkIconSource       *source = NULL;
+  GtkIconSource       *source;
   GtkIconSet          *set = NULL;
   GdkPixbuf           *pixbuf = NULL;
+  int i;
 
   if (theme == NULL)
     theme = gtk_icon_theme_get_default ();
 
-  source = gtk_icon_source_new ();
-
-  gtk_icon_source_set_size (source, GTK_ICON_SIZE_BUTTON);
-  gtk_icon_source_set_size_wildcarded (source, FALSE);
-
   pixbuf = gtk_icon_theme_load_icon (theme, item->stock_id,
                                      32, 0, NULL);
+
   if (pixbuf == NULL)
   {
     g_print ("Cannot load stock icon from theme : %s\n", item->stock_id);
     return;
   }
 
-  gtk_icon_source_set_pixbuf (source, pixbuf);
+  set = gtk_icon_set_new ();
 
-  g_object_unref (G_OBJECT (pixbuf));
+  /*
+   * This is temporary hack to make sure we have all the sizes available.
+   * Ideally we should try loading the pixbuf at the correct size from the theme
+   * for each possible size in GtkIconSize, rather than re-using the same pixbuf
+   */
+  for (i = GTK_ICON_SIZE_MENU; i <= GTK_ICON_SIZE_DIALOG; i++)
+  {
+    source = gtk_icon_source_new ();
+    gtk_icon_source_set_size (source, i);
+    gtk_icon_source_set_size_wildcarded (source, FALSE);
+    gtk_icon_source_set_pixbuf (source, pixbuf);
+    gtk_icon_set_add_source (set, source);
+    gtk_icon_source_free (source);
+  }
 
-  set = gtk_icon_set_new ();
 
-  gtk_icon_set_add_source (set, source);
-  gtk_icon_source_free (source);
 
+
   gtk_icon_factory_add (factory, item->stock_id, set);
   gtk_icon_set_unref (set);
+
+
+
+  g_object_unref (G_OBJECT (pixbuf));
 }
 
 void





More information about the commitlog mailing list