[epiphany/gnome-3-26] flatpak: Allow opening downloaded files
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/gnome-3-26] flatpak: Allow opening downloaded files
- Date: Sun, 19 Nov 2017 20:03:44 +0000 (UTC)
commit 3a7db444960367ed3e6c0fbb95d109a2f2fd143a
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Sun Nov 19 13:53:40 2017 -0600
flatpak: Allow opening downloaded files
embed/ephy-embed-shell.c | 5 +++++
lib/ephy-file-helpers.c | 30 ++++++++++++++++++++++++++++++
lib/ephy-file-helpers.h | 4 +++-
3 files changed, 38 insertions(+), 1 deletions(-)
---
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 85f8997..79a8eb1 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -32,6 +32,7 @@
#include "ephy-encodings.h"
#include "ephy-file-helpers.h"
#include "ephy-filters-manager.h"
+#include "ephy-flatpak-utils.h"
#include "ephy-history-service.h"
#include "ephy-profile-utils.h"
#include "ephy-settings.h"
@@ -1444,6 +1445,10 @@ ephy_embed_shell_launch_handler (EphyEmbedShell *shell,
g_return_val_if_fail (EPHY_IS_EMBED_SHELL (shell), FALSE);
g_return_val_if_fail (file || mime_type, FALSE);
+ if (ephy_is_running_inside_flatpak ()) {
+ return ephy_file_launch_file_via_uri_handler (file);
+ }
+
app = ephy_file_launcher_get_app_info_for_file (file, mime_type);
/* Do not allow recursive calls into the browser, they can lead to
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index 617edb0..361d844 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -1041,3 +1041,33 @@ ephy_open_incognito_window (const char *uri)
g_free (command);
}
+
+gboolean
+ephy_file_launch_via_uri_handler (const char *uri)
+{
+ GdkDisplay *display;
+ GdkAppLaunchContext *context;
+ GError *error = NULL;
+
+ display = gdk_display_get_default ();
+ context = gdk_display_get_app_launch_context (display);
+
+ g_app_info_launch_default_for_uri (uri, G_APP_LAUNCH_CONTEXT (context), &error);
+
+ if (error != NULL) {
+ g_warning ("Failed to launch handler for URI %s: %s", uri, error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+gboolean
+ephy_file_launch_file_via_uri_handler (GFile *file)
+{
+ const char *uri;
+
+ uri = g_file_get_uri (file);
+ return ephy_file_launch_via_uri_handler (uri);
+}
diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h
index 8800dbf..0977fc5 100644
--- a/lib/ephy-file-helpers.h
+++ b/lib/ephy-file-helpers.h
@@ -94,6 +94,8 @@ char * ephy_sanitize_filename (char
GAppInfo * ephy_file_launcher_get_app_info_for_file (GFile *file,
const char *mime_type);
void ephy_open_default_instance_window (void);
-void ephy_open_incognito_window (const char *uri);
+void ephy_open_incognito_window (const char *uri);
+gboolean ephy_file_launch_via_uri_handler (const char *uri);
+gboolean ephy_file_launch_file_via_uri_handler (GFile *file);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]