Add window state to GSettings schema

This commit is contained in:
Gergely Polonkai 2014-10-14 17:10:10 +02:00
parent 026b19a17c
commit 180c3e2703
2 changed files with 41 additions and 0 deletions

View File

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

View File

@ -12,12 +12,32 @@ namespace GnomeGitlab
[GtkChild] [GtkChild]
private Gtk.HeaderBar header_bar; private Gtk.HeaderBar header_bar;
private GLib.Settings settings;
public Window (Application app) public Window (Application app)
{ {
Object (application: app); Object (application: app);
add_action_entries (action_entries, this); 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 (); show_all ();
} }