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

Geniuspaste: Install a custom URL handler for Paste link #403

Merged
merged 1 commit into from Mar 13, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions geniuspaste/src/geniuspaste.c
Expand Up @@ -578,12 +578,30 @@ static gchar *pastebin_parse_response(const Pastebin *pastebin,
return url;
}

static gboolean message_dialog_label_link_activated(GtkLabel *label, gchar *uri, gpointer user_data)
{
utils_open_browser(uri);
return TRUE;
}

static void message_dialog_label_set_url_hook(GtkWidget *widget, gpointer data)
{
if (GTK_IS_LABEL(widget))
{
g_signal_connect(widget,
"activate-link",
G_CALLBACK(message_dialog_label_link_activated),
NULL);
}
}

G_GNUC_PRINTF (4, 5)
static void show_msgbox(GtkMessageType type, GtkButtonsType buttons,
const gchar *main_text,
const gchar *secondary_markup, ...)
{
GtkWidget *dlg;
GtkWidget *dlg_vbox;
va_list ap;
gchar *markup;

Expand All @@ -601,6 +619,12 @@ static void show_msgbox(GtkMessageType type, GtkButtonsType buttons,
"secondary-text", markup,
"secondary-use-markup", TRUE,
NULL);
/* fetch the message area of the dialog and attach a custom URL hook to the labels */
dlg_vbox = gtk_message_dialog_get_message_area(GTK_MESSAGE_DIALOG(dlg));
gtk_container_foreach(GTK_CONTAINER(dlg_vbox),
message_dialog_label_set_url_hook,
NULL);
/* run the dialog */
gtk_dialog_run(GTK_DIALOG(dlg));
gtk_widget_destroy(dlg);
}
Expand Down