Verified Commit 977eac1a authored by Zander Brown's avatar Zander Brown 🔲
Browse files

window: store window size

Fix GNOME/gnome-clocks#113
parent aae3790f
......@@ -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;
}
......
......@@ -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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment