[file-roller/wip/gtk4: 22/54] add dialog: fixed style, save/restore the dialog size




commit 9faac6118fddd4c8fddcd95fc00f053d6114df43
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Oct 1 13:35:49 2022 +0200

    add dialog: fixed style, save/restore the dialog size

 data/org.gnome.FileRoller.gschema.xml |  6 ++++
 src/dlg-add.c                         | 62 ++++++++++++++++++++---------------
 src/fr-file-selector-dialog.c         |  1 -
 src/preferences.h                     |  2 ++
 src/ui/add-dialog-options.ui          | 28 +++++++---------
 src/ui/app.css                        |  8 +++++
 src/ui/file-selector.ui               |  4 +--
 7 files changed, 65 insertions(+), 46 deletions(-)
---
diff --git a/data/org.gnome.FileRoller.gschema.xml b/data/org.gnome.FileRoller.gschema.xml
index baaaa451..f5e2ba83 100644
--- a/data/org.gnome.FileRoller.gschema.xml
+++ b/data/org.gnome.FileRoller.gschema.xml
@@ -212,6 +212,12 @@
     <key name="no-symlinks" type="b">
       <default>true</default>
     </key>
+    <key name="dialog-width" type="i">
+      <default>300</default>
+    </key>
+    <key name="dialog-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">
diff --git a/src/dlg-add.c b/src/dlg-add.c
index d7bff3c1..6c062805 100644
--- a/src/dlg-add.c
+++ b/src/dlg-add.c
@@ -62,9 +62,9 @@ static void dlg_add_folder_save_last_options (DialogData *data);
 
 
 static void
-file_selector_response_cb (GtkDialog *dialog,
-                          int           response,
-                          DialogData   *data)
+file_selector_response_cb (GtkDialog  *dialog,
+                          int         response,
+                          DialogData *data)
 {
        FrWindow    *window = data->window;
        GFile       *current_folder;
@@ -74,6 +74,13 @@ 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);
+       }
+
        if (response == GTK_RESPONSE_NONE)
                return;
 
@@ -86,7 +93,7 @@ file_selector_response_cb (GtkDialog *dialog,
 
        current_folder = fr_file_selector_dialog_get_current_folder (FR_FILE_SELECTOR_DIALOG (data->dialog));
 
-       /* check folder permissions. */
+       /* Check folder permissions. */
 
        if (! _g_file_check_permissions (current_folder, R_OK)) {
                GtkWidget *d;
@@ -106,8 +113,8 @@ file_selector_response_cb (GtkDialog *dialog,
                return;
        }
 
-       update = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("update_checkbutton")));
-       follow_links = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET 
("follow_links_checkbutton")));
+       update = gtk_check_button_get_active (GTK_CHECK_BUTTON (GET_WIDGET ("update_checkbutton")));
+       follow_links = gtk_check_button_get_active (GTK_CHECK_BUTTON (GET_WIDGET 
("follow_links_checkbutton")));
 
        include_files = gtk_editable_get_text (GTK_EDITABLE (GET_WIDGET ("include_files_entry")));
        if (_g_utf8_all_spaces (include_files))
@@ -193,9 +200,8 @@ dlg_add (FrWindow *window)
        /* options menu button */
 
        options_button = gtk_menu_button_new ();
-       gtk_button_set_label (GTK_BUTTON (options_button), _("_Options"));
-       gtk_button_set_use_underline (GTK_BUTTON (options_button), TRUE);
-       gtk_widget_show (options_button);
+       gtk_menu_button_set_icon_name (GTK_MENU_BUTTON (options_button), "document-properties-symbolic");
+       gtk_menu_button_set_use_underline (GTK_MENU_BUTTON (options_button), TRUE);
 
        /* load options */
 
@@ -225,7 +231,7 @@ dlg_add (FrWindow *window)
 
        if (use_header)
                gtk_header_bar_pack_end (GTK_HEADER_BAR (gtk_dialog_get_header_bar (GTK_DIALOG 
(data->dialog))),
-                                        options_button);
+                                        options_button);
 
        /* set data */
 
@@ -244,6 +250,10 @@ dlg_add (FrWindow *window)
 
        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));
 }
 
 
@@ -252,7 +262,7 @@ dlg_add (FrWindow *window)
 
 static void
 dlg_add_folder_save_last_used_options (DialogData *data,
-                                      const char *options_path)
+                                      const char *options_path)
 {
        g_free (data->last_options);
        data->last_options = g_strdup (_g_path_get_basename (options_path));
@@ -287,12 +297,12 @@ sync_widgets_with_options (DialogData *data,
                gtk_editable_set_text (GTK_EDITABLE (GET_WIDGET ("exclude_files_entry")), exclude_files);
        if (exclude_folders != NULL)
                gtk_editable_set_text (GTK_EDITABLE (GET_WIDGET ("exclude_folders_entry")), exclude_folders);
-       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("update_checkbutton")), update);
+       gtk_check_button_set_active (GTK_CHECK_BUTTON (GET_WIDGET ("update_checkbutton")), update);
 
        if ((data->window->archive != NULL) && data->window->archive->propAddCanStoreLinks) {
                gtk_widget_set_sensitive (GET_WIDGET ("follow_links_checkbutton"), TRUE);
                gtk_check_button_set_inconsistent (GTK_CHECK_BUTTON (GET_WIDGET 
("follow_links_checkbutton")), FALSE);
-               gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("follow_links_checkbutton")), ! 
no_follow_symlinks);
+               gtk_check_button_set_active (GTK_CHECK_BUTTON (GET_WIDGET ("follow_links_checkbutton")), ! 
no_follow_symlinks);
        }
        else {
                gtk_widget_set_sensitive (GET_WIDGET ("follow_links_checkbutton"), FALSE);
@@ -376,11 +386,11 @@ dlg_add_folder_load_options (DialogData *data,
        sync_widgets_with_options (data,
                                   folder,
                                   files,
-                                  include_files,
-                                  exclude_files,
-                                  exclude_folders,
-                                  update,
-                                  no_symlinks);
+                                  include_files,
+                                  exclude_files,
+                                  exclude_folders,
+                                  update,
+                                  no_symlinks);
 
        dlg_add_folder_save_last_used_options (data, file_path);
 
@@ -431,12 +441,12 @@ dlg_add_folder_load_last_options (DialogData *data)
 
        sync_widgets_with_options (data,
                                   folder,
-                                  files,
-                                  include_files,
-                                  exclude_files,
-                                  exclude_folders,
-                                  update,
-                                  no_follow_symlinks);
+                                  files,
+                                  include_files,
+                                  exclude_files,
+                                  exclude_folders,
+                                  update,
+                                  no_follow_symlinks);
 
        _g_object_unref (folder);
        g_strfreev (uris);
@@ -473,8 +483,8 @@ get_options_from_widgets (DialogData   *data,
        *file_uris = uris;
        _g_object_list_unref (files);
 
-       *update = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("update_checkbutton")));
-       *no_symlinks = ! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET 
("follow_links_checkbutton")));
+       *update = gtk_check_button_get_active (GTK_CHECK_BUTTON (GET_WIDGET ("update_checkbutton")));
+       *no_symlinks = ! gtk_check_button_get_active (GTK_CHECK_BUTTON (GET_WIDGET 
("follow_links_checkbutton")));
 
        *include_files = gtk_editable_get_text (GTK_EDITABLE (GET_WIDGET ("include_files_entry")));
        if (_g_utf8_all_spaces (*include_files))
diff --git a/src/fr-file-selector-dialog.c b/src/fr-file-selector-dialog.c
index a7797cc0..19c5ee60 100644
--- a/src/fr-file-selector-dialog.c
+++ b/src/fr-file-selector-dialog.c
@@ -616,7 +616,6 @@ fr_file_selector_dialog_init (FrFileSelectorDialog *self)
        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (GET_WIDGET ("files_liststore")), 
FILE_LIST_COLUMN_NAME, GTK_SORT_ASCENDING);
 
        self->location_bar = fr_location_bar_new ();
-       gtk_widget_show (self->location_bar);
        _gtk_box_pack_start (GTK_BOX (GET_WIDGET ("content_box")), self->location_bar, TRUE, FALSE);
        g_signal_connect (self->location_bar,
                          "changed",
diff --git a/src/preferences.h b/src/preferences.h
index 0c107d33..2e1ae4c4 100644
--- a/src/preferences.h
+++ b/src/preferences.h
@@ -65,6 +65,8 @@
 #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"
diff --git a/src/ui/add-dialog-options.ui b/src/ui/add-dialog-options.ui
index 5947c02f..66eaac78 100644
--- a/src/ui/add-dialog-options.ui
+++ b/src/ui/add-dialog-options.ui
@@ -18,28 +18,22 @@
     </section>
   </menu>
   <object class="GtkBox" id="extra_widget">
+    <style>
+      <class name="extra-widget"/>
+    </style>
     <property name="spacing">24</property>
     <child>
       <object class="GtkBox" id="box2">
         <property name="orientation">vertical</property>
-        <property name="spacing">6</property>
-        <child>
-          <object class="GtkLabel" id="label1">
-            <property name="halign">start</property>
-            <property name="label" translatable="1">Add</property>
-            <attributes>
-              <attribute name="weight" value="bold"></attribute>
-            </attributes>
-          </object>
-        </child>
+        <property name="spacing">10</property>
         <child>
           <object class="GtkGrid" id="grid2">
-            <property name="margin-start">12</property>
+            <property name="margin-start">0</property>
             <property name="row_spacing">6</property>
             <property name="column_spacing">6</property>
             <child>
               <object class="GtkLabel" id="label3">
-                <property name="halign">start</property>
+                <property name="halign">end</property>
                 <property name="label" translatable="1">Include _files:</property>
                 <property name="use_underline">1</property>
                 <property name="mnemonic_widget">include_files_entry</property>
@@ -51,7 +45,7 @@
             </child>
             <child>
               <object class="GtkLabel" id="label4">
-                <property name="halign">start</property>
+                <property name="halign">end</property>
                 <property name="label" translatable="1">E_xclude files:</property>
                 <property name="use_underline">1</property>
                 <property name="mnemonic_widget">exclude_files_entry</property>
@@ -63,7 +57,7 @@
             </child>
             <child>
               <object class="GtkLabel" id="label5">
-                <property name="halign">start</property>
+                <property name="halign">end</property>
                 <property name="label" translatable="1">_Exclude folders:</property>
                 <property name="use_underline">1</property>
                 <property name="mnemonic_widget">exclude_folders_entry</property>
@@ -114,11 +108,11 @@
     <child>
       <object class="GtkBox" id="box5">
         <property name="orientation">vertical</property>
-        <property name="spacing">6</property>
+        <property name="spacing">10</property>
         <child>
           <object class="GtkLabel" id="label2">
             <property name="halign">start</property>
-            <property name="label" translatable="1">Actions</property>
+            <property name="label" translatable="1">Options</property>
             <attributes>
               <attribute name="weight" value="bold"></attribute>
             </attributes>
@@ -126,7 +120,7 @@
         </child>
         <child>
           <object class="GtkBox" id="box6">
-            <property name="margin-start">12</property>
+            <property name="margin-start">0</property>
             <property name="orientation">vertical</property>
             <property name="spacing">6</property>
             <child>
diff --git a/src/ui/app.css b/src/ui/app.css
index facf14a2..db9fcb2e 100644
--- a/src/ui/app.css
+++ b/src/ui/app.css
@@ -3,6 +3,14 @@
        border-bottom: 1px solid @borders;
 }
 
+.extra-widget {
+       padding: 15px;
+}
+
+.border-bottom {
+       border-bottom: 1px solid @borders;
+}
+
 .borders-top-bottom {
        border-top: 1px solid @borders;
        border-bottom: 1px solid @borders;
diff --git a/src/ui/file-selector.ui b/src/ui/file-selector.ui
index 02f6fcd4..84ee17f5 100644
--- a/src/ui/file-selector.ui
+++ b/src/ui/file-selector.ui
@@ -45,7 +45,7 @@
   </object>
   <object class="GtkBox" id="content">
     <property name="orientation">vertical</property>
-    <property name="spacing">12</property>
+    <property name="spacing">0</property>
     <child>
       <object class="GtkBox" id="content_box">
         <property name="vexpand">1</property>
@@ -53,7 +53,7 @@
         <child>
           <object class="GtkPaned" id="main_paned">
             <style>
-              <class name="borders-top-bottom"/>
+              <class name="border-bottom"/>
             </style>
             <property name="vexpand">1</property>
             <property name="resize-start-child">0</property>


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