[gnome-games] Use GamesActions for glines, gnect, gnibbles, gnobots2, gnotski
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] Use GamesActions for glines, gnect, gnibbles, gnobots2, gnotski
- Date: Sat, 24 Apr 2010 00:39:22 +0000 (UTC)
commit 644533305944e295ce587c92ed6e986e52a5aa14
Author: Robert Ancell <robert ancell gmail com>
Date: Sat Apr 24 10:36:27 2010 +1000
Use GamesActions for glines, gnect, gnibbles, gnobots2, gnotski
glines/glines.c | 45 +++------------------------------------------
gnect/src/main.c | 47 +++--------------------------------------------
gnibbles/main.c | 48 +++---------------------------------------------
gnobots2/gnobots.c | 2 --
gnobots2/menu.c | 48 +++---------------------------------------------
gnotski/gnotski.c | 51 +++------------------------------------------------
6 files changed, 15 insertions(+), 226 deletions(-)
---
diff --git a/glines/glines.c b/glines/glines.c
index 48b8550..bf746d9 100644
--- a/glines/glines.c
+++ b/glines/glines.c
@@ -46,6 +46,7 @@
#include <libgames-support/games-scores.h>
#include <libgames-support/games-scores-dialog.h>
#include <libgames-support/games-stock.h>
+#include <libgames-support/games-fullscreen-action.h>
#ifdef WITH_SMCLIENT
#include <libgames-support/eggsmclient.h>
@@ -108,7 +109,6 @@ static GtkWidget *preview_widgets[MAXNPIECES];
static GtkWidget *menubar;
static GtkWidget *scoreitem;
static GtkAction *fullscreen_action;
-static GtkAction *leavefullscreen_action;
/* These keep track of what we put in the main table so we
* can reshuffle them when we change the field size. */
@@ -1400,35 +1400,6 @@ set_fast_moves_callback (GtkWidget * widget, gpointer * data)
}
static void
-set_fullscreen_actions (gboolean fullscreen)
-{
- gtk_action_set_sensitive (leavefullscreen_action, fullscreen);
- gtk_action_set_visible (leavefullscreen_action, fullscreen);
-
- gtk_action_set_sensitive (fullscreen_action, !fullscreen);
- gtk_action_set_visible (fullscreen_action, !fullscreen);
-}
-
-static void
-fullscreen_callback (GtkAction * action)
-{
- if (action == fullscreen_action)
- gtk_window_fullscreen (GTK_WINDOW (app));
- else
- gtk_window_unfullscreen (GTK_WINDOW (app));
-}
-
-static gboolean
-window_state_callback (GtkWidget * widget, GdkEventWindowState * event)
-{
- if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) {
- set_fullscreen_actions ((event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) != 0);
- }
-
- return FALSE;
-}
-
-static void
pref_dialog_response (GtkDialog * dialog, gint response, gpointer data)
{
gtk_widget_hide (GTK_WIDGET (dialog));
@@ -1702,10 +1673,6 @@ static const GtkActionEntry actions[] = {
G_CALLBACK (game_help_callback)},
{"About", GTK_STOCK_ABOUT, NULL, NULL, NULL,
G_CALLBACK (game_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)}
};
const char ui_description[] =
@@ -1720,7 +1687,6 @@ const char ui_description[] =
" </menu>"
" <menu action='SettingsMenu'>"
" <menuitem action='Fullscreen'/>"
- " <menuitem action='LeaveFullscreen'/>"
" <menuitem action='Preferences'/>"
" </menu>"
" <menu action='HelpMenu'>"
@@ -1738,11 +1704,8 @@ create_menus (GtkUIManager * ui_manager)
gtk_action_group_add_actions (action_group, actions,
G_N_ELEMENTS (actions), NULL);
- 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 (app)));
+ gtk_action_group_add_action_with_accel (action_group, fullscreen_action, NULL);
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
gtk_ui_manager_add_ui_from_string (ui_manager, ui_description, -1, NULL);
@@ -1848,8 +1811,6 @@ main (int argc, char *argv[])
gtk_window_set_default_size (GTK_WINDOW (app), DEFAULT_WIDTH, DEFAULT_HEIGHT);
g_signal_connect (app, "delete-event",
G_CALLBACK (game_quit_callback), NULL);
- g_signal_connect (app, "window-state-event",
- G_CALLBACK (window_state_callback), NULL);
games_conf_add_window (GTK_WINDOW (app), NULL);
statusbar = gtk_statusbar_new ();
diff --git a/gnect/src/main.c b/gnect/src/main.c
index 4bcf369..c248624 100644
--- a/gnect/src/main.c
+++ b/gnect/src/main.c
@@ -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-fullscreen-action.h>
#include "connect4.h"
#include "main.h"
@@ -372,7 +373,6 @@ GtkAction *player_list_action;
GtkAction *undo_action;
GtkAction *hint_action;
GtkAction *fullscreen_action;
-GtkAction *leave_fullscreen_action;
static void
@@ -386,36 +386,6 @@ stop_anim (void)
}
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 (app));
- } else {
- gtk_window_unfullscreen (GTK_WINDOW (app));
- }
-}
-
-/* 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
game_init (void)
{
g_random_set_seed ((guint) time (NULL));
@@ -1292,10 +1262,6 @@ static const GtkActionEntry action_entry[] = {
{"Scores", GAMES_STOCK_SCORES, NULL, NULL, NULL,
G_CALLBACK (on_game_scores)},
{"Quit", GTK_STOCK_QUIT, NULL, NULL, NULL, G_CALLBACK (on_game_exit)},
- {"Fullscreen", GAMES_STOCK_FULLSCREEN, NULL, NULL, NULL,
- G_CALLBACK (fullscreen_cb)},
- {"LeaveFullscreen", GAMES_STOCK_LEAVE_FULLSCREEN, NULL, NULL, NULL,
- G_CALLBACK (fullscreen_cb)},
{"Preferences", GTK_STOCK_PREFERENCES, NULL, NULL, NULL,
G_CALLBACK (on_settings_preferences)},
{"Contents", GAMES_STOCK_CONTENTS, NULL, NULL, NULL,
@@ -1321,7 +1287,6 @@ static const char ui_description[] =
" </menu>"
" <menu action='ViewMenu'>"
" <menuitem action='Fullscreen'/>"
- " <menuitem action='LeaveFullscreen'/>"
" </menu>"
" <menu action='SettingsMenu'>"
" <menuitem action='Preferences'/>"
@@ -1363,12 +1328,8 @@ create_game_menus (GtkUIManager * ui_manager)
gtk_action_group_get_action (action_group, "LeaveNetworkGame");
hint_action = gtk_action_group_get_action (action_group, "Hint");
undo_action = gtk_action_group_get_action (action_group, "UndoMove");
- 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);
+ fullscreen_action = GTK_ACTION (games_fullscreen_action_new ("Fullscreen", GTK_WINDOW (app)));
+ gtk_action_group_add_action_with_accel (action_group, fullscreen_action, NULL);
}
@@ -1439,8 +1400,6 @@ create_app (void)
G_CALLBACK (on_button_press), NULL);
g_signal_connect (G_OBJECT (app), "key_press_event",
G_CALLBACK (on_key_press), NULL);
- g_signal_connect (G_OBJECT (app), "window_state_event",
- G_CALLBACK (window_state_cb), NULL);
/* We do our own double-buffering. */
gtk_widget_set_double_buffered (GTK_WIDGET (drawarea), FALSE);
diff --git a/gnibbles/main.c b/gnibbles/main.c
index 3fed123..f997838 100644
--- a/gnibbles/main.c
+++ b/gnibbles/main.c
@@ -37,6 +37,7 @@
#include <libgames-support/games-scores.h>
#include <libgames-support/games-stock.h>
#include <libgames-support/games-pause-action.h>
+#include <libgames-support/games-fullscreen-action.h>
#include "main.h"
#include "properties.h"
@@ -118,7 +119,6 @@ static GtkAction *end_game_action;
static GtkAction *preferences_action;
static GtkAction *scores_action;
static GtkAction *fullscreen_action;
-static GtkAction *leave_fullscreen_action;
static ClutterActor *logo;
@@ -129,26 +129,6 @@ hide_cursor (void)
}
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));
- }
-}
-
-static void
network_gui_update (void)
{
@@ -165,18 +145,6 @@ network_gui_update (void)
#endif
}
-static gboolean
-window_state_cb (GtkWidget * widget, GdkEventWindowState * event)
-{
- /* Handle fullscreen, in case something else takes us to/from fullscreen. */
- if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
- set_fullscreen_actions (event->new_window_state
- & GDK_WINDOW_STATE_FULLSCREEN);
-
- return FALSE;
-}
-
-
static void
show_cursor (void)
{
@@ -740,10 +708,6 @@ static const GtkActionEntry action_entry[] = {
{"Scores", GAMES_STOCK_SCORES, NULL, NULL, NULL,
G_CALLBACK (show_scores_cb)},
{"Quit", GTK_STOCK_QUIT, NULL, NULL, NULL, G_CALLBACK (quit_cb)},
- {"Fullscreen", GAMES_STOCK_FULLSCREEN, NULL, NULL, NULL,
- G_CALLBACK (fullscreen_cb)},
- {"LeaveFullscreen", GAMES_STOCK_LEAVE_FULLSCREEN, NULL, NULL, NULL,
- G_CALLBACK (fullscreen_cb)},
{"Preferences", GTK_STOCK_PREFERENCES, NULL, NULL, NULL,
G_CALLBACK (gnibbles_preferences_cb)},
{"Contents", GAMES_STOCK_CONTENTS, NULL, NULL, NULL, G_CALLBACK (help_cb)},
@@ -767,7 +731,6 @@ static const char ui_description[] =
" </menu>"
" <menu action='ViewMenu'>"
" <menuitem action='Fullscreen'/>"
- " <menuitem action='LeaveFullscreen'/>"
" </menu>"
" <menu action='SettingsMenu'>"
" <menuitem action='Preferences'/>"
@@ -802,10 +765,8 @@ create_menus (GtkUIManager * ui_manager)
preferences_action = gtk_action_group_get_action (action_group,
"Preferences");
- fullscreen_action = gtk_action_group_get_action (action_group,
- "Fullscreen");
- leave_fullscreen_action = gtk_action_group_get_action (action_group,
- "LeaveFullscreen");
+ fullscreen_action = GTK_ACTION (games_fullscreen_action_new ("Fullscreen", GTK_WINDOW(window)));
+ gtk_action_group_add_action_with_accel (action_group, fullscreen_action, NULL);
new_network_action = gtk_action_group_get_action (action_group,
"NewNetworkGame");
#ifndef GGZ_CLIENT
@@ -849,8 +810,6 @@ setup_window (void)
G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK (delete_cb), NULL);
- g_signal_connect (G_OBJECT (window), "window_state_event",
- G_CALLBACK (window_state_cb), NULL);
gtk_widget_realize (window);
@@ -859,7 +818,6 @@ setup_window (void)
games_stock_init ();
ui_manager = gtk_ui_manager_new ();
create_menus (ui_manager);
- set_fullscreen_actions (FALSE);
notebook = gtk_notebook_new ();
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
diff --git a/gnobots2/gnobots.c b/gnobots2/gnobots.c
index c3c028f..dc304cf 100644
--- a/gnobots2/gnobots.c
+++ b/gnobots2/gnobots.c
@@ -265,8 +265,6 @@ main (int argc, char *argv[])
g_signal_connect (G_OBJECT (app), "delete_event",
G_CALLBACK (quit_game), NULL);
- g_signal_connect (G_OBJECT (app), "window_state_event",
- G_CALLBACK (window_state_cb), NULL);
statusbar = gnobots_statusbar_new ();
ui_manager = gtk_ui_manager_new ();
diff --git a/gnobots2/menu.c b/gnobots2/menu.c
index b465827..5620795 100644
--- a/gnobots2/menu.c
+++ b/gnobots2/menu.c
@@ -28,6 +28,7 @@
#include <libgames-support/games-help.h>
#include <libgames-support/games-stock.h>
+#include <libgames-support/games-fullscreen-action.h>
#include <libgames-support/games-scores.h>
#include <libgames-support/games-scores-dialog.h>
@@ -45,7 +46,6 @@ GtkAction *random_action;
GtkAction *wait_action;
GtkAction *toolbar_toggle_action;
GtkAction *fullscreen_action;
-GtkAction *leave_fullscreen_action;
/**********************************************************************/
/* Function Prototypes */
@@ -60,8 +60,6 @@ static void teleport_cb (GtkAction * action, gpointer data);
static void randteleport_cb (GtkAction * action, gpointer data);
static void wait_cb (GtkAction * action, gpointer data);
static void show_toolbar_cb (GtkAction * action, gpointer data);
-static void set_fullscreen_actions (gboolean is_fullscreen);
-static void fullscreen_cb (GtkAction * action);
/**********************************************************************/
const GtkActionEntry action_entry[] = {
@@ -80,10 +78,6 @@ const GtkActionEntry action_entry[] = {
N_("Teleport randomly"), G_CALLBACK (randteleport_cb)},
{"Wait", GTK_STOCK_STOP, N_("_Wait"), NULL, N_("Wait for the robots"),
G_CALLBACK (wait_cb)},
- {"Fullscreen", GAMES_STOCK_FULLSCREEN, NULL, NULL, NULL,
- G_CALLBACK (fullscreen_cb)},
- {"LeaveFullscreen", GAMES_STOCK_LEAVE_FULLSCREEN, NULL, NULL, NULL,
- G_CALLBACK (fullscreen_cb)},
{"Preferences", GTK_STOCK_PREFERENCES, NULL, NULL, NULL,
G_CALLBACK (properties_cb)},
@@ -111,7 +105,6 @@ const char ui_description[] =
" <menu action='ViewMenu'>"
" <menuitem action='ShowToolbar'/>"
" <menuitem action='Fullscreen'/>"
- " <menuitem action='LeaveFullscreen'/>"
" </menu>"
" <menu action='MoveMenu'>"
" <menuitem action='Teleport'/>"
@@ -297,37 +290,6 @@ wait_cb (GtkAction * action, gpointer data)
game_keypress (KBD_WAIT);
}
-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 (app));
- } else {
- gtk_window_unfullscreen (GTK_WINDOW (app));
- }
-}
-
-/* Just in case something else takes us to/from fullscreen. */
-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;
-}
-
/**
* create_game_menus
* @ap: application pointer
@@ -361,12 +323,8 @@ create_game_menus (GtkUIManager * ui_manager)
wait_action = gtk_action_group_get_action (action_group, "Wait");
toolbar_toggle_action =
gtk_action_group_get_action (action_group, "ShowToolbar");
- 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);
-
+ fullscreen_action = GTK_ACTION (games_fullscreen_action_new ("Fullscreen", GTK_WINDOW (app)));
+ gtk_action_group_add_action_with_accel (action_group, fullscreen_action, NULL);
return;
}
diff --git a/gnotski/gnotski.c b/gnotski/gnotski.c
index 30bb60d..9914caa 100644
--- a/gnotski/gnotski.c
+++ b/gnotski/gnotski.c
@@ -36,6 +36,7 @@
#include <libgames-support/games-scores.h>
#include <libgames-support/games-scores-dialog.h>
#include <libgames-support/games-stock.h>
+#include <libgames-support/games-fullscreen-action.h>
#ifdef WITH_SMCLIENT
#include <libgames-support/eggsmclient.h>
@@ -73,7 +74,6 @@ GamesPreimage *tiles_preimage;
GtkActionGroup *action_group;
GtkAction *fullscreen_action;
-GtkAction *leave_fullscreen_action;
gboolean clear_buffer = TRUE;
gboolean clear_game = TRUE;
@@ -156,9 +156,6 @@ void game_score (void);
gint game_over (void);
gboolean window_resize_cb (GtkWidget *, GdkEventConfigure *, gpointer);
-static void set_fullscreen_actions (gboolean is_fullscreen);
-static void fullscreen_cb (GtkAction * action);
-static gboolean window_state_cb (GtkWidget * widget, GdkEventWindowState * event);
void new_game (gint requested_level);
@@ -429,10 +426,6 @@ const GtkActionEntry entries[] = {
{"Quit", GTK_STOCK_QUIT, NULL, NULL, NULL, G_CALLBACK (quit_game_cb)},
{"Contents", GAMES_STOCK_CONTENTS, NULL, NULL, NULL, G_CALLBACK (help_cb)},
{"About", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK (about_cb)},
- {"Fullscreen", GAMES_STOCK_FULLSCREEN, NULL, NULL, NULL,
- G_CALLBACK (fullscreen_cb)},
- {"LeaveFullscreen", GAMES_STOCK_LEAVE_FULLSCREEN, NULL, NULL, NULL,
- G_CALLBACK (fullscreen_cb)},
{"Scores", GAMES_STOCK_SCORES, NULL, NULL, NULL, G_CALLBACK (score_cb)}
};
@@ -454,7 +447,6 @@ const char ui_description[] =
" </menu>"
" <menu action='ViewMenu'>"
" <menuitem action='Fullscreen'/>"
- " <menuitem action='LeaveFullscreen'/>"
" </menu>"
" <menu action='HelpMenu'>"
" <menuitem action='Contents'/>"
@@ -542,8 +534,6 @@ main (int argc, char **argv)
g_signal_connect (window, "delete_event",
G_CALLBACK (quit_game_cb), NULL);
- g_signal_connect (window, "window_state_event",
- G_CALLBACK (window_state_cb), NULL);
vbox = gtk_vbox_new (FALSE, 0);
@@ -605,37 +595,6 @@ redraw_all (void)
return FALSE;
}
-
-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 gboolean
movable (gint id)
{
@@ -1073,12 +1032,8 @@ create_menubar (void)
gtk_action_group_add_actions (action_group, entries,
G_N_ELEMENTS (entries), window);
- 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);
+ fullscreen_action = GTK_ACTION (games_fullscreen_action_new ("Fullscreen", GTK_WINDOW (window)));
+ gtk_action_group_add_action_with_accel (action_group, fullscreen_action, NULL);
ui_manager = gtk_ui_manager_new ();
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]