[console/wip/msandova/remember-window-size: 19/19] schema: Add setting to remember size on close
- From: Maximiliano <msandova src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [console/wip/msandova/remember-window-size: 19/19] schema: Add setting to remember size on close
- Date: Thu, 11 Aug 2022 10:27:44 +0000 (UTC)
commit 62e296edc8145b5c027268fa5101d9c4c81e23da
Author: Maximiliano Sandoval R <msandova gnome org>
Date: Thu Aug 11 12:24:49 2022 +0200
schema: Add setting to remember size on close
Enabled by default. If this setting is disabled it will still load the
saved size, but won't save it on close.
data/org.gnome.Console.gschema.xml.in | 3 +++
src/kgx-application.c | 24 ++++++++++++++++++++----
2 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/data/org.gnome.Console.gschema.xml.in b/data/org.gnome.Console.gschema.xml.in
index 7e87e13..5b06808 100644
--- a/data/org.gnome.Console.gschema.xml.in
+++ b/data/org.gnome.Console.gschema.xml.in
@@ -27,5 +27,8 @@
<key name="window-height" type="i">
<default>-1</default>
</key>
+ <key name="remember-window-size" type="b">
+ <default>true</default>
+ </key>
</schema>
</schemalist>
diff --git a/src/kgx-application.c b/src/kgx-application.c
index 42e9cf9..e13d1c8 100644
--- a/src/kgx-application.c
+++ b/src/kgx-application.c
@@ -204,6 +204,15 @@ kgx_application_activate (GApplication *app)
}
+static void
+remember_window_size_changed (KgxApplication *self)
+{
+ if (!g_settings_get_boolean (self->settings, "remember-window-size")) {
+ kgx_application_set_window_size (self, -1, -1);
+ }
+}
+
+
static void
kgx_application_startup (GApplication *app)
{
@@ -248,6 +257,9 @@ kgx_application_startup (GApplication *app)
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"app.zoom-normal", zoom_normal_accels);
+ g_signal_connect_swapped (self->settings, "changed::remember-window-size",
+ G_CALLBACK (remember_window_size_changed), self);
+
self->settings = g_settings_new (KGX_APPLICATION_ID);
g_settings_bind (self->settings, "theme", app, "theme", G_SETTINGS_BIND_DEFAULT);
g_settings_bind (self->settings, "font-scale", app, "font-scale", G_SETTINGS_BIND_DEFAULT);
@@ -978,14 +990,14 @@ KgxWindow *
kgx_application_new_window (KgxApplication *self)
{
GtkWindow *active_window;
- int width, height;
+ int width = -1, height = -1;
g_return_val_if_fail (KGX_IS_APPLICATION (self), NULL);
active_window = gtk_application_get_active_window (GTK_APPLICATION (self));
if (active_window) {
gtk_window_get_default_size (active_window, &width, &height);
- } else {
+ } else if (g_settings_get_boolean (self->settings, "remember-window-size")) {
kgx_application_get_window_size (self, &width, &height);
}
@@ -1024,6 +1036,10 @@ kgx_application_set_window_size (KgxApplication *self,
g_debug ("Saving window geometry: %i×%i", width, height);
- g_settings_set_int (self->settings, "window-width", width);
- g_settings_set_int (self->settings, "window-height", height);
+ if (g_settings_get_boolean (self->settings, "remember-window-size")) {
+ g_debug ("Saving window geometry: %i×%i", width, height);
+
+ g_settings_set_int (self->settings, "window-width", width);
+ g_settings_set_int (self->settings, "window-height", height);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]