diff options
author | Burt P <pburt0@gmail.com> | 2019-07-13 11:58:28 -0500 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2019-07-29 19:44:59 -0700 |
commit | 4fb64a41f4d74e3de672f984fa2617e54ad68d2a (patch) | |
tree | e05990283308606312adbe4cb6beaf1eaaaf8f54 /shell/shell.c | |
parent | 0dca7a1e165cdffa0065455b377d2658f33f4ea2 (diff) |
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 <pburt0@gmail.com>
Diffstat (limited to 'shell/shell.c')
-rw-r--r-- | shell/shell.c | 25 |
1 files changed, 25 insertions, 0 deletions
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); |