[console/wip/msandova/remember-window-size] window: Remember window size
- From: Maximiliano <msandova src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [console/wip/msandova/remember-window-size] window: Remember window size
- Date: Fri, 29 Jul 2022 19:48:41 +0000 (UTC)
commit 33763d5a8aa50a6ecffe0a242cedac61f3648550
Author: Maximiliano Sandoval R <msandova gnome org>
Date: Fri Jul 29 21:46:59 2022 +0200
window: Remember window size
Fixes: https://gitlab.gnome.org/GNOME/console/-/issues/120
data/org.gnome.Console.gschema.xml.in | 6 ++++++
src/kgx-application.c | 14 ++++++++++++++
src/kgx-application.h | 1 +
src/kgx-window.c | 23 +++++++++++++++++++++++
4 files changed, 44 insertions(+)
---
diff --git a/data/org.gnome.Console.gschema.xml.in b/data/org.gnome.Console.gschema.xml.in
index 8bf5d05..7e87e13 100644
--- a/data/org.gnome.Console.gschema.xml.in
+++ b/data/org.gnome.Console.gschema.xml.in
@@ -21,5 +21,11 @@
<key name="scrollback-lines" type="x">
<default>10000</default>
</key>
+ <key name="window-width" type="i">
+ <default>-1</default>
+ </key>
+ <key name="window-height" type="i">
+ <default>-1</default>
+ </key>
</schema>
</schemalist>
diff --git a/src/kgx-application.c b/src/kgx-application.c
index f2a0f7f..3915bdf 100644
--- a/src/kgx-application.c
+++ b/src/kgx-application.c
@@ -1175,8 +1175,15 @@ kgx_application_add_terminal (KgxApplication *self,
if (existing_window) {
window = GTK_WINDOW (existing_window);
} else {
+ int width = g_settings_get_int (self->settings, "window-width");
+ int height = g_settings_get_int (self->settings, "window-height");
+
+ g_debug ("Loading window geometry: %ix%i", width, height);
+
window = g_object_new (KGX_TYPE_WINDOW,
"application", self,
+ "default-width", width,
+ "default-height", height,
NULL);
}
@@ -1189,3 +1196,10 @@ kgx_application_add_terminal (KgxApplication *self,
return KGX_TAB (tab);
}
+
+
+GSettings *
+kgx_application_get_settings (KgxApplication *self)
+{
+ return self->settings;
+}
diff --git a/src/kgx-application.h b/src/kgx-application.h
index fa401cd..ed12c6e 100644
--- a/src/kgx-application.h
+++ b/src/kgx-application.h
@@ -112,5 +112,6 @@ KgxTab * kgx_application_add_terminal (KgxApplication *self,
GFile *working_directory,
GStrv command,
const char *title);
+GSettings * kgx_application_get_settings (KgxApplication *self);
G_END_DECLS
diff --git a/src/kgx-window.c b/src/kgx-window.c
index ddfa0a2..8d2aa4d 100644
--- a/src/kgx-window.c
+++ b/src/kgx-window.c
@@ -79,6 +79,26 @@ zoomed (GObject *object, GParamSpec *pspec, gpointer data)
}
+static void
+save_window_size (KgxWindow *self)
+{
+ GtkApplication *application;
+ GSettings *settings;
+ int width;
+ int height;
+
+ application = gtk_window_get_application (GTK_WINDOW (self));
+ settings = kgx_application_get_settings (KGX_APPLICATION (application));
+
+ kgx_window_get_size (self, &width, &height);
+
+ g_debug ("Saving window geometry: %ix%i", width, height);
+
+ g_settings_set_int (settings, "window-width", width);
+ g_settings_set_int (settings, "window-height", height);
+}
+
+
static void
kgx_window_constructed (GObject *object)
{
@@ -179,6 +199,8 @@ close_response (KgxWindow *self)
{
self->close_anyway = TRUE;
+ save_window_size (self);
+
gtk_window_destroy (GTK_WINDOW (self));
}
@@ -193,6 +215,7 @@ kgx_window_close_request (GtkWindow *window)
children = kgx_pages_get_children (KGX_PAGES (self->pages));
if (children->len < 1 || self->close_anyway) {
+ save_window_size (self);
return FALSE; // Aka no, I don’t want to block closing
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]