gnome-settings-daemon r796 - trunk/plugins/xrandr



Author: federico
Date: Thu Mar 19 23:36:15 2009
New Revision: 796
URL: http://svn.gnome.org/viewvc/gnome-settings-daemon?rev=796&view=rev

Log:
bgo576006 (RANDR) - Implement the XRANDR-2 ApplyConfiguration method, which takes a parent window ID.
We use the parent window as the transient-parent of the confirmation dialog.
The timestamp is not used yet, but it should be used in the future for the
XRR*() calls, which take a timestamp --- however, the wrapper API in
GnomeRR doesn't take timestamps yet.

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

Modified:
   trunk/plugins/xrandr/gsd-xrandr-manager.c

Modified: trunk/plugins/xrandr/gsd-xrandr-manager.c
==============================================================================
--- trunk/plugins/xrandr/gsd-xrandr-manager.c	(original)
+++ trunk/plugins/xrandr/gsd-xrandr-manager.c	Thu Mar 19 23:36:15 2009
@@ -199,7 +199,7 @@
 }
 
 static gboolean
-user_says_things_are_ok (GsdXrandrManager *manager)
+user_says_things_are_ok (GsdXrandrManager *manager, GdkWindow *parent_window)
 {
         TimeoutDialog timeout;
         guint timeout_id;
@@ -223,6 +223,11 @@
                           G_CALLBACK (timeout_response_cb),
                           &timeout);
 
+        gtk_widget_realize (timeout.dialog);
+
+        if (parent_window)
+                gdk_window_set_transient_for (gtk_widget_get_window (timeout.dialog), parent_window);
+
         gtk_widget_show_all (timeout.dialog);
         /* We don't use g_timeout_add_seconds() since we actually care that the user sees "real" second ticks in the dialog */
         timeout_id = g_timeout_add (1000,
@@ -240,7 +245,7 @@
 }
 
 static gboolean
-try_to_apply_intended_configuration (GsdXrandrManager *manager, GError **error)
+try_to_apply_intended_configuration (GsdXrandrManager *manager, GdkWindow *parent_window, guint32 timestamp, GError **error)
 {
         struct GsdXrandrManagerPrivate *priv = manager->priv;
         char *backup_filename;
@@ -261,7 +266,7 @@
 
         /* Confirm with the user */
 
-        if (user_says_things_are_ok (manager))
+        if (user_says_things_are_ok (manager, parent_window))
                 unlink (backup_filename);
         else
                 restore_backup_configuration (manager, backup_filename, intended_filename);
@@ -273,12 +278,35 @@
         return result;
 }
 
-/* DBus method; see gsd-xrandr-manager.xml for the interface definition */
+/* DBus method for org.gnome.SettingsDaemon.XRANDR ApplyConfiguration; see gsd-xrandr-manager.xml for the interface definition */
 static gboolean
 gsd_xrandr_manager_apply_configuration (GsdXrandrManager *manager,
                                         GError          **error)
 {
-        return try_to_apply_intended_configuration (manager, error);
+        return try_to_apply_intended_configuration (manager, NULL, 0, error);
+}
+
+/* DBus method for org.gnome.SettingsDaemon.XRANDR_2 ApplyConfiguration; see gsd-xrandr-manager.xml for the interface definition */
+static gboolean
+gsd_xrandr_manager_2_apply_configuration (GsdXrandrManager *manager,
+                                          long              parent_window_id,
+                                          long              timestamp,
+                                          GError          **error)
+{
+        GdkWindow *parent_window;
+        gboolean result;
+
+        if (parent_window_id != 0)
+                parent_window = gdk_window_foreign_new_for_display (gdk_display_get_default (), parent_window_id);
+        else
+                parent_window = NULL;
+
+        result = try_to_apply_intended_configuration (manager, parent_window, (guint32) timestamp, error);
+
+        if (parent_window)
+                g_object_unref (parent_window);
+
+        return result;
 }
 
 /* We include this after the definition of gsd_xrandr_manager_apply_configuration() so the prototype will already exist */
@@ -1067,7 +1095,7 @@
                 return;
         }
 
-        try_to_apply_intended_configuration (manager, NULL); /* NULL-GError */
+        try_to_apply_intended_configuration (manager, NULL, 0, NULL); /* NULL-GError */
 }
 
 static void



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