Use gtk_show_uri_on_window() in GtkLabel
authorEmmanuele Bassi <ebassi@gnome.org>
Thu, 16 Feb 2017 00:24:57 +0000 (00:24 +0000)
committerBastien Nocera <hadess@hadess.net>
Thu, 16 Feb 2017 15:34:42 +0000 (16:34 +0100)
Avoid the deprecated gtk_show_uri(), and allow activating link in
sandboxed applications.

https://bugzilla.gnome.org/show_bug.cgi?id=778726

demos/gtk-demo/links.c
gtk/gtklabel.c

index 5a39a1a84268ef251027b1e572d18ee68771b32e..210ca6ac6485266a27458e94fc6e7f5835cf2bf2 100644 (file)
@@ -1,7 +1,7 @@
 /* Links
  *
  * GtkLabel can show hyperlinks. The default action is to call
- * gtk_show_uri() on their URI, but it is possible to override
+ * gtk_show_uri_on_window() on their URI, but it is possible to override
  * this with a custom handler.
  */
 
index 612ad3f68f43a092af22200a2d31255f37ad3ff5..fbc8fdfe8e7272d2e8a5649b09a4f5aca000a5a7 100644 (file)
@@ -766,7 +766,7 @@ gtk_label_class_init (GtkLabelClass *class)
      *
      * The signal which gets emitted to activate a URI.
      * Applications may connect to it to override the default behaviour,
-     * which is to call gtk_show_uri().
+     * which is to call gtk_show_uri_on_window().
      *
      * Returns: %TRUE if the link has been activated
      *
@@ -6718,10 +6718,11 @@ gtk_label_activate_link (GtkLabel    *label,
                          const gchar *uri)
 {
   GtkWidget *widget = GTK_WIDGET (label);
+  GtkWidget *top_level = gtk_widget_get_toplevel (widget);
+  guint32 timestamp = gtk_get_current_event_time ();
   GError *error = NULL;
 
-  if (!gtk_show_uri (gtk_widget_get_screen (widget),
-                     uri, gtk_get_current_event_time (), &error))
+  if (!gtk_show_uri_on_window (GTK_WINDOW (top_level), uri, timestamp, &error))
     {
       g_warning ("Unable to show '%s': %s", uri, error->message);
       g_error_free (error);