From: Matthias Clasen Date: Thu, 8 Jun 2023 04:02:05 +0000 (-0400) Subject: print: Drop some private api use X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~1^2~171^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=f22788a3a8429b69f06a27eb4033d6b0dc12a219;p=gtk4.git print: Drop some private api use --- diff --git a/gtk/print/gtkprintoperation-portal.c b/gtk/print/gtkprintoperation-portal.c index 6dc36892c9..474d705467 100644 --- a/gtk/print/gtkprintoperation-portal.c +++ b/gtk/print/gtkprintoperation-portal.c @@ -32,7 +32,6 @@ #include #include #include "gtkwindowprivate.h" -#include "gtkprivate.h" #include "gtkprintoperation-private.h" #include "gtkprintoperation-portal.h" @@ -40,12 +39,32 @@ #include "gtkpagesetup.h" #include "gtkprintbackendprivate.h" -#ifndef PORTAL_BUS_NAME #define PORTAL_BUS_NAME "org.freedesktop.portal.Desktop" #define PORTAL_OBJECT_PATH "/org/freedesktop/portal/desktop" #define PORTAL_REQUEST_INTERFACE "org.freedesktop.portal.Request" #define PORTAL_PRINT_INTERFACE "org.freedesktop.portal.Print" -#endif + +static char * +get_portal_request_path (GDBusConnection *connection, + char **token) +{ + char *sender; + int i; + char *path; + + *token = g_strdup_printf ("gtk%d", g_random_int_range (0, G_MAXINT)); + /* +1 to skip the leading : */ + 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, "/request/", sender, "/", *token, NULL); + + g_free (sender); + + return path; +} typedef struct { GtkPrintOperation *op; @@ -582,7 +601,7 @@ call_prepare_print (GtkPrintOperation *op, char *token; portal->prepare_print_handle = - gtk_get_portal_request_path (g_dbus_proxy_get_connection (portal->proxy), &token); + get_portal_request_path (g_dbus_proxy_get_connection (portal->proxy), &token); portal->response_signal_id = g_dbus_connection_signal_subscribe (g_dbus_proxy_get_connection (G_DBUS_PROXY (portal->proxy)),