[console/zbrown/quick-ci-check: 3/3] window: restore window size




commit d660a1147eaf1f579e70faf43baa39a2853836bd
Author: Maximiliano Sandoval R <msandova gnome org>
Date:   Fri Jul 29 21:46:59 2022 +0200

    window: restore window size
    
    …and new windows inherit the size of the current window
    
    Fix: https://gitlab.gnome.org/GNOME/console/-/issues/120

 src/kgx-application.c | 14 ++++++++++++++
 src/kgx-window.c      |  6 ++++++
 2 files changed, 20 insertions(+)
---
diff --git a/src/kgx-application.c b/src/kgx-application.c
index d1a965c..eafab97 100644
--- a/src/kgx-application.c
+++ b/src/kgx-application.c
@@ -775,9 +775,23 @@ kgx_application_add_terminal (KgxApplication *self,
   if (existing_window) {
     window = GTK_WINDOW (existing_window);
   } else {
+    GtkWindow *active_window;
+    int width = -1, height = -1;
+
+    kgx_settings_get_size (self->settings, &width, &height);
+
+    active_window = gtk_application_get_active_window (GTK_APPLICATION (self));
+    if (active_window) {
+      gtk_window_get_default_size (active_window, &width, &height);
+    }
+
+    g_debug ("new window (%i×%i)", width, height);
+
     window = g_object_new (KGX_TYPE_WINDOW,
                            "application", self,
                            "settings", self->settings,
+                           "default-width", width,
+                           "default-height", height,
                            NULL);
   }
 
diff --git a/src/kgx-window.c b/src/kgx-window.c
index db84e30..8974059 100644
--- a/src/kgx-window.c
+++ b/src/kgx-window.c
@@ -122,6 +122,12 @@ kgx_window_close_request (GtkWindow *window)
   children = kgx_pages_get_children (KGX_PAGES (self->pages));
 
   if (children->len < 1 || self->close_anyway) {
+    if (gtk_window_is_active (GTK_WINDOW (self))) {
+      int width, height;
+      gtk_window_get_default_size (GTK_WINDOW (self), &width, &height);
+      kgx_settings_set_custom_size (self->settings, width, height);
+    }
+
     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]