[gnome-shell] search: copy result to clipboard if requested



commit 0142fae74249744d4952b0c2f084fc0989e4c827
Author: Daiki Ueno <dueno src gnome org>
Date:   Wed May 3 10:28:31 2017 +0200

    search: copy result to clipboard if requested
    
    Some search providers such as GNOME Characters want to copy search
    results to clipboard.  However, on Wayland, clipboards are only
    accessible from applications that have a visible surface on display.
    
    This patch allows a search provider to request the shell to copy a
    search result to clipboard when 'clipboardText' is included in the meta
    of the result.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=775099

 js/ui/remoteSearch.js |    3 ++-
 js/ui/search.js       |    4 ++++
 2 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/remoteSearch.js b/js/ui/remoteSearch.js
index baeaa12..4f376bc 100644
--- a/js/ui/remoteSearch.js
+++ b/js/ui/remoteSearch.js
@@ -278,7 +278,8 @@ const RemoteSearchProvider = new Lang.Class({
                                name: metas[i]['name'],
                                description: metas[i]['description'],
                                createIcon: Lang.bind(this,
-                                                     this.createIcon, metas[i]) });
+                                                     this.createIcon, metas[i]),
+                               clipboardText: metas[i]['clipboardText'] });
         }
         callback(resultMetas);
     },
diff --git a/js/ui/search.js b/js/ui/search.js
index 2ea1afb..4d29e59 100644
--- a/js/ui/search.js
+++ b/js/ui/search.js
@@ -152,6 +152,8 @@ const SearchResultsBase = new Lang.Class({
 
         this._resultDisplays = {};
 
+        this._clipboard = St.Clipboard.get_default();
+
         this._cancellable = new Gio.Cancellable();
     },
 
@@ -181,6 +183,8 @@ const SearchResultsBase = new Lang.Class({
 
     _activateResult: function(result, id) {
         this.provider.activateResult(id, this._terms);
+        if (result.metaInfo.clipboardText)
+            this._clipboard.set_text(St.ClipboardType.CLIPBOARD, result.metaInfo.clipboardText);
         Main.overview.toggle();
     },
 


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