[rygel] ui: Merge PluginPrefSection into MediaExportPrefSection



commit 9f17e26a9647902702e96c7ae67fc76b175b586a
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Mon Feb 14 18:01:58 2011 +0200

    ui: Merge PluginPrefSection into MediaExportPrefSection

 po/POTFILES.in                              |    1 -
 src/ui/Makefile.am                          |    1 -
 src/ui/rygel-media-export-pref-section.vala |   66 +++++++++++++++++-
 src/ui/rygel-plugin-pref-section.vala       |   97 ---------------------------
 4 files changed, 63 insertions(+), 102 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 2c35cf3..5426e42 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -148,7 +148,6 @@ src/rygel/rygel-xbox-hacks.vala
 src/rygel/rygel-changelog.vala
 src/ui/rygel-general-pref-section.vala
 src/ui/rygel-media-export-pref-section.vala
-src/ui/rygel-plugin-pref-section.vala
 src/ui/rygel-preferences-dialog.vala
 src/ui/rygel-preferences-section.vala
 src/ui/rygel-writable-user-config.vala
diff --git a/src/ui/Makefile.am b/src/ui/Makefile.am
index 79d65b6..0680585 100644
--- a/src/ui/Makefile.am
+++ b/src/ui/Makefile.am
@@ -27,7 +27,6 @@ rygel_preferences_SOURCES = \
 			    rygel-preferences-dialog.vala \
 			    rygel-preferences-section.vala \
 			    rygel-general-pref-section.vala \
-			    rygel-plugin-pref-section.vala \
 			    rygel-media-export-pref-section.vala \
 			    rygel-writable-user-config.vala
 
diff --git a/src/ui/rygel-media-export-pref-section.vala b/src/ui/rygel-media-export-pref-section.vala
index 37a4e3b..ba32731 100644
--- a/src/ui/rygel-media-export-pref-section.vala
+++ b/src/ui/rygel-media-export-pref-section.vala
@@ -23,7 +23,10 @@
 using Gtk;
 using Gee;
 
-public class Rygel.MediaExportPrefSection : Rygel.PluginPrefSection {
+public class Rygel.MediaExportPrefSection : PreferencesSection {
+    const string ENABLED_CHECK = "-enabled-checkbutton";
+    const string TITLE_LABEL = "-title-label";
+    const string TITLE_ENTRY = "-title-entry";
     const string NAME = "MediaExport";
     const string URIS_KEY = "uris";
     const string URIS_LABEL = URIS_KEY + "-label";
@@ -34,13 +37,51 @@ public class Rygel.MediaExportPrefSection : Rygel.PluginPrefSection {
     const string REMOVE_BUTTON = "remove-button";
     const string CLEAR_BUTTON = "clear-button";
 
+    private CheckButton enabled_check;
+    private Entry title_entry;
+
+    private ArrayList<Widget> widgets; // All widgets in this section
+
     private TreeView treeview;
     private ListStore liststore;
     private FileChooserDialog dialog;
 
     public MediaExportPrefSection (Builder            builder,
                                    WritableUserConfig config) {
-        base (builder, config, NAME);
+        base (config, NAME);
+
+        this.widgets = new ArrayList<Widget> ();
+
+        this.enabled_check = (CheckButton) builder.get_object (name.down () +
+                                                               ENABLED_CHECK);
+        assert (this.enabled_check != null);
+        this.title_entry = (Entry) builder.get_object (name.down () +
+                                                       TITLE_ENTRY);
+        assert (this.title_entry != null);
+        var title_label = (Label) builder.get_object (name.down () +
+                                                      TITLE_LABEL);
+        assert (title_label != null);
+        this.widgets.add (title_label);
+
+        try {
+            this.enabled_check.active = config.get_enabled (name);
+        } catch (GLib.Error err) {
+            this.enabled_check.active = false;
+        }
+
+        string title;
+        try {
+            title = config.get_title (name);
+        } catch (GLib.Error err) {
+            title = name;
+        }
+
+        title = title.replace ("@REALNAME@", "%n");
+        title = title.replace ("@USERNAME@", "%u");
+        title = title.replace ("@HOSTNAME@", "%h");
+        this.title_entry.set_text (title);
+
+        this.enabled_check.toggled.connect (this.on_enabled_check_toggled);
 
         this.treeview = (TreeView) builder.get_object (URIS_TEXTVIEW);
         assert (this.treeview != null);
@@ -91,7 +132,14 @@ public class Rygel.MediaExportPrefSection : Rygel.PluginPrefSection {
     }
 
     public override void save () {
-        base.save ();
+        this.config.set_bool (this.name,
+                              UserConfig.ENABLED_KEY,
+                              this.enabled_check.active);
+
+        var title = this.title_entry.get_text ().replace ("%n", "@REALNAME@");
+        title = title.replace ("%u", "@USERNAME@");
+        title = title.replace ("%h", "@HOSTNAME@");
+        this.config.set_string (this.name, UserConfig.TITLE_KEY, title);
 
         TreeIter iter;
         var uri_list = new ArrayList<string> ();
@@ -108,6 +156,18 @@ public class Rygel.MediaExportPrefSection : Rygel.PluginPrefSection {
         this.config.set_string_list (this.name, URIS_KEY, uri_list);
     }
 
+    private void reset_widgets_sensitivity () {
+        this.title_entry.sensitive = this.enabled_check.active;
+
+        foreach (var widget in this.widgets) {
+            widget.sensitive = enabled_check.active;
+        }
+    }
+
+    private void on_enabled_check_toggled (ToggleButton enabled_check) {
+        this.reset_widgets_sensitivity ();
+    }
+
     private void on_add_button_clicked (Button button) {
         if (this.dialog.run () == ResponseType.OK) {
             TreeIter iter;



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