gnome-control-center r9241 - trunk/capplets/display



Author: federico
Date: Thu Feb  5 21:20:40 2009
New Revision: 9241
URL: http://svn.gnome.org/viewvc/gnome-control-center?rev=9241&view=rev

Log:
bnc472226 (RANDR) - Put the D-bus connection and proxy in the main App structure, not in local variables.
We'll need this to maintain state for the D-bus async callback.

Signed-off-by: Federico Mena Quintero <federico novell com>

Modified:
   trunk/capplets/display/xrandr-capplet.c

Modified: trunk/capplets/display/xrandr-capplet.c
==============================================================================
--- trunk/capplets/display/xrandr-capplet.c	(original)
+++ trunk/capplets/display/xrandr-capplet.c	Thu Feb  5 21:20:40 2009
@@ -62,6 +62,11 @@
     GtkWidget      *area;
     gboolean	    ignore_gui_changes;
     GConfClient	   *client;
+
+    /* These are used while we are waiting for the ApplyConfiguration method to be executed over D-bus */
+    DBusGConnection *connection;
+    DBusGProxy *proxy;
+    
 };
 
 static void rebuild_gui (App *app);
@@ -1709,8 +1714,6 @@
 apply (App *app)
 {
     GError *error = NULL;
-    DBusGConnection *connection;
-    DBusGProxy *proxy;
 
     gnome_rr_config_sanitize (app->current_configuration);
 
@@ -1725,30 +1728,37 @@
 	return;
     }
 
-    connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
-    if (connection == NULL) {
+    g_assert (app->connection == NULL);
+    g_assert (app->proxy == NULL);
+
+    app->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+    if (app->connection == NULL) {
 	error_message (app, _("Could not get session bus while applying display configuration"), error->message);
 	g_error_free (error);
 	return;
     }
 
-    proxy = dbus_g_proxy_new_for_name (connection,
-				       "org.gnome.SettingsDaemon",
-				       "/org/gnome/SettingsDaemon/XRANDR",
-				       "org.gnome.SettingsDaemon.XRANDR");
-    if (!proxy) {
+    app->proxy = dbus_g_proxy_new_for_name (app->connection,
+					    "org.gnome.SettingsDaemon",
+					    "/org/gnome/SettingsDaemon/XRANDR",
+					    "org.gnome.SettingsDaemon.XRANDR");
+    if (!app->proxy) {
 	error_message (app, _("Could not get org.gnome.SettingsDaemon.XRANDR"), NULL);
+	dbus_g_connection_unref (app->connection);
+	app->connection = NULL;
 	return;
-
     }
 
-    if (!dbus_g_proxy_call (proxy, "ApplyConfiguration", &error, G_TYPE_INVALID, G_TYPE_INVALID)) {
+    if (!dbus_g_proxy_call (app->proxy, "ApplyConfiguration", &error, G_TYPE_INVALID, G_TYPE_INVALID)) {
 	error_message (app, _("Could not apply the selected configuration"), error->message);
 	g_error_free (error);
     }
 
-    g_object_unref (proxy);
-    dbus_g_connection_unref (connection);
+    g_object_unref (app->proxy);
+    app->proxy = NULL;
+
+    dbus_g_connection_unref (app->connection);
+    app->connection = NULL;
 }
 
 #if 0



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