diff options
author | Christopher Davis <christopherdavis@gnome.org> | 2021-09-21 19:19:31 -0700 |
---|---|---|
committer | Christopher Davis <christopherdavis@gnome.org> | 2021-09-21 19:19:31 -0700 |
commit | 3b628ac25b6209d414d1f8964a743e0a2b0a29f9 (patch) | |
tree | 790eec348d08d4a4b30d7edf94c056844b3b18d8 | |
parent | c1a019d31e8b51ddc760be20c7ce6ff7d6e953f9 (diff) | |
download | baobab-3b628ac25b6209d414d1f8964a743e0a2b0a29f9.tar.gz |
window: Clean up window sizing code
GTK4 drops a few of the events used, and we don't need
to get the whole window state.
-rw-r--r-- | data/org.gnome.baobab.gschema.xml | 8 | ||||
-rw-r--r-- | src/baobab-window.vala | 13 |
2 files changed, 8 insertions, 13 deletions
diff --git a/data/org.gnome.baobab.gschema.xml b/data/org.gnome.baobab.gschema.xml index ffdb256..a453903 100644 --- a/data/org.gnome.baobab.gschema.xml +++ b/data/org.gnome.baobab.gschema.xml @@ -25,10 +25,10 @@ <summary>Window size</summary> <description>The initial size of the window</description> </key> - <key name="window-state" type="i"> - <default>0</default> - <summary>Window state</summary> - <description>The GdkWindowState of the window</description> + <key name="is-maximized" type="b"> + <default>false</default> + <summary>Window Maximized</summary> + <description>Whether or not the window is maximized</description> </key> </schema> </schemalist> diff --git a/src/baobab-window.vala b/src/baobab-window.vala index 26c5ff5..fb978a1 100644 --- a/src/baobab-window.vala +++ b/src/baobab-window.vala @@ -150,8 +150,7 @@ namespace Baobab { enable_drop (); // Setup window geometry saving - Gdk.WindowState window_state = (Gdk.WindowState) ui_settings.get_int ("window-state"); - if (Gdk.WindowState.MAXIMIZED in window_state) { + if (ui_settings.get_boolean ("is-maximized")) { maximize (); } @@ -159,17 +158,13 @@ namespace Baobab { ui_settings.get ("window-size", "(ii)", out width, out height); resize (width, height); - window_state_event.connect ((event) => { - ui_settings.set_int ("window-state", event.new_window_state); - return false; - }); + ui_settings.bind ("is-maximized", this, "is-maximized", GLib.SettingsBindFlags.SET); - configure_event.connect ((event) => { - if (!(Gdk.WindowState.MAXIMIZED in get_window ().get_state ())) { + size_allocate.connect ((_) => { + if (!is_maximized) { get_size (out width, out height); ui_settings.set ("window-size", "(ii)", width, height); } - return false; }); destroy.connect (() => { |