[gnome-clocks/zbrown/window-size] window: store window size
- From: Zander <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks/zbrown/window-size] window: store window size
- Date: Tue, 9 Jun 2020 22:32:18 +0000 (UTC)
commit 977eac1aa5e1626f1de4b17c3f136c87d3901250
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
src/application.vala | 3 ---
src/window.vala | 25 ++++++++++++++++---------
2 files changed, 16 insertions(+), 12 deletions(-)
---
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]