summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Dywan <christian@twotoasts.de>2019-04-26 18:58:58 +0200
committerGitHub <noreply@github.com>2019-04-26 18:58:58 +0200
commit8291366d543fe224550debcb43800df96aecc7ab (patch)
treec9c545b5c8cfc536b80bbfcec65ebbf95f23cf68
parent58d68dff423f85a1cc7f5bc84b08298ced19819a (diff)
downloadmidori-git-8291366d543fe224550debcb43800df96aecc7ab.tar.gz
Add Paste & Proceed in the urlbar (#320)
What this does is simple yet incredibly useful: copy text, which can be a URL or words for something to search online, and directly open it.
-rw-r--r--core/urlbar.vala11
1 files changed, 11 insertions, 0 deletions
diff --git a/core/urlbar.vala b/core/urlbar.vala
index 2f37b3e5..4b4ed5a5 100644
--- a/core/urlbar.vala
+++ b/core/urlbar.vala
@@ -276,6 +276,17 @@ namespace Midori {
suggestions.grab_focus ();
}
+ protected override void populate_popup (Gtk.Menu menu) {
+ string? text = Gtk.Clipboard.get_for_display (get_display (), Gdk.SELECTION_CLIPBOARD).wait_for_text ();
+ var menuitem = new Gtk.MenuItem.with_mnemonic ("Paste and p_roceed");
+ menuitem.sensitive = text != null;
+ menuitem.activate.connect (() => {
+ uri = magic_uri (text) ?? CoreSettings.get_default ().uri_for_search (text);
+ });
+ menuitem.show ();
+ menu.insert (menuitem, 3);
+ }
+
void update_icon () {
if (blank) {
primary_icon_name = null;