Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add menu item to open domain-like text in tab #378

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions core/tab.vala
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,25 @@ namespace Midori {
action.activate.connect (() => {
var settings = CoreSettings.get_default ();
var tab = new Tab (null, web_context, settings.uri_for_search (text));
tab.set_data<bool> ("foreground", true);
((Browser)get_toplevel ()).add (tab);
});
menu.append (new WebKit.ContextMenuItem (action));
// Open selected text that looks like a domain
try {
if (!hit.context_is_link () && Soup.tld_get_base_domain (text) != null) {
menu.append (new WebKit.ContextMenuItem.separator ());
action = new Gtk.Action ("text-tab", "Open Link in New _Tab", null, null);
action.activate.connect (() => {
var tab = new Tab (null, web_context, text);
tab.set_data<bool> ("foreground", true);
((Browser)get_toplevel ()).add (tab);
});
menu.append (new WebKit.ContextMenuItem (action));
}
} catch (Error error) {
debug ("Failed to determine domain suffix: %s", error.message);
}
}
if (clear) {
menu.append (new WebKit.ContextMenuItem.separator ());
Expand Down