Add window state to GSettings schema
This commit is contained in:
		@@ -6,4 +6,25 @@
 | 
			
		||||
      <_description>List of GitLab instances to show.</_description>
 | 
			
		||||
    </key>
 | 
			
		||||
  </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>
 | 
			
		||||
 
 | 
			
		||||
@@ -12,12 +12,32 @@ namespace GnomeGitlab
 | 
			
		||||
        [GtkChild]
 | 
			
		||||
        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 ();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user