[gtk] Use defines for bus names
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] Use defines for bus names
- Date: Wed, 15 Aug 2018 22:58:55 +0000 (UTC)
commit a01feae15b0c8079478418406936307746d24b48
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Aug 15 22:53:05 2018 +0000
Use defines for bus names
This helps eradicate typos (we had some here).
Closes https://gitlab.gnome.org/GNOME/gtk/issues/1267
gtk/gtkapplication-dbus.c | 20 ++++++++++++--------
gtk/gtkcolorpickerportal.c | 14 +++++++-------
gtk/gtkfilechoosernativeportal.c | 22 +++++++++++-----------
gtk/gtkprintoperation-portal.c | 17 +++++++++--------
gtk/gtkprivate.h | 8 ++++++++
5 files changed, 47 insertions(+), 34 deletions(-)
---
diff --git a/gtk/gtkapplication-dbus.c b/gtk/gtkapplication-dbus.c
index 561848eb0c..14f7bcc49c 100644
--- a/gtk/gtkapplication-dbus.c
+++ b/gtk/gtkapplication-dbus.c
@@ -24,9 +24,13 @@
#include "gtkapplicationprivate.h"
#include "gtksettings.h"
+#include "gtkprivate.h"
G_DEFINE_TYPE (GtkApplicationImplDBus, gtk_application_impl_dbus, GTK_TYPE_APPLICATION_IMPL)
+#define DBUS_BUS_NAME "org.freedesktop.DBus"
+#define DBUS_OBJECT_PATH "/org/freedesktop/DBus"
+#define DBUS_BUS_INTERFACE "org.freedesktop.DBus"
#define GNOME_DBUS_NAME "org.gnome.SessionManager"
#define GNOME_DBUS_OBJECT_PATH "/org/gnome/SessionManager"
#define GNOME_DBUS_INTERFACE "org.gnome.SessionManager"
@@ -304,9 +308,9 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
if (id && id[0])
{
res = g_dbus_connection_call_sync (dbus->session,
- "org.freedesktop.DBus",
- "/org/freedesktop/DBus",
- "org.freedesktop.DBus",
+ DBUS_BUS_NAME,
+ DBUS_OBJECT_PATH,
+ DBUS_BUS_INTERFACE,
"GetId",
NULL,
NULL,
@@ -340,9 +344,9 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
{
dbus->inhibit_proxy = gtk_application_get_proxy_if_service_present (dbus->session,
G_DBUS_PROXY_FLAGS_NONE,
- "org.freedesktop.portal.Desktop",
- "/org/freedesktop/portal/desktop",
- "org.freedesktop.portal.Inhibit",
+ PORTAL_BUS_NAME,
+ PORTAL_OBJECT_PATH,
+ PORTAL_INHIBIT_INTERFACE,
&error);
if (error)
{
@@ -608,9 +612,9 @@ gtk_application_impl_dbus_uninhibit (GtkApplicationImpl *impl,
if (handle->cookie == cookie)
{
g_dbus_connection_call (dbus->session,
- "org.freedesktop.portal.Desktop",
+ PORTAL_BUS_NAME,
handle->handle,
- "org.freedesktop.portal.Request",
+ PORTAL_REQUEST_INTERFACE,
"Close",
g_variant_new ("()"),
G_VARIANT_TYPE_UNIT,
diff --git a/gtk/gtkcolorpickerportal.c b/gtk/gtkcolorpickerportal.c
index da567ae0b9..90a7b2dbc7 100644
--- a/gtk/gtkcolorpickerportal.c
+++ b/gtk/gtkcolorpickerportal.c
@@ -59,9 +59,9 @@ gtk_color_picker_portal_initable_init (GInitable *initable,
picker->portal_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
- "org.freedesktop.portal.Desktop",
- "/org/freedesktop/portal/desktop",
- "org.freedesktop.portal.Screenshot",
+ PORTAL_BUS_NAME,
+ PORTAL_OBJECT_PATH,
+ PORTAL_SCREENSHOT_INTERFACE,
NULL,
error);
@@ -74,7 +74,7 @@ gtk_color_picker_portal_initable_init (GInitable *initable,
owner = g_dbus_proxy_get_name_owner (picker->portal_proxy);
if (owner == NULL)
{
- g_debug ("org.freedesktop.portal.Screenshot not provided");
+ g_debug ("%s not provided", PORTAL_SCREENSHOT_INTERFACE);
g_clear_object (&picker->portal_proxy);
return FALSE;
}
@@ -197,10 +197,10 @@ gtk_color_picker_portal_pick (GtkColorPicker *cp,
if (sender[i] == '.')
sender[i] = '_';
- handle = g_strdup_printf ("/org/freedesktop/portal/desktop/request/%s/%s", sender, token);
+ handle = g_strconcat (PORTAL_OBJECT_PATH "/request/", sender, "/", token, NULL);
picker->portal_signal_id = g_dbus_connection_signal_subscribe (connection,
- "org.freedesktop.portal.Desktop",
- "org.freedesktop.portal.Request",
+ PORTAL_BUS_NAME,
+ PORTAL_REQUEST_INTERFACE,
"Response",
handle,
NULL,
diff --git a/gtk/gtkfilechoosernativeportal.c b/gtk/gtkfilechoosernativeportal.c
index f6d7c4283c..aaaa13a8eb 100644
--- a/gtk/gtkfilechoosernativeportal.c
+++ b/gtk/gtkfilechoosernativeportal.c
@@ -152,9 +152,9 @@ send_close (FilechooserPortalData *data)
GDBusMessage *message;
GError *error = NULL;
- message = g_dbus_message_new_method_call ("org.freedesktop.portal.Desktop",
- "/org/freedesktop/portal/desktop",
- "org.freedesktop.portal.FileChooser",
+ message = g_dbus_message_new_method_call (PORTAL_BUS_NAME,
+ PORTAL_OBJECT_PATH,
+ PORTAL_FILECHOOSER_INTERFACE,
"Close");
g_dbus_message_set_body (message,
g_variant_new ("(o)", data->portal_handle));
@@ -216,8 +216,8 @@ open_file_msg_cb (GObject *source_object,
data->portal_response_signal_id =
g_dbus_connection_signal_subscribe (data->connection,
- "org.freedesktop.portal.Desktop",
- "org.freedesktop.portal.Request",
+ PORTAL_BUS_NAME,
+ PORTAL_REQUEST_INTERFACE,
"Response",
data->portal_handle,
NULL,
@@ -299,9 +299,9 @@ show_portal_file_chooser (GtkFileChooserNative *self,
char *sender;
int i;
- message = g_dbus_message_new_method_call ("org.freedesktop.portal.Desktop",
- "/org/freedesktop/portal/desktop",
- "org.freedesktop.portal.FileChooser",
+ message = g_dbus_message_new_method_call (PORTAL_BUS_NAME,
+ PORTAL_OBJECT_PATH,
+ PORTAL_FILECHOOSER_INTERFACE,
data->method_name);
token = g_strdup_printf ("gtk%d", g_random_int_range (0, G_MAXINT));
@@ -310,13 +310,13 @@ show_portal_file_chooser (GtkFileChooserNative *self,
if (sender[i] == '.')
sender[i] = '_';
- data->portal_handle = g_strdup_printf ("/org/fredesktop/portal/desktop/request/%s/%s", sender, token);
+ data->portal_handle = g_strconcat (PORTAL_OBJECT_PATH "/request/", sender, "/", token, NULL);
g_free (sender);
data->portal_response_signal_id =
g_dbus_connection_signal_subscribe (data->connection,
- "org.freedesktop.portal.Desktop",
- "org.freedesktop.portal.Request",
+ PORTAL_BUS_NAME,
+ PORTAL_REQUEST_INTERFACE,
"Response",
data->portal_handle,
NULL,
diff --git a/gtk/gtkprintoperation-portal.c b/gtk/gtkprintoperation-portal.c
index 2081c4a7ee..43e6079be6 100644
--- a/gtk/gtkprintoperation-portal.c
+++ b/gtk/gtkprintoperation-portal.c
@@ -37,6 +37,7 @@
#include "gtkshow.h"
#include "gtkintl.h"
#include "gtkwindowprivate.h"
+#include "gtkprivate.h"
typedef struct {
@@ -461,8 +462,8 @@ prepare_print_called (GObject *source,
portal->response_signal_id);
portal->response_signal_id =
g_dbus_connection_signal_subscribe (g_dbus_proxy_get_connection (G_DBUS_PROXY (portal->proxy)),
- "org.freedesktop.portal.Desktop",
- "org.freedesktop.portal.Request",
+ PORTAL_BUS_NAME,
+ PORTAL_REQUEST_INTERFACE,
"Response",
handle,
NULL,
@@ -491,9 +492,9 @@ create_portal_data (GtkPrintOperation *op,
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
- "org.freedesktop.portal.Desktop",
- "/org/freedesktop/portal/desktop",
- "org.freedesktop.portal.Print",
+ PORTAL_BUS_NAME,
+ PORTAL_OBJECT_PATH,
+ PORTAL_PRINT_INTERFACE,
NULL,
&error);
@@ -564,13 +565,13 @@ call_prepare_print (GtkPrintOperation *op,
if (sender[i] == '.')
sender[i] = '_';
- portal->prepare_print_handle = g_strdup_printf ("/org/fredesktop/portal/desktop/request/%s/%s", sender,
token);
+ portal->prepare_print_handle = g_strconcat (PORTAL_OBJECT_PATH "/request/", sender, "/", token, NULL);
g_free (sender);
portal->response_signal_id =
g_dbus_connection_signal_subscribe (g_dbus_proxy_get_connection (G_DBUS_PROXY (portal->proxy)),
- "org.freedesktop.portal.Desktop",
- "org.freedesktop.portal.Request",
+ PORTAL_BUS_NAME,
+ PORTAL_REQUEST_INTERFACE,
"Response",
portal->prepare_print_handle,
NULL,
diff --git a/gtk/gtkprivate.h b/gtk/gtkprivate.h
index 3ecb4c36b7..2675889953 100644
--- a/gtk/gtkprivate.h
+++ b/gtk/gtkprivate.h
@@ -111,6 +111,14 @@ void _gtk_set_slowdown (gdouble slowdown_factor);
gboolean gtk_should_use_portal (void);
+#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_FILECHOOSER_INTERFACE "org.freedesktop.portal.FileChooser"
+#define PORTAL_PRINT_INTERFACE "org.freedesktop.portal.Print"
+#define PORTAL_SCREENSHOT_INTERFACE "org.freedesktop.portal.Screenshot"
+#define PORTAL_INHIBIT_INTERFACE "org.freedesktop.portal.Inhibit"
+
#ifdef G_OS_WIN32
void _gtk_load_dll_with_libgtk3_manifest (const char *dllname);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]