ui: Merge PluginPrefSection into MediaExportPrefSection
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Mon, 14 Feb 2011 16:01:58 +0000 (18:01 +0200)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 17 Feb 2011 23:47:13 +0000 (01:47 +0200)
po/POTFILES.in
src/ui/Makefile.am
src/ui/rygel-media-export-pref-section.vala
src/ui/rygel-plugin-pref-section.vala [deleted file]

index 2c35cf3..5426e42 100644 (file)
@@ -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
index 79d65b6..0680585 100644 (file)
@@ -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
 
index 37a4e3b..ba32731 100644 (file)
 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;
diff --git a/src/ui/rygel-plugin-pref-section.vala b/src/ui/rygel-plugin-pref-section.vala
deleted file mode 100644 (file)
index c048128..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2009 Nokia Corporation.
- *
- * 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 Gtk;
-using Gee;
-
-public class Rygel.PluginPrefSection : PreferencesSection {
-    const string ENABLED_CHECK = "-enabled-checkbutton";
-    const string TITLE_LABEL = "-title-label";
-    const string TITLE_ENTRY = "-title-entry";
-
-    private CheckButton enabled_check;
-    private Entry title_entry;
-
-    protected ArrayList<Widget> widgets; // All widgets in this section
-
-    public PluginPrefSection (Builder            builder,
-                              WritableUserConfig config,
-                              string             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);
-    }
-
-    public override void 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);
-    }
-
-    protected 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 ();
-    }
-}