gnome-settings-daemon r802 - in trunk: . plugins/xrandr



Author: federico
Date: Thu Mar 26 17:36:50 2009
New Revision: 802
URL: http://svn.gnome.org/viewvc/gnome-settings-daemon?rev=802&view=rev

Log:
(RANDR) - Ensure that there will be a backup file before committing changes

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

Modified:
   trunk/ChangeLog
   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 26 17:36:50 2009
@@ -1106,6 +1106,31 @@
 }
 
 static void
+ensure_current_configuration_is_saved (void)
+{
+        GnomeRRScreen *rr_screen;
+        GnomeRRConfig *rr_config;
+
+        /* Normally, gnome_rr_config_save() creates a backup file based on the
+         * old monitors.xml.  However, if *that* file didn't exist, there is
+         * nothing from which to create a backup.  So, here we'll save the
+         * current/unchanged configuration and then let our caller call
+         * gnome_rr_config_save() again with the new/changed configuration, so
+         * that there *will* be a backup file in the end.
+         */
+
+        rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), NULL, NULL, NULL); /* NULL-GError */
+        if (!rr_screen)
+                return;
+
+        rr_config = gnome_rr_config_new_current (rr_screen);
+        gnome_rr_config_save (rr_config, NULL); /* NULL-GError */
+
+        gnome_rr_config_free (rr_config);
+        gnome_rr_screen_destroy (rr_screen);
+}
+
+static void
 output_rotation_item_activate_cb (GtkCheckMenuItem *item, gpointer data)
 {
         GsdXrandrManager *manager = GSD_XRANDR_MANAGER (data);
@@ -1118,6 +1143,8 @@
 	if (!gtk_check_menu_item_get_active (item))
 		return;
 
+        ensure_current_configuration_is_saved ();
+
         output = g_object_get_data (G_OBJECT (item), "output");
         rotation = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "rotation"));
 



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