[shotwell] Visual clean-up of Saved Search dialog



commit af31b398a6b532a4ffa7a3e0d35e4d4e2a3079fa
Author: Jens Georg <mail jensge org>
Date:   Fri Aug 31 12:01:01 2018 +0200

    Visual clean-up of Saved Search dialog
    
     * Move Add button to bottom of list
     * Fix spacing
     * When using header bars, move the title edit into the header bar

 data/ui/saved_search_dialog.ui      | 100 +++++++++++++++---------------------
 src/searches/SavedSearchDialog.vala |  29 ++++++++++-
 2 files changed, 69 insertions(+), 60 deletions(-)
---
diff --git a/data/ui/saved_search_dialog.ui b/data/ui/saved_search_dialog.ui
index 825b750c..f56fd179 100644
--- a/data/ui/saved_search_dialog.ui
+++ b/data/ui/saved_search_dialog.ui
@@ -1,9 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.0 -->
 <interface domain="shotwell">
   <requires lib="gtk+" version="3.18"/>
   <template class="SavedSearchDialog" parent="GtkDialog">
     <property name="can_focus">False</property>
+    <property name="border_width">0</property>
     <property name="title" translatable="yes">Search</property>
     <property name="resizable">False</property>
     <property name="modal">True</property>
@@ -17,6 +18,8 @@
         <child internal-child="action_area">
           <object class="GtkButtonBox">
             <property name="can_focus">False</property>
+            <property name="margin_right">18</property>
+            <property name="margin_bottom">12</property>
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="button1">
@@ -57,16 +60,16 @@
           <object class="GtkBox" id="criteria">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="border_width">3</property>
+            <property name="border_width">18</property>
             <property name="orientation">vertical</property>
-            <property name="spacing">5</property>
             <child>
               <object class="GtkBox" id="hbox3">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
+                <property name="margin_bottom">18</property>
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
-                <property name="spacing">3</property>
+                <property name="spacing">12</property>
                 <child>
                   <object class="GtkLabel" id="Name of search:">
                     <property name="visible">True</property>
@@ -104,27 +107,14 @@
                 <property name="position">0</property>
               </packing>
             </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <object class="GtkSeparator" id="hseparator1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
             <child>
               <object class="GtkBox" id="hbox2">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
+                <property name="margin_bottom">6</property>
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
-                <property name="spacing">3</property>
+                <property name="spacing">12</property>
                 <child>
                   <object class="GtkLabel" id="Match">
                     <property name="visible">True</property>
@@ -173,46 +163,11 @@
                 <child>
                   <placeholder/>
                 </child>
-                <child>
-                  <object class="GtkButton" id="add_criteria">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <child>
-                      <object class="GtkImage">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="icon_name">list-add-symbolic</property>
-                        <property name="icon_size">1</property>
-                      </object>
-                    </child>
-                    <style>
-                      <class name="image-button"/>
-                    </style>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="pack_type">end</property>
-                    <property name="position">4</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSeparator" id="hseparator2">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
               </object>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
-                <property name="position">4</property>
+                <property name="position">1</property>
               </packing>
             </child>
             <child>
@@ -230,6 +185,33 @@
                       <object class="GtkListBox" id="row_listbox">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
+                        <child>
+                          <object class="GtkListBoxRow">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="valign">center</property>
+                            <child>
+                              <object class="GtkButton" id="add_criteria">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <property name="valign">start</property>
+                                <property name="relief">none</property>
+                                <child>
+                                  <object class="GtkImage">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="icon_name">list-add-symbolic</property>
+                                    <property name="icon_size">1</property>
+                                  </object>
+                                </child>
+                                <style>
+                                  <class name="image-button"/>
+                                </style>
+                              </object>
+                            </child>
+                          </object>
+                        </child>
                       </object>
                     </child>
                   </object>
@@ -238,12 +220,9 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
-                <property name="position">5</property>
+                <property name="position">2</property>
               </packing>
             </child>
-            <child>
-              <placeholder/>
-            </child>
           </object>
           <packing>
             <property name="expand">False</property>
@@ -257,5 +236,8 @@
       <action-widget response="-6">button1</action-widget>
       <action-widget response="-5">button2</action-widget>
     </action-widgets>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
   </template>
 </interface>
diff --git a/src/searches/SavedSearchDialog.vala b/src/searches/SavedSearchDialog.vala
index f5558bff..601b5604 100644
--- a/src/searches/SavedSearchDialog.vala
+++ b/src/searches/SavedSearchDialog.vala
@@ -655,6 +655,7 @@ public class SavedSearchDialog : Gtk.Dialog {
     private bool edit_mode = false;
     private SavedSearch? previous_search = null;
     private bool valid = false;
+    private ulong notify_id = 0;
     
     public SavedSearchDialog() {
         Object (use_header_bar : Resources.use_header_bar());
@@ -703,6 +704,12 @@ public class SavedSearchDialog : Gtk.Dialog {
         add_criteria.clicked.connect(on_add_criteria);
         
         search_title.changed.connect(on_title_changed);
+        if (Resources.use_header_bar() == 1) {
+            var box = search_title.get_parent();
+            box.remove(search_title);
+            box.get_parent().remove(box);
+            (get_header_bar() as Gtk.HeaderBar).set_custom_title (search_title);
+        }
     }
     
     // Displays the dialog.
@@ -711,9 +718,14 @@ public class SavedSearchDialog : Gtk.Dialog {
         destroy();
     }
     
+    double upper;
     // Adds a row of search criteria.
     private void on_add_criteria() {
+        this.upper = row_listbox.get_adjustment().upper;
+        this.notify_id = row_listbox.get_adjustment().notify["upper"].connect(on_scroll);
         add_text_search();
+        // Wait for upper to change. Then scroll to it, disconnect afterwards
+        // Otherwise the ListBox will randomly scroll to the bottom
     }
     
     private void add_text_search() {
@@ -725,11 +737,26 @@ public class SavedSearchDialog : Gtk.Dialog {
     private void add_row(SearchRowContainer row) {
         if (row_list.size == 1)
             row_list.get(0).allow_removal(true);
-        row_listbox.add(row.get_widget());
+        row_listbox.insert(row.get_widget(), row_list.size);
         row_list.add(row);
         row.remove.connect(on_remove_row);
         row.changed.connect(on_row_changed);
         set_valid(row.is_complete());
+
+    }
+
+    private void on_scroll() {
+        var adj = row_listbox.get_adjustment();
+        if (adj.upper < this.upper) {
+            return;
+        }
+
+        if (this.notify_id != 0) {
+            adj.disconnect(this.notify_id);
+            this.notify_id = 0;
+        }
+
+        adj.value = adj.upper;
     }
     
     // Removes a row of search criteria.


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