From 4295134455ea99ad14a0eb43ed31e03fbeebb623 Mon Sep 17 00:00:00 2001 From: Juhani Krekelä Date: Sat, 24 Jul 2021 19:15:10 +0300 Subject: Unify context menus for URLs and OSC 8 hyperlinks Currently weltschmerz has separate context menus for the two types of URIs one can interact with, even though they contain the same option with only a little different phrasing. This makes both use the same context menu, and standardizes terminology to "URI". This unification is in preparation for an upcoming "Open with …" feature which will programmatically add items to context menu for URIs. Without this, we would need to duplicate logic for each of the separate menus. --- terminal.vala | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'terminal.vala') diff --git a/terminal.vala b/terminal.vala index 076d665..13409f4 100644 --- a/terminal.vala +++ b/terminal.vala @@ -24,8 +24,7 @@ class Terminal : Gtk.Overlay { [GtkChild] unowned Gtk.InfoBar infobar; [GtkChild] unowned Gtk.Label infobar_label; [GtkChild] unowned Gtk.Menu standard_context_menu; - [GtkChild] unowned Gtk.Menu url_context_menu; - [GtkChild] unowned Gtk.Menu hyperlink_context_menu; + [GtkChild] unowned Gtk.Menu uri_context_menu; [GtkChild] unowned Gtk.MenuItem copy_item_text; [GtkChild] unowned Gtk.MenuItem copy_item_html; [GtkChild] unowned Gtk.MenuItem open_terminal_item; @@ -62,8 +61,7 @@ class Terminal : Gtk.Overlay { vte.search_set_wrap_around(true); - url_context_menu.attach_to_widget(vte, null); - hyperlink_context_menu.attach_to_widget(vte, null); + uri_context_menu.attach_to_widget(vte, null); standard_context_menu.attach_to_widget(vte, null); clipboard = Gtk.Clipboard.get_default(window.get_display()); @@ -403,10 +401,8 @@ class Terminal : Gtk.Overlay { url_match = vte.match_check_event(event, null); hyperlink_match = vte.hyperlink_check_event(event); - if (url_match != null) { - url_context_menu.popup_at_pointer(event); - } else if (hyperlink_match != null) { - hyperlink_context_menu.popup_at_pointer(event); + if (url_match != null || hyperlink_match != null) { + uri_context_menu.popup_at_pointer(event); } else { copy_item_text.set_sensitive(vte.get_has_selection()); copy_item_html.set_sensitive(vte.get_has_selection()); -- cgit v1.2.3-2-gb3c3