[gnome-games] gnobots2: Remove games_settings_bind_window_state
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] gnobots2: Remove games_settings_bind_window_state
- Date: Wed, 29 Aug 2012 23:46:37 +0000 (UTC)
commit 3af7d00a87e906a0dfaea1c59cf02111104f5ae5
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Aug 30 11:39:24 2012 +1200
gnobots2: Remove games_settings_bind_window_state
gnobots2/data/org.gnome.gnobots2.gschema.xml.in | 20 +++
gnobots2/src/Makefile.am | 2 -
gnobots2/src/game.c | 14 --
gnobots2/src/games-settings.c | 171 -----------------------
gnobots2/src/games-settings.h | 40 ------
gnobots2/src/gnobots.c | 50 ++++++-
gnobots2/src/properties.c | 1 -
7 files changed, 62 insertions(+), 236 deletions(-)
---
diff --git a/gnobots2/data/org.gnome.gnobots2.gschema.xml.in b/gnobots2/data/org.gnome.gnobots2.gschema.xml.in
index 861bb7b..4b9aa9b 100644
--- a/gnobots2/data/org.gnome.gnobots2.gschema.xml.in
+++ b/gnobots2/data/org.gnome.gnobots2.gschema.xml.in
@@ -116,5 +116,25 @@
<_description>The key used to wait.</_description>
</key>
+ <key name="window-width" type="i">
+ <default>720</default>
+ <_summary>Width of the window in pixels</_summary>
+ </key>
+
+ <key name="window-height" type="i">
+ <default>566</default>
+ <_summary>Height of the window in pixels</_summary>
+ </key>
+
+ <key name="window-is-maximized" type="b">
+ <default>false</default>
+ <_summary>true if the window is maximized</_summary>
+ </key>
+
+ <key name="window-is-fullscreen" type="b">
+ <default>false</default>
+ <_summary>true if the window is fullscren</_summary>
+ </key>
+
</schema>
</schemalist>
diff --git a/gnobots2/src/Makefile.am b/gnobots2/src/Makefile.am
index 9ff679a..e0ed83e 100644
--- a/gnobots2/src/Makefile.am
+++ b/gnobots2/src/Makefile.am
@@ -32,8 +32,6 @@ gnobots2_SOURCES = \
games-gridframe.h \
games-preimage.c \
games-preimage.h \
- games-settings.c \
- games-settings.h \
games-stock.c \
games-stock.h \
cursor-down.h \
diff --git a/gnobots2/src/game.c b/gnobots2/src/game.c
index 4134ccb..190636a 100644
--- a/gnobots2/src/game.c
+++ b/gnobots2/src/game.c
@@ -634,20 +634,6 @@ init_game (void)
/**
- * quit_game
- *
- * Description:
- * Stop animation timeouts and exit.
- **/
-void
-quit_game (void)
-{
- destroy_game_timer ();
- gtk_main_quit ();
-}
-
-
-/**
* start_new_game
*
* Description:
diff --git a/gnobots2/src/gnobots.c b/gnobots2/src/gnobots.c
index 2cf84a7..d3c94b3 100644
--- a/gnobots2/src/gnobots.c
+++ b/gnobots2/src/gnobots.c
@@ -42,22 +42,20 @@
#include "game.h"
#include "cursors.h"
#include "games-gridframe.h"
-#include "games-settings.h"
#include "games-stock.h"
/* Minimum sizes. */
#define MINIMUM_TILE_WIDTH 8
#define MINIMUM_TILE_HEIGHT MINIMUM_TILE_WIDTH
-#define DEFAULT_WIDTH 720
-#define DEFAULT_HEIGHT 566
-
#define KEY_GEOMETRY_GROUP "geometry"
/**********************************************************************/
/* Exported Variables */
/**********************************************************************/
GtkWidget *app = NULL;
+static gint window_width = 0, window_height = 0;
+static gboolean window_is_fullscreen = FALSE, window_is_maximized = FALSE;
GtkWidget *game_area = NULL;
GamesScores *highscores;
GSettings *settings;
@@ -120,6 +118,38 @@ static const GamesScoresCategory scorecats[] = {
/* Function Definitions */
/**********************************************************************/
+static gboolean
+window_configure_event_cb (GtkWidget *widget, GdkEventConfigure *event)
+{
+ if (!window_is_maximized && !window_is_fullscreen)
+ {
+ window_width = event->width;
+ window_height = event->height;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+window_state_event_cb (GtkWidget *widget, GdkEventWindowState *event)
+{
+ if ((event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) != 0)
+ window_is_maximized = (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0;
+ if ((event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) != 0)
+ window_is_fullscreen = (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) != 0;
+ return FALSE;
+}
+
+void
+quit_game (void)
+{
+ g_settings_set_int (settings, "window-width", window_width);
+ g_settings_set_int (settings, "window-height", window_height);
+ g_settings_set_boolean (settings, "window-is-maximized", window_is_maximized);
+ g_settings_set_boolean (settings, "window-is-fullscreen", window_is_fullscreen);
+ gtk_main_quit ();
+}
+
/**
* main
* @argc: number of arguments
@@ -182,12 +212,16 @@ main (int argc, char *argv[])
app = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (app), _("Robots"));
-
- gtk_window_set_default_size (GTK_WINDOW (app), DEFAULT_WIDTH, DEFAULT_HEIGHT);
- games_settings_bind_window_state ("/org/gnome/gnobots2/", GTK_WINDOW (app));
+ g_signal_connect (GTK_WINDOW (app), "configure-event", G_CALLBACK (window_configure_event_cb), NULL);
+ g_signal_connect (GTK_WINDOW (app), "window-state-event", G_CALLBACK (window_state_event_cb), NULL);
+ gtk_window_set_default_size (GTK_WINDOW (app), g_settings_get_int (settings, "window-width"), g_settings_get_int (settings, "window-height"));
+ if (g_settings_get_boolean (settings, "window-is-fullscreen"))
+ gtk_window_fullscreen (GTK_WINDOW (app));
+ if (g_settings_get_boolean (settings, "window-is-maximized"))
+ gtk_window_maximize (GTK_WINDOW (app));
g_signal_connect (G_OBJECT (app), "delete_event",
- G_CALLBACK (quit_game), NULL);
+ G_CALLBACK (quit_game), NULL);
statusbar = gnobots_statusbar_new ();
ui_manager = gtk_ui_manager_new ();
diff --git a/gnobots2/src/properties.c b/gnobots2/src/properties.c
index 2560430..f96d456 100644
--- a/gnobots2/src/properties.c
+++ b/gnobots2/src/properties.c
@@ -40,7 +40,6 @@
#include "game.h"
#include "menu.h"
#include "games-file-list.h"
-#include "games-settings.h"
/**********************************************************************/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]