[gnome-games] Make GamesPauseAction and GamesFullscreenAction to correctly provide toggle actions for pausing and
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] Make GamesPauseAction and GamesFullscreenAction to correctly provide toggle actions for pausing and
- Date: Fri, 23 Apr 2010 13:46:50 +0000 (UTC)
commit d722c50689b12a15fefc8f14960804faee70f352
Author: Robert Ancell <robert ancell gmail com>
Date: Fri Apr 23 23:46:23 2010 +1000
Make GamesPauseAction and GamesFullscreenAction to correctly provide toggle actions for pausing and fullscreen
libgames-support/Makefile.am | 4 +
libgames-support/games-fullscreen-action.c | 178 ++++++++++++++++++++++++++++
libgames-support/games-fullscreen-action.h | 55 +++++++++
libgames-support/games-pause-action.c | 135 +++++++++++++++++++++
libgames-support/games-pause-action.h | 55 +++++++++
mahjongg/mahjongg.c | 77 ++----------
6 files changed, 440 insertions(+), 64 deletions(-)
---
diff --git a/libgames-support/Makefile.am b/libgames-support/Makefile.am
index e5dd35c..5f33c20 100644
--- a/libgames-support/Makefile.am
+++ b/libgames-support/Makefile.am
@@ -23,10 +23,14 @@ libgames_support_la_SOURCES = \
games-conf.h \
games-debug.c \
games-debug.h \
+ games-fullscreen-action.c \
+ games-fullscreen-action.h \
games-glib-compat.h \
games-gtk-compat.h \
games-help.c \
games-help.h \
+ games-pause-action.c \
+ games-pause-action.h \
games-profile.c \
games-profile.h \
games-runtime.c \
diff --git a/libgames-support/games-fullscreen-action.c b/libgames-support/games-fullscreen-action.c
new file mode 100644
index 0000000..9926401
--- /dev/null
+++ b/libgames-support/games-fullscreen-action.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright © 2010 Robert Ancell
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Robert Ancell <robert ancell gmail com>
+ */
+
+#include <glib/gi18n.h>
+
+#include "games-fullscreen-action.h"
+#include "games-stock.h"
+
+enum {
+ PROP_0,
+ PROP_WINDOW,
+ PROP_IS_FULLSCREEN
+};
+
+struct GamesFullscreenActionPrivate
+{
+ GtkWindow *window;
+ gboolean is_fullscreen;
+};
+
+G_DEFINE_TYPE (GamesFullscreenAction, games_fullscreen_action, GTK_TYPE_ACTION);
+
+GamesFullscreenAction *
+games_fullscreen_action_new (const gchar *name, GtkWindow *window)
+{
+ return g_object_new (GAMES_FULLSCREEN_ACTION_TYPE, "name", name, "window", window, NULL);
+}
+
+void
+games_fullscreen_action_set_is_fullscreen (GamesFullscreenAction *action, gboolean is_fullscreen)
+{
+// g_return_if_fail (G
+
+ if (is_fullscreen)
+ gtk_window_fullscreen (action->priv->window);
+ else
+ gtk_window_unfullscreen (action->priv->window);
+}
+
+gboolean
+games_fullscreen_action_get_is_fullscreen (GamesFullscreenAction *action)
+{
+ return action->priv->is_fullscreen;
+}
+
+static gboolean
+window_state_event_cb (GtkWidget *widget,
+ GdkEventWindowState *event,
+ GamesFullscreenAction *action)
+{
+ gboolean is_fullscreen;
+
+ if ((event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) == 0)
+ return FALSE;
+
+ is_fullscreen = (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) != 0;
+ if ((action->priv->is_fullscreen && is_fullscreen) || (!action->priv->is_fullscreen && !is_fullscreen))
+ return FALSE;
+
+ action->priv->is_fullscreen = is_fullscreen;
+ if (action->priv->is_fullscreen)
+ gtk_action_set_stock_id (GTK_ACTION (action), GAMES_STOCK_LEAVE_FULLSCREEN);
+ else
+ gtk_action_set_stock_id (GTK_ACTION (action), GAMES_STOCK_FULLSCREEN);
+
+ g_object_notify (G_OBJECT (action), "is-fullscreen");
+
+ return FALSE;
+}
+
+static void
+games_fullscreen_action_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GamesFullscreenAction *self;
+
+ self = GAMES_FULLSCREEN_ACTION (object);
+
+ switch (prop_id) {
+ case PROP_WINDOW:
+ self->priv->window = g_object_ref (g_value_get_object (value));
+ g_signal_connect (self->priv->window, "window-state-event",
+ G_CALLBACK (window_state_event_cb), self);
+ break;
+ case PROP_IS_FULLSCREEN:
+ games_fullscreen_action_set_is_fullscreen (self, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+games_fullscreen_action_get_property(GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GamesFullscreenAction *self;
+
+ self = GAMES_FULLSCREEN_ACTION (object);
+
+ switch (prop_id) {
+ case PROP_WINDOW:
+ g_value_set_object (value, self->priv->window);
+ break;
+ case PROP_IS_FULLSCREEN:
+ g_value_set_boolean (value, games_fullscreen_action_get_is_fullscreen (self));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+games_fullscreen_action_init (GamesFullscreenAction *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GAMES_FULLSCREEN_ACTION_TYPE, GamesFullscreenActionPrivate);
+ gtk_action_set_stock_id (GTK_ACTION (self), GAMES_STOCK_FULLSCREEN);
+}
+
+static void
+games_fullscreen_action_activate (GtkAction *action)
+{
+ GamesFullscreenAction *self = GAMES_FULLSCREEN_ACTION (action);
+ games_fullscreen_action_set_is_fullscreen (self, !self->priv->is_fullscreen);
+}
+
+static void
+games_fullscreen_action_class_init (GamesFullscreenActionClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
+
+ action_class->activate = games_fullscreen_action_activate;
+ object_class->set_property = games_fullscreen_action_set_property;
+ object_class->get_property = games_fullscreen_action_get_property;
+
+ g_object_class_install_property(object_class,
+ PROP_WINDOW,
+ g_param_spec_object("window",
+ "window",
+ "The window being controlled",
+ GTK_TYPE_WINDOW,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property(object_class,
+ PROP_IS_FULLSCREEN,
+ g_param_spec_boolean("is-fullscreen",
+ "is-fullscreen",
+ "True if game is fullscreen",
+ FALSE,
+ G_PARAM_READWRITE));
+
+ g_type_class_add_private (klass, sizeof (GamesFullscreenActionPrivate));
+}
diff --git a/libgames-support/games-fullscreen-action.h b/libgames-support/games-fullscreen-action.h
new file mode 100644
index 0000000..5ac9a64
--- /dev/null
+++ b/libgames-support/games-fullscreen-action.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2010 Robert Ancell
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Robert Ancell <robert ancell gmail com>
+ */
+
+#ifndef __GAMES_FULLSCREEN_ACTION_H__
+#define __GAMES_FULLSCREEN_ACTION_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GAMES_FULLSCREEN_ACTION_TYPE (games_fullscreen_action_get_type ())
+#define GAMES_FULLSCREEN_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_FULLSCREEN_ACTION_TYPE, GamesFullscreenAction))
+
+typedef struct GamesFullscreenActionPrivate GamesFullscreenActionPrivate;
+
+typedef struct
+{
+ GtkAction parent_instance;
+ GamesFullscreenActionPrivate *priv;
+} GamesFullscreenAction;
+
+typedef struct
+{
+ GtkActionClass parent_class;
+} GamesFullscreenActionClass;
+
+GType games_fullscreen_action_get_type (void);
+
+GamesFullscreenAction *games_fullscreen_action_new (const gchar *name, GtkWindow *window);
+
+void games_fullscreen_action_set_is_fullscreen (GamesFullscreenAction *action, gboolean is_fullscreen);
+
+gboolean games_fullscreen_action_get_is_fullscreen (GamesFullscreenAction *action);
+
+G_END_DECLS
+
+#endif /* __GAMES_FULLSCREEN_ACTION_H__ */
diff --git a/libgames-support/games-pause-action.c b/libgames-support/games-pause-action.c
new file mode 100644
index 0000000..dbd21ff
--- /dev/null
+++ b/libgames-support/games-pause-action.c
@@ -0,0 +1,135 @@
+/*
+ * Copyright © 2010 Robert Ancell
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Robert Ancell <robert ancell gmail com>
+ */
+
+#include "games-pause-action.h"
+#include "games-stock.h"
+
+enum {
+ PROP_0,
+ PROP_IS_PAUSED
+};
+
+struct GamesPauseActionPrivate
+{
+ gboolean is_paused;
+};
+
+G_DEFINE_TYPE (GamesPauseAction, games_pause_action, GTK_TYPE_ACTION);
+
+GamesPauseAction *
+games_pause_action_new (const char *name)
+{
+ return g_object_new (GAMES_PAUSE_ACTION_TYPE, "name", name, NULL);
+}
+
+void
+games_pause_action_set_is_paused (GamesPauseAction *action, gboolean is_paused)
+{
+ if ((action->priv->is_paused && is_paused) || (!action->priv->is_paused && !is_paused))
+ return;
+ action->priv->is_paused = is_paused;
+ if (is_paused)
+ gtk_action_set_stock_id (GTK_ACTION (action), GAMES_STOCK_RESUME_GAME);
+ else
+ gtk_action_set_stock_id (GTK_ACTION (action), GAMES_STOCK_PAUSE_GAME);
+ g_object_notify (G_OBJECT (action), "is-paused");
+}
+
+gboolean
+games_pause_action_get_is_paused (GamesPauseAction *action)
+{
+ return action->priv->is_paused;
+}
+
+static void
+games_pause_action_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GamesPauseAction *self;
+
+ self = GAMES_PAUSE_ACTION (object);
+
+ switch (prop_id) {
+ case PROP_IS_PAUSED:
+ games_pause_action_set_is_paused (self, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+games_pause_action_get_property(GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GamesPauseAction *self;
+
+ self = GAMES_PAUSE_ACTION (object);
+
+ switch (prop_id) {
+ case PROP_IS_PAUSED:
+ g_value_set_boolean (value, games_pause_action_get_is_paused (self));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+games_pause_action_init (GamesPauseAction *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GAMES_PAUSE_ACTION_TYPE, GamesPauseActionPrivate);
+ gtk_action_set_stock_id (GTK_ACTION (self), GAMES_STOCK_PAUSE_GAME);
+}
+
+static void
+games_pause_action_activate (GtkAction *action)
+{
+ GamesPauseAction *self = GAMES_PAUSE_ACTION (action);
+ games_pause_action_set_is_paused (self, !self->priv->is_paused);
+}
+
+static void
+games_pause_action_class_init (GamesPauseActionClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
+
+ action_class->activate = games_pause_action_activate;
+ object_class->set_property = games_pause_action_set_property;
+ object_class->get_property = games_pause_action_get_property;
+
+ g_object_class_install_property(object_class,
+ PROP_IS_PAUSED,
+ g_param_spec_boolean("is-paused",
+ "is-paused",
+ "True if game is paused",
+ FALSE,
+ G_PARAM_READWRITE));
+
+ g_type_class_add_private (klass, sizeof (GamesPauseActionPrivate));
+}
diff --git a/libgames-support/games-pause-action.h b/libgames-support/games-pause-action.h
new file mode 100644
index 0000000..fdff193
--- /dev/null
+++ b/libgames-support/games-pause-action.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2010 Robert Ancell
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Robert Ancell <robert ancell gmail com>
+ */
+
+#ifndef __GAMES_PAUSE_ACTION_H__
+#define __GAMES_PAUSE_ACTION_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GAMES_PAUSE_ACTION_TYPE (games_pause_action_get_type ())
+#define GAMES_PAUSE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_PAUSE_ACTION_TYPE, GamesPauseAction))
+
+typedef struct GamesPauseActionPrivate GamesPauseActionPrivate;
+
+typedef struct
+{
+ GtkAction parent_instance;
+ GamesPauseActionPrivate *priv;
+} GamesPauseAction;
+
+typedef struct
+{
+ GtkActionClass parent_class;
+} GamesPauseActionClass;
+
+GType games_pause_action_get_type (void);
+
+GamesPauseAction *games_pause_action_new (const char *name);
+
+void games_pause_action_set_is_paused (GamesPauseAction *action, gboolean is_paused);
+
+gboolean games_pause_action_get_is_paused (GamesPauseAction *action);
+
+G_END_DECLS
+
+#endif /* __GAMES_PAUSE_ACTION_H__ */
diff --git a/mahjongg/mahjongg.c b/mahjongg/mahjongg.c
index 5ca8bb2..19fb07b 100644
--- a/mahjongg/mahjongg.c
+++ b/mahjongg/mahjongg.c
@@ -33,6 +33,8 @@
#include <libgames-support/games-scores.h>
#include <libgames-support/games-scores-dialog.h>
#include <libgames-support/games-runtime.h>
+#include <libgames-support/games-fullscreen-action.h>
+#include <libgames-support/games-pause-action.h>
#include "mahjongg.h"
#include "drawing.h"
@@ -69,7 +71,6 @@ static GtkWidget *colour_well = NULL;
static GtkWidget *pref_dialog = NULL;
static GtkAction *pause_action;
-static GtkAction *resume_action;
static GtkAction *hint_action;
static GtkAction *redo_action;
static GtkAction *undo_action;
@@ -77,7 +78,6 @@ static GtkAction *restart_action;
static GtkAction *scores_action;
static GtkAction *show_toolbar_action;
static GtkAction *fullscreen_action;
-static GtkAction *leavefullscreen_action;
/* Available tilsets */
static GList *tileset_list = NULL;
@@ -119,7 +119,7 @@ void check_free (void);
void undo_tile_callback (void);
void properties_callback (void);
void shuffle_tiles_callback (void);
-void pause_callback (void);
+void pause_callback (GamesPauseAction *action);
void new_game (gboolean shuffle);
void
@@ -148,37 +148,6 @@ mahjongg_theme_warning (gchar * message)
gtk_widget_destroy (dialog);
}
-static void
-set_fullscreen_actions (gboolean is_fullscreen)
-{
- gtk_action_set_sensitive (leavefullscreen_action, is_fullscreen);
- gtk_action_set_visible (leavefullscreen_action, is_fullscreen);
-
- gtk_action_set_sensitive (fullscreen_action, !is_fullscreen);
- gtk_action_set_visible (fullscreen_action, !is_fullscreen);
-}
-
-static void
-fullscreen_callback (GtkAction * action)
-{
- if (action == fullscreen_action)
- gtk_window_fullscreen (GTK_WINDOW (window));
- else
- gtk_window_unfullscreen (GTK_WINDOW (window));
-}
-
-static gboolean
-window_state_callback (GtkWidget * widget, GdkEventWindowState * event)
-{
- if (!(event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN))
- return FALSE;
-
- set_fullscreen_actions (event->new_window_state &
- GDK_WINDOW_STATE_FULLSCREEN);
-
- return FALSE;
-}
-
/* At the end of the game, hint, shuffle and pause all become unavailable. */
/* Undo and Redo are handled elsewhere. */
static void
@@ -193,14 +162,10 @@ update_menu_sensitivities (void)
gtk_action_set_sensitive (hint_action, FALSE);
gtk_action_set_sensitive (undo_action, FALSE);
gtk_action_set_sensitive (redo_action, FALSE);
- gtk_action_set_visible (pause_action, FALSE);
- gtk_action_set_visible (resume_action, TRUE);
} else {
gtk_action_set_sensitive (hint_action, moves_left > 0);
gtk_action_set_sensitive (undo_action, undo_state);
gtk_action_set_sensitive (redo_action, redo_state);
- gtk_action_set_visible (pause_action, TRUE);
- gtk_action_set_visible (resume_action, FALSE);
}
/* This is a workaround to make sure that all toolbar elements are
@@ -480,7 +445,7 @@ void
tile_event (gint tileno, gint button)
{
if (paused) {
- pause_callback ();
+ pause_callback (NULL);
return;
}
@@ -957,7 +922,7 @@ about_callback (void)
}
void
-pause_callback (void)
+pause_callback (GamesPauseAction *action)
{
static gboolean noloops = FALSE;
@@ -969,7 +934,8 @@ pause_callback (void)
noloops = TRUE;
stop_hints ();
- paused = !paused;
+ if (action)
+ paused = games_pause_action_get_is_paused (action);
draw_all_tiles ();
update_menu_sensitivities ();
if (paused) {
@@ -1246,10 +1212,6 @@ static const GtkActionEntry actions[] = {
G_CALLBACK (new_game_cb)},
{"RestartGame", GAMES_STOCK_RESTART_GAME, NULL, NULL,
N_("Restart the current game"), G_CALLBACK (restart_game_cb)},
- {"PauseGame", GAMES_STOCK_PAUSE_GAME, NULL, NULL, N_("Pause the game"),
- G_CALLBACK (pause_callback)},
- {"ResumeGame", GAMES_STOCK_RESUME_GAME, NULL, NULL,
- N_("Resume the paused game"), G_CALLBACK (pause_callback)},
{"UndoMove", GAMES_STOCK_UNDO_MOVE, NULL, NULL, N_("Undo the last move"),
G_CALLBACK (undo_tile_callback)},
{"RedoMove", GAMES_STOCK_REDO_MOVE, NULL, NULL, N_("Redo the last move"),
@@ -1259,10 +1221,6 @@ static const GtkActionEntry actions[] = {
{"Scores", GAMES_STOCK_SCORES, NULL, NULL, NULL,
G_CALLBACK (scores_callback)},
{"Quit", GTK_STOCK_QUIT, NULL, NULL, NULL, G_CALLBACK (quit_cb)},
- {"Fullscreen", GAMES_STOCK_FULLSCREEN, NULL, NULL, NULL,
- G_CALLBACK (fullscreen_callback)},
- {"LeaveFullscreen", GAMES_STOCK_LEAVE_FULLSCREEN, NULL, NULL, NULL,
- G_CALLBACK (fullscreen_callback)},
{"Preferences", GTK_STOCK_PREFERENCES, NULL, NULL, NULL,
G_CALLBACK (properties_callback)},
{"Contents", GAMES_STOCK_CONTENTS, NULL, NULL, NULL, G_CALLBACK (help_cb)},
@@ -1281,7 +1239,6 @@ static const char ui_description[] =
" <menuitem action='NewGame'/>"
" <menuitem action='RestartGame'/>"
" <menuitem action='PauseGame'/>"
- " <menuitem action='ResumeGame'/>"
" <separator/>"
" <menuitem action='UndoMove'/>"
" <menuitem action='RedoMove'/>"
@@ -1293,7 +1250,6 @@ static const char ui_description[] =
" </menu>"
" <menu action='SettingsMenu'>"
" <menuitem action='Fullscreen'/>"
- " <menuitem action='LeaveFullscreen'/>"
" <menuitem action='ShowToolbar'/>"
" <separator/>"
" <menuitem action='Preferences'/>"
@@ -1307,12 +1263,10 @@ static const char ui_description[] =
" <toolitem action='NewGame'/>"
" <toolitem action='RestartGame'/>"
" <toolitem action='PauseGame'/>"
- " <toolitem action='ResumeGame'/>"
" <separator/>"
" <toolitem action='UndoMove'/>"
" <toolitem action='RedoMove'/>"
" <toolitem action='Hint'/>"
- " <toolitem action='LeaveFullscreen'/>"
" </toolbar>"
"</ui>";
@@ -1333,8 +1287,9 @@ create_menus (GtkUIManager * ui_manager)
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
gtk_ui_manager_add_ui_from_string (ui_manager, ui_description, -1, NULL);
restart_action = gtk_action_group_get_action (action_group, "RestartGame");
- pause_action = gtk_action_group_get_action (action_group, "PauseGame");
- resume_action = gtk_action_group_get_action (action_group, "ResumeGame");
+ pause_action = GTK_ACTION (games_pause_action_new ("PauseGame"));
+ g_signal_connect (G_OBJECT (pause_action), "notify::is-paused", G_CALLBACK (pause_callback), NULL);
+ gtk_action_group_add_action_with_accel (action_group, pause_action, NULL);
hint_action = gtk_action_group_get_action (action_group, "Hint");
undo_action = gtk_action_group_get_action (action_group, "UndoMove");
redo_action = gtk_action_group_get_action (action_group, "RedoMove");
@@ -1342,11 +1297,8 @@ create_menus (GtkUIManager * ui_manager)
show_toolbar_action =
gtk_action_group_get_action (action_group, "ShowToolbar");
- fullscreen_action =
- gtk_action_group_get_action (action_group, "Fullscreen");
- leavefullscreen_action =
- gtk_action_group_get_action (action_group, "LeaveFullscreen");
- set_fullscreen_actions (FALSE);
+ fullscreen_action = GTK_ACTION (games_fullscreen_action_new ("Fullscreen", GTK_WINDOW (window)));
+ gtk_action_group_add_action_with_accel (action_group, fullscreen_action, NULL);
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (show_toolbar_action),
games_conf_get_boolean (NULL, KEY_SHOW_TOOLBAR, NULL));
@@ -1437,9 +1389,6 @@ main (int argc, char *argv[])
load_preferences ();
- g_signal_connect (window, "window-state-event",
- G_CALLBACK (window_state_callback), NULL);
-
/* Statusbar for a chrono, Tiles left and Moves left */
status_box = gtk_hbox_new (FALSE, 10);
@@ -1478,7 +1427,7 @@ main (int argc, char *argv[])
gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (statusbar), FALSE);
create_menus (ui_manager);
- accel_group = gtk_ui_manager_get_accel_group (ui_manager);
+ accel_group = gtk_ui_manager_get_accel_group (ui_manager);
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
box = gtk_ui_manager_get_widget (ui_manager, "/MainMenu");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]