[rygel] ui: Better way of setting plugin widgets' sensitivity
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rygel] ui: Better way of setting plugin widgets' sensitivity
- Date: Sun, 27 Sep 2009 23:24:58 +0000 (UTC)
commit 902f07161db9a3ac3bc90d30cdf186fa23691dde
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Mon Sep 28 01:37:38 2009 +0300
ui: Better way of setting plugin widgets' sensitivity
Instead of PluginPref implementations overriding a handler, they just
provide a list of all widgets.
src/ui/rygel-media-export-pref-section.vala | 21 ++++-----------------
src/ui/rygel-plugin-pref-section.vala | 12 ++++++++++--
src/ui/rygel-tracker-pref-section.vala | 13 ++++---------
3 files changed, 18 insertions(+), 28 deletions(-)
---
diff --git a/src/ui/rygel-media-export-pref-section.vala b/src/ui/rygel-media-export-pref-section.vala
index 2dc7421..7e07135 100644
--- a/src/ui/rygel-media-export-pref-section.vala
+++ b/src/ui/rygel-media-export-pref-section.vala
@@ -37,8 +37,6 @@ public class Rygel.MediaExportPrefSection : Rygel.PluginPrefSection {
private ListStore liststore;
private FileChooserDialog dialog;
- private ArrayList<Button> buttons;
-
public MediaExportPrefSection (Builder builder,
UserConfig config) {
base (builder, config, NAME);
@@ -56,6 +54,7 @@ public class Rygel.MediaExportPrefSection : Rygel.PluginPrefSection {
"text",
0,
null);
+ this.widgets.add (this.treeview);
try {
var uris = config.get_string_list (this.name, URIS_KEY);
@@ -70,19 +69,17 @@ public class Rygel.MediaExportPrefSection : Rygel.PluginPrefSection {
this.dialog.set_current_folder (Environment.get_home_dir ());
this.dialog.show_hidden = false;
- this.buttons = new ArrayList<Button> ();
-
var button = (Button) builder.get_object (ADD_BUTTON);
button.clicked += this.on_add_button_clicked;
- this.buttons.add (button);
+ this.widgets.add (button);
button = (Button) builder.get_object (REMOVE_BUTTON);
button.clicked += this.on_remove_button_clicked;
- this.buttons.add (button);
+ this.widgets.add (button);
button = (Button) builder.get_object (CLEAR_BUTTON);
button.clicked += this.on_clear_button_clicked;
- this.buttons.add (button);
+ this.widgets.add (button);
}
public override void save () {
@@ -103,16 +100,6 @@ public class Rygel.MediaExportPrefSection : Rygel.PluginPrefSection {
this.config.set_string_list (this.name, URIS_KEY, uri_list);
}
- protected override void on_enabled_check_toggled (
- CheckButton enabled_check) {
- base.on_enabled_check_toggled (enabled_check);
-
- this.treeview.sensitive = enabled_check.active;
- foreach (var button in this.buttons) {
- button.sensitive = enabled_check.active;
- }
- }
-
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
index 453d2d7..bd1ff04 100644
--- a/src/ui/rygel-plugin-pref-section.vala
+++ b/src/ui/rygel-plugin-pref-section.vala
@@ -21,6 +21,7 @@
* 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";
@@ -29,11 +30,15 @@ public class Rygel.PluginPrefSection : PreferencesSection {
private CheckButton enabled_check;
private Entry title_entry;
+ protected ArrayList<Widget> widgets; // All widgets in this section
+
public PluginPrefSection (Builder builder,
UserConfig 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);
@@ -69,8 +74,11 @@ public class Rygel.PluginPrefSection : PreferencesSection {
this.config.set_string (this.name, UserConfig.TITLE_KEY, title);
}
- protected virtual void on_enabled_check_toggled (
- CheckButton enabled_check) {
+ protected void on_enabled_check_toggled (CheckButton enabled_check) {
this.title_entry.sensitive = enabled_check.active;
+
+ foreach (var widget in this.widgets) {
+ widget.sensitive = enabled_check.active;
+ }
}
}
diff --git a/src/ui/rygel-tracker-pref-section.vala b/src/ui/rygel-tracker-pref-section.vala
index 3fc5b6d..5ca4e76 100644
--- a/src/ui/rygel-tracker-pref-section.vala
+++ b/src/ui/rygel-tracker-pref-section.vala
@@ -47,6 +47,10 @@ public class Rygel.TrackerPrefSection : Rygel.PluginPrefSection {
this.pictures_check = (CheckButton) builder.get_object (PICTURES_CHECK);
assert (this.pictures_check != null);
+ this.widgets.add (this.videos_check);
+ this.widgets.add (this.music_check);
+ this.widgets.add (this.pictures_check);
+
this.videos_check.active = true;
this.music_check.active = true;
this.pictures_check.active = true;
@@ -66,13 +70,4 @@ public class Rygel.TrackerPrefSection : Rygel.PluginPrefSection {
config.set_bool (this.name, MUSIC_KEY, this.music_check.active);
config.set_bool (this.name, PICTURES_KEY, this.pictures_check.active);
}
-
- protected override void on_enabled_check_toggled (
- CheckButton enabled_check) {
- base.on_enabled_check_toggled (enabled_check);
-
- this.videos_check.sensitive = enabled_check.active;
- this.music_check.sensitive = enabled_check.active;
- this.pictures_check.sensitive = enabled_check.active;
- }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]