This workarounds a strange crash on Windows when the default GTK URL handler is called. We need the URL handler only on the secondary text label but we cannot access it directly, so iterate over all labels of the message dialog's message area and attach the custom handler to all of the labels. This shouldn't harm much as only the secondary label contains a link.
Here is the gdb backtrace from running on Windows: ``` Thread 1 received signal SIGSEGV, Segmentation fault. 0x61a3ca04 in ?? () from H:\all\bin\libgtk-win32-2.0-0.dll (gdb) bt #0 0x61a3ca04 in ?? () from H:\all\bin\libgtk-win32-2.0-0.dll #1 0x61a4f96c in ?? () from H:\all\bin\libgtk-win32-2.0-0.dll #2 0x63c45fd2 in ?? () from H:\all\bin\libgobject-2.0-0.dll #3 0x63c57c26 in ?? () from H:\all\bin\libgobject-2.0-0.dll #4 0x63c5f31a in ?? () from H:\all\bin\libgobject-2.0-0.dll #5 0x63c5faf7 in ?? () from H:\all\bin\libgobject-2.0-0.dll #6 0x61a3fd4e in ?? () from H:\all\bin\libgtk-win32-2.0-0.dll #7 0x61a42c16 in ?? () from H:\all\bin\libgtk-win32-2.0-0.dll #8 0x61a4e72c in ?? () from H:\all\bin\libgtk-win32-2.0-0.dll #9 0x63c45f1c in ?? () from H:\all\bin\libgobject-2.0-0.dll #10 0x63c57c26 in ?? () from H:\all\bin\libgobject-2.0-0.dll #11 0x63c5f31a in ?? () from H:\all\bin\libgobject-2.0-0.dll #12 0x63c5faf7 in ?? () from H:\all\bin\libgobject-2.0-0.dll #13 0x61b691e3 in ?? () from H:\all\bin\libgtk-win32-2.0-0.dll #14 0x61a4cdb0 in ?? () from H:\all\bin\libgtk-win32-2.0-0.dll #15 0x61a4d15c in ?? () from H:\all\bin\libgtk-win32-2.0-0.dll #16 0x6c5791c4 in ?? () from H:\all\bin\libgdk-win32-2.0-0.dll #17 0x687f3783 in ?? () from H:\all\bin\libglib-2.0-0.dll #18 0x687f39dc in ?? () from H:\all\bin\libglib-2.0-0.dll #19 0x687f3e93 in ?? () from H:\all\bin\libglib-2.0-0.dll #20 0x619d2c7c in ?? () from H:\all\bin\libgtk-win32-2.0-0.dll #21 0x02fc29d9 in show_msgbox () from H:\all\lib\geany\geniuspaste.dll #22 0x02fc2e8e in paste () from H:\all\lib\geany\geniuspaste.dll #23 0x02fc2f0e in item_activate () from H:\all\lib\geany\geniuspaste.dll #24 0x63c45fd2 in ?? () from H:\all\bin\libgobject-2.0-0.dll #25 0x63c57871 in ?? () from H:\all\bin\libgobject-2.0-0.dll #26 0x63c5f890 in ?? () from H:\all\bin\libgobject-2.0-0.dll #27 0x63c5faf7 in ?? () from H:\all\bin\libgobject-2.0-0.dll #28 0x61b67fad in ?? () from H:\all\bin\libgtk-win32-2.0-0.dll #29 0x61a60ae7 in ?? () from H:\all\bin\libgtk-win32-2.0-0.dll #30 0x61a60e20 in ?? () from H:\all\bin\libgtk-win32-2.0-0.dll #31 0x61a4e72c in ?? () from H:\all\bin\libgtk-win32-2.0-0.dll #32 0x63c45fd2 in ?? () from H:\all\bin\libgobject-2.0-0.dll #33 0x63c57c26 in ?? () from H:\all\bin\libgobject-2.0-0.dll #34 0x63c5f31a in ?? () from H:\all\bin\libgobject-2.0-0.dll #35 0x63c5faf7 in ?? () from H:\all\bin\libgobject-2.0-0.dll #36 0x61b691e3 in ?? () from H:\all\bin\libgtk-win32-2.0-0.dll #37 0x61a4cdb0 in ?? () from H:\all\bin\libgtk-win32-2.0-0.dll #38 0x61a4d15c in ?? () from H:\all\bin\libgtk-win32-2.0-0.dll #39 0x6c5791c4 in ?? () from H:\all\bin\libgdk-win32-2.0-0.dll #40 0x687f3783 in ?? () from H:\all\bin\libglib-2.0-0.dll #41 0x687f39dc in ?? () from H:\all\bin\libglib-2.0-0.dll #42 0x687f3e93 in ?? () from H:\all\bin\libglib-2.0-0.dll ---Type <return> to continue, or q <return> to quit--- #43 0x61a4c11f in ?? () from H:\all\bin\libgtk-win32-2.0-0.dll #44 0x6a181c39 in main_lib (argc=1, argv=0x4dec90) at libmain.c:1229 #45 0x00401650 in main (argc=3, argv=0x4dec90) at main.c:27 (gdb) ``` which doesn't really help much. Unfortunately, I don't have a GTK runtime with debug symbols.
Anyway, using `utils_open_browser()` has the nice side effect that the link will be opened with the browser configured in Geany. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany-plugins/pull/403
-- Commit Summary --
* Geniuspaste: Install a custom URL handler for Paste link
-- File Changes --
M geniuspaste/src/geniuspaste.c (26)
-- Patch Links --
https://github.com/geany/geany-plugins/pull/403.patch https://github.com/geany/geany-plugins/pull/403.diff
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/403
@@ -601,6 +620,13 @@ 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),
(GtkCallback)message_dialog_label_set_url_hook,
no need for the `GtkCallback` cast as the function has (and should have) the appropriate signature.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/403/files#r55921809
@@ -578,12 +578,31 @@ static gchar *pastebin_parse_response(const Pastebin *pastebin, return url; }
+gboolean message_dialog_label_link_activated(GtkLabel *label, gchar *uri, gpointer user_data) +{
- utils_open_browser(uri);
- return TRUE;
+}
+void message_dialog_label_set_url_hook(GtkWidget *widget, gpointer data)
static
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/403/files#r55921811
@@ -578,12 +578,31 @@ static gchar *pastebin_parse_response(const Pastebin *pastebin, return url; }
+gboolean message_dialog_label_link_activated(GtkLabel *label, gchar *uri, gpointer user_data)
static
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/403/files#r55921812
LGBI, apart some indentation. I'll try it, but sounds fair
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/403#issuecomment-195746335
@@ -601,6 +620,13 @@ 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),
(GtkCallback)message_dialog_label_set_url_hook,
Thanks, fixed.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/403/files#r55921953
@@ -578,12 +578,31 @@ static gchar *pastebin_parse_response(const Pastebin *pastebin, return url; }
+gboolean message_dialog_label_link_activated(GtkLabel *label, gchar *uri, gpointer user_data) +{
- utils_open_browser(uri);
- return TRUE;
+}
+void message_dialog_label_set_url_hook(GtkWidget *widget, gpointer data)
Thanks, fixed.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/403/files#r55921955
@@ -578,12 +578,31 @@ static gchar *pastebin_parse_response(const Pastebin *pastebin, return url; }
+gboolean message_dialog_label_link_activated(GtkLabel *label, gchar *uri, gpointer user_data)
Thanks, fixed.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/403/files#r55921956
LGBI
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/403#issuecomment-195749862
OK, LGTM. I don't love the workaround, but it seem to work just fine. Tested on Linux and Windows.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/403#issuecomment-195757954
Merged #403.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/403#event-587611774
github-comments@lists.geany.org