[gnome-games] gnotravex: Remove games_settings_bind_window_state
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] gnotravex: Remove games_settings_bind_window_state
- Date: Tue, 21 Aug 2012 04:47:41 +0000 (UTC)
commit bd87a8f27c80d55d11a14dd45fef0d0e1facd9f7
Author: Robert Ancell <robert ancell canonical com>
Date: Tue Aug 21 16:18:19 2012 +1200
gnotravex: Remove games_settings_bind_window_state
gnotravex/data/org.gnome.gnotravex.gschema.xml.in | 16 +++++++++++++
gnotravex/src/gnotravex.vala | 26 ++++++++++++++++++++-
2 files changed, 41 insertions(+), 1 deletions(-)
---
diff --git a/gnotravex/data/org.gnome.gnotravex.gschema.xml.in b/gnotravex/data/org.gnome.gnotravex.gschema.xml.in
index b3d46aa..1f65b3a 100644
--- a/gnotravex/data/org.gnome.gnotravex.gschema.xml.in
+++ b/gnotravex/data/org.gnome.gnotravex.gschema.xml.in
@@ -6,5 +6,21 @@
<_summary>The size of the playing grid</_summary>
<_description>The value of this key is used to decide the size of the playing grid.</_description>
</key>
+ <key name="window-width" type="i">
+ <default>600</default>
+ <_summary>Width of the window in pixels</_summary>
+ </key>
+ <key name="window-height" type="i">
+ <default>400</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/gnotravex/src/gnotravex.vala b/gnotravex/src/gnotravex.vala
index f49c0e4..a9235ec 100644
--- a/gnotravex/src/gnotravex.vala
+++ b/gnotravex/src/gnotravex.vala
@@ -19,6 +19,8 @@ public class Gnotravex : Gtk.Application
};
private Gtk.Window window;
+ private int window_width;
+ private int window_height;
private bool is_fullscreen;
private bool is_maximized;
@@ -74,8 +76,13 @@ public class Gnotravex : Gtk.Application
window = new Gtk.ApplicationWindow (this);
window.title = _("Tetravex");
+ window.configure_event.connect (window_configure_event_cb);
window.window_state_event.connect (window_state_event_cb);
- GnomeGamesSupport.settings_bind_window_state ("/org/gnome/gnotravex/", window);
+ window.set_default_size (settings.get_int ("window-width"), settings.get_int ("window-height"));
+ if (settings.get_boolean ("window-is-fullscreen"))
+ window.fullscreen ();
+ else if (settings.get_boolean ("window-is-maximized"))
+ window.maximize ();
(lookup_action ("size") as SimpleAction).set_state ("%d".printf (settings.get_int (KEY_GRID_SIZE)));
@@ -139,6 +146,17 @@ public class Gnotravex : Gtk.Application
new_game ();
}
+ private bool window_configure_event_cb (Gdk.EventConfigure event)
+ {
+ if (!is_maximized && !is_fullscreen)
+ {
+ window_width = event.width;
+ window_height = event.height;
+ }
+
+ return false;
+ }
+
private bool window_state_event_cb (Gdk.EventWindowState event)
{
if ((event.changed_mask & Gdk.WindowState.MAXIMIZED) != 0)
@@ -157,6 +175,12 @@ public class Gnotravex : Gtk.Application
protected override void shutdown ()
{
base.shutdown ();
+
+ /* Save window state */
+ settings.set_int ("window-width", window_width);
+ settings.set_int ("window-height", window_height);
+ settings.set_boolean ("window-is-maximized", is_maximized);
+ settings.set_boolean ("window-is-fullscreen", is_fullscreen);
}
protected override void activate ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]