diff options
author | Federico Mena Quintero <federico@novell.com> | 2009-01-27 20:28:10 +0000 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2009-01-27 20:28:10 +0000 |
commit | 6f014c36c97d0d8bf03e45d3f49f5083506f103e (patch) | |
tree | 89d10a28baaaeb6e45d8925cbf4b91f7c2138021 | |
parent | 82ab78001ac92c6b31460f53c62e02bf95b271bb (diff) | |
download | gnome-desktop-6f014c36c97d0d8bf03e45d3f49f5083506f103e.tar.gz |
bgo545115 - Add public API to get intended/backup filenames for the RANDR configuration
2009-01-27 Federico Mena Quintero <federico@novell.com>
http://bugzilla.gnome.org/show_bug.cgi?id=545115 - Ask for
confirmation, with a timeout, after changing the RANDR
configuration for if we leave the user with an unusable display.
This also handles the case where the machine may crash after
changing the configuration; the old/known-good configuration will
be restored when the user restarts his session.
Add public API to get to $(XDG_CONFIG_HOME)/monitors.xml and a
backup of that file (monitors.xml.backup):
* libgnomeui/gnome-rr-config.h
(gnome_rr_config_get_backup_filename,
gnome_rr_config_get_intended_filename): New prototypes.
* gnome-rr-config.c (gnome_rr_config_get_backup_filename): Implement.
(gnome_rr_config_get_intended_filename): Implement.
(get_config_filename): Replaced by gnome_rr_config_get_intended_filename().
Signed-off-by: Federico Mena Quintero <federico@novell.com>
svn path=/trunk/; revision=5364
-rw-r--r-- | libgnome-desktop/ChangeLog | 20 | ||||
-rw-r--r-- | libgnome-desktop/gnome-rr-config.c | 38 | ||||
-rw-r--r-- | libgnome-desktop/libgnomeui/gnome-rr-config.h | 3 |
3 files changed, 45 insertions, 16 deletions
diff --git a/libgnome-desktop/ChangeLog b/libgnome-desktop/ChangeLog index 64d92f3d..4cb45b33 100644 --- a/libgnome-desktop/ChangeLog +++ b/libgnome-desktop/ChangeLog @@ -1,3 +1,23 @@ +2009-01-27 Federico Mena Quintero <federico@novell.com> + + http://bugzilla.gnome.org/show_bug.cgi?id=545115 - Ask for + confirmation, with a timeout, after changing the RANDR + configuration for if we leave the user with an unusable display. + This also handles the case where the machine may crash after + changing the configuration; the old/known-good configuration will + be restored when the user restarts his session. + + Add public API to get to $(XDG_CONFIG_HOME)/monitors.xml and a + backup of that file (monitors.xml.backup): + + * libgnomeui/gnome-rr-config.h + (gnome_rr_config_get_backup_filename, + gnome_rr_config_get_intended_filename): New prototypes. + + * gnome-rr-config.c (gnome_rr_config_get_backup_filename): Implement. + (gnome_rr_config_get_intended_filename): Implement. + (get_config_filename): Replaced by gnome_rr_config_get_intended_filename(). + 2009-01-25 Vincent Untz <vuntz@gnome.org> * gnome-rr-config.c: (get_config_filename): create the config dir if it diff --git a/libgnome-desktop/gnome-rr-config.c b/libgnome-desktop/gnome-rr-config.c index 35efc493..0db7fa55 100644 --- a/libgnome-desktop/gnome-rr-config.c +++ b/libgnome-desktop/gnome-rr-config.c @@ -33,7 +33,8 @@ #include "libgnomeui/gnome-rr-config.h" #include "edid.h" -#define CONFIG_BASENAME "monitors.xml" +#define CONFIG_INTENDED_BASENAME "monitors.xml" +#define CONFIG_BACKUP_BASENAME "monitors.xml.backup" /* In version 0 of the config file format, we had several <configuration> * toplevel elements and no explicit version number. So, the filed looked @@ -78,7 +79,6 @@ static void output_free (GnomeOutputInfo *output); static GnomeOutputInfo *output_copy (GnomeOutputInfo *output); static gchar *get_old_config_filename (void); -static gchar *get_config_filename (void); typedef struct Parser Parser; @@ -432,7 +432,7 @@ configurations_read (GError **error) /* Try the new configuration file... */ - filename = get_config_filename (); + filename = gnome_rr_config_get_intended_filename (); err = NULL; @@ -917,25 +917,31 @@ gnome_rr_config_applicable (GnomeRRConfig *configuration, /* Database management */ -static gchar * -get_old_config_filename (void) +static void +ensure_config_directory (void) { - return g_build_filename (g_get_home_dir(), ".gnome2", CONFIG_BASENAME, NULL); + g_mkdir_with_parents (g_get_user_config_dir (), 0700); } static gchar * -get_config_filename (void) +get_old_config_filename (void) { - const char *config_dir; - - config_dir = g_get_user_config_dir (); + ensure_config_directory (); + return g_build_filename (g_get_home_dir(), ".gnome2", CONFIG_INTENDED_BASENAME, NULL); +} - if (!g_file_test (config_dir, G_FILE_TEST_IS_DIR)) - { - g_mkdir_with_parents (config_dir, 0700); - } +char * +gnome_rr_config_get_backup_filename (void) +{ + ensure_config_directory (); + return g_build_filename (g_get_user_config_dir (), CONFIG_BACKUP_BASENAME, NULL); +} - return g_build_filename (config_dir, CONFIG_BASENAME, NULL); +char * +gnome_rr_config_get_intended_filename (void) +{ + ensure_config_directory (); + return g_build_filename (g_get_user_config_dir (), CONFIG_INTENDED_BASENAME, NULL); } static const char * @@ -1092,7 +1098,7 @@ gnome_rr_config_save (GnomeRRConfig *configuration, GError **error) g_string_append_printf (output, "</monitors>\n"); - filename = get_config_filename (); + filename = gnome_rr_config_get_intended_filename (); result = g_file_set_contents (filename, output->str, -1, error); g_free (filename); diff --git a/libgnome-desktop/libgnomeui/gnome-rr-config.h b/libgnome-desktop/libgnomeui/gnome-rr-config.h index a59db557..ffff2def 100644 --- a/libgnome-desktop/libgnomeui/gnome-rr-config.h +++ b/libgnome-desktop/libgnomeui/gnome-rr-config.h @@ -92,6 +92,9 @@ gboolean gnome_rr_config_applicable (GnomeRRConfig *configuration, GnomeRRScreen *screen, GError **error); +char *gnome_rr_config_get_backup_filename (void); +char *gnome_rr_config_get_intended_filename (void); + /* A utility function that isn't really in the spirit of this file, but I don't * don't know a better place for it. */ |