File gnome-control-center-bnc486019-confirmation-dialog-transient.diff of Package gnome-control-center

diff --git a/capplets/display/xrandr-capplet.c b/capplets/display/xrandr-capplet.c
index b646c67..132a3cd 100644
--- a/capplets/display/xrandr-capplet.c
+++ b/capplets/display/xrandr-capplet.c
@@ -69,6 +69,11 @@ struct App
     DBusGConnection *connection;
     DBusGProxy *proxy;
     DBusGProxyCall *proxy_call;
+
+    enum {
+	APPLYING_VERSION_1,
+	APPLYING_VERSION_2
+    } apply_configuration_state;
 };
 
 static void rebuild_gui (App *app);
@@ -77,6 +82,7 @@ static gboolean output_overlaps (GnomeOutputInfo *output, GnomeRRConfig *config)
 static void select_current_output_from_dialog_position (App *app);
 static void monitor_on_off_toggled_cb (GtkToggleButton *toggle, gpointer data);
 static void get_geometry (GnomeOutputInfo *output, int *w, int *h);
+static void apply_configuration_returned_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, void *data);
 
 #define ROTATE_TABLET_KEY "/apps/gnome_settings_daemon/xrandr/rotate_tablet_with_monitor"
 
@@ -90,7 +96,9 @@ error_message (App *app, const char *primary_text, const char *secondary_text)
 				     GTK_MESSAGE_ERROR,
 				     GTK_BUTTONS_CLOSE,
 				     "%s", primary_text);
-    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", secondary_text);
+
+    if (secondary_text)
+	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", secondary_text);
 
     gtk_dialog_run (GTK_DIALOG (dialog));
     gtk_widget_destroy (dialog);
@@ -1715,6 +1723,54 @@ check_required_virtual_size (App *app)
     }
 }
 
+static void
+begin_version2_apply_configuration (App *app, GdkWindow *parent_window, guint32 timestamp)
+{
+    XID parent_window_xid;
+
+    parent_window_xid = GDK_WINDOW_XID (parent_window);
+
+    app->proxy = dbus_g_proxy_new_for_name (app->connection,
+					    "org.gnome.SettingsDaemon",
+					    "/org/gnome/SettingsDaemon/XRANDR",
+					    "org.gnome.SettingsDaemon.XRANDR_2");
+    g_assert (app->proxy != NULL); /* that call does not fail unless we pass bogus names */
+
+    app->apply_configuration_state = APPLYING_VERSION_2;
+    app->proxy_call = dbus_g_proxy_begin_call (app->proxy, "ApplyConfiguration",
+					       apply_configuration_returned_cb, app,
+					       NULL,
+					       G_TYPE_INT64, (gint64) parent_window_xid,
+					       G_TYPE_INT64, (gint64) timestamp,
+					       G_TYPE_INVALID,
+					       G_TYPE_INVALID);
+    /* FIXME: we don't check for app->proxy_call == NULL, which could happen if
+     * the connection was disconnected.  This is left as an exercise for the
+     * reader.
+     */
+}
+
+static void
+begin_version1_apply_configuration (App *app)
+{
+    app->proxy = dbus_g_proxy_new_for_name (app->connection,
+					    "org.gnome.SettingsDaemon",
+					    "/org/gnome/SettingsDaemon/XRANDR",
+					    "org.gnome.SettingsDaemon.XRANDR");
+    g_assert (app->proxy != NULL); /* that call does not fail unless we pass bogus names */
+
+    app->apply_configuration_state = APPLYING_VERSION_1;
+    app->proxy_call = dbus_g_proxy_begin_call (app->proxy, "ApplyConfiguration",
+					       apply_configuration_returned_cb, app,
+					       NULL,
+					       G_TYPE_INVALID,
+					       G_TYPE_INVALID);
+    /* FIXME: we don't check for app->proxy_call == NULL, which could happen if
+     * the connection was disconnected.  This is left as an exercise for the
+     * reader.
+     */
+}
+
 /* Callback for dbus_g_proxy_begin_call() */
 static void
 apply_configuration_returned_cb (DBusGProxy       *proxy,
@@ -1731,8 +1787,19 @@ apply_configuration_returned_cb (DBusGProxy       *proxy,
     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);
+	if (app->apply_configuration_state == APPLYING_VERSION_2
+	    && g_error_matches (error, DBUS_GERROR, DBUS_GERROR_UNKNOWN_METHOD)) {
+	    g_error_free (error);
+
+	    g_object_unref (app->proxy);
+	    app->proxy = NULL;
+
+	    begin_version1_apply_configuration (app);
+	    return;
+	} else {
+	    error_message (app, _("Could not apply the selected configuration"), error->message);
+	    g_error_free (error);
+	}
     }
 
     g_object_unref (app->proxy);
@@ -1774,23 +1841,9 @@ apply (App *app)
 	return;
     }
 
-    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;
-    }
-
     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);
+
+    begin_version2_apply_configuration (app, gtk_widget_get_window (app->dialog), gtk_get_current_event_time ());
 }
 
 #if 0
openSUSE Build Service is sponsored by