[gtk/gtk-3-24] Add utility functions for portal paths
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-3-24] Add utility functions for portal paths
- Date: Fri, 31 Aug 2018 03:18:19 +0000 (UTC)
commit 6829719d6db2136489c2377a7355c4f33ebbd738
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Aug 30 13:05:55 2018 -0400
Add utility functions for portal paths
The paths that we create for requests and sessions
need some icky code to create. Keep it in one place.
gtk/gtkprivate.c | 36 ++++++++++++++++++++++++++++++++++++
gtk/gtkprivate.h | 4 ++++
2 files changed, 40 insertions(+)
---
diff --git a/gtk/gtkprivate.c b/gtk/gtkprivate.c
index 02448d7f92..6428347f04 100644
--- a/gtk/gtkprivate.c
+++ b/gtk/gtkprivate.c
@@ -291,3 +291,39 @@ gtk_should_use_portal (void)
return use_portal[0] == '1';
}
+
+static char *
+get_portal_path (GDBusConnection *connection,
+ const char *kind,
+ char **token)
+{
+ char *sender;
+ int i;
+ char *path;
+
+ *token = g_strdup_printf ("gtk%d", g_random_int_range (0, G_MAXINT));
+ sender = g_strdup (g_dbus_connection_get_unique_name (connection) + 1);
+ for (i = 0; sender[i]; i++)
+ if (sender[i] == '.')
+ sender[i] = '_';
+
+ path = g_strconcat ("/org/freedesktop/portal/desktop", "/", kind, "/", sender, "/", token, NULL);
+
+ g_free (sender);
+
+ return path;
+}
+
+char *
+gtk_get_portal_request_path (GDBusConnection *connection,
+ char **token)
+{
+ return get_portal_path (connection, "request", token);
+}
+
+char *
+gtk_get_portal_session_path (GDBusConnection *connection,
+ char **token)
+{
+ return get_portal_path (connection, "session", token);
+}
diff --git a/gtk/gtkprivate.h b/gtk/gtkprivate.h
index af130cd3f0..af7e58b5e9 100644
--- a/gtk/gtkprivate.h
+++ b/gtk/gtkprivate.h
@@ -96,6 +96,10 @@ gdouble _gtk_get_slowdown ();
void _gtk_set_slowdown (gdouble slowdown_factor);
gboolean gtk_should_use_portal (void);
+char *gtk_get_portal_request_path (GDBusConnection *connection,
+ char **token);
+char *gtk_get_portal_session_path (GDBusConnection *connection,
+ char **token);
#ifdef G_OS_WIN32
void _gtk_load_dll_with_libgtk3_manifest (const char *dllname);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]