diff options
author | Matthias Clasen <mclasen@redhat.com> | 2018-08-30 13:05:55 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2018-08-30 22:53:36 -0400 |
commit | b271db253f307bcab7651434502dcb1e27b905dd (patch) | |
tree | dc4702bfabd1cea0da93cf6231a4368801911603 /gtk/gtkprivate.c | |
parent | eb9f95e9fa6fa01cfb04f0a2cbf7af6c103fc528 (diff) | |
download | gtk+-b271db253f307bcab7651434502dcb1e27b905dd.tar.gz |
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.
Diffstat (limited to 'gtk/gtkprivate.c')
-rw-r--r-- | gtk/gtkprivate.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gtk/gtkprivate.c b/gtk/gtkprivate.c index 52240f61f9..b8a34f32b5 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 (PORTAL_OBJECT_PATH, "/", 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); +} |