[rygel/config] Convenient methods to read boolean and integer.



commit ed7552b8d5b8526bf204000a416092d4de20c164
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Apr 21 17:46:57 2009 +0300

    Convenient methods to read boolean and integer.
    
    Provide convenient methods to read boolean and integer from gconf.
---
 src/rygel/rygel-config-reader.vala |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/src/rygel/rygel-config-reader.vala b/src/rygel/rygel-config-reader.vala
index d32dab7..364ca77 100644
--- a/src/rygel/rygel-config-reader.vala
+++ b/src/rygel/rygel-config-reader.vala
@@ -80,5 +80,41 @@ public class Rygel.ConfigReader {
 
         return val;
     }
+
+    private int get_int (string section,
+                         string key,
+                         int    min,
+                         int    max,
+                         int    default_value) {
+        int val;
+        var path = ROOT_GCONF_PATH + section + "/" + key;
+
+        try {
+            val = this.gconf.get_int (path);
+        } catch (GLib.Error error) {
+            val = default_value;
+        }
+
+        if (val < min || val > max) {
+            val = default_value;
+        }
+
+        return val;
+    }
+
+    private bool get_bool (string section,
+                           string key,
+                           bool   default_value) {
+        bool val;
+        var path = ROOT_GCONF_PATH + section + "/" + key;
+
+        try {
+            val = this.gconf.get_bool (path);
+        } catch (GLib.Error error) {
+            val = default_value;
+        }
+
+        return val;
+    }
 }
 



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