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



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

Log:
bnc472226 (RANDR) - Use an async D-bus call to avoid blocking the GUI while gnome-settings-daemon changes the RANDR parameters

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:54 2009
@@ -66,7 +66,7 @@
     /* These are used while we are waiting for the ApplyConfiguration method to be executed over D-bus */
     DBusGConnection *connection;
     DBusGProxy *proxy;
-    
+    DBusGProxyCall *proxy_call;
 };
 
 static void rebuild_gui (App *app);
@@ -1710,6 +1710,36 @@
     }
 }
 
+/* Callback for dbus_g_proxy_begin_call() */
+static void
+apply_configuration_returned_cb (DBusGProxy       *proxy,
+				 DBusGProxyCall   *call_id,
+				 void             *data)
+{
+    App *app = data;
+    gboolean success;
+    GError *error;
+
+    g_assert (call_id == app->proxy_call);
+
+    error = NULL;
+    success = dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID);
+
+    if (!success) {
+	error_message (app, _("Could not apply the selected configuration"), error->message);
+	g_error_free (error);
+    }
+
+    g_object_unref (app->proxy);
+    app->proxy = NULL;
+
+    dbus_g_connection_unref (app->connection);
+    app->connection = NULL;
+    app->proxy_call = NULL;
+
+    gtk_widget_set_sensitive (app->dialog, TRUE);
+}
+
 static void
 apply (App *app)
 {
@@ -1730,6 +1760,7 @@
 
     g_assert (app->connection == NULL);
     g_assert (app->proxy == NULL);
+    g_assert (app->proxy_call == NULL);
 
     app->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
     if (app->connection == NULL) {
@@ -1749,16 +1780,12 @@
 	return;
     }
 
-    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 (app->proxy);
-    app->proxy = NULL;
-
-    dbus_g_connection_unref (app->connection);
-    app->connection = NULL;
+    gtk_widget_set_sensitive (app->dialog, FALSE);
+    app->proxy_call = dbus_g_proxy_begin_call (app->proxy, "ApplyConfiguration",
+					       apply_configuration_returned_cb, app,
+					       NULL,
+					       G_TYPE_INVALID,
+					       G_TYPE_INVALID);
 }
 
 #if 0



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