Add window state to GSettings schema

Gergely Polonkai 9 years ago
parent 026b19a17c
commit 180c3e2703

@ -6,4 +6,25 @@
<_description>List of GitLab instances to show.</_description>
<schema id="eu.polonkai.gergely.gnome-gitlab.state" path="/eu/polonkai/gergely/gnome-gitlab/state/">
<child schema="eu.polonkai.gergely.gnome-gitlab.state.window" name="window"/>
<schema id="eu.polonkai.gergely.gnome-gitlab.state.window" path="/eu/polonkai/gergely/gnome-gitlab/state/window/">
<key type="i" name="state">
<_summary>Window state</_summary>
State of the window: i.e. maximized.
<key type="(ii)" name="size">
<default>(800, 600)</default>
<_summary>Window width and height</_summary>
Width and height of the window

@ -12,12 +12,32 @@ namespace GnomeGitlab
private Gtk.HeaderBar header_bar;
private GLib.Settings settings;
public Window (Application app)
Object (application: app);
add_action_entries (action_entries, this);
settings = new Settings ("eu.polonkai.gergely.gnome-gitlab.state.window");
settings.delay ();
destroy.connect (() => {
settings.apply ();
Gdk.WindowState window_state = (Gdk.WindowState)settings.get_int ("state");
if (Gdk.WindowState.MAXIMIZED in window_state) {
maximize ();
int width, height;
settings.get ("size", "(ii)", out width, out height);
resize (width, height);
show_all ();