[gnome-builder/gnome-builder-3-28] app: use xdg-open under flatpak



commit b86f10bfc72f855096cc4a5da22e62f51a28c0f9
Author: Christian Hergert <chergert redhat com>
Date:   Thu Aug 16 12:55:48 2018 -0700

    app: use xdg-open under flatpak
    
    We need a workaround because gtk_show_uri_on_window() is not working
    correctly for us, despite the portal. We're opening the URI locally which
    is not what we want.
    
    # Conflicts:
    #       src/libide/application/ide-application-actions.c

 src/libide/application/ide-application-actions.c | 33 ++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/src/libide/application/ide-application-actions.c 
b/src/libide/application/ide-application-actions.c
index d9c21fee4..e943b6ddf 100644
--- a/src/libide/application/ide-application-actions.c
+++ b/src/libide/application/ide-application-actions.c
@@ -34,6 +34,8 @@
 #include "greeter/ide-greeter-perspective.h"
 #include "keybindings/ide-shortcuts-window.h"
 #include "preferences/ide-preferences-window.h"
+#include "subprocess/ide-subprocess.h"
+#include "subprocess/ide-subprocess-launcher.h"
 #include "workbench/ide-workbench.h"
 #include "util/ide-flatpak.h"
 
@@ -205,8 +207,35 @@ ide_application_actions_help_cb (GObject      *object,
 
       uri = g_strdup_printf ("file://%s/en/index.html", file_base);
 
-      if (!gtk_show_uri_on_window (focused_window, uri, gtk_get_current_event_time (), &error))
-        g_warning ("Failed to load documentation: %s", error->message);
+      g_debug ("Documentation URI: %s", uri);
+
+      if (ide_is_flatpak ())
+        {
+          g_autoptr(IdeSubprocessLauncher) launcher = NULL;
+          g_autoptr(IdeSubprocess) subprocess = NULL;
+
+          /* We can't currently trust gtk_show_uri_on_window() because it tries
+           * to open our HTML page with Builder inside our current flatpak
+           * environment! We need to ensure this is fixed upstream, but it's
+           * currently unclear how to do so since we register handles for html.
+           */
+
+          launcher = ide_subprocess_launcher_new (0);
+          ide_subprocess_launcher_set_run_on_host (launcher, TRUE);
+          ide_subprocess_launcher_set_clear_env (launcher, FALSE);
+          ide_subprocess_launcher_push_argv (launcher, "xdg-open");
+          ide_subprocess_launcher_push_argv (launcher, uri);
+
+          if (!(subprocess = ide_subprocess_launcher_spawn (launcher, NULL, &error)))
+            g_warning ("Failed to spawn xdg-open for documentation: %s", error->message);
+        }
+      else
+        {
+          if (!gtk_show_uri_on_window (focused_window, uri, gtk_get_current_event_time (), &error))
+            g_warning ("Failed to load documentation: %s", error->message);
+        }
+
+      IDE_EXIT;
     }
 
   IDE_EXIT;


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