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



Author: federico
Date: Tue Mar 31 01:56:27 2009
New Revision: 9398
URL: http://svn.gnome.org/viewvc/gnome-control-center?rev=9398&view=rev

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

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

Modified:
   trunk/capplets/display/ChangeLog
   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	Tue Mar 31 01:56:27 2009
@@ -1767,6 +1767,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);
+}
+
 /* Callback for dbus_g_proxy_begin_call() */
 static void
 apply_configuration_returned_cb (DBusGProxy       *proxy,
@@ -1819,6 +1844,8 @@
 
     foo_scroll_area_invalidate (FOO_SCROLL_AREA (app->area));
 
+    ensure_current_configuration_is_saved ();
+
     if (!gnome_rr_config_save (app->current_configuration, &error))
     {
 	error_message (app, _("Could not save the monitor configuration"), error->message);



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