[rygel/config] New class for editing of user configuration.



commit 1146b26a50be11d32617ad55118d760f82a262fc
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Apr 21 18:33:35 2009 +0300

    New class for editing of user configuration.
---
 src/ui/Makefile.am              |   13 ++++--
 src/ui/rygel-config-editor.vala |   86 +++++++++++++++++++++++++++++++++++++++
 src/ui/rygel-preferences.vala   |    8 ++--
 3 files changed, 98 insertions(+), 9 deletions(-)

diff --git a/src/ui/Makefile.am b/src/ui/Makefile.am
index dbfef4a..1cd52da 100644
--- a/src/ui/Makefile.am
+++ b/src/ui/Makefile.am
@@ -21,16 +21,19 @@ AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
 bin_PROGRAMS = rygel-preferences
 
 BUILT_SOURCES = rygel.stamp \
-		rygel-preferences.c
+		rygel-preferences.c \
+		rygel-config-editor.c
 
 rygel_preferences_SOURCES = rygel-preferences.c \
-                            rygel-preferences.vala
+			    rygel-preferences.vala \
+			    rygel-config-editor.c \
+			    rygel-config-editor.vala
 
 rygel.stamp: $(filter %.vala,$(rygel_preferences_SOURCES))
 	$(VALAC) -C --vapidir=$(rygeldir) \
-	--pkg rygel-1.0 --pkg gupnp-1.0 --pkg gupnp-av-1.0 --pkg dbus-glib-1 \
-	--pkg gconf-2.0 --pkg gstreamer-0.10 --pkg gio-2.0 --pkg gee-1.0 \
-        --pkg gtk+-2.0 $^
+	--pkg rygel-1.0 --pkg cstuff --pkg gupnp-1.0 --pkg gupnp-av-1.0 \
+	--pkg dbus-glib-1 --pkg gconf-2.0 --pkg gstreamer-0.10 \
+	--pkg gio-2.0 --pkg gee-1.0 --pkg gtk+-2.0 $^
 	touch $@
 
 rygel_preferences_LDADD = $(LIBGUPNP_LIBS) \
diff --git a/src/ui/rygel-config-editor.vala b/src/ui/rygel-config-editor.vala
new file mode 100644
index 0000000..74929cd
--- /dev/null
+++ b/src/ui/rygel-config-editor.vala
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2008,2009 Nokia Corporation, all rights reserved.
+ * Copyright (C) 2008,2009 Zeeshan Ali (Khattak) <zeeshanak gnome org>.
+ *
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ *                               <zeeshan ali nokia com>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+using GConf;
+using CStuff;
+
+/**
+ * User configuration editor for Rygel.
+ */
+public class Rygel.ConfigEditor : ConfigReader {
+    public ConfigEditor () {
+        base ();
+    }
+
+    public void set_title (string section, string title) {
+        this.set_string (section, "Title", title);
+    }
+
+    public void set_udn (string section, string? udn) {
+        var value = udn;
+
+        if (value == null) {
+            value = Utils.generate_random_udn ();
+        }
+
+        this.set_string (section, "UDN", value);
+    }
+
+    public void set_string (string section,
+                            string key,
+                            string value) {
+        var path = ROOT_GCONF_PATH + section + "/" + key;
+
+        try {
+            this.gconf.set_string (path, value);
+        } catch (GLib.Error error) {
+            // No big deal
+        }
+    }
+
+    public void set_int (string section,
+                         string key,
+                         int    value) {
+        var path = ROOT_GCONF_PATH + section + "/" + key;
+
+        try {
+            this.gconf.set_int (path, value);
+        } catch (GLib.Error error) {
+            // No big deal
+        }
+    }
+
+    public void set_bool (string section,
+                          string key,
+                          bool   value) {
+        var path = ROOT_GCONF_PATH + section + "/" + key;
+
+        try {
+            this.gconf.set_bool (path, value);
+        } catch (GLib.Error error) {
+            // No big deal
+        }
+    }
+}
+
diff --git a/src/ui/rygel-preferences.vala b/src/ui/rygel-preferences.vala
index ff3b9e8..7b1c0e1 100644
--- a/src/ui/rygel-preferences.vala
+++ b/src/ui/rygel-preferences.vala
@@ -26,18 +26,18 @@ public class Rygel.Preferences : Dialog {
     public Preferences () {
         this.title = "Rygel Preferences";
 
-        var config_reader = new Rygel.ConfigReader ();
+        var config_editor = new Rygel.ConfigEditor ();
 
         this.add_string_pref ("IP",
-                              config_reader.host_ip,
+                              config_editor.host_ip,
                               "The IP to advertise the UPnP MediaServer on");
         this.add_int_pref ("Port",
-                           config_reader.port,
+                           config_editor.port,
                            uint16.MIN,
                            uint16.MAX,
                            "The port to advertise the UPnP MediaServer on");
         this.add_boolean_pref ("XBox support",
-                               config_reader.enable_xbox,
+                               config_editor.enable_xbox,
                                "Enable Xbox support");
 
         this.add_button (STOCK_OK, ResponseType.ACCEPT);



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