[dconf-editor] Rework a bit copy.



commit f4eb112ece4ac298428ebfdede82325dd5b8ad9c
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Mon Dec 17 14:24:58 2018 +0100

    Rework a bit copy.

 editor/about-list.vala             |  25 +++---
 editor/adaptative-pathbar.vala     |   2 +-
 editor/base-view.vala              |   7 +-
 editor/base-window.vala            | 179 +++++++++++++++++++++++++++++++++++++
 editor/bookmarks-list.vala         |   5 +-
 editor/bookmarks.vala              |   5 ++
 editor/browser-stack.vala          |  25 ++++--
 editor/browser-view.vala           |  20 +++--
 editor/browser-window.vala         | 100 +--------------------
 editor/dconf-editor.css            |  10 ++-
 editor/dconf-editor.vala           |  12 +--
 editor/dconf-headerbar.vala        |   7 ++
 editor/dconf-window.vala           |  33 ++++---
 editor/delayed-setting-view.vala   |   5 +-
 editor/modifications-revealer.vala |   7 ++
 editor/overlayed-list.vala         |  16 ++--
 editor/registry-info.vala          |  22 +++--
 editor/registry-list.vala          |  15 ++--
 editor/registry-search.vala        |  17 ++--
 editor/registry-view.vala          |   4 +-
 20 files changed, 329 insertions(+), 187 deletions(-)
---
diff --git a/editor/about-list.vala b/editor/about-list.vala
index 86dbda2..65ae5db 100644
--- a/editor/about-list.vala
+++ b/editor/about-list.vala
@@ -82,7 +82,7 @@ private class AboutList : OverlayedList
     private static inline void show_apropos (ref GLib.ListStore main_list_store)
     {
         main_list_store.remove_all ();
-        main_list_store.append (new AboutListItem.from_icon_name    (AboutDialogInfos.logo_icon_name));
+        main_list_store.append (new AboutListItem.from_icon_name    (AboutDialogInfos.logo_icon_name, 
AboutDialogInfos.program_name));
         main_list_store.append (new AboutListItem.from_label        (AboutDialogInfos.program_name, 
"bold-label"));
         main_list_store.append (new AboutListItem.from_label        (AboutDialogInfos.version));
         main_list_store.append (new AboutListItem.from_label        (AboutDialogInfos.comments));
@@ -98,7 +98,7 @@ private class AboutList : OverlayedList
     private static inline void show_credits (ref GLib.ListStore main_list_store)
     {
         main_list_store.remove_all ();
-        main_list_store.append (new AboutListItem.from_icon_name    (AboutDialogInfos.logo_icon_name));
+        main_list_store.append (new AboutListItem.from_icon_name    (AboutDialogInfos.logo_icon_name, 
AboutDialogInfos.program_name));
         main_list_store.append (new AboutListItem.from_label        (AboutDialogInfos.program_name, 
"bold-label"));
 
         string authors = "";
@@ -119,18 +119,12 @@ private class AboutList : OverlayedList
 
 private class AboutListItem : OverlayedListRow
 {
-    [CCode (notify = false)] public string? copy_text { internal get; construct; default = null; }
+    [CCode (notify = false)] public string copy_text { internal get; construct; default = ""; }
 
-    internal override string? get_copy_text ()
+    internal override bool handle_copy_text (out string text)
     {
-        string? nullable_selection = Clipboard.@get (Gdk.SELECTION_PRIMARY).wait_for_text ();
-        if (nullable_selection != null)
-        {
-             string selection = ((!) nullable_selection).dup ();
-             if (selection != "" && copy_text != null && selection in (!) copy_text)
-                return selection;
-        }
-        return copy_text;
+        text = copy_text;
+        return true;
     }
 
     internal AboutListItem.from_label (string text, string? css_class = null)
@@ -144,13 +138,16 @@ private class AboutListItem : OverlayedListRow
         label.wrap = true;
         label.justify = Justification.CENTER;
         label.selectable = true;
+        label.can_focus = false;
         if (css_class != null)
             label.get_style_context ().add_class ((!) css_class);
         add (label);
     }
 
-    internal AboutListItem.from_icon_name (string icon_name)
+    internal AboutListItem.from_icon_name (string icon_name, string copy_text)
     {
+        Object (copy_text: copy_text);
+
         Image image = new Image.from_icon_name (icon_name, IconSize.DIALOG);
         image.pixel_size = 128;
         image.visible = true;
@@ -158,7 +155,7 @@ private class AboutListItem : OverlayedListRow
         add (image);
     }
 
-    internal AboutListItem.from_link (string link, string text)
+    internal AboutListItem.from_link (string link, string text) // TODO do not allow button focus, and 
activate it on row activation
     {
         Object (copy_text: link);
 
diff --git a/editor/adaptative-pathbar.vala b/editor/adaptative-pathbar.vala
index 98395b4..07472b5 100644
--- a/editor/adaptative-pathbar.vala
+++ b/editor/adaptative-pathbar.vala
@@ -212,6 +212,6 @@ private interface Pathbar
     /* called from inside the pathbar, by ShortPathbar and LargePathbarItem (so cannot make "protected") */
     internal static void add_copy_path_entry (ref GLib.Menu section)
     {
-        section.append (_("Copy current path"), "key.copy-path"); // or "app.copy(\"" + 
get_action_target_value ().get_string () + "\")"
+        section.append (_("Copy current path"), "base.copy-alt"); // or "app.copy(\"" + 
get_action_target_value ().get_string () + "\")"
     }
 }
diff --git a/editor/base-view.vala b/editor/base-view.vala
index bc2e16e..b045426 100644
--- a/editor/base-view.vala
+++ b/editor/base-view.vala
@@ -22,11 +22,12 @@ private class BaseView : Stack, AdaptativeWidget
 {
     [GtkChild] protected Grid current_child_grid;
 
-    internal virtual string? get_copy_text ()
+    internal virtual bool handle_copy_text (out string copy_text)
     {
         if (in_window_about)
-            return about_list.get_copy_text (); // TODO copying logo...
-        return null;
+            return about_list.handle_copy_text (out copy_text); // TODO copying logo...
+        else
+            return BaseWindow.no_copy_text (out copy_text);
     }
 
     internal virtual void close_popovers () {}
diff --git a/editor/base-window.vala b/editor/base-window.vala
index 913658e..9c00755 100644
--- a/editor/base-window.vala
+++ b/editor/base-window.vala
@@ -59,10 +59,189 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
 
     private const GLib.ActionEntry [] action_entries =
     {
+        { "copy",               copy                },  // <P>c
+        { "copy-alt",           copy_alt            },  // <P>C
+
+        { "paste",              paste               },  // <P>v
+        { "paste-alt",          paste_alt           },  // <P>V
+
+        { "toggle-hamburger",   toggle_hamburger    },  // F10
+        { "menu",               menu_pressed        },  // Menu
+
         { "show-default-view",  show_default_view },
         { "about",              about }
     };
 
+    /*\
+    * * keyboard copy actions
+    \*/
+
+    protected virtual bool handle_copy_text (out string copy_text)
+    {
+        return base_view.handle_copy_text (out copy_text);
+    }
+    protected virtual bool get_alt_copy_text (out string copy_text)
+    {
+        return no_copy_text (out copy_text);
+    }
+    internal static bool no_copy_text (out string copy_text)
+    {
+        copy_text = "";
+        return false;
+    }
+    internal static bool copy_clipboard_text (out string copy_text)
+    {
+        string? nullable_selection = Clipboard.@get (Gdk.SELECTION_PRIMARY).wait_for_text ();
+        if (nullable_selection != null)
+        {
+             string selection = ((!) nullable_selection).dup ();
+             if (selection != "")
+             {
+                copy_text = selection;
+                return true;
+             }
+        }
+        return no_copy_text (out copy_text);
+    }
+    internal static inline bool is_empty_text (string text)
+    {
+        return text == "";
+    }
+
+    private void copy (/* SimpleAction action, Variant? path_variant */)
+    {
+        Widget? focus = get_focus ();
+        if (focus != null)
+        {
+            if ((!) focus is Editable)  // GtkEntry, GtkSearchEntry, GtkSpinButton
+            {
+                int garbage1, garbage2;
+                if (((Editable) (!) focus).get_selection_bounds (out garbage1, out garbage2))
+                {
+                    ((Editable) (!) focus).copy_clipboard ();
+                    return;
+                }
+            }
+            else if ((!) focus is TextView)
+            {
+                if (((TextView) (!) focus).get_buffer ().get_has_selection ())
+                {
+                    ((TextView) (!) focus).copy_clipboard ();
+                    return;
+                }
+            }
+            else if ((!) focus is Label)
+            {
+                int garbage1, garbage2;
+                if (((Label) (!) focus).get_selection_bounds (out garbage1, out garbage2))
+                {
+                    ((Label) (!) focus).copy_clipboard ();
+                    return;
+                }
+            }
+        }
+
+        base_view.close_popovers ();
+
+        string text;
+        if (handle_copy_text (out text))
+            copy_text (text);
+    }
+
+    private void copy_alt (/* SimpleAction action, Variant? path_variant */)
+    {
+        if (base_view.is_in_in_window_mode ())        // TODO better
+            return;
+
+        base_view.close_popovers ();
+
+        string text;
+        if (get_alt_copy_text (out text))
+            copy_text (text);
+    }
+
+    private inline void copy_text (string text)
+        requires (!is_empty_text (text))
+    {
+        ((ConfigurationEditor) get_application ()).copy ((!) text);
+    }
+
+    /*\
+    * * keyboard paste actions
+    \*/
+
+    protected virtual void paste_text (string? text) {}
+
+    private void paste (/* SimpleAction action, Variant? variant */)
+    {
+        if (base_view.is_in_in_window_mode ())
+            return;
+
+        Widget? focus = get_focus ();
+        if (focus != null)
+        {
+            if ((!) focus is Entry)
+            {
+                ((Entry) (!) focus).paste_clipboard ();
+                return;
+            }
+            if ((!) focus is TextView)
+            {
+                ((TextView) (!) focus).paste_clipboard ();
+                return;
+            }
+        }
+
+        paste_clipboard_content ();
+    }
+
+    private void paste_alt (/* SimpleAction action, Variant? variant */)
+    {
+        close_in_window_panels ();
+
+        paste_clipboard_content ();
+    }
+
+    private void paste_clipboard_content ()
+    {
+        Gdk.Display? display = Gdk.Display.get_default ();
+        if (display == null)    // ?
+            return;
+
+        string? clipboard_content;
+        if (get_clipboard_content (out clipboard_content))
+            paste_text (clipboard_content);
+    }
+
+    private static inline bool get_clipboard_content (out string? clipboard_content)
+    {
+        Gdk.Display? display = Gdk.Display.get_default ();
+        if (display == null)            // ?
+        {
+            clipboard_content = null;   // garbage
+            return false;
+        }
+
+        clipboard_content = Clipboard.get_default ((!) display).wait_for_text ();
+        return true;
+    }
+
+    /*\
+    * * keyboard open menus actions
+    \*/
+
+    private void toggle_hamburger (/* SimpleAction action, Variant? variant */)
+    {
+        headerbar.toggle_hamburger_menu ();
+        base_view.close_popovers ();
+    }
+
+    protected virtual void menu_pressed (/* SimpleAction action, Variant? variant */)
+    {
+        headerbar.toggle_hamburger_menu ();
+        base_view.close_popovers ();
+    }
+
     /*\
     * * global callbacks
     \*/
diff --git a/editor/bookmarks-list.vala b/editor/bookmarks-list.vala
index 5d5450d..c6ed5fc 100644
--- a/editor/bookmarks-list.vala
+++ b/editor/bookmarks-list.vala
@@ -534,9 +534,10 @@ private class Bookmark : OverlayedListRow
             set_detailed_action_name (inactive_action_name);
     }
 
-    internal override string? get_copy_text ()
+    internal override bool handle_copy_text (out string copy_text)
     {
-        return bookmark_name;
+        copy_text = bookmark_name;
+        return true;
     }
 
     /*\
diff --git a/editor/bookmarks.vala b/editor/bookmarks.vala
index 4ef3594..683607a 100644
--- a/editor/bookmarks.vala
+++ b/editor/bookmarks.vala
@@ -212,6 +212,11 @@ private class Bookmarks : MenuButton
         return bookmarks_list.previous_match ();
     }
 
+    internal bool handle_copy_text (out string copy_text)
+    {
+        return bookmarks_list.handle_copy_text (out copy_text);
+    }
+
     internal void bookmark_current_path ()
     {
         if (bookmarked_switch.get_active ())
diff --git a/editor/browser-stack.vala b/editor/browser-stack.vala
index 8a8951f..96aa040 100644
--- a/editor/browser-stack.vala
+++ b/editor/browser-stack.vala
@@ -88,13 +88,20 @@ private class BrowserStack : Grid, AdaptativeWidget
         stack.set_transition_type (is_ancestor && current_view != ViewType.SEARCH ? 
StackTransitionType.CROSSFADE : StackTransitionType.NONE);
     }
 
-    internal void select_row (string selected, uint16 last_context_id)
+    internal void select_row (string selected, uint16 last_context_id, bool grab_focus_if_needed)
         requires (ViewType.displays_objects_list (current_view))
     {
         if (selected == "")
-            ((RegistryList) stack.get_visible_child ()).select_first_row ();
+        {
+            if (current_view == ViewType.SEARCH)
+                ((RegistrySearch) stack.get_visible_child ()).select_first_row ();
+            else if (current_view == ViewType.FOLDER)
+                ((RegistryView) stack.get_visible_child ()).select_first_row (grab_focus_if_needed);
+            else
+                assert_not_reached ();
+        }
         else
-            ((RegistryList) stack.get_visible_child ()).select_row_named (selected, last_context_id, 
current_view == ViewType.FOLDER);
+            ((RegistryList) stack.get_visible_child ()).select_row_named (selected, last_context_id, 
(current_view == ViewType.FOLDER) && grab_focus_if_needed);
     }
 
     internal void prepare_object_view (string full_name, uint16 context_id, Variant properties, bool 
is_parent)
@@ -130,18 +137,18 @@ private class BrowserStack : Grid, AdaptativeWidget
             search_view.clean ();
     }
 
-    internal string? get_copy_text ()
+    internal bool handle_copy_text (out string copy_text)
     {
-        return ((BrowsableView) stack.get_visible_child ()).get_copy_text ();
+        return ((BrowsableView) stack.get_visible_child ()).handle_copy_text (out copy_text);
     }
 
-    internal string? get_copy_path_text ()
+    internal bool handle_alt_copy_text (out string copy_text)
     {
         if (current_view == ViewType.SEARCH)
-            return search_view.get_copy_path_text ();
+            return search_view.handle_alt_copy_text (out copy_text);
 
         warning ("BrowserView get_copy_path_text() called but current view is not search results view.");
-        return null;
+        return BaseWindow.no_copy_text (out copy_text);
     }
 
     internal bool toggle_row_popover ()
@@ -252,5 +259,5 @@ private class BrowserStack : Grid, AdaptativeWidget
 
 private interface BrowsableView
 {
-    internal abstract string? get_copy_text ();
+    internal abstract bool handle_copy_text (out string copy_text);
 }
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index 3ce29ec..c51b980 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -400,7 +400,7 @@ private class BrowserView : BaseView, AdaptativeWidget
     internal void select_row (string selected)
         requires (ViewType.displays_objects_list (current_view))
     {
-        current_child.select_row (selected, last_context_id);
+        current_child.select_row (selected, last_context_id, !is_in_in_window_mode ());
     }
 
     internal void prepare_object_view (string full_name, uint16 context_id, Variant properties, bool 
is_parent)
@@ -530,18 +530,20 @@ private class BrowserView : BaseView, AdaptativeWidget
 
     // current row property
     internal string get_selected_row_name () { return current_child.get_selected_row_name (); }
-    internal override string? get_copy_text ()
+    internal override bool handle_copy_text (out string copy_text)
     {
         if (in_window_bookmarks)
-            return bookmarks_list.get_copy_text ();
+            return bookmarks_list.handle_copy_text (out copy_text);
         if (in_window_modifications)
-            return modifications_list.get_copy_text ();
-        string? base_copy_text = base.get_copy_text ();
-        if (base_copy_text != null)
-            return base_copy_text;
-        return current_child.get_copy_text ();
+            return modifications_list.handle_copy_text (out copy_text);
+        if (base.handle_copy_text (out copy_text))
+            return true;
+        return current_child.handle_copy_text (out copy_text);
+    }
+    internal bool handle_alt_copy_text (out string copy_text)
+    {
+        return current_child.handle_alt_copy_text (out copy_text);
     }
-    internal string? get_copy_path_text ()   { return current_child.get_copy_path_text ();    }
 
     // values changes
     internal void gkey_value_push (string full_name, uint16 context_id, Variant key_value, bool 
is_key_default)
diff --git a/editor/browser-window.vala b/editor/browser-window.vala
index e4174c4..7129736 100644
--- a/editor/browser-window.vala
+++ b/editor/browser-window.vala
@@ -401,9 +401,6 @@ private abstract class BrowserWindow : BaseWindow
 
     private const GLib.ActionEntry [] key_action_entries =
     {
-        { "copy",               copy                },  // <P>c
-        { "copy-path",          copy_path           },  // <P>C
-
         { "next-match",         next_match          },  // <P>g // usual shortcut for "next-match"     in a 
SearchEntry; see also "Down"
         { "previous-match",     previous_match      },  // <P>G // usual shortcut for "previous-match" in a 
SearchEntry; see also "Up"
 
@@ -413,62 +410,12 @@ private abstract class BrowserWindow : BaseWindow
         { "edit-path-end",      edit_path_end       },  // <P>l
         { "edit-path-last",     edit_path_last      },  // <P>L
 
-        { "paste",              paste               },  // <P>v
-        { "paste-force",        paste_force         },  // <P>V
-
         { "open-root",          open_root           },  // <S><A>Up
         { "open-parent",        open_current_parent },  //    <A>Up
         { "open-child",         open_child          },  //    <A>Down
         { "open-last-child",    open_last_child     },  // <S><A>Down
-
-        { "toggle-hamburger",   toggle_hamburger    },  // F10
-        { "menu",               menu_pressed        },  // Menu
     };
 
-    /*\
-    * * keyboard copy actions
-    \*/
-
-    protected abstract string get_copy_text ();
-    protected abstract string get_copy_path_text ();
-
-    private void copy                                   (/* SimpleAction action, Variant? path_variant */)
-    {
-        Widget? focus = get_focus ();
-        if (focus != null)
-        {
-            if ((!) focus is Entry)
-            {
-                ((Entry) (!) focus).copy_clipboard ();
-                return;
-            }
-            if ((!) focus is TextView)
-            {
-                ((TextView) (!) focus).copy_clipboard ();
-                return;
-            }
-        }
-
-        browser_view.close_popovers ();
-
-        _copy (get_copy_text ());
-    }
-
-    private void copy_path                              (/* SimpleAction action, Variant? path_variant */)
-    {
-        if (is_in_in_window_mode ())        // TODO better
-            return;
-
-        browser_view.close_popovers ();
-
-        _copy (get_copy_path_text ());
-    }
-
-    private inline void _copy (string text)
-    {
-        ((ConfigurationEditor) get_application ()).copy (text);
-    }
-
     /*\
     * * keyboard "Down" and "<Primary>g" (next match), "Up" and "<Primary><Shift>G" (previous match)
     \*/
@@ -562,44 +509,10 @@ private abstract class BrowserWindow : BaseWindow
     * * keyboard paste actions
     \*/
 
-    private void paste                                  (/* SimpleAction action, Variant? variant */)
+    protected override void paste_text (string? text)
     {
-        if (is_in_in_window_mode ())
-            return;
-
-        Widget? focus = get_focus ();
-        if (focus != null)
-        {
-            if ((!) focus is Entry)
-            {
-                ((Entry) (!) focus).paste_clipboard ();
-                return;
-            }
-            if ((!) focus is TextView)
-            {
-                ((TextView) (!) focus).paste_clipboard ();
-                return;
-            }
-        }
-
-        search_clipboard_content ();
-    }
-
-    private void paste_force                            (/* SimpleAction action, Variant? variant */)
-    {
-        close_in_window_panels ();
-        search_clipboard_content ();
-    }
-
-    private void search_clipboard_content ()
-    {
-        Gdk.Display? display = Gdk.Display.get_default ();
-        if (display == null)    // ?
-            return;
-
-        string? clipboard_content = Clipboard.get_default ((!) display).wait_for_text ();
-        if (clipboard_content != null)
-            request_search (true, PathEntry.SearchMode.EDIT_PATH_MOVE_END, clipboard_content);
+        if (text != null)
+            request_search (true, PathEntry.SearchMode.EDIT_PATH_MOVE_END, text);
         else
             request_search (true, PathEntry.SearchMode.SEARCH);
     }
@@ -635,12 +548,7 @@ private abstract class BrowserWindow : BaseWindow
     * * keyboard open menus actions
     \*/
 
-    private void toggle_hamburger                       (/* SimpleAction action, Variant? variant */)
-    {
-        headerbar.toggle_hamburger_menu ();
-    }
-
-    private void menu_pressed                           (/* SimpleAction action, Variant? variant */)
+    protected override void menu_pressed ()
     {
         if (browser_view.toggle_row_popover ()) // handles in-window bookmarks
             headerbar.close_popovers ();
diff --git a/editor/dconf-editor.css b/editor/dconf-editor.css
index e7a3f2f..0b0526c 100644
--- a/editor/dconf-editor.css
+++ b/editor/dconf-editor.css
@@ -143,10 +143,18 @@
 \*/
 
 .about-list            > scrolledwindow > viewport > list > row {
-  padding:4px;
   min-height:1.3rem;
 }
 
+.about-list            > scrolledwindow > viewport > list > row > label {
+  margin:4px;
+}
+
+.about-list            > scrolledwindow > viewport > list > row > button {
+  margin-top:2px;
+  margin-bottom:2px;
+}
+
 /*\
 * * lists rows height and icon
 \*/
diff --git a/editor/dconf-editor.vala b/editor/dconf-editor.vala
index c437b27..84a8721 100644
--- a/editor/dconf-editor.vala
+++ b/editor/dconf-editor.vala
@@ -297,8 +297,8 @@ private class ConfigurationEditor : Gtk.Application
         add_action_entries (action_entries, this);
         set_accels_for_action ("kbd.toggle-bookmark",   {        "<Primary>b",
                                                           "<Shift><Primary>b" });
-        set_accels_for_action ("key.copy",              {        "<Primary>c" });
-        set_accels_for_action ("key.copy-path",         { "<Shift><Primary>c" });
+        set_accels_for_action ("base.copy",             {        "<Primary>c" });
+        set_accels_for_action ("base.copy-alt",         { "<Shift><Primary>c" });
         set_accels_for_action ("kbd.bookmark",          {        "<Primary>d" });
         set_accels_for_action ("kbd.unbookmark",        { "<Shift><Primary>d" });
         set_accels_for_action ("key.toggle-search",     {        "<Primary>f" });   // TODO 
<Shift><Primary>f something?
@@ -310,17 +310,17 @@ private class ConfigurationEditor : Gtk.Application
         set_accels_for_action ("key.edit-path-last",    { "<Shift><Primary>l" });
         set_accels_for_action ("app.quit",              {        "<Primary>q" });
         set_accels_for_action ("app.apply-and-quit",    { "<Shift><Primary>q" });
-        set_accels_for_action ("key.paste",             {        "<Primary>v" });   // 
https://bugzilla.gnome.org/show_bug.cgi?id=762257 is WONTFIX
-        set_accels_for_action ("key.paste-force",       { "<Shift><Primary>v" });
+        set_accels_for_action ("base.paste",            {        "<Primary>v" });   // 
https://bugzilla.gnome.org/show_bug.cgi?id=762257 is WONTFIX
+        set_accels_for_action ("base.paste-alt",        { "<Shift><Primary>v" });
 
         set_accels_for_action ("key.open-root",         { "<Shift><Alt>Up"    });
         set_accels_for_action ("key.open-parent",       {        "<Alt>Up"    });
         set_accels_for_action ("key.open-child",        {        "<Alt>Down"  });
         set_accels_for_action ("key.open-last-child",   { "<Shift><Alt>Down"  });
 
-        set_accels_for_action ("key.toggle-hamburger",  {          "F10"      });
+        set_accels_for_action ("base.toggle-hamburger", {          "F10"      });
         set_accels_for_action ("kbd.escape",            {          "Escape"   });
-        set_accels_for_action ("key.menu",              {          "Menu"     });
+        set_accels_for_action ("base.menu",             {          "Menu"     });
 
         set_accels_for_action ("kbd.set-to-default",    { "<Primary>Delete",
                                                           "<Primary>KP_Delete",
diff --git a/editor/dconf-headerbar.vala b/editor/dconf-headerbar.vala
index b593e4b..56051e7 100644
--- a/editor/dconf-headerbar.vala
+++ b/editor/dconf-headerbar.vala
@@ -477,6 +477,13 @@ private class DConfHeaderBar : BrowserHeaderBar, AdaptativeWidget
         return base.previous_match ();  // false
     }
 
+    internal bool handle_copy_text (out string copy_text)
+    {
+        if (bookmarks_button.active)
+            return bookmarks_button.handle_copy_text (out copy_text);
+        return BaseWindow.no_copy_text (out copy_text);
+    }
+
     /*\
     * * popovers methods
     \*/
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index f596c7f..8800a1b 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -994,28 +994,35 @@ private class DConfWindow : BrowserWindow
     * * navigation helpers
     \*/
 
-    protected override string get_copy_text ()
+    protected override bool handle_copy_text (out string copy_text)
     {
         model.copy_action_called ();
 
-        string? selected_row_text = browser_view.get_copy_text ();
-        if (selected_row_text == null && current_type == ViewType.OBJECT)
-            selected_row_text = model.get_suggested_key_copy_text (current_path, 
browser_view.last_context_id);
-        return selected_row_text == null ? current_path : (!) selected_row_text;
+        if (headerbar.handle_copy_text (out copy_text))     // for bookmarks popovers
+            return true;
+        if (revealer.handle_copy_text (out copy_text))      // for delayed settings popovers
+            return true;
+        if (browser_view.handle_copy_text (out copy_text))  // for in-window panels and for content
+            return true;
+        if (current_type == ViewType.OBJECT)
+            copy_text = model.get_suggested_key_copy_text (current_path, browser_view.last_context_id);
+        if (BaseWindow.is_empty_text (copy_text))
+            copy_text = current_path;
+        return true;
     }
 
-    protected override string get_copy_path_text ()
+    protected override bool get_alt_copy_text (out string copy_text)
     {
+        model.copy_action_called ();
+
         if (headerbar.search_mode_enabled)
         {
-            model.copy_action_called ();
-            return browser_view.get_copy_path_text () ?? saved_view;
+            if (!browser_view.handle_alt_copy_text (out copy_text))
+                copy_text = saved_view;
         }
-
-        if (browser_view.current_view == ViewType.OBJECT)
-            model.copy_action_called ();
-
-        return current_path;
+        else
+            copy_text = current_path;
+        return true;
     }
 
     /*\
diff --git a/editor/delayed-setting-view.vala b/editor/delayed-setting-view.vala
index ef5fd5a..9421682 100644
--- a/editor/delayed-setting-view.vala
+++ b/editor/delayed-setting-view.vala
@@ -50,9 +50,10 @@ private class DelayedSettingView : OverlayedListRow
         }
     }
 
-    internal override string? get_copy_text ()
+    internal override bool handle_copy_text (out string copy_text)
     {
-        return full_name;
+        copy_text = full_name;
+        return true;
     }
 
     /*\
diff --git a/editor/modifications-revealer.vala b/editor/modifications-revealer.vala
index 8f72c0d..752800e 100644
--- a/editor/modifications-revealer.vala
+++ b/editor/modifications-revealer.vala
@@ -149,6 +149,13 @@ private class ModificationsRevealer : Revealer, AdaptativeWidget
         return modifications_list.previous_match ();
     }
 
+    internal bool handle_copy_text (out string copy_text)
+    {
+        if (delayed_list_button.active)
+            return modifications_list.handle_copy_text (out copy_text);
+        return BaseWindow.no_copy_text (out copy_text);
+    }
+
     /*\
     * * Modifications list public functions
     \*/
diff --git a/editor/overlayed-list.vala b/editor/overlayed-list.vala
index 9515e8c..f3a48f5 100644
--- a/editor/overlayed-list.vala
+++ b/editor/overlayed-list.vala
@@ -221,11 +221,11 @@ private abstract class OverlayedList : Overlay, AdaptativeWidget
         adjustment.set_value (adjustment.get_upper ());
     }
 
-    internal string? get_copy_text ()
+    internal bool handle_copy_text (out string copy_text)
     {
-        return _get_copy_text (ref main_list_box);
+        return _handle_copy_text (out copy_text, ref main_list_box);
     }
-    private static inline string? _get_copy_text (ref ListBox main_list_box)
+    private static inline bool _handle_copy_text (out string copy_text, ref ListBox main_list_box)
     {
         List<weak ListBoxRow> selected_rows = main_list_box.get_selected_rows ();
         OverlayedListRow row;
@@ -234,7 +234,9 @@ private abstract class OverlayedList : Overlay, AdaptativeWidget
             case 0:
                 Widget? focus_child = main_list_box.get_focus_child ();
                 if (focus_child == null)
-                    return null;
+                    return BaseWindow.copy_clipboard_text (out copy_text);
+                if (BaseWindow.copy_clipboard_text (out copy_text))
+                    return true;
                 if (!((!) focus_child is OverlayedListRow))
                     assert_not_reached ();
                 row = (OverlayedListRow) (!) focus_child;
@@ -246,9 +248,9 @@ private abstract class OverlayedList : Overlay, AdaptativeWidget
                 row = (OverlayedListRow) selected_row;
                 break;
             default:
-                return null;
+                return BaseWindow.no_copy_text (out copy_text);
         }
-        return row.get_copy_text ();  // FIXME row should keep focus
+        return row.handle_copy_text (out copy_text);  // FIXME row should keep focus
     }
 
     /*\
@@ -377,5 +379,5 @@ private abstract class OverlayedList : Overlay, AdaptativeWidget
 
 private abstract class OverlayedListRow : ListBoxRow
 {
-    internal abstract string? get_copy_text ();
+    internal abstract bool handle_copy_text (out string copy_text);
 }
diff --git a/editor/registry-info.vala b/editor/registry-info.vala
index 06b31b5..9eead2c 100644
--- a/editor/registry-info.vala
+++ b/editor/registry-info.vala
@@ -389,15 +389,18 @@ private class RegistryInfo : Grid, BrowsableView
         return Key.cool_text_value_from_variant ((!) key_value);
     }
 
-    internal string? get_copy_text () // can compile with "private", but is public 2/2
+    internal bool handle_copy_text (out string copy_text) // can compile with "private", but is public 2/2
     {
+        if (BaseWindow.copy_clipboard_text (out copy_text))
+            return true;
+
         Widget? focused_row = properties_list_box.get_focus_child ();
         if (focused_row == null)
-            return null;
+            return BaseWindow.no_copy_text (out copy_text);
         else if ((!) focused_row is PropertyRow)
-            return ((PropertyRow) (!) focused_row).get_copy_text ();
+            return ((PropertyRow) (!) focused_row).handle_copy_text (out copy_text);
         else    // separator
-            return null;
+            return BaseWindow.no_copy_text (out copy_text);
     }
 
     private static void on_value_has_changed (ModificationsHandler _modifications_handler, KeyEditorChild 
key_editor_child, string full_name, uint16 context_id, bool has_schema, string type_code, bool is_valid)
@@ -613,6 +616,8 @@ private class PropertyRow : ListBoxRowWrapper
         value_label.yalign = 0;
         value_label.wrap = true;
         value_label.wrap_mode = Pango.WrapMode.WORD_CHAR;
+        value_label.selectable = true;
+        value_label.can_focus = false;
 
         StyleContext context = value_label.get_style_context ();
         if (use_italic)
@@ -651,11 +656,14 @@ private class PropertyRow : ListBoxRowWrapper
         grid.valign = Align.CENTER;
     }
 
-    internal string? get_copy_text ()
+    internal bool handle_copy_text (out string copy_text)
     {
         if (value_widget != null)
-            return ((Label) (!) value_widget).get_label ();
+        {
+            copy_text = ((Label) (!) value_widget).get_label ();
+            return true;
+        }
         else
-            return null;
+            return BaseWindow.no_copy_text (out copy_text);
     }
 }
diff --git a/editor/registry-list.vala b/editor/registry-list.vala
index 6ea47fc..d163363 100644
--- a/editor/registry-list.vala
+++ b/editor/registry-list.vala
@@ -171,8 +171,6 @@ private abstract class RegistryList : Grid, BrowsableView, AdaptativeWidget
         return ((SimpleSettingObject) list_model.get_object (position)).full_name;
     }
 
-    internal abstract void select_first_row ();
-
     internal void select_row_named (string selected, uint16 context_id, bool grab_focus)
     {
         check_resize ();
@@ -290,19 +288,24 @@ private abstract class RegistryList : Grid, BrowsableView, AdaptativeWidget
         return true;
     }
 
-    internal string? get_copy_text () // can compile with "private", but is public 1/2
+    internal bool handle_copy_text (out string copy_text) // can compile with "private", but is public 1/2
+    {
+        return _handle_copy_text (out copy_text, ref key_list_box);
+    }
+    private bool _handle_copy_text (out string copy_text, ref ListBox key_list_box)
     {
         ListBoxRow? selected_row = (ListBoxRow?) key_list_box.get_selected_row ();
         if (selected_row == null)
-            return null;
+            return BaseWindow.no_copy_text (out copy_text);
 
         ClickableListBoxRow row = (ClickableListBoxRow) ((!) selected_row).get_child ();
 
         if (ModelUtils.is_folder_context_id (row.context_id)
          || ModelUtils.is_undefined_context_id (row.context_id))
-            return _get_folder_or_search_copy_text (row);
+            copy_text = _get_folder_or_search_copy_text (row);
         else
-            return _get_key_copy_text (row, modifications_handler);
+            copy_text = _get_key_copy_text (row, modifications_handler);
+        return true;
     }
     private static inline string _get_folder_or_search_copy_text (ClickableListBoxRow row)
     {
diff --git a/editor/registry-search.vala b/editor/registry-search.vala
index 01d481e..8a34170 100644
--- a/editor/registry-search.vala
+++ b/editor/registry-search.vala
@@ -34,7 +34,7 @@ private class RegistrySearch : RegistryList
     * * Simple public calls
     \*/
 
-    internal override void select_first_row ()
+    internal void select_first_row ()
     {
         if (old_term != null)   //happens when pasting an invalid path
             _select_first_row (key_list_box, (!) old_term);
@@ -45,9 +45,9 @@ private class RegistrySearch : RegistryList
         return _return_pressed (key_list_box);
     }
 
-    internal string? get_copy_path_text ()
+    internal bool handle_alt_copy_text (out string copy_text)
     {
-        return _get_copy_path_text (key_list_box);
+        return _handle_alt_copy_text (out copy_text, ref key_list_box);
     }
 
     internal void clean ()
@@ -146,21 +146,21 @@ private class RegistrySearch : RegistryList
     * * Keyboard calls
     \*/
 
-    private static string? _get_copy_path_text (ListBox key_list_box)
+    private static bool _handle_alt_copy_text (out string copy_text, ref ListBox key_list_box)
     {
         ListBoxRow? selected_row = key_list_box.get_selected_row ();
         if (selected_row == null)
-            return null;
-        return _get_action_target ((!) selected_row);
+            return BaseWindow.no_copy_text (out copy_text);
+        _get_action_target ((!) selected_row, out copy_text);
+        return true;
     }
 
-    private static string _get_action_target (ListBoxRow selected_row)
+    private static void _get_action_target (ListBoxRow selected_row, out string action_target)
     {
         Variant? variant = selected_row.get_action_target_value ();
         if (variant == null)
             assert_not_reached ();
 
-        string action_target;
         if (((!) variant).get_type_string () == "s")    // directory
             action_target = ((!) variant).get_string ();
         else
@@ -168,7 +168,6 @@ private class RegistrySearch : RegistryList
             uint16 unused;
             ((!) variant).@get ("(sq)", out action_target, out unused);
         }
-        return action_target;
     }
 
     /*\
diff --git a/editor/registry-view.vala b/editor/registry-view.vala
index b8e36a1..b593136 100644
--- a/editor/registry-view.vala
+++ b/editor/registry-view.vala
@@ -89,7 +89,7 @@ private class RegistryView : RegistryList
         return false;
     }
 
-    internal override void select_first_row ()
+    internal void select_first_row (bool grab_focus_if_needed)
     {
         uint n_items = list_model.get_n_items ();
         if (n_items == 0)
@@ -111,7 +111,7 @@ private class RegistryView : RegistryList
         }
         if (row == null)
             assert_not_reached ();
-        select_row_and_if_true_grab_focus ((!) row, true);
+        select_row_and_if_true_grab_focus ((!) row, grab_focus_if_needed);
     }
 
     /*\



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