[polari] utils: Use newly added show_uri_on_window() if possible



commit 72688ca1d152dd9a8bde006b6f46b64c39d51bd4
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Oct 17 18:19:23 2016 +0200

    utils: Use newly added show_uri_on_window() if possible
    
    With Flatpak portals, open a URI may trigger a dialog before the actual
    URI is shown. GTK+ added another convenience method to associate a window
    as transient parent for this case, use it when possible.

 src/utils.js |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/utils.js b/src/utils.js
index db87177..ee376b4 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -159,11 +159,14 @@ function findChannels(str, server) {
 }
 
 function openURL(url, timestamp) {
+    let app = Gio.Application.get_default();
     try {
-        Gtk.show_uri (Gdk.Screen.get_default(), url, timestamp);
+        if (app.active_window)
+            Gtk.show_uri_on_window (app.active_window, url, timestamp)
+        else
+            Gtk.show_uri (Gdk.Screen.get_default(), url, timestamp);
     } catch(e) {
         let n = new AppNotifications.SimpleOutput(_("Failed to open link"));
-        let app = Gio.Application.get_default();
         app.notificationQueue.addNotification(n);
         debug("failed to open %s: %s".format(url, e.message));
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]