[gnome-games] Use new GamesActions for gnomine, gnotravex, quadrapassel



commit 5e3046895e91ad672b409d921d2b1a4c5201b810
Author: Robert Ancell <robert ancell gmail com>
Date:   Sat Apr 24 10:13:47 2010 +1000

    Use new GamesActions for gnomine, gnotravex, quadrapassel

 gnomine/gnomine.c                     |  132 +++++++--------------------------
 gnotravex/gnotravex.c                 |   72 ++----------------
 libgames-support/games-pause-action.c |   16 ++++
 libgames-support/games-pause-action.h |    2 +
 libgames-support/games-stock.c        |   34 ---------
 libgames-support/games-stock.h        |    3 -
 mahjongg/mahjongg.c                   |    2 +-
 quadrapassel/tetris.cpp               |   18 +----
 8 files changed, 58 insertions(+), 221 deletions(-)
---
diff --git a/gnomine/gnomine.c b/gnomine/gnomine.c
index 2a39bdb..a9d4ce3 100644
--- a/gnomine/gnomine.c
+++ b/gnomine/gnomine.c
@@ -41,6 +41,8 @@
 #include <libgames-support/games-scores.c>
 #include <libgames-support/games-scores-dialog.h>
 #include <libgames-support/games-stock.h>
+#include <libgames-support/games-pause-action.h>
+#include <libgames-support/games-fullscreen-action.h>
 
 #ifdef WITH_SMCLIENT
 #include <libgames-support/eggsmclient.h>
@@ -88,13 +90,10 @@ gint fsize = -1;
 gboolean use_question_marks = TRUE;
 gboolean use_overmine_warning = TRUE;
 gboolean use_autoflag = FALSE;
-gboolean game_paused = FALSE;
 
 GtkAction *hint_action;
 GtkAction *fullscreen_action;
-GtkAction *leavefullscreen_action;
 GtkAction *pause_action;
-GtkAction *resume_action;
 
 /*GstElement *sound_player;*/
 
@@ -293,10 +292,7 @@ new_game (void)
 
   set_flabel (GTK_MINEFIELD (mfield));
 
-  gtk_action_set_visible (pause_action, TRUE);
   gtk_action_set_sensitive (pause_action, TRUE);
-  gtk_action_set_visible (resume_action, FALSE);
-  gtk_action_set_sensitive (resume_action, FALSE);
   gtk_widget_hide (resume_container);
   gtk_widget_show (mfield_container);
 }
@@ -341,41 +337,35 @@ hint_callback (void)
 }
 
 static void
-pause_callback (GtkWidget * widget, GdkEventFocus * event, gpointer data)
+pause_callback (GtkAction * action, gpointer data)
 {
-  if (games_clock_is_started (GAMES_CLOCK (clk))
-      && (!disable_hiding)) {
+  if (games_pause_action_get_is_paused (GAMES_PAUSE_ACTION (pause_action))) {
     gtk_widget_hide (mfield_container);
     gtk_widget_show (resume_container);
     gtk_widget_grab_focus (resume_button);
-
+  
     gtk_action_set_sensitive (hint_action, FALSE);
     games_clock_stop (GAMES_CLOCK (clk));
-
-    gtk_action_set_visible (pause_action, FALSE);
-    gtk_action_set_sensitive (pause_action, FALSE);
-
-    gtk_action_set_visible (resume_action, TRUE);
-    gtk_action_set_sensitive (resume_action, TRUE);
-
-    game_paused = TRUE;
+  }
+  else {
+    gtk_widget_hide (resume_container);
+    gtk_widget_show (mfield_container);
+    gtk_action_set_sensitive (hint_action, TRUE);
+    games_clock_start (GAMES_CLOCK (clk));
   }
 }
 
 static void
-resume_game_cb (GtkButton * widget, gpointer data)
+focus_out_callback (GtkWidget * widget, GdkEventFocus * event, gpointer data)
 {
-  gtk_widget_hide (resume_container);
-  gtk_widget_show (mfield_container);
-  gtk_action_set_sensitive (hint_action, TRUE);
-  games_clock_start (GAMES_CLOCK (clk));
-
-  gtk_action_set_visible (pause_action, TRUE);
-  gtk_action_set_sensitive(pause_action, TRUE);
-  gtk_action_set_visible (resume_action, FALSE);
-  gtk_action_set_sensitive(resume_action, FALSE);
+  if (games_clock_is_started (GAMES_CLOCK (clk)) && (!disable_hiding))
+    games_pause_action_set_is_paused (GAMES_PAUSE_ACTION (pause_action), TRUE);
+}
 
-  game_paused = FALSE;
+static void
+resume_game_cb (GtkWidget * widget, GdkEventFocus * event, gpointer data)
+{
+  games_pause_action_set_is_paused (GAMES_PAUSE_ACTION (pause_action), FALSE);
 }
 
 static void
@@ -622,57 +612,6 @@ use_overmine_toggle_cb (GtkCheckButton * check, gpointer data)
 }
 
 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;
-}
-
-
-static gboolean
-pause_key_callback(GtkWidget *widget, GdkEventKey *event,
-gpointer data )
-{
-
-  if(event->keyval == GDK_Pause)
-  {
-    if(game_paused)
-      resume_game_cb(NULL, NULL); // Resume the game
-    else
-      pause_callback(NULL, NULL, NULL); // Pause the game
-
-    return TRUE;
-  }
-
-  return FALSE;
-}
-
-
-static void
 create_preferences (void)
 {
   GtkWidget *table;
@@ -835,10 +774,6 @@ const GtkActionEntry actions[] = {
   {"SettingsMenu", NULL, N_("_Settings")},
   {"HelpMenu", NULL, N_("_Help")},
   {"NewGame", GAMES_STOCK_NEW_GAME, NULL, NULL, NULL, G_CALLBACK (new_game)},
-  {"PauseGame", GAMES_STOCK_PAUSE_GAME, NULL, NULL, NULL,
-   G_CALLBACK (pause_callback)},
-  {"ResumeGame", GAMES_STOCK_RESUME_GAME, NULL, NULL, NULL,
-   G_CALLBACK (resume_game_cb)},
   {"Hint", GAMES_STOCK_HINT, NULL, NULL, NULL, G_CALLBACK (hint_callback)},
   {"Scores", GAMES_STOCK_SCORES, NULL, NULL, NULL,
    G_CALLBACK (scores_callback)},
@@ -847,11 +782,7 @@ const GtkActionEntry actions[] = {
    G_CALLBACK (preferences_callback)},
   {"Contents", GAMES_STOCK_CONTENTS, NULL, NULL, NULL,
    G_CALLBACK (help_callback)},
-  {"About", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK (about_callback)},
-  {"Fullscreen", GAMES_STOCK_FULLSCREEN, NULL, NULL, NULL,
-   G_CALLBACK (fullscreen_callback)},
-  {"LeaveFullscreen", GAMES_STOCK_LEAVE_FULLSCREEN, NULL, NULL, NULL,
-   G_CALLBACK (fullscreen_callback)}
+  {"About", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK (about_callback)}
 };
 
 const char ui_description[] =
@@ -861,7 +792,6 @@ const char ui_description[] =
   "      <menuitem action='NewGame'/>"
   "      <menuitem action='Hint'/>"
   "      <menuitem action='PauseGame'/>"
-  "      <menuitem action='ResumeGame'/>"
   "      <separator/>"
   "      <menuitem action='Scores'/>"
   "      <separator/>"
@@ -869,7 +799,6 @@ const char ui_description[] =
   "    </menu>"
   "    <menu action='SettingsMenu'>"
   "      <menuitem action='Fullscreen'/>"
-  "      <menuitem action='LeaveFullscreen'/>"
   "      <menuitem action='Preferences'/>"
   "    </menu>"
   "    <menu action='HelpMenu'>"
@@ -895,15 +824,12 @@ create_ui_manager (const gchar * group)
   gtk_ui_manager_add_ui_from_string (ui_manager, ui_description, -1, NULL);
   hint_action = gtk_action_group_get_action (action_group, "Hint");
 
-  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);
 
-  pause_action = gtk_action_group_get_action (action_group, "PauseGame");
-  resume_action = gtk_action_group_get_action (action_group, "ResumeGame");
-  gtk_action_set_visible (resume_action, FALSE);
+  pause_action = GTK_ACTION (games_pause_action_new ("PauseGame"));
+  g_signal_connect (G_OBJECT (pause_action), "state-changed", G_CALLBACK (pause_callback), NULL);
+  gtk_action_group_add_action_with_accel (action_group, pause_action, NULL);
 
   return ui_manager;
 }
@@ -1091,13 +1017,7 @@ main (int argc, char *argv[])
   g_signal_connect (G_OBJECT (window), "delete_event",
 		    G_CALLBACK (quit_game), NULL);
   g_signal_connect (G_OBJECT (window), "focus_out_event",
-		    G_CALLBACK (pause_callback), NULL);
-  g_signal_connect (G_OBJECT (window), "window_state_event",
-		    G_CALLBACK (window_state_callback), NULL);
-
-  // For pause/resume with the keyboard pause key
-  g_signal_connect (G_OBJECT (window), "key_press_event", 
-                    G_CALLBACK (pause_key_callback), NULL); 
+		    G_CALLBACK (focus_out_callback), NULL);
 
   all_boxes = gtk_vbox_new (FALSE, 0);
   gtk_widget_show (all_boxes);
diff --git a/gnotravex/gnotravex.c b/gnotravex/gnotravex.c
index 6781e84..07a16a1 100644
--- a/gnotravex/gnotravex.c
+++ b/gnotravex/gnotravex.c
@@ -38,6 +38,8 @@
 #include <libgames-support/games-scores-dialog.h>
 #include <libgames-support/games-runtime.h>
 #include <libgames-support/games-stock.h>
+#include <libgames-support/games-pause-action.h>
+#include <libgames-support/games-fullscreen-action.h>
 
 #ifdef WITH_SMCLIENT
 #include <libgames-support/eggsmclient.h>
@@ -271,14 +273,10 @@ void new_game (void);
 static int save_state_cb (EggSMClient *client, GKeyFile *keyfile, gpointer client_data);
 static int quit_cb (EggSMClient *client, gpointer client_data);
 #endif /* WITH_SMCLIENT */
-static void set_fullscreen_actions (gboolean is_fullscreen);
-static void fullscreen_cb (GtkAction * action);
-static gboolean window_state_cb (GtkWidget * widget, GdkEventWindowState * event);
 static void load_default_background (void);
 
 static GtkAction *new_game_action;
 static GtkAction *pause_action;
-static GtkAction *resume_action;
 static GtkAction *hint_action;
 static GtkAction *solve_action;
 static GtkAction *scores_action;
@@ -287,7 +285,6 @@ static GtkAction *move_left_action;
 static GtkAction *move_right_action;
 static GtkAction *move_down_action;
 static GtkAction *fullscreen_action;
-static GtkAction *leave_fullscreen_action;
 
 
 /* ------------------------- MENU ------------------------ */
@@ -312,20 +309,11 @@ const GtkActionEntry action_entry[] = {
   {"HelpMenu", NULL, N_("_Help")},
   {"NewGame", GAMES_STOCK_NEW_GAME, NULL, NULL, NULL,
    G_CALLBACK (new_game_cb)},
-  {"PauseGame", GAMES_STOCK_PAUSE_GAME, NULL, NULL, NULL,
-   G_CALLBACK (pause_cb)},
-  {"ResumeGame", GAMES_STOCK_RESUME_GAME, NULL, NULL, NULL,
-   G_CALLBACK (pause_cb)},
   {"Hint", GAMES_STOCK_HINT, NULL, NULL, NULL, G_CALLBACK (hint_cb)},
   {"Solve", GTK_STOCK_REFRESH, N_("Sol_ve"), NULL, N_("Solve the game"),
    G_CALLBACK (solve_cb)},
   {"Scores", GAMES_STOCK_SCORES, NULL, NULL, NULL, G_CALLBACK (score_cb)},
   {"Quit", GTK_STOCK_QUIT, NULL, NULL, NULL, G_CALLBACK (quit_game_cb)},
-  {"Fullscreen", GAMES_STOCK_FULLSCREEN, NULL, NULL, NULL,
-   G_CALLBACK (fullscreen_cb)},
-  {"LeaveFullscreen", GAMES_STOCK_LEAVE_FULLSCREEN, NULL, NULL, NULL,
-   G_CALLBACK (fullscreen_cb)},
-
   {"MoveUp", GTK_STOCK_GO_UP, N_("_Up"), "<control>Up",
    N_("Move the pieces up"), G_CALLBACK (move_up_cb)},
   {"MoveLeft", GTK_STOCK_GO_BACK, N_("_Left"), "<control>Left",
@@ -364,7 +352,6 @@ static const char ui_description[] =
   "    <menu action='GameMenu'>"
   "      <menuitem action='NewGame'/>"
   "      <menuitem action='PauseGame'/>"
-  "      <menuitem action='ResumeGame'/>"
   "      <separator/>"
   "      <menu action='MoveMenu'>"
   "        <menuitem action='MoveUp'/>"
@@ -381,7 +368,6 @@ static const char ui_description[] =
   "    </menu>"
   "    <menu action='SettingsMenu'>"
   "      <menuitem action='Fullscreen'/>"
-  "      <menuitem action='LeaveFullscreen'/>"
   "      <menuitem action='ClickToMove'/>"
   "      <separator/>"
   "      <menuitem action='Size2x2'/>"
@@ -606,8 +592,6 @@ create_window (void)
   gtk_widget_realize (window);
   g_signal_connect (G_OBJECT (window), "delete_event",
                     G_CALLBACK (quit_game_cb), NULL);
-  g_signal_connect (G_OBJECT (window), "window_state_event",
-                    G_CALLBACK (window_state_cb), NULL);
 }
 
 gboolean
@@ -627,7 +611,7 @@ gint
 button_press_space (GtkWidget * widget, GdkEventButton * event)
 {
   if (game_state == paused)
-    gtk_action_activate (resume_action);
+    gtk_action_activate (pause_action);
 
   if (game_state != playing)
     return FALSE;
@@ -1615,8 +1599,6 @@ create_menu (GtkUIManager * ui_manager)
   gtk_ui_manager_add_ui_from_string (ui_manager, ui_description, -1, NULL);
 
   new_game_action = gtk_action_group_get_action (action_group, "NewGame");
-  pause_action = gtk_action_group_get_action (action_group, "PauseGame");
-  resume_action = gtk_action_group_get_action (action_group, "ResumeGame");
   hint_action = gtk_action_group_get_action (action_group, "Hint");
   solve_action = gtk_action_group_get_action (action_group, "Solve");
   scores_action = gtk_action_group_get_action (action_group, "Scores");
@@ -1624,12 +1606,11 @@ create_menu (GtkUIManager * ui_manager)
   move_left_action = gtk_action_group_get_action (action_group, "MoveLeft");
   move_right_action = gtk_action_group_get_action (action_group, "MoveRight");
   move_down_action = gtk_action_group_get_action (action_group, "MoveDown");
-  fullscreen_action =
-    gtk_action_group_get_action (action_group, "Fullscreen");
-  leave_fullscreen_action =
-    gtk_action_group_get_action (action_group, "LeaveFullscreen");
-
-  set_fullscreen_actions (FALSE);
+  pause_action = GTK_ACTION (games_pause_action_new ("PauseGame"));
+  g_signal_connect (G_OBJECT (pause_action), "state-changed", G_CALLBACK (pause_cb), NULL);
+  gtk_action_group_add_action_with_accel (action_group, pause_action, NULL);
+  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_action_group_add_toggle_actions (action_group, toggles,
                                        G_N_ELEMENTS (toggles), NULL);
@@ -1640,7 +1621,6 @@ create_menu (GtkUIManager * ui_manager)
     size_action[i] =
       gtk_action_group_get_action (action_group, size_action_entry[i].name);
 
-  games_stock_set_pause_actions (pause_action, resume_action);
   return gtk_ui_manager_get_widget (ui_manager, "/MainMenu");
 }
 
@@ -1663,10 +1643,7 @@ new_game (void){
   gchar *str;
 
   /* Reset pause menu */
-  gtk_action_set_visible(pause_action, TRUE);
   gtk_action_set_sensitive(pause_action, TRUE);
-  gtk_action_set_visible(resume_action, FALSE);
-  gtk_action_set_sensitive(resume_action, FALSE);
 
   game_state = gameover;
 
@@ -1746,7 +1723,7 @@ size_cb (GtkAction * action, gpointer data)
   gdk_drawable_get_size (gtk_widget_get_window (space), &width, &height);
 
   if (game_state == paused)
-    gtk_action_activate (resume_action);
+    gtk_action_activate (pause_action);
 
   if (size == newsize)
     return;
@@ -2017,37 +1994,6 @@ about_cb (GtkAction * action, gpointer data)
 }
 
 static void
-set_fullscreen_actions (gboolean is_fullscreen)
-{
-  gtk_action_set_sensitive (leave_fullscreen_action, is_fullscreen);
-  gtk_action_set_visible (leave_fullscreen_action, is_fullscreen);
-
-  gtk_action_set_sensitive (fullscreen_action, !is_fullscreen);
-  gtk_action_set_visible (fullscreen_action, !is_fullscreen);
-}
-
-static void
-fullscreen_cb (GtkAction * action)
-{
-  if (action == fullscreen_action) {
-    gtk_window_fullscreen (GTK_WINDOW (window));
-  } else {
-    gtk_window_unfullscreen (GTK_WINDOW (window));
-  }
-}
-
-/* Just in case something else takes us to/from fullscreen. */
-static gboolean
-window_state_cb (GtkWidget * widget, GdkEventWindowState * event)
-{
-  if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
-    set_fullscreen_actions (event->new_window_state &
-                            GDK_WINDOW_STATE_FULLSCREEN);
-    
-  return FALSE;
-}
-
-static void
 load_default_background (void)
 {
   GdkPixmap *pm;
diff --git a/libgames-support/games-pause-action.c b/libgames-support/games-pause-action.c
index dbd21ff..cbe1786 100644
--- a/libgames-support/games-pause-action.c
+++ b/libgames-support/games-pause-action.c
@@ -27,6 +27,12 @@ enum {
     PROP_IS_PAUSED
 };
 
+enum {
+    STATE_CHANGED,
+    LAST_SIGNAL
+};
+static guint signals[LAST_SIGNAL] = { 0, };
+
 struct GamesPauseActionPrivate
 {
     gboolean is_paused;
@@ -51,6 +57,7 @@ games_pause_action_set_is_paused (GamesPauseAction *action, gboolean is_paused)
     else
         gtk_action_set_stock_id (GTK_ACTION (action), GAMES_STOCK_PAUSE_GAME);
     g_object_notify (G_OBJECT (action), "is-paused");
+    g_signal_emit (G_OBJECT (action), signals[STATE_CHANGED], 0);
 }
 
 gboolean
@@ -131,5 +138,14 @@ games_pause_action_class_init (GamesPauseActionClass *klass)
                                                          FALSE,
                                                          G_PARAM_READWRITE));
 
+    signals[STATE_CHANGED] =
+        g_signal_new ("state-changed",
+                      G_TYPE_FROM_CLASS (klass),
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET (GamesPauseActionClass, state_changed),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE, 0);
+
     g_type_class_add_private (klass, sizeof (GamesPauseActionPrivate));
 }
diff --git a/libgames-support/games-pause-action.h b/libgames-support/games-pause-action.h
index fdff193..9dcad92 100644
--- a/libgames-support/games-pause-action.h
+++ b/libgames-support/games-pause-action.h
@@ -40,6 +40,8 @@ typedef struct
 typedef struct
 {
     GtkActionClass parent_class;
+
+    void (*state_changed)(GamesPauseAction *action);
 } GamesPauseActionClass;
 
 GType games_pause_action_get_type (void);
diff --git a/libgames-support/games-stock.c b/libgames-support/games-stock.c
index 2215588..59cee84 100644
--- a/libgames-support/games-stock.c
+++ b/libgames-support/games-stock.c
@@ -171,40 +171,6 @@ games_stock_prepare_for_statusbar_tooltips (GtkUIManager * ui_manager,
                     G_CALLBACK (disconnect_proxy_cb), statusbar);
 }
 
-typedef struct {
-  GtkAction *pause_action;
-  GtkAction *resume_action;
-} PauseActions;
-
-static void
-set_pause_actions (GtkAction * active, PauseActions * actions)
-{
-  gboolean paused;
-
-  paused = (active == actions->pause_action);
-  gtk_action_set_visible (actions->pause_action, !paused);
-  gtk_action_set_sensitive (actions->pause_action, !paused);
-  gtk_action_set_visible (actions->resume_action, paused);
-  gtk_action_set_sensitive (actions->resume_action, paused);
-}
-
-void
-games_stock_set_pause_actions (GtkAction * pause_action,
-                               GtkAction * resume_action)
-{
-  PauseActions *actions;
-
-  actions = g_new (PauseActions, 1);
-  actions->pause_action = pause_action;
-  actions->resume_action = resume_action;
-  g_signal_connect (pause_action, "activate", G_CALLBACK (set_pause_actions),
-                    actions);
-  g_signal_connect (resume_action, "activate", G_CALLBACK (set_pause_actions),
-                    actions);
-
-  set_pause_actions (resume_action, actions);
-}
-
 #endif /* !HAVE_HILDON */
 
 /* This will become GTK_CHECK_VERSION (2, 15, x) once the patch from gtk+ bug 511332 is committed */
diff --git a/libgames-support/games-stock.h b/libgames-support/games-stock.h
index f5bd18f..57a3097 100644
--- a/libgames-support/games-stock.h
+++ b/libgames-support/games-stock.h
@@ -54,9 +54,6 @@ G_BEGIN_DECLS
 
 void games_stock_init (void);
 
-void games_stock_set_pause_actions (GtkAction * pause_action,
-                                    GtkAction * resume_action);
-
 void games_stock_prepare_for_statusbar_tooltips (GtkUIManager * ui_manager,
                                                  GtkWidget * statusbar);
 
diff --git a/mahjongg/mahjongg.c b/mahjongg/mahjongg.c
index 42b7ff6..ed56752 100644
--- a/mahjongg/mahjongg.c
+++ b/mahjongg/mahjongg.c
@@ -1290,7 +1290,7 @@ create_menus (GtkUIManager * ui_manager)
   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 (games_pause_action_new ("PauseGame"));
-  g_signal_connect (G_OBJECT (pause_action), "notify::is-paused", G_CALLBACK (pause_callback), NULL);
+  g_signal_connect (G_OBJECT (pause_action), "state-changed", 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");
diff --git a/quadrapassel/tetris.cpp b/quadrapassel/tetris.cpp
index 50c4ac8..ad1c9cf 100644
--- a/quadrapassel/tetris.cpp
+++ b/quadrapassel/tetris.cpp
@@ -35,6 +35,7 @@
 #include <libgames-support/games-runtime.h>
 #include <libgames-support/games-sound.h>
 #include <libgames-support/games-stock.h>
+#include <libgames-support/games-pause-action.h>
 
 #include "tetris.h"
 #include "blocks.h"
@@ -108,8 +109,6 @@ Tetris::Tetris(int cmdlLevel):
 	{ "SettingsMenu", NULL, N_("_Settings") },
 	{ "HelpMenu", NULL, N_("_Help") },
 	{ "NewGame", GAMES_STOCK_NEW_GAME, NULL, NULL, NULL, G_CALLBACK (gameNew) },
-	{ "Pause", GAMES_STOCK_PAUSE_GAME, NULL, NULL, NULL, G_CALLBACK (gamePause) },
-	{ "Resume", GAMES_STOCK_RESUME_GAME, NULL, NULL, NULL, G_CALLBACK (gamePause) },
 	{ "Scores", GAMES_STOCK_SCORES, NULL, NULL, NULL, G_CALLBACK (gameTopTen) },
 	{ "EndGame", GAMES_STOCK_END_GAME, NULL, NULL, NULL, G_CALLBACK (gameEnd) },
 	{ "Quit", GTK_STOCK_QUIT, NULL, NULL, NULL, G_CALLBACK (gameQuit) },
@@ -124,7 +123,6 @@ Tetris::Tetris(int cmdlLevel):
 	"    <menu action='GameMenu'>"
 	"      <menuitem action='NewGame'/>"
 	"      <menuitem action='Pause'/>"
-	"      <menuitem action='Resume'/>"
 	"      <separator/>"
 	"      <menuitem action='Scores'/>"
 	"      <menuitem action='EndGame'/>"
@@ -191,14 +189,13 @@ Tetris::Tetris(int cmdlLevel):
 	gtk_window_add_accel_group (GTK_WINDOW (w), accel_group);
 
 	new_game_action = gtk_action_group_get_action (action_group, "NewGame");
-	pause_action = gtk_action_group_get_action (action_group, "Pause");
-	resume_action = gtk_action_group_get_action (action_group, "Resume");
+	pause_action = GTK_ACTION (games_pause_action_new ("Pause"));
+    g_signal_connect (G_OBJECT (pause_action), "state-changed", G_CALLBACK (gamePause), this);
+	gtk_action_group_add_action_with_accel (action_group, pause_action, NULL);
 	scores_action = gtk_action_group_get_action (action_group, "Scores");
 	end_game_action = gtk_action_group_get_action (action_group, "EndGame");
 	preferences_action = gtk_action_group_get_action (action_group, "Preferences");
 
-	games_stock_set_pause_actions (pause_action, resume_action);
-
 	menubar = gtk_ui_manager_get_widget (ui_manager, "/MainMenu");
 
 	GtkWidget * hb = gtk_hbox_new(FALSE, 0);
@@ -1179,11 +1176,6 @@ Tetris::togglePause()
 		field->showPauseMessage();
 	else
 		field->hidePauseMessage();
-
-	gtk_action_set_sensitive (pause_action, !paused);
-	gtk_action_set_sensitive (resume_action, paused);
-	gtk_action_set_visible (pause_action, !paused);
-	gtk_action_set_visible (resume_action, paused);
 }
 
 void
@@ -1264,8 +1256,6 @@ Tetris::gameNew(GtkAction *action, void *d)
 	t->field->putBlockInField(FALLING);
 	t->preview->previewBlock(blocknr_next, color_next);
 
-	gtk_action_set_visible(t->pause_action, TRUE);
-	gtk_action_set_visible(t->resume_action, FALSE);
 	gtk_action_set_sensitive(t->pause_action, TRUE);
 	gtk_action_set_sensitive(t->end_game_action, TRUE);
 	gtk_action_set_sensitive(t->preferences_action, FALSE);



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