[gnome-clocks/zbrown/window-size] window: store window size



commit 941dcf576f8e6947f6bf7ef2254196278eadb7cb
Author: Zander Brown <zbrown gnome org>
Date:   Mon Jun 8 02:05:08 2020 +0100

    window: store window size
    
    Fix https://gitlab.gnome.org/GNOME/gnome-clocks/-/issues/113

 data/org.gnome.clocks.gschema.xml.in |  8 ++++----
 src/application.vala                 |  3 ---
 src/window.vala                      | 25 ++++++++++++++++---------
 3 files changed, 20 insertions(+), 16 deletions(-)
---
diff --git a/data/org.gnome.clocks.gschema.xml.in b/data/org.gnome.clocks.gschema.xml.in
index 71128ff..ae13a5f 100644
--- a/data/org.gnome.clocks.gschema.xml.in
+++ b/data/org.gnome.clocks.gschema.xml.in
@@ -16,10 +16,10 @@
     </key>
     <key name="timers" type="aa{sv}">
        <default>[]</default>
-       <summary>Configured Timers</summary>
-       <description>
-       List of timers set.
-       </description>
+      <summary>Configured Timers</summary>
+      <description>
+      List of timers set.
+      </description>
     </key>
     <key name="geolocation" type="b">
       <default>true</default>
diff --git a/src/application.vala b/src/application.vala
index 8945d7d..caa4448 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -41,9 +41,6 @@ public class Application : Gtk.Application {
     private Window ensure_window () ensures (window != null) {
         if (window == null) {
             window = new Window (this);
-            ((Window) window).delete_event.connect (() => {
-               return ((Window) window).hide_on_delete ();
-            });
         }
         return (Window) window;
     }
diff --git a/src/window.vala b/src/window.vala
index b294246..c8ad6cf 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -68,10 +68,6 @@ public class Window : Hdy.ApplicationWindow {
         settings = new Settings ("org.gnome.clocks.state.window");
         settings.delay ();
 
-        destroy.connect (() => {
-            settings.apply ();
-        });
-
         // GSettings gives us the nick, which matches the stack page name
         stack.visible_child_name = settings.get_string ("panel-id");
 
@@ -82,15 +78,15 @@ public class Window : Hdy.ApplicationWindow {
         pane_changed ();
 
         // Setup window geometry saving
-        Gdk.WindowState window_state = (Gdk.WindowState)settings.get_int ("state");
+        var window_state = (Gdk.WindowState) settings.get_int ("state");
         if (Gdk.WindowState.MAXIMIZED in window_state) {
             maximize ();
+        } else {
+            int width, height;
+            settings.get ("size", "(ii)", out width, out height);
+            resize (width, height);
         }
 
-        int width, height;
-        settings.get ("size", "(ii)", out width, out height);
-        resize (width, height);
-
         world.show_standalone.connect ((w, l) => {
             stack.visible_child = w;
             world_standalone.location = l;
@@ -207,6 +203,16 @@ public class Window : Hdy.ApplicationWindow {
         world.add_location (location);
     }
 
+    public override void destroy () {
+        settings.apply ();
+    }
+
+    public override bool delete_event (Gdk.EventAny event) {
+        settings.apply ();
+
+        return hide_on_delete ();
+    }
+
     public override bool key_press_event (Gdk.EventKey event) {
         uint keyval;
         bool handled = false;
@@ -251,6 +257,7 @@ public class Window : Hdy.ApplicationWindow {
 
     protected override bool window_state_event (Gdk.EventWindowState event) {
         settings.set_int ("state", event.new_window_state);
+
         return base.window_state_event (event);
     }
 


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