[gnome-games] gnome-mahjongg: Remove games_settings_bind_window_state
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] gnome-mahjongg: Remove games_settings_bind_window_state
- Date: Tue, 21 Aug 2012 04:47:46 +0000 (UTC)
commit 5a934ae7a1517aa01cfcaf7f4bf19cf636a5913e
Author: Robert Ancell <robert ancell canonical com>
Date: Tue Aug 21 16:23:32 2012 +1200
gnome-mahjongg: Remove games_settings_bind_window_state
.../data/org.gnome.gnome-mahjongg.gschema.xml.in | 20 +++++++++
gnome-mahjongg/src/gnome-mahjongg.vala | 45 +++++++++++++++++++-
2 files changed, 63 insertions(+), 2 deletions(-)
---
diff --git a/gnome-mahjongg/data/org.gnome.gnome-mahjongg.gschema.xml.in b/gnome-mahjongg/data/org.gnome.gnome-mahjongg.gschema.xml.in
index 9e924ec..d8c106e 100644
--- a/gnome-mahjongg/data/org.gnome.gnome-mahjongg.gschema.xml.in
+++ b/gnome-mahjongg/data/org.gnome.gnome-mahjongg.gschema.xml.in
@@ -17,5 +17,25 @@
<default>"#34385b"</default>
</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/gnome-mahjongg/src/gnome-mahjongg.vala b/gnome-mahjongg/src/gnome-mahjongg.vala
index e281a88..9443983 100644
--- a/gnome-mahjongg/src/gnome-mahjongg.vala
+++ b/gnome-mahjongg/src/gnome-mahjongg.vala
@@ -7,6 +7,11 @@ public class Mahjongg : Gtk.Application
private List<Map> maps = null;
private Gtk.ApplicationWindow window;
+ private int window_width;
+ private int window_height;
+ private bool is_fullscreen;
+ private bool is_maximized;
+
private GameView game_view;
private Gtk.ToolButton pause_button;
private Gtk.ToolItem status_item;
@@ -41,8 +46,13 @@ public class Mahjongg : Gtk.Application
window = new Gtk.ApplicationWindow (this);
window.title = _("Mahjongg");
- window.set_default_size (530, 440);
- GnomeGamesSupport.settings_bind_window_state ("/org/gnome/gnome-mahjongg/", window);
+ window.configure_event.connect (window_configure_event_cb);
+ window.window_state_event.connect (window_state_event_cb);
+ 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 ();
var status_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 10);
@@ -140,6 +150,37 @@ public class Mahjongg : Gtk.Application
tick_cb ();
}
+ 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)
+ is_maximized = (event.new_window_state & Gdk.WindowState.MAXIMIZED) != 0;
+ if ((event.changed_mask & Gdk.WindowState.FULLSCREEN) != 0)
+ is_fullscreen = (event.new_window_state & Gdk.WindowState.FULLSCREEN) != 0;
+ return false;
+ }
+
+ 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);
+ }
+
public override void activate ()
{
window.present ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]