xdg-desktop-portal/SOURCES/0003-open-uri-Always-open-U...

76 lines
2.6 KiB
Diff

From a82f40b933f1918e7b7c30830b54e713860b8494 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Thu, 16 Apr 2020 16:38:47 +0200
Subject: [PATCH 3/5] open-uri: Always open URIs in default app
Always open URIs and directories in the default application, as both
GNOME and KDE have Settings allowing those to be changed easily.
(cherry picked from commit 1dbdd31a8f4d4bb5808e85e46bf8fe8443290159)
---
src/open-uri.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/open-uri.c b/src/open-uri.c
index 35ba644..21b180e 100644
--- a/src/open-uri.c
+++ b/src/open-uri.c
@@ -445,8 +445,8 @@ get_content_type_for_file (const char *path,
}
static gboolean
-can_skip_app_chooser (const char *scheme,
- const char *content_type)
+should_use_default_app (const char *scheme,
+ const char *content_type)
{
const char *skipped_schemes[] = {
"http",
@@ -562,7 +562,7 @@ handle_open_in_thread_func (GTask *task,
gboolean writable = FALSE;
gboolean ask = FALSE;
gboolean open_dir = FALSE;
- gboolean can_skip = FALSE;
+ gboolean use_default_app = FALSE;
const char *reason;
parent_window = (const char *)g_object_get_data (G_OBJECT (request), "parent-window");
@@ -632,7 +632,7 @@ handle_open_in_thread_func (GTask *task,
/* collect all the information */
find_recommended_choices (scheme, content_type, &default_app, &choices, &n_choices);
- can_skip = can_skip_app_chooser (scheme, content_type);
+ use_default_app = should_use_default_app (scheme, content_type);
get_latest_choice_info (app_id, content_type,
&latest_id, &latest_count, &latest_threshold,
&ask_for_content_type);
@@ -640,11 +640,10 @@ handle_open_in_thread_func (GTask *task,
skip_app_chooser = FALSE;
reason = NULL;
- /* apply default handling: skip if the we have a default handler and its http or inode/directory */
- if (default_app != NULL && can_skip)
+ /* apply default handling: skip if the we have a default handler */
+ if (default_app != NULL && use_default_app)
{
- if (!skip_app_chooser)
- reason = "Allowing to skip app chooser: can use default";
+ reason = "Allowing to skip app chooser: can use default";
skip_app_chooser = TRUE;
}
@@ -685,7 +684,9 @@ handle_open_in_thread_func (GTask *task,
{
const char *app;
- if (latest_id != NULL)
+ if (default_app != NULL && use_default_app)
+ app = default_app;
+ else if (latest_id != NULL)
app = latest_id;
else if (default_app != NULL)
app = default_app;
--
2.26.2