diff --git a/capplets/display/ChangeLog b/capplets/display/ChangeLog index ea429d65a..3fbf7bfe9 100644 --- a/capplets/display/ChangeLog +++ b/capplets/display/ChangeLog @@ -1,3 +1,10 @@ +2009-03-30 Federico Mena Quintero + + * xrandr-capplet.c (ensure_current_configuration_is_saved): Save + monitors.xml with the current configuration before changing it, so + that we'll have something to go back to even on a first-time login + (when monitors.xml doesn't exist). + 2009-03-20 Federico Mena Quintero * xrandr-capplet.c (begin_version2_apply_configuration): There is no need diff --git a/capplets/display/xrandr-capplet.c b/capplets/display/xrandr-capplet.c index c30d0cf85..1054900f5 100644 --- a/capplets/display/xrandr-capplet.c +++ b/capplets/display/xrandr-capplet.c @@ -1767,6 +1767,31 @@ begin_version1_apply_configuration (App *app) */ } +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 @@ apply (App *app) 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);