[rygel] core,ui: Diff between read-only and writable config
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Subject: [rygel] core,ui: Diff between read-only and writable config
- Date: Sat, 4 Jul 2009 15:15:02 +0000 (UTC)
commit 4d69b36dd03561ecf99b53780610df9aff38a497
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Thu Jun 25 00:20:47 2009 +0300
core,ui: Diff between read-only and writable config
read-only: Reads config from system-installed config file as well and
doesn't support saving of changes.
writable: Reads config only from user's config file and supports saving
of changes.
src/rygel/rygel-user-config.vala | 12 ++++++++++--
src/ui/rygel-preferences-dialog.vala | 2 +-
2 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/src/rygel/rygel-user-config.vala b/src/rygel/rygel-user-config.vala
index 25f6a9c..da681d8 100644
--- a/src/rygel/rygel-user-config.vala
+++ b/src/rygel/rygel-user-config.vala
@@ -123,12 +123,15 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
return config;
}
- public UserConfig () throws Error {
+ public UserConfig (bool read_only=true) throws Error {
this.key_file = new KeyFile ();
var dirs = new string[2];
dirs[0] = Environment.get_user_config_dir ();
- dirs[1] = BuildConfig.SYS_CONFIG_DIR;
+ if (!read_only) {
+ // We only write to user config
+ dirs[1] = BuildConfig.SYS_CONFIG_DIR;
+ }
this.key_file.load_from_dirs (CONFIG_FILE,
dirs,
@@ -136,6 +139,9 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
KeyFileFlags.KEEP_COMMENTS |
KeyFileFlags.KEEP_TRANSLATIONS);
debug ("Loaded user configuration from file '%s'", this.path);
+ if (read_only) {
+ this.path = null; // No need to keep the path around
+ }
DBus.Connection connection = DBus.Bus.get (DBus.BusType.SESSION);
@@ -150,6 +156,8 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
}
public void save () {
+ return_if_fail (this.path != null);
+
size_t length;
var data = this.key_file.to_data (out length);
diff --git a/src/ui/rygel-preferences-dialog.vala b/src/ui/rygel-preferences-dialog.vala
index 22019c1..c53edeb 100644
--- a/src/ui/rygel-preferences-dialog.vala
+++ b/src/ui/rygel-preferences-dialog.vala
@@ -34,7 +34,7 @@ public class Rygel.PreferencesDialog : GLib.Object {
ArrayList<PreferencesSection> sections;
public PreferencesDialog () throws Error {
- this.config = new UserConfig ();
+ this.config = new UserConfig (false);
this.builder = new Builder ();
this.builder.add_from_file (UI_FILE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]