[dconf-editor] Use a GAction to change path.



commit 8f3dc4df79633ac019831284d80ee6b72ae5cb60
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Tue Sep 27 17:13:59 2016 +0200

    Use a GAction to change path.

 editor/dconf-window.vala |    8 ++++++++
 editor/pathbar-item.ui   |    1 +
 editor/pathbar.ui        |    2 ++
 editor/pathbar.vala      |    9 ++-------
 4 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 499b358..1f9b038 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -30,6 +30,8 @@ class DConfWindow : ApplicationWindow
 {
     private const GLib.ActionEntry [] action_entries =
     {
+        { "open-path", open_path, "s" },
+
         { "reset-recursive", reset_recursively },
         { "reset-visible", reset },
         { "enter-delay-mode", enter_delay_mode }
@@ -264,6 +266,12 @@ class DConfWindow : ApplicationWindow
     * * Action entries
     \*/
 
+    private void open_path (SimpleAction action, Variant? path_variant)
+        requires (path_variant != null)
+    {
+        request_path (((!) path_variant).get_string ());
+    }
+
     private void reset ()
     {
         registry_view.reset (false);
diff --git a/editor/pathbar-item.ui b/editor/pathbar-item.ui
index 47b76c2..0934642 100644
--- a/editor/pathbar-item.ui
+++ b/editor/pathbar-item.ui
@@ -3,6 +3,7 @@
   <!-- interface-requires gtk+ 3.0 -->
   <template class="PathBarItem" parent="GtkButton">
     <property name="focus-on-click">False</property>
+    <property name="action-name">win.open-path</property>
     <child>
       <object class="GtkLabel" id="text_label">
         <property name="visible">True</property>
diff --git a/editor/pathbar.ui b/editor/pathbar.ui
index 029b8ea..1db278d 100644
--- a/editor/pathbar.ui
+++ b/editor/pathbar.ui
@@ -10,6 +10,8 @@
       <object class="GtkButton" id="root_button">
         <property name="visible">True</property>
         <property name="focus-on-click">False</property>
+        <property name="action-name">win.open-path</property>
+        <property name="action-target">'/'</property>
         <child>
           <object class="GtkLabel">
             <style>
diff --git a/editor/pathbar.vala b/editor/pathbar.vala
index 939bca4..56f5037 100644
--- a/editor/pathbar.vala
+++ b/editor/pathbar.vala
@@ -27,7 +27,6 @@ public class PathBar : Box, PathElement
     construct
     {
         add_slash_label ();
-        root_button.clicked.connect (() => request_path ("/"));
     }
 
     /*\
@@ -77,7 +76,6 @@ public class PathBar : Box, PathElement
                     return;
                 }
 
-                child.disconnect (((PathBarItem) child).path_bar_item_clicked_handler);
                 child.destroy ();
                 destroy_all = true;
             });
@@ -142,11 +140,10 @@ public class PathBar : Box, PathElement
     private void add_path_bar_item (string label, string complete_path, bool block)
     {
         PathBarItem path_bar_item = new PathBarItem (label);
-
-        path_bar_item.path_bar_item_clicked_handler = path_bar_item.clicked.connect (() => request_path 
(complete_path));
-        activate_item (path_bar_item, block);
+        path_bar_item.action_target = new Variant.string (complete_path);
 
         add (path_bar_item);
+        activate_item (path_bar_item, block);   // has to be after add()
     }
 
     private void activate_item (Widget item, bool state)
@@ -164,8 +161,6 @@ public class PathBar : Box, PathElement
 [GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/pathbar-item.ui")]
 private class PathBarItem : Button
 {
-    public ulong path_bar_item_clicked_handler = 0;
-
     public string text_string { get; construct; }
     [GtkChild] private Label text_label;
 


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