From 0142fae74249744d4952b0c2f084fc0989e4c827 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Wed, 3 May 2017 10:28:31 +0200 Subject: [PATCH] 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 deletion(-) diff --git a/js/ui/remoteSearch.js b/js/ui/remoteSearch.js index baeaa1269..4f376bc31 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 2ea1afb62..4d29e59ef 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(); },