[gnome-control-center/wip/carlosg/centralized-panel-auto-orientation: 197/200] display: Use a proxy for org.gnome.Mutter.DisplayConfig




commit 1ae3ebcfb2c10a4cfe6c5e784e3b2e23117f20aa
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Jun 11 15:57:45 2020 +0200

    display: Use a proxy for org.gnome.Mutter.DisplayConfig
    
    It will be more convenient than a direct DBus call in future commits.

 panels/display/cc-display-config-dbus.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)
---
diff --git a/panels/display/cc-display-config-dbus.c b/panels/display/cc-display-config-dbus.c
index aa7c673be..13e9b20fd 100644
--- a/panels/display/cc-display-config-dbus.c
+++ b/panels/display/cc-display-config-dbus.c
@@ -877,6 +877,7 @@ struct _CcDisplayConfigDBus
 
   GVariant *state;
   GDBusConnection *connection;
+  GDBusProxy *proxy;
 
   int min_width;
   int min_height;
@@ -996,17 +997,13 @@ config_apply (CcDisplayConfigDBus *self,
 
   cc_display_config_dbus_ensure_non_offset_coords (self);
 
-  retval = g_dbus_connection_call_sync (self->connection,
-                                        "org.gnome.Mutter.DisplayConfig",
-                                        "/org/gnome/Mutter/DisplayConfig",
-                                        "org.gnome.Mutter.DisplayConfig",
-                                        "ApplyMonitorsConfig",
-                                        build_apply_parameters (self, method),
-                                        NULL,
-                                        G_DBUS_CALL_FLAGS_NO_AUTO_START,
-                                        -1,
-                                        NULL,
-                                        error);
+  retval = g_dbus_proxy_call_sync (self->proxy,
+                                   "ApplyMonitorsConfig",
+                                   build_apply_parameters (self, method),
+                                   G_DBUS_CALL_FLAGS_NO_AUTO_START,
+                                   -1,
+                                   NULL,
+                                   error);
   return retval != NULL;
 }
 
@@ -1432,6 +1429,7 @@ cc_display_config_dbus_constructed (GObject *object)
   g_autoptr(GVariantIter) monitors = NULL;
   g_autoptr(GVariantIter) logical_monitors = NULL;
   g_autoptr(GVariantIter) props = NULL;
+  g_autoptr(GError) error = NULL;
 
   g_variant_get (self->state,
                  CURRENT_STATE_FORMAT,
@@ -1472,6 +1470,17 @@ cc_display_config_dbus_constructed (GObject *object)
 
   construct_monitors (self, monitors, logical_monitors);
 
+  self->proxy = g_dbus_proxy_new_sync (self->connection,
+                                       G_DBUS_PROXY_FLAGS_NONE,
+                                       NULL,
+                                       "org.gnome.Mutter.DisplayConfig",
+                                       "/org/gnome/Mutter/DisplayConfig",
+                                       "org.gnome.Mutter.DisplayConfig",
+                                       NULL,
+                                       &error);
+  if (error)
+    g_warning ("Could not create DisplayConfig proxy: %s", error->message);
+
   G_OBJECT_CLASS (cc_display_config_dbus_parent_class)->constructed (object);
 }
 
@@ -1524,6 +1533,7 @@ cc_display_config_dbus_finalize (GObject *object)
 
   g_clear_pointer (&self->state, g_variant_unref);
   g_clear_object (&self->connection);
+  g_clear_object (&self->proxy);
 
   g_list_foreach (self->monitors, (GFunc) g_object_unref, NULL);
   g_clear_pointer (&self->monitors, g_list_free);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]