[gnome-games] aisleriot: Set freecell-mode on window construction
- From: Christian Persch <chpe src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-games] aisleriot: Set freecell-mode on window construction
- Date: Tue, 1 Dec 2009 22:00:48 +0000 (UTC)
commit 28fe8aa0b7f20bbf9b0ddcf28fb4d57c6e9f2c0d
Author: Christian Persch <chpe gnome org>
Date: Tue Dec 1 21:21:05 2009 +0100
aisleriot: Set freecell-mode on window construction
And set the title immediately. This avoids setting the default title of
"AisleRiot" and then have it change to "Freecell" when the game loads a
short time after.
aisleriot/sol.c | 7 ++--
aisleriot/window.c | 99 ++++++++++++++++++++++++++++++++++++++--------------
aisleriot/window.h | 4 +--
3 files changed, 77 insertions(+), 33 deletions(-)
---
diff --git a/aisleriot/sol.c b/aisleriot/sol.c
index f72c1a2..9b0cbb3 100644
--- a/aisleriot/sol.c
+++ b/aisleriot/sol.c
@@ -349,12 +349,12 @@ main_prog (void *closure, int argc, char *argv[])
games_stock_init ();
- data.window = AISLERIOT_WINDOW (aisleriot_window_new ());
+ gtk_window_set_default_icon_name (data.freecell ? "gnome-freecell" : "gnome-aisleriot");
+
+ data.window = AISLERIOT_WINDOW (aisleriot_window_new (data.freecell));
g_signal_connect (data.window, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
- gtk_window_set_default_icon_name (data.freecell ? "gnome-freecell" : "gnome-aisleriot");
-
#ifdef WITH_SMCLIENT
sm_client = egg_sm_client_get ();
g_signal_connect (sm_client, "save-state",
@@ -397,7 +397,6 @@ main_prog (void *closure, int argc, char *argv[])
#endif /* HAVE_HILDON */
if (data.freecell) {
- aisleriot_window_set_freecell_mode (data.window);
aisleriot_window_set_game (data.window, FREECELL_VARIATION, data.seed);
} else {
aisleriot_window_set_game (data.window, data.variation, data.seed);
diff --git a/aisleriot/window.c b/aisleriot/window.c
index 0bee60f..1a99aa5 100644
--- a/aisleriot/window.c
+++ b/aisleriot/window.c
@@ -188,6 +188,11 @@ enum {
OPTION_RADIOMENU
};
+enum {
+ PROP_0,
+ PROP_FREECELL_MODE
+};
+
/* Game choice dialogue */
enum {
@@ -1925,7 +1930,10 @@ game_type_changed_cb (AisleriotGame *game,
g_object_set (priv->action[ACTION_HELP_GAME], "label", game_name, NULL);
g_object_set (priv->action[ACTION_OPTIONS_MENU], "label", game_name, NULL);
- gtk_window_set_title (GTK_WINDOW (window), game_name);
+ /* In freecell mode, we've already set the title to something different */
+ if (!priv->freecell_mode) {
+ gtk_window_set_title (GTK_WINDOW (window), game_name);
+ }
g_free (game_name);
@@ -2190,6 +2198,36 @@ screen_changed_cb (GtkWidget *widget,
#endif /* HAVE_CLUTTER || HAVE_CANBERRA_GTK */
+/*
+ * aisleriot_window_set_freecell_mode:
+ * @window:
+ *
+ * Sets @window to FreeCell mode. In FreeCell mode,
+ * the window is using the FreeCell variation, and doesn't allow
+ * changing the game type.
+ */
+static void
+aisleriot_window_set_freecell_mode (AisleriotWindow *window,
+ gboolean freecell_mode)
+{
+ AisleriotWindowPrivate *priv = window->priv;
+ GtkAction *action;
+
+ priv->freecell_mode = freecell_mode != FALSE;
+
+ if (freecell_mode) {
+ /* Inhibit game changing */
+ action = gtk_action_group_get_action (priv->action_group, "Select");
+ gtk_action_set_visible (action, FALSE);
+ action = gtk_action_group_get_action (priv->action_group, "RecentMenu");
+ gtk_action_set_visible (action, FALSE);
+
+ gtk_window_set_title (GTK_WINDOW (window), _("Freecell Solitaire"));
+ } else {
+ gtk_window_set_title (GTK_WINDOW (window), _("AisleRiot"));
+ }
+}
+
/* Class implementation */
#ifdef HAVE_HILDON
@@ -2974,6 +3012,23 @@ aisleriot_window_finalize (GObject *object)
}
static void
+aisleriot_window_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ AisleriotWindow *window = AISLERIOT_WINDOW (object);
+
+ switch (property_id) {
+ case PROP_FREECELL_MODE:
+ aisleriot_window_set_freecell_mode (window, g_value_get_boolean (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+static void
aisleriot_window_class_init (AisleriotWindowClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
@@ -2981,6 +3036,7 @@ aisleriot_window_class_init (AisleriotWindowClass *klass)
gobject_class->dispose = aisleriot_window_dispose;
gobject_class->finalize = aisleriot_window_finalize;
+ gobject_class->set_property = aisleriot_window_set_property;
widget_class->window_state_event = aisleriot_window_state_event;
#if GTK_CHECK_VERSION (2, 10, 0)
@@ -2988,6 +3044,20 @@ aisleriot_window_class_init (AisleriotWindowClass *klass)
#endif
g_type_class_add_private (gobject_class, sizeof (AisleriotWindowPrivate));
+
+ /**
+ * AisleriotWindow:freecell-mode:
+ *
+ * Whether the window is in freecell mode.
+ */
+ g_object_class_install_property
+ (gobject_class,
+ PROP_FREECELL_MODE,
+ g_param_spec_boolean ("freecell-mode", NULL, NULL,
+ FALSE,
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
}
/* public API */
@@ -2998,36 +3068,13 @@ aisleriot_window_class_init (AisleriotWindowClass *klass)
* Returns: a new #AisleriotWindow
*/
GtkWidget *
-aisleriot_window_new (void)
+aisleriot_window_new (gboolean freecell_mode)
{
return g_object_new (AISLERIOT_TYPE_WINDOW,
- "title", _("AisleRiot"),
+ "freecell-mode", freecell_mode,
NULL);
}
-/**
- * aisleriot_window_set_freecell_mode:
- * @window:
- *
- * Sets @window to FreeCell mode. In FreeCell mode,
- * the window is using the FreeCell variation, and doesn't allow
- * changing the game type.
- */
-void
-aisleriot_window_set_freecell_mode (AisleriotWindow *window)
-{
- AisleriotWindowPrivate *priv = window->priv;
- GtkAction *action;
-
- priv->freecell_mode = TRUE;
-
- /* Inhibit game changing */
- action = gtk_action_group_get_action (priv->action_group, "Select");
- gtk_action_set_visible (action, FALSE);
- action = gtk_action_group_get_action (priv->action_group, "RecentMenu");
- gtk_action_set_visible (action, FALSE);
-}
-
typedef struct {
AisleriotWindow *window;
char *game_file;
diff --git a/aisleriot/window.h b/aisleriot/window.h
index a3ac5a9..f4e8efe 100644
--- a/aisleriot/window.h
+++ b/aisleriot/window.h
@@ -61,9 +61,7 @@ typedef GtkWindowClass AisleriotWindowClass;
GType aisleriot_window_get_type (void);
-GtkWidget *aisleriot_window_new (void);
-
-void aisleriot_window_set_freecell_mode (AisleriotWindow * window);
+GtkWidget *aisleriot_window_new (gboolean freecell_mode);
void aisleriot_window_set_game (AisleriotWindow * window,
const char *game_file, guint seed);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]