[gnome-games] aisleriot: Make pixbuf-drawing a property on ArStyle too
- From: Christian Persch <chpe src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-games] aisleriot: Make pixbuf-drawing a property on ArStyle too
- Date: Mon, 4 Jan 2010 18:15:13 +0000 (UTC)
commit 50f98ef72936f16ff5c9cdde9ed35515b7f54139
Author: Christian Persch <chpe gnome org>
Date: Mon Jan 4 19:11:42 2010 +0100
aisleriot: Make pixbuf-drawing a property on ArStyle too
And remove the extra debug UI for this from sol-nonclutter; it can now
be tweaked from the ArStyle property editor like any of the other
properties.
aisleriot/ar-style-private.h | 10 ++++++
aisleriot/ar-style.c | 66 +++++++++++++++++++++++++++++++++++++++++-
aisleriot/ar-style.h | 8 +++++
aisleriot/board-noclutter.c | 42 ++++++++++----------------
aisleriot/board-noclutter.h | 3 --
aisleriot/window.c | 59 -------------------------------------
6 files changed, 99 insertions(+), 89 deletions(-)
---
diff --git a/aisleriot/ar-style-private.h b/aisleriot/ar-style-private.h
index 4293b21..dd35f40 100644
--- a/aisleriot/ar-style-private.h
+++ b/aisleriot/ar-style-private.h
@@ -37,6 +37,12 @@ static const GdkColor default_selection_color = { 0, 0 /* red */, 0 /* green */,
#define MAX_CARD_STEP (1.0) /* FIXMEchpe: allow values > 1.0 here? */
#define DEFAULT_CARD_STEP (0.2)
+#ifdef HAVE_HILDON
+#define DEFAULT_PIXBUF_DRAWING (FALSE)
+#else
+#define DEFAULT_PIXBUF_DRAWING (TRUE)
+#endif
+
struct _ArStylePrivate
{
GamesCardTheme* card_theme;
@@ -71,6 +77,10 @@ struct _ArStylePrivate
guint show_focus : 1;
guint show_highlight : 1;
guint show_seleccion : 1;
+
+#ifndef HAVE_CLUTTER
+ guint pixbuf_drawing : 1;
+#endif
};
#ifdef HAVE_CLUTTER
diff --git a/aisleriot/ar-style.c b/aisleriot/ar-style.c
index 95bf340..1c614c1 100644
--- a/aisleriot/ar-style.c
+++ b/aisleriot/ar-style.c
@@ -20,6 +20,8 @@
#include "ar-style.h"
#include "ar-style-private.h"
+#include <libgames-support/games-debug.h>
+
enum
{
PROP_0,
@@ -35,9 +37,12 @@ enum
PROP_FOCUS_LINE_WIDTH,
PROP_FOCUS_PADDING,
PROP_INTERIOR_FOCUS,
+#ifndef HAVE_CLUTTER
+ PROP_PIXBUF_DRAWING,
+#endif
PROP_RTL,
PROP_SELECTION_COLOR,
- PROP_TOUCHSCREEN_MODE,
+ PROP_TOUCHSCREEN_MODE
};
/* private functions */
@@ -74,6 +79,27 @@ ar_style_init (ArStyle *style)
priv->rtl = FALSE;
priv->interior_focus = FALSE;
priv->click_to_move = FALSE;
+
+#ifndef HAVE_CLUTTER
+
+#ifdef HAVE_HILDON
+ priv->use_pixbuf_drawing = FALSE;
+#else
+{
+ const char *env;
+
+ env = g_getenv ("AISLERIOT_PIXBUF_DRAWING");
+
+ /* Default to pixbuf drawing */
+ priv->pixbuf_drawing = env == NULL || g_ascii_strtoull (env, NULL, 10) != 0;
+}
+#endif /* HAVE_HILDON */
+
+ _games_debug_print (GAMES_DEBUG_GAME_STYLE,
+ "[ArStyle %p] Using %s drawing\n",
+ style, priv->pixbuf_drawing ? "pixbuf" : "pixmap");
+
+#endif /* !HAVE_CLUTTER */
}
static void
@@ -147,6 +173,12 @@ ar_style_get_property (GObject *object,
g_value_set_boolean (value, ar_style_get_interior_focus (style));
break;
+#ifndef HAVE_CLUTTER
+ case PROP_PIXBUF_DRAWING:
+ g_value_set_boolean (value, ar_style_get_pixbuf_drawing (style));
+ break;
+#endif
+
case PROP_RTL:
g_value_set_boolean (value, ar_style_get_rtl (style));
break;
@@ -218,6 +250,11 @@ ar_style_set_property (GObject *object,
priv->interior_focus = g_value_get_boolean (value) != FALSE;
break;
+#ifndef HAVE_CLUTTER
+ case PROP_PIXBUF_DRAWING:
+ priv->pixbuf_drawing = g_value_get_boolean (value) != FALSE;
+#endif
+
case PROP_RTL:
priv->rtl = g_value_get_boolean (value) != FALSE;
break;
@@ -378,6 +415,16 @@ ar_style_class_init (ArStyleClass *klass)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
+#ifndef HAVE_CLUTTER
+ g_object_class_install_property
+ (object_class,
+ PROP_PIXBUF_DRAWING,
+ g_param_spec_boolean (AR_STYLE_PROP_PIXBUF_DRAWING, NULL, NULL,
+ DEFAULT_PIXBUF_DRAWING,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+#endif /* !HAVE_CLUTTER */
+
g_object_class_install_property
(object_class,
PROP_RTL,
@@ -763,3 +810,20 @@ ar_style_check_dnd_drag_threshold (ArStyle *style,
return (ABS (x2 - x1) > priv->dnd_drag_threshold ||
ABS (y2 - y1) > priv->dnd_drag_threshold);
}
+
+#ifndef HAVE_CLUTTER
+/**
+ * ar_style_get_pixbuf_drawing:
+ * @style:
+ *
+ * Returns: wether to use pixbuf drawing
+ */
+gboolean
+ar_style_get_pixbuf_drawing (ArStyle *style)
+{
+ ArStylePrivate *priv = style->priv;
+
+ return priv->pixbuf_drawing;
+}
+
+#endif /* !HAVE_CLUTTER */
diff --git a/aisleriot/ar-style.h b/aisleriot/ar-style.h
index 6e08984..a88175f 100644
--- a/aisleriot/ar-style.h
+++ b/aisleriot/ar-style.h
@@ -117,6 +117,14 @@ gboolean ar_style_check_dnd_drag_threshold (ArStyle *style,
float x2,
float y2);
+#ifndef HAVE_CLUTTER
+
+#define AR_STYLE_PROP_PIXBUF_DRAWING "pixbuf-drawing"
+
+gboolean ar_style_get_pixbuf_drawing (ArStyle *style);
+
+#endif /* !HAVE_CLUTTER */
+
G_END_DECLS
#endif /* __AR_STYLE_H__ */
diff --git a/aisleriot/board-noclutter.c b/aisleriot/board-noclutter.c
index 78b7876..88fa97e 100644
--- a/aisleriot/board-noclutter.c
+++ b/aisleriot/board-noclutter.c
@@ -2478,6 +2478,22 @@ aisleriot_board_sync_style (ArStyle *style,
redraw_selection = TRUE;
}
+ if (pspec_name == NULL || pspec_name == I_(AR_STYLE_PROP_PIXBUF_DRAWING)) {
+ gboolean pixbuf_drawing;
+
+ pixbuf_drawing = ar_style_get_pixbuf_drawing (priv->style);
+ if (pixbuf_drawing == priv->use_pixbuf_drawing)
+ return;
+
+ priv->use_pixbuf_drawing = pixbuf_drawing;
+
+ games_card_images_set_cache_mode (priv->images,
+ pixbuf_drawing ? CACHE_PIXBUFS : CACHE_PIXMAPS);
+
+ update_geometry |= TRUE;
+ queue_redraw |= TRUE;
+ }
+
if (update_geometry && GTK_WIDGET_REALIZED (widget)) {
aisleriot_board_setup_geometry (board);
}
@@ -3529,29 +3545,3 @@ aisleriot_board_abort_move (AisleriotBoard *board)
{
clear_state (board);
}
-
-void
-aisleriot_board_set_pixbuf_drawing (AisleriotBoard *board,
- gboolean use_pixbuf_drawing)
-{
- AisleriotBoardPrivate *priv = board->priv;
- GtkWidget *widget = GTK_WIDGET (board);
-
- use_pixbuf_drawing = use_pixbuf_drawing != FALSE;
-
- if (use_pixbuf_drawing == priv->use_pixbuf_drawing)
- return;
-
- priv->use_pixbuf_drawing = use_pixbuf_drawing;
-
- games_card_images_set_cache_mode (priv->images,
- use_pixbuf_drawing ? CACHE_PIXBUFS : CACHE_PIXMAPS);
-
- if (GTK_WIDGET_REALIZED (widget) &&
- priv->geometry_set) {
- /* Need to update the geometry, so we update the cached card images! */
- aisleriot_board_setup_geometry (board);
-
- gtk_widget_queue_draw (widget);
- }
-}
diff --git a/aisleriot/board-noclutter.h b/aisleriot/board-noclutter.h
index be09594..e386b38 100644
--- a/aisleriot/board-noclutter.h
+++ b/aisleriot/board-noclutter.h
@@ -66,9 +66,6 @@ GtkWidget *aisleriot_board_new (ArStyle *style,
void aisleriot_board_abort_move (AisleriotBoard * board);
-void aisleriot_board_set_pixbuf_drawing (AisleriotBoard * board,
- gboolean use_pixbuf_drawing);
-
G_END_DECLS
#endif /* !AISLERIOT_BOARD_H */
diff --git a/aisleriot/window.c b/aisleriot/window.c
index 980e6a7..856b984 100644
--- a/aisleriot/window.c
+++ b/aisleriot/window.c
@@ -187,10 +187,6 @@ struct _AisleriotWindowPrivate
guint load_idle_id;
-#ifndef HAVE_CLUTTER
- guint use_pixbuf_drawing : 1;
-#endif
-
guint changing_game_type : 1;
guint freecell_mode : 1;
guint toolbar_visible : 1;
@@ -860,19 +856,6 @@ debug_choose_seed_cb (GtkAction *action,
gtk_window_present (GTK_WINDOW (dialog));
}
-#ifndef HAVE_CLUTTER
-static void
-debug_pixbuf_drawing_cb (GtkToggleAction *action,
- AisleriotWindow *window)
-{
- AisleriotWindowPrivate *priv = window->priv;
- gboolean active;
-
- active = gtk_toggle_action_get_active (action);
- aisleriot_board_set_pixbuf_drawing (priv->board, active);
-}
-#endif /* !HAVE_CLUTTER */
-
static void
debug_tweak_cb (GtkAction *action,
AisleriotWindow *window)
@@ -2315,11 +2298,6 @@ aisleriot_window_init (AisleriotWindow *window)
G_CALLBACK (animations_toggle_cb),
FALSE /* not active by default */ },
#endif /* HAVE_CLUTTER */
-#if defined(ENABLE_DEBUG_UI) && !defined(HAVE_CLUTTER)
- { "DebugPixbufDrawing", NULL, "_Pixbuf drawing", NULL, NULL,
- G_CALLBACK (debug_pixbuf_drawing_cb),
- FALSE },
-#endif /* ENABLE_DEBUG_UI */
};
static const char names[][16] = {
@@ -2379,9 +2357,6 @@ aisleriot_window_init (AisleriotWindow *window)
#ifdef ENABLE_DEBUG_UI
"<menu action='DebugMenu'>"
"<menuitem action='DebugChooseSeed'/>"
-#ifndef HAVE_CLUTTER
- "<menuitem action='DebugPixbufDrawing'/>"
-#endif /* !HAVE_CLUTTER */
"<menuitem action='DebugTweakStyle'/>"
"</menu>"
#endif /* ENABLE_DEBUG_UI */
@@ -2434,9 +2409,6 @@ aisleriot_window_init (AisleriotWindow *window)
#ifdef ENABLE_DEBUG_UI
"<menu action='DebugMenu'>"
"<menuitem action='DebugTweakStyle'/>"
-#ifndef HAVE_CLUTTER
- "<menuitem action='DebugPixbufDrawing'/>"
-#endif
"<separator/>"
"<menuitem action='DebugChooseSeed'/>"
"<menuitem action='DebugMoveNextScreen'/>"
@@ -2504,30 +2476,6 @@ aisleriot_window_init (AisleriotWindow *window)
priv->game = aisleriot_game_new ();
-#ifndef HAVE_CLUTTER
-
-#ifdef HAVE_HILDON
- priv->use_pixbuf_drawing = FALSE;
-#else
-{
- const char *env;
-
- env = g_getenv ("AISLERIOT_PIXBUF_DRAWING");
-
- /* Default to pixbuf drawing */
- priv->use_pixbuf_drawing = env == NULL || g_ascii_strtoull (env, NULL, 10) != 0;
-}
-#endif /* HAVE_HILDON */
-
-#ifdef GNOME_ENABLE_DEBUG
- if (priv->use_pixbuf_drawing)
- g_print ("Using pixbuf drawing method\n");
- else
- g_print ("Using pixmap drawing method\n");
-#endif /* GNOME_ENABLE_DEBUG */
-
-#endif /* !HAVE_CLUTTER */
-
priv->theme_manager = games_card_themes_new ();
priv->board_style = ar_style_new ();
@@ -2559,8 +2507,6 @@ aisleriot_window_init (AisleriotWindow *window)
/* FIXMEchpe: unref baize & board_actor here? */
#else
priv->board = AISLERIOT_BOARD (aisleriot_board_new (priv->board_style, priv->game));
-
- aisleriot_board_set_pixbuf_drawing (priv->board, priv->use_pixbuf_drawing);
#endif /* HAVE_CLUTTER */
theme_name = games_conf_get_string (NULL, aisleriot_conf_get_key (CONF_THEME), NULL);
@@ -2854,11 +2800,6 @@ aisleriot_window_init (AisleriotWindow *window)
g_signal_connect (window, "notify::is-topmost",
G_CALLBACK (sync_window_topmost_cb), NULL);
#endif
-
-#if defined(ENABLE_DEBUG_UI) && !defined(HAVE_CLUTTER)
- action = gtk_action_group_get_action (priv->action_group, "DebugPixbufDrawing");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), priv->use_pixbuf_drawing);
-#endif /* ENABLE_DEBUG_UI && !HAVE_CLUTTER */
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]