[baobab/wip/cdavis/use-event-controllers: 3/3] window: Clean up window sizing code
- From: Christopher Davis <christopherdavis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab/wip/cdavis/use-event-controllers: 3/3] window: Clean up window sizing code
- Date: Wed, 22 Sep 2021 07:50:32 +0000 (UTC)
commit 3b628ac25b6209d414d1f8964a743e0a2b0a29f9
Author: Christopher Davis <christopherdavis gnome org>
Date: Tue Sep 21 19:19:31 2021 -0700
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.
data/org.gnome.baobab.gschema.xml | 8 ++++----
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 (() => {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]