[gnome-games] iagno: Remove games_settings_bind_window_state



commit 0620541e4a6c11c6423cc148b91e25c9e2d975ae
Author: Robert Ancell <robert ancell canonical com>
Date:   Tue Aug 21 16:32:17 2012 +1200

    iagno: Remove games_settings_bind_window_state

 iagno/data/org.gnome.iagno.gschema.xml.in |   16 ++++++++++
 iagno/src/iagno.vala                      |   45 +++++++++++++++++++++++++++-
 2 files changed, 59 insertions(+), 2 deletions(-)
---
diff --git a/iagno/data/org.gnome.iagno.gschema.xml.in b/iagno/data/org.gnome.iagno.gschema.xml.in
index 1eb89ec..7b2d51e 100644
--- a/iagno/data/org.gnome.iagno.gschema.xml.in
+++ b/iagno/data/org.gnome.iagno.gschema.xml.in
@@ -22,5 +22,21 @@
       <_summary>Sound</_summary>
       <_description>Whether or not to play event sounds.</_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/iagno/src/iagno.vala b/iagno/src/iagno.vala
index a2def8e..0610435 100644
--- a/iagno/src/iagno.vala
+++ b/iagno/src/iagno.vala
@@ -5,6 +5,10 @@ public class Iagno : Gtk.Application
 
     /* Widgets */
     private Gtk.Window window;
+    private int window_width;
+    private int window_height;
+    private bool is_fullscreen;
+    private bool is_maximized;
     private Gtk.InfoBar infobar;
     private Gtk.Statusbar statusbar;
     private uint statusbar_id;
@@ -74,11 +78,17 @@ public class Iagno : Gtk.Application
             return;
         }
         set_app_menu (builder.get_object ("iagno-menu") as MenuModel);
-        window = builder.get_object ("window") as Gtk.Window;
         var top_grid = builder.get_object ("grid") as Gtk.Grid;
         window.set_title (_("Iagno"));
+        window = builder.get_object ("window") as Gtk.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 ();
 
-        GnomeGamesSupport.settings_bind_window_state ("/org/gnome/iagno/", window);
         add_window (window);
 
         undo_action.set_enabled (true);
@@ -147,6 +157,37 @@ public class Iagno : Gtk.Application
         window.show ();
     }
 
+    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);
+    }
+
+    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;
+    }
+
     private void quit_cb ()
     {
         window.destroy ();



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