diff -Nurp gnome-desktop-2.22.0-patched/libgnome-desktop/libgnomeui/monitor-db.h gnome-desktop-2.22.0-working/libgnome-desktop/libgnomeui/monitor-db.h --- gnome-desktop-2.22.0-patched/libgnome-desktop/libgnomeui/monitor-db.h 2008-03-17 11:04:17.000000000 -0700 +++ gnome-desktop-2.22.0-working/libgnome-desktop/libgnomeui/monitor-db.h 2008-03-27 19:04:56.000000000 -0700 @@ -44,6 +44,9 @@ gboolean configuration_match Configuration *config2); gboolean configuration_save (Configuration *configuration, GError **err); +gboolean configuration_save_onetime (Configuration *configuration, + GError **err); + gboolean configuration_apply_stored (RWScreen *screen); gboolean configuration_applicable (Configuration *configuration, RWScreen *screen); diff -Nurp gnome-desktop-2.22.0-patched/libgnome-desktop/monitor-db.c gnome-desktop-2.22.0-working/libgnome-desktop/monitor-db.c --- gnome-desktop-2.22.0-patched/libgnome-desktop/monitor-db.c 2008-03-17 11:04:17.000000000 -0700 +++ gnome-desktop-2.22.0-working/libgnome-desktop/monitor-db.c 2008-03-27 18:56:42.000000000 -0700 @@ -631,6 +631,14 @@ get_filename (void) g_get_home_dir(), ".gnome2", "monitors.xml", NULL)); } +static const gchar * +get_onetime_filename (void) +{ + return idle_free ( + g_build_filename ( + g_get_home_dir(), ".gnome2", "monitors-onetime.xml", NULL)); +} + static const char * get_rotation_name (RWRotation r) { @@ -717,7 +725,7 @@ emit_configuration (Configuration *confi } gboolean -configuration_save (Configuration *configuration, GError **err) +configuration_save_to_file (Configuration *configuration, GError **err, const gchar* filename) { Configuration **configurations; GString *output = g_string_new(""); @@ -738,7 +746,19 @@ configuration_save (Configuration *confi emit_configuration (configuration, output); - return g_file_set_contents (get_filename(), output->str, -1, err); + return g_file_set_contents (filename, output->str, -1, err); +} + +gboolean +configuration_save (Configuration *configuration, GError **err) +{ + return configuration_save_to_file (configuration, err, get_filename()); +} + +gboolean +configuration_save_onetime (Configuration *configuration, GError **err) +{ + return configuration_save_to_file (configuration, err, get_onetime_filename()); } static gboolean @@ -773,13 +793,33 @@ apply_configuration (Configuration *conf gboolean configuration_apply_stored (RWScreen *screen) { - char *file = g_build_filename ( - g_get_home_dir(), ".gnome2", "monitors.xml", NULL); - Configuration **configs = configurations_read (file, NULL); + char *file; + Configuration **configs; Configuration *current; Configuration *found; gboolean result; + file = g_build_filename (g_get_home_dir(), ".gnome2", "monitors-onetime.xml", NULL); + configs = configurations_read (file, NULL); + if ( ! configs ) { + /* No monitors-onetime.xml file, so try monitors.xml */ + g_free(file); + file = g_build_filename (g_get_home_dir(), ".gnome2", "monitors.xml", NULL); + configs = configurations_read (file, NULL); + } else { + /* monitors-onetime.xml was loaded; now remove it before trying anything so + * if there are problems, we won't re-load it again */ + if (! unlink(file)) { + g_print("Cannot unlink %s - cowardly refusing to apply it\n", file); + return FALSE; + } + } + + if (!screen) { + g_print("No valid screens to apply stored configuration\n"); + return FALSE; + } + rw_screen_refresh (screen); current = configuration_new_current (screen);