From 4fb64a41f4d74e3de672f984fa2617e54ad68d2a Mon Sep 17 00:00:00 2001 From: Burt P Date: Sat, 13 Jul 2019 11:58:28 -0500 Subject: uri_handler functions from sysobj This allows link clicks to be intercepted so that they might be used by the application internally before falling back to the system uri handler. I've also found the default GTK label link handler to be unreliable outside of GNOME Shell, and this will use xdg-open instead. Signed-off-by: Burt P --- shell/shell.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'shell') diff --git a/shell/shell.c b/shell/shell.c index 75ee8300..31836d62 100644 --- a/shell/shell.c +++ b/shell/shell.c @@ -720,6 +720,22 @@ select_first_tree_item(gpointer data) return FALSE; } +gboolean hardinfo_link(const gchar *uri) { + /* Clicked link events pass through here on their + * way to the default handler (xdg-open). + * + * TODO: In the future, links could be used to + * jump to different pages in hardinfo. + * + * if (g_str_has_prefix(uri, "hardinfo:")) { + * hardinfo_navigate(g_utf8_strchr(uri, strlen("hardinfo"), ':') + 1); + * return TRUE; + * } + */ + + return FALSE; /* didn't handle it */ +} + void shell_init(GSList * modules) { if (shell) { @@ -729,6 +745,8 @@ void shell_init(GSList * modules) DEBUG("initializing shell"); + uri_set_function(hardinfo_link); + create_window(); shell_action_set_property("ConnectToAction", "is-important", TRUE); @@ -1502,6 +1520,10 @@ static void module_selected_show_info_list(GKeyFile *key_file, ngroups > 1); } +static gboolean detail_activate_link (GtkLabel *label, gchar *uri, gpointer user_data) { + return uri_open(uri); +} + static void module_selected_show_info_detail(GKeyFile *key_file, ShellModuleEntry *entry, gchar **groups) @@ -1570,6 +1592,9 @@ static void module_selected_show_info_detail(GKeyFile *key_file, gtk_box_pack_start(GTK_BOX(value_box), value_icon, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(value_box), value_label, TRUE, TRUE, 0); + g_signal_connect(key_label, "activate-link", G_CALLBACK(detail_activate_link), NULL); + g_signal_connect(value_label, "activate-link", G_CALLBACK(detail_activate_link), NULL); + gtk_widget_show(key_label); gtk_widget_show(value_box); gtk_widget_show(value_label); -- cgit v1.2.3