[file-roller/wip/gtk4: 28/54] Use an utility function to save/restore windows size




commit 98f06eebc016fc8eaa47628458238a958a9437ee
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Oct 1 17:29:21 2022 +0200

    Use an utility function to save/restore windows size

 data/org.gnome.FileRoller.gschema.xml |  8 ++++----
 src/dlg-add.c                         | 13 ++-----------
 src/fr-window.c                       |  2 --
 src/preferences.c                     |  6 +++---
 src/preferences.h                     |  2 --
 5 files changed, 9 insertions(+), 22 deletions(-)
---
diff --git a/data/org.gnome.FileRoller.gschema.xml b/data/org.gnome.FileRoller.gschema.xml
index f5e2ba83..9687ee28 100644
--- a/data/org.gnome.FileRoller.gschema.xml
+++ b/data/org.gnome.FileRoller.gschema.xml
@@ -212,20 +212,20 @@
     <key name="no-symlinks" type="b">
       <default>true</default>
     </key>
-    <key name="dialog-width" type="i">
+    <key name="width" type="i">
       <default>300</default>
     </key>
-    <key name="dialog-height" type="i">
+    <key name="height" type="i">
       <default>300</default>
     </key>
   </schema>
 
   <schema id="org.gnome.FileRoller.Dialogs.LastOutput" path="/org/gnome/file-roller/dialogs/last-output/" 
gettext-domain="file-roller">
     <key name="width" type="i">
-      <default>-1</default>
+      <default>500</default>
     </key>
     <key name="height" type="i">
-      <default>-1</default>
+      <default>500</default>
     </key>
   </schema>
 
diff --git a/src/dlg-add.c b/src/dlg-add.c
index 6c062805..4c1c1e06 100644
--- a/src/dlg-add.c
+++ b/src/dlg-add.c
@@ -74,12 +74,7 @@ file_selector_response_cb (GtkDialog  *dialog,
        const char  *exclude_folders;
        GList       *files;
 
-       int width, height;
-       gtk_window_get_default_size (GTK_WINDOW (data->dialog), &width, &height);
-       if ((width > 0) && (height > 0)) {
-               g_settings_set_int (data->settings, PREF_ADD_DIALOG_WIDTH, width);
-               g_settings_set_int (data->settings, PREF_ADD_DIALOG_HEIGHT, height);
-       }
+       pref_util_save_window_geometry (GTK_WINDOW (data->dialog), "Add");
 
        if (response == GTK_RESPONSE_NONE)
                return;
@@ -249,11 +244,7 @@ dlg_add (FrWindow *window)
                          data);
 
        gtk_window_set_modal (GTK_WINDOW (data->dialog), TRUE);
-       gtk_widget_show (data->dialog);
-
-       gtk_window_set_default_size (GTK_WINDOW (data->dialog),
-                                    g_settings_get_int (data->settings, PREF_ADD_DIALOG_WIDTH),
-                                    g_settings_get_int (data->settings, PREF_ADD_DIALOG_HEIGHT));
+       pref_util_restore_window_geometry (GTK_WINDOW (data->dialog), "Add");
 }
 
 
diff --git a/src/fr-window.c b/src/fr-window.c
index 92d4f24f..939221c3 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -7399,7 +7399,6 @@ fr_window_view_last_output (FrWindow   *window,
                               NULL);
        gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
        gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
-       gtk_widget_set_size_request (dialog, 500, 300);
 
        /* Add text */
 
@@ -7426,7 +7425,6 @@ fr_window_view_last_output (FrWindow   *window,
        gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolled), text_view);
        _gtk_box_pack_start (GTK_BOX (vbox), scrolled, TRUE, TRUE);
 
-       gtk_widget_show (vbox);
        _gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox, TRUE, TRUE);
 
        /* signals */
diff --git a/src/preferences.c b/src/preferences.c
index 85f9e57e..d0683d4e 100644
--- a/src/preferences.c
+++ b/src/preferences.c
@@ -40,7 +40,7 @@ pref_util_save_window_geometry (GtkWindow  *window,
        schema = g_strconcat (FILE_ROLLER_SCHEMA_DIALOGS, ".", dialog_id, NULL);
        settings = g_settings_new (schema);
 
-       gtk_widget_get_size_request (GTK_WIDGET (window), &width, &height);
+       gtk_window_get_default_size (window, &width, &height);
        g_settings_set_int (settings, "width", width);
        g_settings_set_int (settings, "height", height);
 
@@ -63,9 +63,9 @@ pref_util_restore_window_geometry (GtkWindow  *window,
 
        width = g_settings_get_int (settings, "width");
        height = g_settings_get_int (settings, "height");
-       if ((width != -1) && (height != 1))
-               gtk_window_set_default_size (window, width, height);
        gtk_window_present (window);
+       if ((width > 0) && (height > 0))
+               gtk_window_set_default_size (window, width, height);
 
        g_object_unref (settings);
        g_free (schema);
diff --git a/src/preferences.h b/src/preferences.h
index 2e1ae4c4..0c107d33 100644
--- a/src/preferences.h
+++ b/src/preferences.h
@@ -65,8 +65,6 @@
 #define PREF_ADD_UPDATE                   "update"
 #define PREF_ADD_RECURSIVE                "recursive"
 #define PREF_ADD_NO_FOLLOW_SYMLINKS       "no-symlinks"
-#define PREF_ADD_DIALOG_WIDTH             "dialog-width"
-#define PREF_ADD_DIALOG_HEIGHT            "dialog-height"
 
 #define PREF_NEW_DEFAULT_EXTENSION        "default-extension"
 #define PREF_NEW_ENCRYPT_HEADER           "encrypt-header"


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