gnome-games r8466 - in trunk: aisleriot libgames-support
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8466 - in trunk: aisleriot libgames-support
- Date: Tue, 6 Jan 2009 18:19:30 +0000 (UTC)
Author: chpe
Date: Tue Jan 6 18:19:30 2009
New Revision: 8466
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8466&view=rev
Log:
Make loading and storing the theme from/to pref work again.
Modified:
trunk/aisleriot/board-noclutter.c
trunk/aisleriot/window.c
trunk/libgames-support/games-card-theme-fixed.c
trunk/libgames-support/games-card-theme-kde.c
trunk/libgames-support/games-card-theme-preimage.c
trunk/libgames-support/games-card-theme-private.h
trunk/libgames-support/games-card-theme-pysol.c
trunk/libgames-support/games-card-theme-sliced.c
trunk/libgames-support/games-card-theme-svg.c
trunk/libgames-support/games-card-theme.c
trunk/libgames-support/games-card-theme.h
trunk/libgames-support/games-debug.c
trunk/libgames-support/games-debug.h
trunk/libgames-support/render-cards.c
Modified: trunk/aisleriot/board-noclutter.c
==============================================================================
--- trunk/aisleriot/board-noclutter.c (original)
+++ trunk/aisleriot/board-noclutter.c Tue Jan 6 18:19:30 2009
@@ -3364,7 +3364,6 @@
GParamSpec *pspec)
{
AisleriotBoard *board = AISLERIOT_BOARD (object);
- AisleriotBoardPrivate *priv = board->priv;
switch (prop_id) {
case PROP_THEME:
Modified: trunk/aisleriot/window.c
==============================================================================
--- trunk/aisleriot/window.c (original)
+++ trunk/aisleriot/window.c Tue Jan 6 18:19:30 2009
@@ -1455,21 +1455,6 @@
games_card_theme_set_font_options (theme, font_options);
}
- //XXX FIXMEchpe
-#if 0//#ifdef HAVE_GNOME
- /* Compatibility with old settings */
- if (g_str_has_suffix (theme, ".svg")) {
- *g_strrstr (theme, ".svg") = '\0';
- } else if (g_str_has_suffix (theme, ".png")) {
- *g_strrstr (theme, ".png") = '\0';
- }
-#endif /* HAVE_GNOME */
-
-// if (aisleriot_board_set_card_theme (priv->board, info)) {
- // XXX FIXMEchpe
- //games_conf_set_string (NULL, aisleriot_conf_get_key (CONF_THEME), theme);
-// }
-
aisleriot_board_set_card_theme (priv->board, theme);
}
@@ -1480,6 +1465,7 @@
AisleriotWindowPrivate *priv = window->priv;
GamesCardThemeInfo *info;
GamesCardTheme *theme;
+ const char *theme_name;
if (!gtk_toggle_action_get_active (action))
return;
@@ -1496,6 +1482,9 @@
return; // FIXMEchpe re-set the right radio action to active!!
aisleriot_window_take_card_theme (window, theme);
+
+ theme_name = games_card_theme_info_get_persistent_name (info);
+ games_conf_set_string (NULL, aisleriot_conf_get_key (CONF_THEME), theme_name);
}
static void
Modified: trunk/libgames-support/games-card-theme-fixed.c
==============================================================================
--- trunk/libgames-support/games-card-theme-fixed.c (original)
+++ trunk/libgames-support/games-card-theme-fixed.c Tue Jan 6 18:19:30 2009
@@ -298,18 +298,29 @@
const char *filename)
{
GamesCardThemeInfo *info;
- char *display_name;
+ char *display_name, *pref_name;
if (!g_str_has_suffix (filename, ".card-theme"))
return NULL;
display_name = games_filename_to_display_name (filename);
+
+ /* On Hildon, fixed is the default. For pref backward compatibility,
+ * we don't add the fixed: prefix there.
+ */
+#ifdef HAVE_HILDON
+ pref_name = g_strdup (filename);
+ *(strrchr (filename, '.')) = '\0'; /* strip extension */
+#else
+ pref_name = g_strdup_printf ("fixed:%s", filename);
+#endif
+
info = _games_card_theme_info_new (G_OBJECT_CLASS_TYPE (klass),
path,
filename,
- display_name,
+ display_name /* adopts */,
+ pref_name,
NULL, NULL);
- g_free (display_name);
return info;
}
Modified: trunk/libgames-support/games-card-theme-kde.c
==============================================================================
--- trunk/libgames-support/games-card-theme-kde.c (original)
+++ trunk/libgames-support/games-card-theme-kde.c Tue Jan 6 18:19:30 2009
@@ -252,7 +252,7 @@
GamesCardThemeInfo *info = NULL;
char *base_path = NULL, *key_file_path = NULL;
GKeyFile *key_file = NULL;
- char *svg_filename = NULL, *name = NULL, *display_name;
+ char *svg_filename = NULL, *name = NULL, *display_name, *pref_name;
base_path = g_build_filename (path, filename, NULL);
if (!g_file_test (path, G_FILE_TEST_IS_DIR))
@@ -272,13 +272,13 @@
goto out;
display_name = g_strdup_printf ("%s (KDE)", name);
-
+ pref_name = g_strdup_printf ("kde:%s", filename);
info = _games_card_theme_info_new (G_OBJECT_CLASS_TYPE (klass),
base_path,
svg_filename,
- display_name,
+ display_name /* adopts */,
+ pref_name /* adopts */,
NULL, NULL);
- g_free (display_name);
out:
g_free (base_path);
Modified: trunk/libgames-support/games-card-theme-preimage.c
==============================================================================
--- trunk/libgames-support/games-card-theme-preimage.c (original)
+++ trunk/libgames-support/games-card-theme-preimage.c Tue Jan 6 18:19:30 2009
@@ -231,9 +231,9 @@
info = _games_card_theme_info_new (G_OBJECT_CLASS_TYPE (klass),
path,
filename,
- display_name,
+ display_name /* adopts */,
+ NULL /* filled in by the derived classes */,
NULL, NULL);
- g_free (display_name);
return info;
}
Modified: trunk/libgames-support/games-card-theme-private.h
==============================================================================
--- trunk/libgames-support/games-card-theme-private.h (original)
+++ trunk/libgames-support/games-card-theme-private.h Tue Jan 6 18:19:30 2009
@@ -17,6 +17,9 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include "games-card.h"
+#include "games-preimage.h"
+
#define FLOAT_TO_INT_CEIL(f) ((int) (f + 0.5f))
/* GamesCardThemeInfo */
@@ -27,6 +30,7 @@
char *path;
char *filename;
char *display_name;
+ char *pref_name;
gpointer data;
GDestroyNotify destroy_notify;
@@ -35,7 +39,8 @@
GamesCardThemeInfo *_games_card_theme_info_new (GType type,
const char *path,
const char *filename,
- const char *display_name,
+ char *display_name /* adopts */,
+ char *pref_name /* adopts */,
gpointer data,
GDestroyNotify destroy_notify);
Modified: trunk/libgames-support/games-card-theme-pysol.c
==============================================================================
--- trunk/libgames-support/games-card-theme-pysol.c (original)
+++ trunk/libgames-support/games-card-theme-pysol.c Tue Jan 6 18:19:30 2009
@@ -349,7 +349,7 @@
{
GamesCardThemeInfo *info = NULL;
PySolConfigTxtData *pysol_data;
- char *display_name;
+ char *display_name, *pref_name;
if (!g_str_has_prefix (filename, "cardset-"))
return NULL;
@@ -359,14 +359,14 @@
return NULL;
display_name = g_strdup_printf ("%s (PySol)", pysol_data->name);
-
+ pref_name = g_strdup_printf ("pysol:%s", filename + strlen ("cardset-"));
info = _games_card_theme_info_new (G_OBJECT_CLASS_TYPE (klass),
path,
filename,
- display_name,
+ display_name /* adopts */,
+ pref_name /* adopts */,
pysol_data,
(GDestroyNotify) pysol_config_txt_data_free);
- g_free (display_name);
return info;
}
Modified: trunk/libgames-support/games-card-theme-sliced.c
==============================================================================
--- trunk/libgames-support/games-card-theme-sliced.c (original)
+++ trunk/libgames-support/games-card-theme-sliced.c Tue Jan 6 18:19:30 2009
@@ -182,11 +182,14 @@
const char *filename)
{
GamesCardThemeInfo *info;
- char *name, *display_name;
+ char *name, *display_name, *pref_name;
info = GAMES_CARD_THEME_CLASS (games_card_theme_sliced_parent_class)->get_theme_info (klass, path, filename);
- if (info)
+ if (info) {
+ g_assert (info->pref_name == NULL);
+ info->pref_name = g_strdup_printf ("sliced:%s", filename);
return info;
+ }
/* This class also supports the old-style PNG format */
if (!g_str_has_suffix (filename, ".png"))
@@ -194,13 +197,14 @@
name = games_filename_to_display_name (filename);
display_name = g_strdup_printf ("%s (Ugly)", name);
+ pref_name = g_strdup_printf ("sliced:%s", filename);
info = _games_card_theme_info_new (G_OBJECT_CLASS_TYPE (klass),
path,
filename,
- display_name,
+ display_name /* adopts */,
+ pref_name /* adopts */,
NULL, NULL);
g_free (name);
- g_free (display_name);
return info;
}
Modified: trunk/libgames-support/games-card-theme-svg.c
==============================================================================
--- trunk/libgames-support/games-card-theme-svg.c (original)
+++ trunk/libgames-support/games-card-theme-svg.c Tue Jan 6 18:19:30 2009
@@ -104,6 +104,28 @@
{
}
+static GamesCardThemeInfo *
+games_card_theme_svg_class_get_theme_info (GamesCardThemeClass *klass,
+ const char *path,
+ const char *filename)
+{
+ GamesCardThemeInfo *info;
+
+ info = GAMES_CARD_THEME_CLASS (games_card_theme_svg_parent_class)->get_theme_info (klass, path, filename);
+ if (info) {
+ g_assert (info->pref_name == NULL);
+
+ /* SVG is the default. For pref backward compatibility,
+ * we don't add a svg: prefix there. We don't strip the .svg
+ * extension anymore though.
+ */
+ info->pref_name = g_strdup (filename);
+ return info;
+ }
+
+ return NULL;
+}
+
static void
games_card_theme_svg_class_get_theme_infos (GamesCardThemeClass *klass,
GList **list)
@@ -121,6 +143,7 @@
GamesCardThemeClass *theme_class = GAMES_CARD_THEME_CLASS (klass);
GamesCardThemePreimageClass *preimage_theme_class = GAMES_CARD_THEME_PREIMAGE_CLASS (klass);
+ theme_class->get_theme_info = games_card_theme_svg_class_get_theme_info;
theme_class->get_theme_infos = games_card_theme_svg_class_get_theme_infos;
theme_class->get_card_pixbuf = games_card_theme_svg_get_card_pixbuf;
Modified: trunk/libgames-support/games-card-theme.c
==============================================================================
--- trunk/libgames-support/games-card-theme.c (original)
+++ trunk/libgames-support/games-card-theme.c Tue Jan 6 18:19:30 2009
@@ -26,8 +26,6 @@
#include <gtk/gtk.h>
#include "games-debug.h"
-#include "games-find-file.h"
-#include "games-files.h"
#include "games-preimage.h"
#include "games-profile.h"
#include "games-runtime.h"
@@ -98,13 +96,18 @@
GList *l;
GamesCardThemeInfo *theme_info = NULL;
+ g_print ("_games_card_theme_get_info_by_type_and_name type %s filename %s\n", g_type_name (type), filename);
+
for (l = theme_infos; l != NULL; l = l->next) {
GamesCardThemeInfo *info = (GamesCardThemeInfo *) l->data;
+ g_print ("==> comparing with type %s filename %s\n", g_type_name (info->type), info->filename);
+
if (info->type != type ||
strcmp (info->filename, filename) != 0)
continue;
+ g_print ("==> !! MATCH!!\n");
theme_info = info;
break;
}
@@ -112,47 +115,6 @@
return theme_info;
}
-#if 0
-static gboolean
-games_card_theme_load_theme_with_fallback (GamesCardTheme *theme,
- GamesCardThemeInfo *info)
-{
- const char *env;
-
- if ((env = g_getenv ("GAMES_CARD_THEME_NAME")))
- theme_name = env;
-
- if (!theme_dir)
- theme_dir = _games_card_theme_class_get_default_theme_path (theme->klass);
-
- if (games_card_theme_load_theme (theme, theme_dir, theme_name))
- return TRUE;
-
- // FIXMEchpe: compare strict dir equality, not just != NULL
- /* Try fallback in default theme directory */
- if (theme_dir != NULL &&
- games_card_theme_load_theme (theme, NULL, theme_name))
- return TRUE;
-
- g_warning ("Failed to load theme '%s'; trying fallback theme '%s'",
- theme_name, GAMES_CARD_THEME_DEFAULT);
-
- if (strcmp (theme_name, GAMES_CARD_THEME_DEFAULT) != 0 &&
- (games_card_theme_load_theme (theme, theme_dir, GAMES_CARD_THEME_DEFAULT)))
- return FALSE;
- if (theme_dir != NULL &&
- strcmp (theme_name, GAMES_CARD_THEME_DEFAULT) != 0 &&
- (games_card_theme_load_theme (theme, NULL, GAMES_CARD_THEME_DEFAULT)))
- return FALSE;
-
- g_warning ("Failed to load fallback theme!");
-
- return FALSE;
- //FIXMEchpe how to design fallback now...
-// return games_card_theme_load_theme (theme, info);
-}
-#endif
-
/* Class implementation */
G_DEFINE_ABSTRACT_TYPE (GamesCardTheme, games_card_theme, G_TYPE_OBJECT);
@@ -217,46 +179,6 @@
return NULL;
}
-#if 0
-
-static GList *
-games_card_theme_get_themes_list (GamesCardThemeClass *klass,
- const char *theme_dir)
-{
- GamesFileList *files;
- GList *l, *list;
- const char *glob;
- GamesCardThemeInfo * (* get_theme_info) (GamesCardThemeClass *, const char *) = klass->get_theme_info;
-
- glob = _games_card_theme_class_get_theme_glob (klass);
-
- if (!theme_dir)
- theme_dir = _games_card_theme_class_get_default_theme_path (klass);
-
- if (!theme_dir || !glob)
- return NULL;
-
- files = games_file_list_new (glob, theme_dir, NULL);
- games_file_list_transform_basename (files);
-
- for (l = files->list; l != NULL; l = l->next) {
- const char *filename = (const char *) l->data;
- char *dot;
-
- dot = strrchr (filename, '.');
- if (dot) {
- *dot = '\0';
- }
- }
-
- list = files->list;
- files->list = NULL;
- g_object_unref (files);
-
- return list;
-}
-#endif
-
static void
games_card_theme_class_init (GamesCardThemeClass * klass)
{
@@ -563,18 +485,19 @@
filename = colon + 1;
#ifdef HAVE_RSVG
- if (strncmp (theme_name, "svg", type_str_len) == 0)
+ if (strncmp (theme_name, "svg", type_str_len) == 0) {
type = GAMES_TYPE_CARD_THEME_SVG;
- else if (strncmp (theme_name, "kde", type_str_len) == 0)
+ } else if (strncmp (theme_name, "kde", type_str_len) == 0) {
type = GAMES_TYPE_CARD_THEME_KDE;
- else
+ } else
#endif
#ifndef HAVE_HILDON
- if (strncmp (theme_name, "sliced", type_str_len) == 0)
+ if (strncmp (theme_name, "sliced", type_str_len) == 0) {
type = GAMES_TYPE_CARD_THEME_SLICED;
- else if (strncmp (theme_name, "pysol", type_str_len) == 0)
+ } else if (strncmp (theme_name, "pysol", type_str_len) == 0) {
type = GAMES_TYPE_CARD_THEME_PYSOL;
- else
+ filename = free_me = g_strdup_printf ("cardset-%s", filename);
+ } else
#endif
if (strncmp (theme_name, "fixed", type_str_len) == 0)
type = GAMES_TYPE_CARD_THEME_FIXED;
@@ -686,8 +609,11 @@
* _games_card_theme_info_new:
* @type:
* @path:
- * @name:
+ * @filename:
* @diplay_name:
+ * @pref_name:
+ * @data:
+ * @destroy_notify:
*
* Returns: a new #GamesCardThemeInfo with refcount 1
*/
@@ -695,8 +621,9 @@
_games_card_theme_info_new (GType type,
const char *path,
const char *filename,
- const char *display_name,
- gpointer data /* adopted */,
+ char *display_name /* adopts */,
+ char *pref_name /* adopts */,
+ gpointer data /* adoptes */,
GDestroyNotify destroy_notify)
{
GamesCardThemeInfo *info;
@@ -711,7 +638,8 @@
info->type = type;
info->path = g_strdup (path);
info->filename = g_strdup (filename);
- info->display_name = g_strdup (display_name);
+ info->display_name = display_name;
+ info->pref_name = pref_name;
info->data = data;
info->destroy_notify = destroy_notify;
@@ -756,8 +684,6 @@
_games_card_theme_info_collate (GamesCardThemeInfo *a,
GamesCardThemeInfo *b)
{
- int val;
-
g_return_val_if_fail (a != NULL && b != NULL, 0);
if (a->type != b->type)
@@ -822,6 +748,7 @@
g_free (info->path);
g_free (info->filename);
g_free (info->display_name);
+ g_free (info->pref_name);
if (info->data && info->destroy_notify)
info->destroy_notify (info->data);
@@ -834,10 +761,10 @@
}
/**
- * games_card_theme_info_unref:
+ * games_card_theme_info_get_display_name :
* @info:
*
- * Unrefs @info. If the refcount reaches %0, frees @info.
+ * Returns: the user readable name of @info
*/
const char *
games_card_theme_info_get_display_name (GamesCardThemeInfo *info)
@@ -846,3 +773,19 @@
return info->display_name;
}
+
+/**
+ * games_card_theme_info_get_persistent_name :
+ * @info:
+ *
+ * Returns: the user readable name of @info
+ */
+const char *
+games_card_theme_info_get_persistent_name (GamesCardThemeInfo *info)
+{
+ g_return_val_if_fail (info != NULL, NULL);
+
+ g_return_val_if_fail (info->pref_name, NULL);
+
+ return info->pref_name;
+}
Modified: trunk/libgames-support/games-card-theme.h
==============================================================================
--- trunk/libgames-support/games-card-theme.h (original)
+++ trunk/libgames-support/games-card-theme.h Tue Jan 6 18:19:30 2009
@@ -23,8 +23,7 @@
#include <glib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
-#include "games-card.h"
-#include "games-preimage.h"
+#include <gtk/gtk.h>
G_BEGIN_DECLS
@@ -49,6 +48,8 @@
const char *games_card_theme_info_get_display_name (GamesCardThemeInfo *info);
+const char *games_card_theme_info_get_persistent_name (GamesCardThemeInfo *info);
+
/* GamesCardTheme (abstract) */
#define GAMES_TYPE_CARD_THEME (games_card_theme_get_type ())
Modified: trunk/libgames-support/games-debug.c
==============================================================================
--- trunk/libgames-support/games-debug.c (original)
+++ trunk/libgames-support/games-debug.c Tue Jan 6 18:19:30 2009
@@ -22,7 +22,9 @@
#include "games-debug.h"
+#ifdef GNOME_ENABLE_DEBUG
GamesDebugFlags _games_debug_flags;
+#endif
void
_games_debug_init (void)
Modified: trunk/libgames-support/games-debug.h
==============================================================================
--- trunk/libgames-support/games-debug.h (original)
+++ trunk/libgames-support/games-debug.h Tue Jan 6 18:19:30 2009
@@ -18,8 +18,8 @@
/* The interfaces in this file are subject to change at any time. */
-#ifndef GNOME_ENABLE_DEBUG_H
-#define GNOME_ENABLE_DEBUG_H
+#ifndef GNOME_DEBUG_H
+#define GNOME_DEBUG_H
#include <glib.h>
@@ -33,22 +33,26 @@
GAMES_DEBUG_SOUND = 1 << 2,
} GamesDebugFlags;
+#ifdef GNOME_ENABLE_DEBUG
+extern GamesDebugFlags _games_debug_flags;
+#endif
+
void _games_debug_init (void);
-extern GamesDebugFlags _games_debug_flags;
static inline gboolean _games_debug_on (GamesDebugFlags flags) G_GNUC_CONST G_GNUC_UNUSED;
static inline gboolean
_games_debug_on (GamesDebugFlags flags)
{
+#ifdef GNOME_ENABLE_DEBUG
return (_games_debug_flags & flags) == flags;
+#else
+ return FALSE;
+#endif
}
#ifdef GNOME_ENABLE_DEBUG
#define _GAMES_DEBUG_IF(flags) if (G_UNLIKELY (_games_debug_on (flags)))
-#else
-#define _GAMES_DEBUG_IF(flags) if (0)
-#endif
#if defined(__GNUC__) && G_HAVE_GNUC_VARARGS
#define _games_debug_print(flags, fmt, ...) \
@@ -67,6 +71,11 @@
}
#endif
+#else
+#define _GAMES_DEBUG_IF(flags) if (0)
+#define _games_debug_print(...)
+#endif /* GNOME_ENABLE_DEBUG */
+
G_END_DECLS
-#endif /* !GNOME_ENABLE_DEBUG_H */
+#endif /* !GNOME_DEBUG_H */
Modified: trunk/libgames-support/render-cards.c
==============================================================================
--- trunk/libgames-support/render-cards.c (original)
+++ trunk/libgames-support/render-cards.c Tue Jan 6 18:19:30 2009
@@ -133,8 +133,9 @@
theme_info = _games_card_theme_info_new (GAMES_TYPE_CARD_THEME_SVG,
theme_dir,
- theme_name /* FIXMEchpe append .svg */,
+ g_strdup_printf ("svg:%s.svg", theme_name) /* FIXMEchpe is this correct? */,
theme_name,
+ NULL,
NULL, NULL);
theme = games_card_theme_get (theme_info);
if (!theme) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]