[dconf-editor] Move Bookmarks in PathWidget.



commit bd213129f7a46c482e6b089fe68770e8c788464d
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Tue Sep 11 15:26:09 2018 +0200

    Move Bookmarks in PathWidget.

 editor/dconf-editor.ui   | 35 ++++++++---------------------------
 editor/dconf-window.vala | 48 ++++++++++++++++++++----------------------------
 editor/pathwidget.ui     | 18 ++++++++++++------
 editor/pathwidget.vala   | 39 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 79 insertions(+), 61 deletions(-)
---
diff --git a/editor/dconf-editor.ui b/editor/dconf-editor.ui
index ffa31ff..32fb75b 100644
--- a/editor/dconf-editor.ui
+++ b/editor/dconf-editor.ui
@@ -19,6 +19,14 @@
         <property name="visible">True</property>
         <property name="show-close-button">True</property>
         <property name="has-subtitle">False</property>
+        <child type="title">
+          <object class="PathWidget" id="path_widget">
+            <property name="visible">True</property>
+            <property name="hexpand">False</property>
+            <signal name="search-changed" handler="search_changed_cb"/>
+            <signal name="search-stopped" handler="search_stopped_cb"/>
+          </object>
+        </child>
         <child>
           <object class="GtkMenuButton" id="info_button">
             <property name="visible">True</property>
@@ -47,33 +55,6 @@
             <property name="pack-type">end</property>
           </packing>
         </child>
-        <child>
-          <object class="Bookmarks" id="bookmarks_button">
-            <property name="visible">True</property>
-            <property name="valign">center</property>
-            <property name="focus-on-click">False</property>
-            <property name="schema-path">/ca/desrt/dconf-editor/</property>
-            <property name="sensitive" bind-source="path_widget" bind-property="search-mode-enabled" 
bind-flags="sync-create|invert-boolean"/>
-            <!-- <accelerator key="B" signal="activate" modifiers="GDK_CONTROL_MASK"/> TODO -->
-            <style>
-              <class name="image-button"/> <!-- TODO https://bugzilla.gnome.org/show_bug.cgi?id=756731 -->
-            </style>
-          </object>
-          <packing>
-            <property name="pack-type">end</property>
-          </packing>
-        </child>
-        <child type="title">
-          <object class="PathWidget" id="path_widget">
-            <property name="visible">True</property>
-            <property name="hexpand">False</property>
-            <signal name="search-changed" handler="search_changed_cb"/>
-            <signal name="search-stopped" handler="search_stopped_cb"/>
-          </object>
-          <packing>
-            <property name="pack-type">start</property>
-          </packing>
-        </child>
       </object>
     </child>
     <child>
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 7e3fe9d..08d9644 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -55,7 +55,6 @@ private class DConfWindow : ApplicationWindow
 
     private GLib.Settings settings = new GLib.Settings ("ca.desrt.dconf-editor.Settings");
 
-    [GtkChild] private Bookmarks bookmarks_button;
     [GtkChild] private MenuButton info_button;
     [GtkChild] private PathWidget path_widget;
 
@@ -468,8 +467,7 @@ private class DConfWindow : ApplicationWindow
     private void open_folder (SimpleAction action, Variant? path_variant)
         requires (path_variant != null)
     {
-        if (bookmarks_button.active)
-            bookmarks_button.active = false;
+        path_widget.close_popovers ();
 
         string full_name = ((!) path_variant).get_string ();
 
@@ -479,8 +477,7 @@ private class DConfWindow : ApplicationWindow
     private void open_object (SimpleAction action, Variant? path_variant)
         requires (path_variant != null)
     {
-        if (bookmarks_button.active)
-            bookmarks_button.active = false;
+        path_widget.close_popovers ();
         revealer.hide_modifications_list ();
 
         string full_name;
@@ -671,7 +668,7 @@ private class DConfWindow : ApplicationWindow
         if (reload)
         {
             reload_search_action.set_enabled (false);
-            browser_view.set_search_parameters (saved_view, bookmarks_button.get_bookmarks ());
+            browser_view.set_search_parameters (saved_view, path_widget.get_bookmarks ());
             reload_search_next = false;
         }
         if (mode != PathEntry.SearchMode.UNCLEAR)
@@ -712,7 +709,6 @@ private class DConfWindow : ApplicationWindow
         current_path = path;
 
         browser_view.set_path (type, path);
-        bookmarks_button.set_path (type, path);
         path_widget.set_path (type, path);
         invalidate_popovers_without_reload ();
     }
@@ -842,11 +838,11 @@ private class DConfWindow : ApplicationWindow
             switch (name)
             {
                 case "b":
+                case "B":
                     if (info_button.active)
                         info_button.active = false;
                     browser_view.discard_row_popover ();
-                    if (bookmarks_button.sensitive)
-                        bookmarks_button.clicked ();
+                    path_widget.click_bookmarks_button ();
                     return true;
 
                 case "c":
@@ -865,25 +861,24 @@ private class DConfWindow : ApplicationWindow
                     return true;
 
                 case "d":
-                    if (bookmarks_button.sensitive == false)
+                    if (!path_widget.is_bookmarks_button_sensitive)
                         return true;
                     if (info_button.active)
                         info_button.active = false;
                     browser_view.discard_row_popover ();
-                    bookmarks_button.set_bookmarked (current_path, true);
+                    path_widget.set_bookmarked (current_path, true);
                     return true;
                 case "D":
-                    if (bookmarks_button.sensitive == false)
+                    if (!path_widget.is_bookmarks_button_sensitive)
                         return true;
                     if (info_button.active)
                         info_button.active = false;
                     browser_view.discard_row_popover ();
-                    bookmarks_button.set_bookmarked (current_path, false);
+                    path_widget.set_bookmarked (current_path, false);
                     return true;
 
                 case "f":
-                    if (bookmarks_button.active)    // should never happen if path_widget.search_mode_enabled
-                        bookmarks_button.active = false;
+                    path_widget.close_popovers ();  // should never be needed if 
path_widget.search_mode_enabled
                     if (info_button.active)         // should never happen if path_widget.search_mode_enabled
                         info_button.active = false;
                     browser_view.discard_row_popover ();   // could happen if path_widget.search_mode_enabled
@@ -896,13 +891,13 @@ private class DConfWindow : ApplicationWindow
                     return true;
 
                 case "g":   // usual shortcut for "next-match" in a SearchEntry; see also "Down"
-                    if (bookmarks_button.active == false
+                    if (!path_widget.is_bookmarks_button_active
                      && info_button.active == false
                      && !revealer.get_modifications_list_state ())
                         return browser_view.down_pressed ();
                     return false;
                 case "G":   // usual shortcut for "previous-match" in a SearchEntry; see also "Up"
-                    if (bookmarks_button.active == false
+                    if (!path_widget.is_bookmarks_button_active
                      && info_button.active == false
                      && !revealer.get_modifications_list_state ())
                         return browser_view.up_pressed ();
@@ -936,7 +931,7 @@ private class DConfWindow : ApplicationWindow
 
                 case "Return":
                 case "KP_Enter":
-                    if (info_button.active || bookmarks_button.active)
+                    if (info_button.active || path_widget.is_bookmarks_button_active)
                         return false;
                     browser_view.discard_row_popover ();
                     browser_view.toggle_boolean_key ();
@@ -948,7 +943,7 @@ private class DConfWindow : ApplicationWindow
                 case "decimalpoint":
                 case "period":
                 case "KP_Decimal":
-                    if (info_button.active || bookmarks_button.active)
+                    if (info_button.active || path_widget.is_bookmarks_button_active)
                         return false;
                     if (revealer.dismiss_selected_modification ())
                     {
@@ -986,18 +981,17 @@ private class DConfWindow : ApplicationWindow
         if (name == "F10")
         {
             browser_view.discard_row_popover ();
-            if (bookmarks_button.active)
-                bookmarks_button.active = false;
+            path_widget.close_popovers ();
             return false;
         }
 
         if (name == "Up"    // see also <ctrl>G
-         && bookmarks_button.active == false
+         && !path_widget.is_bookmarks_button_active
          && info_button.active == false
          && !revealer.get_modifications_list_state ())
             return browser_view.up_pressed ();
         if (name == "Down"  // see also <ctrl>g
-         && bookmarks_button.active == false
+         && !path_widget.is_bookmarks_button_active
          && info_button.active == false
          && !revealer.get_modifications_list_state ())
             return browser_view.down_pressed ();
@@ -1028,8 +1022,7 @@ private class DConfWindow : ApplicationWindow
         {
             if (browser_view.toggle_row_popover ())
             {
-                if (bookmarks_button.active)
-                    bookmarks_button.active = false;
+                path_widget.close_popovers ();
                 if (info_button.active)
                     info_button.active = false;
             }
@@ -1037,8 +1030,7 @@ private class DConfWindow : ApplicationWindow
                 return true;
             else if (info_button.active == false)
             {
-                if (bookmarks_button.active)
-                    bookmarks_button.active = false;
+                path_widget.close_popovers ();
                 browser_view.discard_row_popover ();
                 info_button.active = true;
             }
@@ -1047,7 +1039,7 @@ private class DConfWindow : ApplicationWindow
             return true;
         }
 
-        if (bookmarks_button.active || info_button.active)
+        if (path_widget.is_bookmarks_button_active || info_button.active)
             return false;
 
         if (!path_widget.search_mode_enabled &&
diff --git a/editor/pathwidget.ui b/editor/pathwidget.ui
index 65d1400..ef46a07 100644
--- a/editor/pathwidget.ui
+++ b/editor/pathwidget.ui
@@ -32,9 +32,6 @@
           </packing>
         </child>
       </object>
-      <packing>
-        <property name="pack-type">start</property>
-      </packing>
     </child>
     <child>
       <object class="GtkToggleButton" id="search_toggle">
@@ -61,9 +58,18 @@
           </object>
         </child>
       </object>
-      <packing>
-        <property name="pack-type">end</property>
-      </packing>
+    </child>
+    <child>
+      <object class="Bookmarks" id="bookmarks_button">
+        <property name="visible">True</property>
+        <property name="valign">center</property>
+        <property name="focus-on-click">False</property>
+        <property name="schema-path">/ca/desrt/dconf-editor/</property>
+        <!-- <accelerator key="B" signal="activate" modifiers="GDK_CONTROL_MASK"/> TODO -->
+        <style>
+          <class name="image-button"/> <!-- TODO https://bugzilla.gnome.org/show_bug.cgi?id=756731 -->
+        </style>
+      </object>
     </child>
   </template>
 </interface>
diff --git a/editor/pathwidget.vala b/editor/pathwidget.vala
index 01e38dd..db20651 100644
--- a/editor/pathwidget.vala
+++ b/editor/pathwidget.vala
@@ -25,6 +25,8 @@ private class PathWidget : Box
     [GtkChild] private PathBar      pathbar;
     [GtkChild] private PathEntry    searchentry;
 
+    [GtkChild] private Bookmarks    bookmarks_button;
+
     internal signal void search_changed ();
     internal signal void search_stopped ();
 
@@ -75,6 +77,7 @@ private class PathWidget : Box
     {
         pathbar.set_path (type, path);
         searchentry.set_path (type, path);
+        bookmarks_button.set_path (type, path);
 
         if (type == ViewType.SEARCH && !search_mode_enabled)
             enter_search_mode ();
@@ -115,6 +118,20 @@ private class PathWidget : Box
         searchentry.prepare (mode);
     }
 
+    /* bookmarks button */
+    internal bool is_bookmarks_button_sensitive { get { return bookmarks_button.sensitive;  }}
+    internal bool is_bookmarks_button_active    { get { return bookmarks_button.active;     }}
+
+    internal string [] get_bookmarks ()
+    {
+        return bookmarks_button.get_bookmarks ();
+    }
+
+    internal void set_bookmarked (string path, bool new_state)
+    {
+        bookmarks_button.set_bookmarked (path, new_state);
+    }
+
 /*      string [] tokens = full_name.split (" ");
         uint index = 0;
         string token;
@@ -129,6 +146,28 @@ private class PathWidget : Box
             index++;
         } */
 
+    /*\
+    * * bookmarks
+    \*/
+
+    construct
+    {
+        // TODO here again, allow to use in UI file "bind-property" without "bind-source", using the 
instanciated object as source
+        bind_property ("search-mode-enabled", bookmarks_button, "sensitive", BindingFlags.SYNC_CREATE | 
BindingFlags.INVERT_BOOLEAN);
+    }
+
+    internal void close_popovers ()
+    {
+        if (bookmarks_button.active)
+            bookmarks_button.active = false;
+    }
+
+    internal void click_bookmarks_button ()
+    {
+        if (bookmarks_button.sensitive)
+            bookmarks_button.clicked ();
+    }
+
     /*\
     * * sizing
     \*/


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