[gnome-text-editor] session: track maximized state of windows



commit 25c60a874e72112d14eb67053403acf5ca250048
Author: Christian Hergert <chergert redhat com>
Date:   Fri May 20 12:37:33 2022 -0700

    session: track maximized state of windows
    
    Fixes #380

 src/editor-session.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/src/editor-session.c b/src/editor-session.c
index 6e3ce95..0f98170 100644
--- a/src/editor-session.c
+++ b/src/editor-session.c
@@ -223,6 +223,9 @@ add_window_state (EditorSession   *self,
                                     "{'size', <(%u,%u)>}",
                                     CLAMP (width, 0, 10000),
                                     CLAMP (height, 0, 10000));
+      g_variant_builder_add_parsed (builder,
+                                    "{'maximized', <%b>}",
+                                    gtk_window_is_maximized (GTK_WINDOW (window)));
 
       /* Add all of the pages from the window */
       g_variant_builder_open (builder, G_VARIANT_TYPE ("{sv}"));
@@ -1755,6 +1758,7 @@ editor_session_restore_v1 (EditorSession *self,
   while (g_variant_iter_loop (&iter, "@a{sv}", &window))
     {
       g_autoptr(GVariant) pages = NULL;
+      gboolean maximized = FALSE;
 
       if (!g_variant_lookup (window, "size", "(uu)", &width, &height) ||
           width > HUGE_WINDOW || height > HUGE_WINDOW)
@@ -1763,6 +1767,9 @@ editor_session_restore_v1 (EditorSession *self,
           height = 0;
         }
 
+      if (!g_variant_lookup (window, "maximized", "b", &maximized))
+        maximized = FALSE;
+
       if ((pages = g_variant_lookup_value (window, "pages", G_VARIANT_TYPE ("aa{sv}"))) &&
           g_variant_n_children (pages) > 0)
         {
@@ -1779,6 +1786,9 @@ editor_session_restore_v1 (EditorSession *self,
               continue;
             }
 
+          if (maximized)
+            gtk_window_maximize (GTK_WINDOW (ewin));
+
           gtk_window_present (GTK_WINDOW (ewin));
         }
       else


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]