appinfo: Only use portal as fallback

We currently assume that the OpenURI portal should be used
unconditionally when running inside a flatpak sandbox. While
the portal is what we usually want, there are exceptions:
Yelp is now included in the GNOME runtime to allow displaying
help without exporting the user documentation, and the sandboxed
app itself may register a scheme handler.
To account for those cases transparently, always try the normal
code path first and only fall back to calling the portal when
that fails.

https://bugzilla.gnome.org/show_bug.cgi?id=780471
This commit is contained in:
Florian Müllner 2017-03-19 22:33:56 +01:00
parent c675a4ef82
commit 05f0d8199b

View File

@ -975,12 +975,15 @@ g_app_info_launch_default_for_uri (const char *uri,
GAppLaunchContext *launch_context,
GError **error)
{
if (launch_default_for_uri (uri, launch_context, error))
return TRUE;
#ifdef G_OS_UNIX
if (glib_should_use_portal ())
return launch_default_with_portal (uri, launch_context, error);
else
#endif
return launch_default_for_uri (uri, launch_context, error);
return FALSE;
}
/**
@ -1011,16 +1014,16 @@ g_app_info_launch_default_for_uri_async (const char *uri,
GError *error = NULL;
GTask *task;
res = launch_default_for_uri (uri, context, &error);
#ifdef G_OS_UNIX
if (glib_should_use_portal ())
if (!res && glib_should_use_portal ())
{
launch_default_with_portal_async (uri, context, cancellable, callback, user_data);
return;
}
#endif
res = launch_default_for_uri (uri, context, &error);
task = g_task_new (context, cancellable, callback, user_data);
if (!res)
g_task_return_error (task, error);