[dconf-editor] Remove PathElement.



commit b80d4cdbeb7b09494c62a718fd19ce0731dad2df
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Mon Jan 8 01:19:29 2018 +0100

    Remove PathElement.

 editor/browser-view.ui       |    2 -
 editor/browser-view.vala     |   10 ++----
 editor/dconf-window.vala     |    7 +----
 editor/key-list-box-row.vala |   63 ++++++++++++++++++++++++++++--------------
 editor/registry-search.ui    |    1 -
 editor/registry-search.vala  |   23 +++++----------
 editor/registry-view.ui      |    1 -
 editor/registry-view.vala    |   17 ++++------
 8 files changed, 61 insertions(+), 63 deletions(-)
---
diff --git a/editor/browser-view.ui b/editor/browser-view.ui
index 77a5a84..3e3c566 100644
--- a/editor/browser-view.ui
+++ b/editor/browser-view.ui
@@ -17,7 +17,6 @@
         <child>
           <object class="RegistryView"  id="browse_view">
             <property name="visible">True</property>
-            <signal name="request_path" handler="request_path_test"/>
           </object>
           <packing>
             <property name="name">browse-view</property>
@@ -34,7 +33,6 @@
         <child>
           <object class="RegistrySearch"  id="search_results_view">
             <property name="visible">True</property>
-            <signal name="request_path" handler="request_path_test"/>
           </object>
           <packing>
             <property name="name">search-results-view</property>
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index f337a33..d93450f 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -26,8 +26,10 @@ public enum Behaviour {
 }
 
 [GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/browser-view.ui")]
-class BrowserView : Grid, PathElement
+class BrowserView : Grid
 {
+    public signal void request_path (string path, bool notify_missing = true, bool strict = true);
+
     private const GLib.ActionEntry [] action_entries =
     {
         { "reload", reload }
@@ -119,12 +121,6 @@ class BrowserView : Grid, PathElement
             });
     }
 
-    [GtkCallback]
-    private void request_path_test (string test)
-    {
-        request_path (test);
-    }
-
     public void set_directory (Directory directory, string? selected)
     {
         SettingsModel model = modifications_handler.model;
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index bbec383..b66f454 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -284,7 +284,7 @@ class DConfWindow : ApplicationWindow
     \*/
 
     [GtkCallback]
-    private void request_path (string full_name, bool notify_missing=true, bool strict=true)
+    private void request_path (string full_name, bool notify_missing = true, bool strict = true)
     {
 //        browser_view.set_search_mode (false);  // TODO not useful when called from bookmark
         Gtk.Settings? gtk_settings = Gtk.Settings.get_default ();
@@ -667,8 +667,3 @@ class DConfWindow : ApplicationWindow
         notification_revealer.set_reveal_child (false);
     }
 }
-
-public interface PathElement
-{
-    public signal void request_path (string path, bool notify_missing=true, bool strict=true);
-}
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index c79dd22..e3ad03a 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -76,8 +76,6 @@ private class ListBoxRowHeader : Grid
 
 private abstract class ClickableListBoxRow : EventBox
 {
-    public signal void on_row_clicked ();
-    public signal void on_open_parent ();
     public signal void on_delete_call ();
 
     public signal void on_popover_disappear ();
@@ -85,7 +83,7 @@ private abstract class ClickableListBoxRow : EventBox
 
     public abstract string get_text ();
 
-    public bool search_result_mode { protected get; construct; default=false; }
+    public bool search_result_mode { protected get; construct; default = false; }
 
     public ModificationsHandler modifications_handler { protected get; construct; }
 
@@ -167,12 +165,14 @@ private class FolderListBoxRow : ClickableListBoxRow
 {
     [GtkChild] private Label folder_name_label;
     public string full_name;
+    private string parent_path;
 
-    public FolderListBoxRow (string label, string path, bool search_result_mode=false)
+    public FolderListBoxRow (string label, string path, string _parent_path, bool search_result_mode = false)
     {
         Object (search_result_mode: search_result_mode);
         folder_name_label.set_text (search_result_mode ? path : label);
         full_name = path;
+        parent_path = _parent_path;
     }
 
     public override string get_text ()
@@ -182,13 +182,17 @@ private class FolderListBoxRow : ClickableListBoxRow
 
     protected override bool generate_popover (ContextPopover popover)  // TODO better
     {
+        Variant variant;
+
         if (search_result_mode)
         {
-            popover.new_action ("open_parent", () => on_open_parent ());
+            variant = new Variant.string (parent_path);
+            popover.new_gaction ("open_parent", "ui.open-path(" + variant.print (false) + ")");    // TODO 
selection 1/3
             popover.new_section ();
         }
 
-        popover.new_action ("open", () => on_row_clicked ());
+        variant = new Variant.string (full_name);
+        popover.new_gaction ("open", "ui.open-path(" + variant.print (false) + ")");
         popover.new_copy_action (get_text ());
 
         popover.new_section ();
@@ -305,7 +309,7 @@ private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
         key_info_label.set_label (_("No Schema Found"));
     }
 
-    public KeyListBoxRowEditableNoSchema (DConfKey _key, ModificationsHandler modifications_handler, bool 
search_result_mode=false)
+    public KeyListBoxRowEditableNoSchema (DConfKey _key, ModificationsHandler modifications_handler, bool 
search_result_mode = false)
     {
         Object (key: _key, modifications_handler: modifications_handler, search_result_mode : 
search_result_mode);
     }
@@ -344,6 +348,8 @@ private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
     protected override bool generate_popover (ContextPopover popover)
     {
         SettingsModel model = modifications_handler.model;
+        Variant variant;
+
         if (model.is_key_ghost (key))
         {
             popover.new_copy_action (get_text ());
@@ -352,11 +358,13 @@ private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
 
         if (search_result_mode)
         {
-            popover.new_action ("open_parent", () => on_open_parent ());
+            variant = new Variant.string (SettingsModel.get_parent_path (key.full_name));
+            popover.new_gaction ("open_parent", "ui.open-path(" + variant.print (false) + ")");    // TODO 
selection 2/3
             popover.new_section ();
         }
 
-        popover.new_action ("customize", () => on_row_clicked ());
+        variant = new Variant.string (key.full_name);
+        popover.new_gaction ("customize", "ui.open-path(" + variant.print (false) + ")");
         popover.new_copy_action (get_text ());
 
 
@@ -439,7 +447,7 @@ private class KeyListBoxRowEditable : KeyListBoxRow
         }
     }
 
-    public KeyListBoxRowEditable (GSettingsKey _key, ModificationsHandler modifications_handler, bool 
search_result_mode=false)
+    public KeyListBoxRowEditable (GSettingsKey _key, ModificationsHandler modifications_handler, bool 
search_result_mode = false)
     {
         Object (key: _key, modifications_handler: modifications_handler, search_result_mode : 
search_result_mode);
     }
@@ -480,9 +488,12 @@ private class KeyListBoxRowEditable : KeyListBoxRow
     protected override bool generate_popover (ContextPopover popover)
     {
         SettingsModel model = modifications_handler.model;
+        Variant variant;
+
         if (search_result_mode)
         {
-            popover.new_action ("open_parent", () => on_open_parent ());
+            variant = new Variant.string (SettingsModel.get_parent_path (key.full_name));
+            popover.new_gaction ("open_parent", "ui.open-path(" + variant.print (false) + ")");    // TODO 
selection 3/3
             popover.new_section ();
         }
 
@@ -490,7 +501,8 @@ private class KeyListBoxRowEditable : KeyListBoxRow
         bool planned_change = modifications_handler.key_has_planned_change (key);
         Variant? planned_value = modifications_handler.get_key_planned_value (key);
 
-        popover.new_action ("customize", () => on_row_clicked ());
+        variant = new Variant.string (key.full_name);
+        popover.new_gaction ("customize", "ui.open-path(" + variant.print (false) + ")");
         popover.new_copy_action (get_text ());
 
         if (key.type_string == "b" || key.type_string == "<enum>" || key.type_string == "mb"
@@ -603,9 +615,6 @@ private class ContextPopover : Popover
 
         switch (action_action)
         {
-            case "customize":
-                /* Translators: "open key-editor dialog" action in the right-click menu on the list of keys 
*/
-                current_section.append (_("Customize…"), group_dot_action);         return;
             case "default1":
                 /* Translators: "reset key value" action in the right-click menu on the list of keys */
                 current_section.append (_("Set to default"), group_dot_action);     return;
@@ -614,12 +623,6 @@ private class ContextPopover : Popover
             case "dismiss":
                 /* Translators: "dismiss change" action in the right-click menu on a key with pending 
changes */
                 current_section.append (_("Dismiss change"), group_dot_action);     return;
-            case "open":
-                /* Translators: "open folder" action in the right-click menu on a folder */
-                current_section.append (_("Open"), group_dot_action);               return;
-            case "open_parent":
-                /* Translators: "open parent folder" action in the right-click menu on a folder in a search 
result */
-                current_section.append (_("Open parent folder"), group_dot_action);               return;
             case "erase":
                 /* Translators: "erase key" action in the right-click menu on a key without schema */
                 current_section.append (_("Erase key"), group_dot_action);          return;
@@ -634,6 +637,24 @@ private class ContextPopover : Popover
         }
     }
 
+    public void new_gaction (string action_name, string action_action)
+    {
+        switch (action_name)
+        {
+            case "customize":
+                /* Translators: "open key-editor dialog" action in the right-click menu on the list of keys 
*/
+                current_section.append (_("Customize…"), action_action);            return;
+            case "open":
+                /* Translators: "open folder" action in the right-click menu on a folder */
+                current_section.append (_("Open"), action_action);                  return;
+            case "open_parent":
+                /* Translators: "open parent folder" action in the right-click menu on a folder in a search 
result */
+                current_section.append (_("Open parent folder"), action_action);    return;
+            default:
+                assert_not_reached ();
+        }
+    }
+
     public void new_copy_action (string text)
     {
         /* Translators: "copy to clipboard" action in the right-click menu on the list of keys */
diff --git a/editor/registry-search.ui b/editor/registry-search.ui
index 1a5ba84..7f42ae4 100644
--- a/editor/registry-search.ui
+++ b/editor/registry-search.ui
@@ -16,7 +16,6 @@
               <class name="keys-list"/>
               <class name="search-results-list"/>
             </style>
-            <signal name="row-activated" handler="row_activated_cb"/>
             <child type="placeholder">
               <object class="RegistryPlaceholder">
                 <property name="label" translatable="yes">No matches</property>
diff --git a/editor/registry-search.vala b/editor/registry-search.vala
index db4c0ea..a67c805 100644
--- a/editor/registry-search.vala
+++ b/editor/registry-search.vala
@@ -18,7 +18,7 @@
 using Gtk;
 
 [GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/registry-search.ui")]
-class RegistrySearch : Grid, PathElement, BrowsableView
+class RegistrySearch : Grid, BrowsableView
 {
     public Behaviour behaviour { private get; set; }
 
@@ -146,7 +146,7 @@ class RegistrySearch : Grid, PathElement, BrowsableView
 
         if (setting_object is Directory)
         {
-            row = new FolderListBoxRow (setting_object.name, setting_object.full_name, !is_local_result);
+            row = new FolderListBoxRow (setting_object.name, setting_object.full_name, 
SettingsModel.get_parent_path (setting_object.full_name), !is_local_result);
             on_delete_call_handler = row.on_delete_call.connect (() => browser_view.reset_directory 
((Directory) setting_object, true));
         }
         else
@@ -175,27 +175,26 @@ class RegistrySearch : Grid, PathElement, BrowsableView
                 });
         }
 
-        ulong on_row_clicked_handler = row.on_row_clicked.connect (() => request_path 
(setting_object.full_name));
-        ulong on_row_open_parent_handler = row.on_open_parent.connect (() => {
-                request_path (parent_path); // TODO selected
-            });
         ulong button_press_event_handler = row.button_press_event.connect (on_button_pressed);
 
         row.destroy.connect (() => {
                 row.disconnect (on_delete_call_handler);
-                row.disconnect (on_row_clicked_handler);
-                row.disconnect (on_row_open_parent_handler);
                 row.disconnect (button_press_event_handler);
             });
 
         /* Wrapper ensures max width for rows */
         ListBoxRowWrapper wrapper = new ListBoxRowWrapper ();
+
         wrapper.set_halign (Align.CENTER);
         wrapper.add (row);
         if (row is FolderListBoxRow)
             wrapper.get_style_context ().add_class ("folder-row");
         else
             wrapper.get_style_context ().add_class ("key-row");
+
+        wrapper.action_name = "ui.open-path";
+        wrapper.action_target = setting_object.full_name;
+
         return wrapper;
     }
 
@@ -232,7 +231,7 @@ class RegistrySearch : Grid, PathElement, BrowsableView
         if (selected_row == null)
             return false;
 
-        ((ClickableListBoxRow) ((!) selected_row).get_child ()).on_row_clicked ();
+        ((ClickableListBoxRow) ((!) selected_row).get_child ()).activate ();
 
         return true;
     }
@@ -268,12 +267,6 @@ class RegistrySearch : Grid, PathElement, BrowsableView
         return false;
     }
 
-    [GtkCallback]
-    private void row_activated_cb (ListBoxRow list_box_row)
-    {
-        ((ClickableListBoxRow) list_box_row.get_child ()).on_row_clicked ();
-    }
-
     public void invalidate_popovers ()
     {
         uint position = 0;
diff --git a/editor/registry-view.ui b/editor/registry-view.ui
index 664e84b..f724e5e 100644
--- a/editor/registry-view.ui
+++ b/editor/registry-view.ui
@@ -20,7 +20,6 @@
             <style>
               <class name="keys-list"/>
             </style>
-            <signal name="row-activated" handler="row_activated_cb"/>
             <child type="placeholder">
               <object class="RegistryPlaceholder">
                 <property name="label" translatable="yes">No keys in this path</property>
diff --git a/editor/registry-view.vala b/editor/registry-view.vala
index d5808af..36bf7aa 100644
--- a/editor/registry-view.vala
+++ b/editor/registry-view.vala
@@ -18,7 +18,7 @@
 using Gtk;
 
 [GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/registry-view.ui")]
-class RegistryView : Grid, PathElement, BrowsableView
+class RegistryView : Grid, BrowsableView
 {
     public Behaviour behaviour { private get; set; }
 
@@ -179,7 +179,7 @@ class RegistryView : Grid, PathElement, BrowsableView
 
         if (setting_object is Directory)
         {
-            row = new FolderListBoxRow (setting_object.name, setting_object.full_name);
+            row = new FolderListBoxRow (setting_object.name, setting_object.full_name, 
SettingsModel.get_parent_path (setting_object.full_name));
             on_delete_call_handler = row.on_delete_call.connect (() => browser_view.reset_directory 
((Directory) setting_object, true));
         }
         else
@@ -208,23 +208,26 @@ class RegistryView : Grid, PathElement, BrowsableView
                 });
         }
 
-        ulong on_row_clicked_handler = row.on_row_clicked.connect (() => request_path 
(setting_object.full_name));
         ulong button_press_event_handler = row.button_press_event.connect (on_button_pressed);
 
         row.destroy.connect (() => {
                 row.disconnect (on_delete_call_handler);
-                row.disconnect (on_row_clicked_handler);
                 row.disconnect (button_press_event_handler);
             });
 
         /* Wrapper ensures max width for rows */
         ListBoxRowWrapper wrapper = new ListBoxRowWrapper ();
+
         wrapper.set_halign (Align.CENTER);
         wrapper.add (row);
         if (row is FolderListBoxRow)
             wrapper.get_style_context ().add_class ("folder-row");
         else
             wrapper.get_style_context ().add_class ("key-row");
+
+        wrapper.action_name = "ui.open-path";
+        wrapper.action_target = setting_object.full_name;
+
         return wrapper;
     }
 
@@ -287,12 +290,6 @@ class RegistryView : Grid, PathElement, BrowsableView
         return false;
     }
 
-    [GtkCallback]
-    private void row_activated_cb (ListBoxRow list_box_row)
-    {
-        ((ClickableListBoxRow) list_box_row.get_child ()).on_row_clicked ();
-    }
-
     public void invalidate_popovers ()
     {
         uint position = 0;


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