[rygel/config] General options are loaded/saved on demand



commit 9dbba34610d8548b46e239645f348c55266a420f
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Apr 29 01:33:31 2009 +0300

    General options are loaded/saved on demand
---
 src/rygel/rygel-configuration.vala  |   92 +++++++++++++++++++++++++---------
 src/ui/rygel-general-pref-page.vala |   25 ++-------
 2 files changed, 73 insertions(+), 44 deletions(-)

diff --git a/src/rygel/rygel-configuration.vala b/src/rygel/rygel-configuration.vala
index aca774f..80337ba 100644
--- a/src/rygel/rygel-configuration.vala
+++ b/src/rygel/rygel-configuration.vala
@@ -45,35 +45,77 @@ public class Rygel.Configuration {
 
     protected GConf.Client gconf;
 
-    public bool enable_xbox;
-    public string host_ip;
-    public int port;
+    public bool enable_xbox {
+        get {
+            return this.get_bool ("general", XBOX_KEY, false);
+        }
+        set {
+            this.set_bool ("general", XBOX_KEY, value);
+        }
+    }
+
+    private string _host_ip;
+    public string host_ip {
+        get {
+            _host_ip = this.get_string ("general", IP_KEY, null);
+            return _host_ip;
+        }
+        set {
+            this.set_string ("general", IP_KEY, value);
+        }
+    }
 
-    public bool transcoding;
-    public bool mp3_transcoder;
-    public bool mp2ts_transcoder;
-    public bool lpcm_transcoder;
+    public int port {
+        get {
+            return this.get_int ("general",
+                                 PORT_KEY,
+                                 uint16.MIN,
+                                 uint16.MAX,
+                                 0);
+        }
+        set {
+            this.set_int ("general", PORT_KEY, value);
+        }
+    }
+
+    public bool transcoding {
+        get {
+            return this.get_bool ("general", TRANSCODING_KEY, true);
+        }
+        set {
+            this.set_bool ("general", TRANSCODING_KEY, value);
+        }
+    }
+
+    public bool mp3_transcoder {
+        get {
+            return this.get_bool ("general", MP3_TRANSCODER_KEY, true);
+        }
+        set {
+            this.set_bool ("general", MP3_TRANSCODER_KEY, value);
+        }
+    }
+
+    public bool mp2ts_transcoder {
+        get {
+            return this.get_bool ("general", MP2TS_TRANSCODER_KEY, true);
+        }
+        set {
+            this.set_bool ("general", MP2TS_TRANSCODER_KEY, value);
+        }
+    }
+
+    public bool lpcm_transcoder {
+        get {
+            return this.get_bool ("general", LPCM_TRANSCODER_KEY, true);
+        }
+        set {
+            this.set_bool ("general", LPCM_TRANSCODER_KEY, value);
+        }
+    }
 
     public Configuration () {
         this.gconf = GConf.Client.get_default ();
-
-        this.enable_xbox = this.get_bool ("general", XBOX_KEY, false);
-        this.host_ip = this.get_string ("general", IP_KEY, null);
-        this.port = this.get_int ("general",
-                                  PORT_KEY,
-                                  uint16.MIN,
-                                  uint16.MAX,
-                                  0);
-        this.transcoding = this.get_bool ("general", TRANSCODING_KEY, true);
-        this.mp3_transcoder = this.get_bool ("general",
-                                             MP3_TRANSCODER_KEY,
-                                             true);
-        this.mp2ts_transcoder = this.get_bool ("general",
-                                               MP2TS_TRANSCODER_KEY,
-                                               true);
-        this.lpcm_transcoder = this.get_bool ("general",
-                                              LPCM_TRANSCODER_KEY,
-                                              true);
     }
 
     public bool get_enabled (string section) {
diff --git a/src/ui/rygel-general-pref-page.vala b/src/ui/rygel-general-pref-page.vala
index 551fb22..c406902 100644
--- a/src/ui/rygel-general-pref-page.vala
+++ b/src/ui/rygel-general-pref-page.vala
@@ -68,25 +68,12 @@ public class Rygel.GeneralPrefPage : PreferencesPage {
     }
 
     public override void save () {
-        this.config.set_string (this.section,
-                                Configuration.IP_KEY,
-                                this.ip_entry.get_text ());
+        this.config.host_ip = this.ip_entry.get_text ();
+        this.config.port = (int) this.port_spin.get_value ();
 
-        this.config.set_int (this.section,
-                             Configuration.PORT_KEY,
-                             (int) this.port_spin.get_value ());
-
-        this.config.set_bool (this.section,
-                              Configuration.TRANSCODING_KEY,
-                              this.trans_check.active);
-        this.config.set_bool (this.section,
-                              Configuration.MP3_TRANSCODER_KEY,
-                              this.mp3_check.active);
-        this.config.set_bool (this.section,
-                              Configuration.MP2TS_TRANSCODER_KEY,
-                              this.mp2ts_check.active);
-        this.config.set_bool (this.section,
-                              Configuration.LPCM_TRANSCODER_KEY,
-                              this.lpcm_check.active);
+        this.config.transcoding = this.trans_check.active;
+        this.config.mp3_transcoder = this.mp3_check.active;
+        this.config.mp2ts_transcoder = this.mp2ts_check.active;
+        this.config.lpcm_transcoder = this.lpcm_check.active;
     }
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]