mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 14:10:30 +00:00
Merge branch 'wip/hadess/portal-fixes' into 'master'
Portal fixes See merge request GNOME/gtk!1585
This commit is contained in:
commit
2a3dab5b94
@ -51,7 +51,7 @@ gtk_color_picker_portal_initable_init (GInitable *initable,
|
|||||||
GtkColorPickerPortal *picker = GTK_COLOR_PICKER_PORTAL (initable);
|
GtkColorPickerPortal *picker = GTK_COLOR_PICKER_PORTAL (initable);
|
||||||
char *owner;
|
char *owner;
|
||||||
GVariant *ret;
|
GVariant *ret;
|
||||||
guint version;
|
guint version = 0;
|
||||||
|
|
||||||
if (!gdk_should_use_portal ())
|
if (!gdk_should_use_portal ())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -81,8 +81,12 @@ gtk_color_picker_portal_initable_init (GInitable *initable,
|
|||||||
g_free (owner);
|
g_free (owner);
|
||||||
|
|
||||||
ret = g_dbus_proxy_get_cached_property (picker->portal_proxy, "version");
|
ret = g_dbus_proxy_get_cached_property (picker->portal_proxy, "version");
|
||||||
g_variant_get (ret, "u", &version);
|
if (ret)
|
||||||
|
{
|
||||||
|
version = g_variant_get_uint32 (ret);
|
||||||
g_variant_unref (ret);
|
g_variant_unref (ret);
|
||||||
|
}
|
||||||
|
|
||||||
if (version != 2)
|
if (version != 2)
|
||||||
{
|
{
|
||||||
g_debug ("Screenshot portal version: %u", version);
|
g_debug ("Screenshot portal version: %u", version);
|
||||||
|
@ -423,11 +423,19 @@ gtk_file_chooser_native_portal_show (GtkFileChooserNative *self,
|
|||||||
|
|
||||||
action = gtk_file_chooser_get_action (GTK_FILE_CHOOSER (self));
|
action = gtk_file_chooser_get_action (GTK_FILE_CHOOSER (self));
|
||||||
|
|
||||||
if (action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
if (action == GTK_FILE_CHOOSER_ACTION_OPEN)
|
||||||
action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
|
||||||
method_name = "OpenFile";
|
method_name = "OpenFile";
|
||||||
else if (action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
else if (action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
||||||
method_name = "SaveFile";
|
method_name = "SaveFile";
|
||||||
|
else if (action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
||||||
|
{
|
||||||
|
if (gtk_get_portal_interface_version (connection, "org.freedesktop.portal.FileChooser") < 3)
|
||||||
|
{
|
||||||
|
g_warning ("GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER is not supported by GtkFileChooserNativePortal because portal is too old");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
method_name = "OpenFile";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_warning ("GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER is not supported by GtkFileChooserNativePortal");
|
g_warning ("GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER is not supported by GtkFileChooserNativePortal");
|
||||||
|
@ -268,6 +268,63 @@ _gtk_ensure_resources (void)
|
|||||||
g_once (®ister_resources_once, register_resources, NULL);
|
g_once (®ister_resources_once, register_resources, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* gtk_get_portal_interface_version:
|
||||||
|
* @connection: a session #GDBusConnection
|
||||||
|
* @interface_name: the interface name for the portal interface
|
||||||
|
* we're interested in.
|
||||||
|
*
|
||||||
|
* Returns: the version number of the portal, or 0 on error.
|
||||||
|
*/
|
||||||
|
guint
|
||||||
|
gtk_get_portal_interface_version (GDBusConnection *connection,
|
||||||
|
const char *interface_name)
|
||||||
|
{
|
||||||
|
GDBusProxy *proxy = NULL;
|
||||||
|
GError *error = NULL;
|
||||||
|
GVariant *ret = NULL;
|
||||||
|
char *owner = NULL;
|
||||||
|
guint version = 0;
|
||||||
|
|
||||||
|
proxy = g_dbus_proxy_new_sync (connection,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
"org.freedesktop.portal.Desktop",
|
||||||
|
"/org/freedesktop/portal/desktop",
|
||||||
|
interface_name,
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
if (!proxy)
|
||||||
|
{
|
||||||
|
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||||
|
g_warning ("Could not query portal version on interface '%s': %s",
|
||||||
|
interface_name, error->message);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
owner = g_dbus_proxy_get_name_owner (proxy);
|
||||||
|
if (owner == NULL)
|
||||||
|
{
|
||||||
|
g_debug ("%s not provided by any service", interface_name);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = g_dbus_proxy_get_cached_property (proxy, "version");
|
||||||
|
if (ret)
|
||||||
|
version = g_variant_get_uint32 (ret);
|
||||||
|
|
||||||
|
g_debug ("Got version %u for portal interface '%s'",
|
||||||
|
version, interface_name);
|
||||||
|
|
||||||
|
out:
|
||||||
|
g_clear_object (&proxy);
|
||||||
|
g_clear_error (&error);
|
||||||
|
g_clear_pointer (&ret, g_variant_unref);
|
||||||
|
g_clear_pointer (&owner, g_free);
|
||||||
|
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
get_portal_path (GDBusConnection *connection,
|
get_portal_path (GDBusConnection *connection,
|
||||||
const char *kind,
|
const char *kind,
|
||||||
|
@ -115,6 +115,8 @@ char *gtk_get_portal_request_path (GDBusConnection *connection,
|
|||||||
char **token);
|
char **token);
|
||||||
char *gtk_get_portal_session_path (GDBusConnection *connection,
|
char *gtk_get_portal_session_path (GDBusConnection *connection,
|
||||||
char **token);
|
char **token);
|
||||||
|
guint gtk_get_portal_interface_version (GDBusConnection *connection,
|
||||||
|
const char *interface_name);
|
||||||
|
|
||||||
#define PORTAL_BUS_NAME "org.freedesktop.portal.Desktop"
|
#define PORTAL_BUS_NAME "org.freedesktop.portal.Desktop"
|
||||||
#define PORTAL_OBJECT_PATH "/org/freedesktop/portal/desktop"
|
#define PORTAL_OBJECT_PATH "/org/freedesktop/portal/desktop"
|
||||||
|
Loading…
Reference in New Issue
Block a user