gnome-desktop r5364 - in trunk/libgnome-desktop: . libgnomeui
- From: federico svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-desktop r5364 - in trunk/libgnome-desktop: . libgnomeui
- Date: Tue, 27 Jan 2009 20:28:10 +0000 (UTC)
Author: federico
Date: Tue Jan 27 20:28:10 2009
New Revision: 5364
URL: http://svn.gnome.org/viewvc/gnome-desktop?rev=5364&view=rev
Log:
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>
Modified:
trunk/libgnome-desktop/ChangeLog
trunk/libgnome-desktop/gnome-rr-config.c
trunk/libgnome-desktop/libgnomeui/gnome-rr-config.h
Modified: trunk/libgnome-desktop/gnome-rr-config.c
==============================================================================
--- trunk/libgnome-desktop/gnome-rr-config.c (original)
+++ trunk/libgnome-desktop/gnome-rr-config.c Tue Jan 27 20:28:10 2009
@@ -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 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 @@
/* Try the new configuration file... */
- filename = get_config_filename ();
+ filename = gnome_rr_config_get_intended_filename ();
err = NULL;
@@ -917,25 +917,31 @@
/* 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 @@
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);
Modified: trunk/libgnome-desktop/libgnomeui/gnome-rr-config.h
==============================================================================
--- trunk/libgnome-desktop/libgnomeui/gnome-rr-config.h (original)
+++ trunk/libgnome-desktop/libgnomeui/gnome-rr-config.h Tue Jan 27 20:28:10 2009
@@ -92,6 +92,9 @@
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.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]