[dconf-editor] Prepare folder rows.



commit 063f10f143a66b9939a650287bc6c67678260bf0
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Apr 29 02:14:03 2016 +0200

    Prepare folder rows.

 editor/dconf-window.vala     |   10 +++++-----
 editor/key-list-box-row.vala |   23 +++++++++++++----------
 2 files changed, 18 insertions(+), 15 deletions(-)
---
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index bde41a9..fd28a9f 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -200,7 +200,7 @@ class DConfWindow : ApplicationWindow
         {
             KeyListBoxRowEditable key_list_box_row = new KeyListBoxRowEditable ((GSettingsKey) item);
             key_list_box_row.button_press_event.connect (on_button_pressed);
-            key_list_box_row.show_dialog.connect (() => {
+            key_list_box_row.on_row_clicked.connect (() => {
                     KeyEditor key_editor = new KeyEditor ((GSettingsKey) item);
                     key_editor.set_transient_for (this);
                     key_editor.run ();
@@ -211,7 +211,7 @@ class DConfWindow : ApplicationWindow
         {
             KeyListBoxRowEditableNoSchema key_list_box_row = new KeyListBoxRowEditableNoSchema ((DConfKey) 
item);
             key_list_box_row.button_press_event.connect (on_button_pressed);
-            key_list_box_row.show_dialog.connect (() => {
+            key_list_box_row.on_row_clicked.connect (() => {
                     KeyEditorNoSchema key_editor = new KeyEditorNoSchema ((DConfKey) item);
                     key_editor.set_transient_for (this);
                     key_editor.run ();
@@ -223,7 +223,7 @@ class DConfWindow : ApplicationWindow
 
     private bool on_button_pressed (Widget widget, Gdk.EventButton event)
     {
-        ListBoxRow list_box_row = (ListBoxRow) ((KeyListBoxRow) widget).get_parent ();
+        ListBoxRow list_box_row = (ListBoxRow) widget.get_parent ();
         key_list_box.select_row (list_box_row);
         list_box_row.grab_focus ();
         return false;
@@ -234,7 +234,7 @@ class DConfWindow : ApplicationWindow
     {
         search_next_button.set_sensitive (true);        // TODO better, or maybe just hide search_bar 2/2
 
-        ((KeyListBoxRow) list_box_row.get_child ()).show_dialog ();
+        ((ClickableListBoxRow) list_box_row.get_child ()).on_row_clicked ();
     }
 
     /*\
@@ -309,7 +309,7 @@ class DConfWindow : ApplicationWindow
                 case "c":
                     ListBoxRow? selected_row = (ListBoxRow) key_list_box.get_selected_row ();
                     ConfigurationEditor application = (ConfigurationEditor) get_application ();
-                    application.copy (selected_row == null ? current_path : ((KeyListBoxRow) ((!) 
selected_row).get_child ()).get_text ());
+                    application.copy (selected_row == null ? current_path : ((ClickableListBoxRow) ((!) 
selected_row).get_child ()).get_text ());
                     return true;
                 case "C":
                     ((ConfigurationEditor) get_application ()).copy (current_path);
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index fa169ed..0584624 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -17,6 +17,13 @@
 
 using Gtk;
 
+private interface ClickableListBoxRow : Object
+{
+    public signal void on_row_clicked ();
+
+    public abstract string get_text ();
+}
+
 [GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/key-list-box-row.ui")]
 private abstract class KeyListBoxRow : EventBox
 {
@@ -24,13 +31,9 @@ private abstract class KeyListBoxRow : EventBox
     [GtkChild] protected Label key_value_label;
     [GtkChild] protected Label key_info_label;
 
-    public signal void show_dialog ();
-
     protected ContextPopover? nullable_popover;
     protected virtual bool generate_popover (ContextPopover popover) { return false; }      // no popover 
should be created
 
-    public abstract string get_text ();
-
     public override bool button_press_event (Gdk.EventButton event)     // list_box_row selection is done 
elsewhere
     {
         if (event.button == Gdk.BUTTON_SECONDARY)
@@ -58,7 +61,7 @@ private abstract class KeyListBoxRow : EventBox
     }
 }
 
-private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
+private class KeyListBoxRowEditableNoSchema : KeyListBoxRow, ClickableListBoxRow
 {
     public DConfKey key { get; private set; }
 
@@ -82,14 +85,14 @@ private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
             });
     }
 
-    protected override string get_text ()
+    protected string get_text ()
     {
         return key.full_name + " " + key.value.print (false);
     }
 
     protected override bool generate_popover (ContextPopover popover)
     {
-        popover.new_action ("customize", () => { show_dialog (); });
+        popover.new_action ("customize", () => { on_row_clicked (); });
         popover.new_copy_action (get_text ());
 
         if (key.type_string == "b" || key.type_string == "mb")
@@ -107,7 +110,7 @@ private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
     }
 }
 
-private class KeyListBoxRowEditable : KeyListBoxRow
+private class KeyListBoxRowEditable : KeyListBoxRow, ClickableListBoxRow
 {
     public GSettingsKey key { get; private set; }
 
@@ -129,14 +132,14 @@ private class KeyListBoxRowEditable : KeyListBoxRow
             });
     }
 
-    protected override string get_text ()
+    protected string get_text ()
     {
         return key.schema_id + " " + key.name + " " + key.value.print (false);
     }
 
     protected override bool generate_popover (ContextPopover popover)
     {
-        popover.new_action ("customize", () => { show_dialog (); });
+        popover.new_action ("customize", () => { on_row_clicked (); });
         popover.new_copy_action (get_text ());
 
         if (key.type_string == "b" || key.type_string == "<enum>" || key.type_string == "mb")


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