[dconf-editor] Make pasting work.



commit 47107c67dcd7ce98257caa60b17a1d9ba220a0de
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Thu Sep 20 15:26:05 2018 +0200

    Make pasting work.

 editor/dconf-window.vala    | 16 ++++++++++++++--
 editor/pathentry.vala       |  2 +-
 editor/registry-search.vala | 12 +++++++++---
 3 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 643b5af..0f31fee 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -728,7 +728,7 @@ private class DConfWindow : ApplicationWindow
 
     public static bool is_path_invalid (string path)
     {
-        return path.has_prefix ("/") && path.contains ("//");
+        return path.has_prefix ("/") && (path.contains ("//") || path.contains (" "));
     }
 
     private void request_config (string full_name)
@@ -1065,6 +1065,18 @@ private class DConfWindow : ApplicationWindow
                     request_search (true, PathEntry.SearchMode.EDIT_PATH_SELECT_LAST_WORD);
                     return true;
 
+                case "v":   // https://bugzilla.gnome.org/show_bug.cgi?id=762257 is WONTFIX
+                    if (!focus_is_text_widget)
+                    {
+                        Gdk.Display? display = Gdk.Display.get_default ();
+                        if (display == null)    // ?
+                            return false;
+                        string? clipboard_content = Clipboard.get_default ((!) display).wait_for_text ();
+                        request_search (true, PathEntry.SearchMode.EDIT_PATH_MOVE_END, clipboard_content);
+                        return true;
+                    }
+                    return false;
+
                 case "F1":
                     browser_view.discard_row_popover ();
                     if ((event.state & Gdk.ModifierType.SHIFT_MASK) == 0)
@@ -1102,7 +1114,7 @@ private class DConfWindow : ApplicationWindow
                     return true;
 
                 default:
-                    break;  // TODO make <ctrl>v work; https://bugzilla.gnome.org/show_bug.cgi?id=762257 is 
WONTFIX
+                    break;
             }
         }
 
diff --git a/editor/pathentry.vala b/editor/pathentry.vala
index 263db17..267c96e 100644
--- a/editor/pathentry.vala
+++ b/editor/pathentry.vala
@@ -94,7 +94,7 @@ private class PathEntry : Box
         switch (mode)
         {
             case SearchMode.EDIT_PATH_MOVE_END:
-                search_entry.text = current_path;
+                search_entry.text = search == null ? current_path : (!) search;
                 entry_grab_focus_without_selecting ();
                 return;
 
diff --git a/editor/registry-search.vala b/editor/registry-search.vala
index 9f8c2e9..a173726 100644
--- a/editor/registry-search.vala
+++ b/editor/registry-search.vala
@@ -35,7 +35,8 @@ private class RegistrySearch : RegistryList
 
     internal override void select_first_row ()
     {
-        _select_first_row (key_list_box, (!) old_term);
+        if (old_term != null)   //happens when pasting an invalid path
+            _select_first_row (key_list_box, (!) old_term);
     }
 
     internal bool return_pressed ()
@@ -178,8 +179,13 @@ private class RegistrySearch : RegistryList
     internal void start_search (string term)
         requires (current_path_if_search_mode != null)
     {
-        if ((old_term != null && term == (!) old_term)
-         || DConfWindow.is_path_invalid (term))
+        if (DConfWindow.is_path_invalid (term))
+        {
+            if (old_term != null)
+                ensure_selection (key_list_box, (!) old_term);
+            return;
+        }
+        if (old_term != null && term == (!) old_term)
         {
             ensure_selection (key_list_box, (!) old_term);
             return;


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