gnome-games r7341 - trunk/libgames-support



Author: chpe
Date: Sun Feb 10 23:04:31 2008
New Revision: 7341
URL: http://svn.gnome.org/viewvc/gnome-games?rev=7341&view=rev

Log:
2008-02-11  Christian Persch  <chpe gnome org>

	* Makefile.am:
	* games-stock.c: (games_stock_init):
	* games-stock.h: Use private themeable icons. Preparation for bug
	#474698.

Modified:
   trunk/libgames-support/ChangeLog
   trunk/libgames-support/Makefile.am
   trunk/libgames-support/games-stock.c
   trunk/libgames-support/games-stock.h

Modified: trunk/libgames-support/Makefile.am
==============================================================================
--- trunk/libgames-support/Makefile.am	(original)
+++ trunk/libgames-support/Makefile.am	Sun Feb 10 23:04:31 2008
@@ -15,16 +15,6 @@
 	games-marshal.list	\
 	$(NULL)
 
-if !HAVE_HILDON
-icondir = $(datadir)/gnome-games-common/icons
-icon_DATA = \
-	icons/teleport.png	\
-	icons/rteleport.png	\
-	$(NULL)
-
-EXTRA_DIST += $(icon_DATA)
-endif
-
 noinst_LTLIBRARIES = libgames-support.la
 
 BUILT_SOURCES = \
@@ -98,7 +88,7 @@
 	-DDATADIR="\"$(datadir)\""				\
 	-DCOMMON_DATADIR="\"$(datadir)/gnome-games-common\""	\
 	-DCARDDIR="\"$(carddir)\""				\
-	-DICONDIR="\"$(icondir)\""				\
+	-DICONDIR="\"$(pkgdatadir)/icons\""			\
 	-DSCORESDIR="\"$(scoredir)\""				\
 	-DSOUNDDIR="\"$(pkgdatadir)/sounds\""			\
 	$(NULL)

Modified: trunk/libgames-support/games-stock.c
==============================================================================
--- trunk/libgames-support/games-stock.c	(original)
+++ trunk/libgames-support/games-stock.c	Sun Feb 10 23:04:31 2008
@@ -204,27 +204,6 @@
   set_pause_actions (resume_action, actions);
 }
 
-static void
-add_icon_from_file (GtkIconFactory * icon_factory,
-                    const char *stock_id, const char *filename)
-{
-  GtkIconSource *source;
-  GtkIconSet *set;
-  char *path;
-
-  source = gtk_icon_source_new ();
-  set = gtk_icon_set_new ();
-
-  path = games_build_filename (ICONDIR, filename);
-  gtk_icon_source_set_filename (source, path);
-  g_free (path);
-
-  gtk_icon_set_add_source (set, source);
-  gtk_icon_factory_add (icon_factory, stock_id, set);
-  gtk_icon_set_unref (set);
-  gtk_icon_source_free (source);
-}
-
 #endif /* !HAVE_HILDON */
 
 /* This will become GTK_CHECK_VERSION (2, 15, x) once the patch from gtk+ bug 511332 is committed */
@@ -317,13 +296,13 @@
   };
 #endif
 
+  /* Private icon names */
+  const char *private_icon_names[] = {
 #ifndef HAVE_HILDON
-  /* These stocks are using a private icon file */
-  const char *stock_item_with_file[][2] = {
-    { GAMES_STOCK_TELEPORT,   "teleport.png" },
-    { GAMES_STOCK_RTELEPORT,  "rteleport.png" },
-  };
+    GAMES_STOCK_TELEPORT,
+    GAMES_STOCK_RTELEPORT
 #endif /* !HAVE_HILDON */
+  };
 
 /* Use different accels on GTK/GNOME and Maemo */
 #ifdef HAVE_HILDON
@@ -371,11 +350,9 @@
 #undef STOCK_ACCEL
 
   guint i;
-#if !defined(HAVE_GTK_ICON_FACTORY_ADD_ALIAS) || !defined(HAVE_HILDON)
   GtkIconFactory *icon_factory;
 
   icon_factory = gtk_icon_factory_new ();
-#endif /* !HAVE_GTK_ICON_FACTORY_ADD_ALIAS || !HAVE_HILDON */
 
 #ifdef HAVE_GTK_ICON_FACTORY_ADD_ALIAS
   for (i = 0; i < G_N_ELEMENTS (stock_icon_aliases); ++i) {
@@ -398,20 +375,22 @@
   }
 #endif /* HAVE_GTK_ICON_FACTORY_ADD_ALIAS */
 
-#ifndef HAVE_HILDON
-  /* only need icons on non-hildon */
-  for (i = 0; i < G_N_ELEMENTS (stock_item_with_file); i++) {
-    add_icon_from_file (icon_factory,
-                        stock_item_with_file[i][0],
-                        stock_item_with_file[i][1]);
+  /* Register our private themeable icons */
+  for (i = 0; i < G_N_ELEMENTS (private_icon_names); i++) {
+    register_stock_icon (icon_factory,
+                         private_icon_names[i],
+                         private_icon_names[i]);
   }
-#endif /* !HAVE_HILDON */
 
-#if !defined(HAVE_GTK_ICON_FACTORY_ADD_ALIAS) || !defined(HAVE_HILDON)
   gtk_icon_factory_add_default (icon_factory);
   g_object_unref (icon_factory);
-#endif /* !HAVE_GTK_ICON_FACTORY_ADD_ALIAS || !HAVE_HILDON */
 
+  /* GtkIconTheme will then look in our custom hicolor dir
+   * for icons as well as the standard search paths.
+   */
+  /* FIXME: multi-head! */
+  gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), ICONDIR);
+ 
   gtk_stock_add_static (games_stock_items, G_N_ELEMENTS (games_stock_items));
 }
 

Modified: trunk/libgames-support/games-stock.h
==============================================================================
--- trunk/libgames-support/games-stock.h	(original)
+++ trunk/libgames-support/games-stock.h	Sun Feb 10 23:04:31 2008
@@ -53,8 +53,8 @@
 #define GAMES_STOCK_CONTENTS         "games-contents"
 #define GAMES_STOCK_RESET            "games-reset"
 /* These belong to us */
-#define GAMES_STOCK_TELEPORT         "games-teleport"
-#define GAMES_STOCK_RTELEPORT        "games-random-teleport"
+#define GAMES_STOCK_TELEPORT         "teleport"
+#define GAMES_STOCK_RTELEPORT        "teleport-random"
 
 void games_stock_init (void);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]