private static Widget GetWidget(PreferenceBase preference, Type type) { Widget pref_widget = null; Widget widget = null; if (type == typeof (bool)) { pref_widget = new PreferenceCheckButton (preference); } else if (type == typeof (string)) { pref_widget = new PreferenceEntry (preference); } else if (type == typeof (int)) { var schema_preference = preference as SchemaPreference<int>; if (schema_preference == null) { pref_widget = new PreferenceSpinButton (preference); } else { pref_widget = new PreferenceSpinButton (preference, schema_preference.MinValue, schema_preference.MaxValue); } } if (pref_widget != null) { pref_widget.Sensitive = preference.Sensitive; pref_widget.Visible = preference.Visible; DescriptionLabel label = null; if (preference.ShowDescription) { VBox box = new VBox (); box.PackStart (pref_widget, false, false, 0); label = new DescriptionLabel (preference.Description); label.Visible = !String.IsNullOrEmpty (preference.Description); label.PackInto (box, false); widget = box; } preference.Changed += delegate (Root pref) { ThreadAssist.ProxyToMain (delegate { pref_widget.Sensitive = pref.Sensitive; pref_widget.Visible = pref.Visible; /*if (label != null) { label.Text = pref.Description; label.Visible = !String.IsNullOrEmpty (preference.Description); }*/ if (pref_widget is PreferenceCheckButton) { (pref_widget as PreferenceCheckButton).Label = pref.Name; } }); }; } return widget ?? pref_widget; }
private static Widget GetWidget(PreferenceBase preference, Type type) { Widget pref_widget = null; Widget widget = null; if (type == typeof(bool)) { pref_widget = new PreferenceCheckButton(preference); } else if (type == typeof(string)) { pref_widget = new PreferenceEntry(preference); } else if (type == typeof(int)) { var schema_preference = preference as SchemaPreference <int>; if (schema_preference == null) { pref_widget = new PreferenceSpinButton(preference); } else { pref_widget = new PreferenceSpinButton(preference, schema_preference.MinValue, schema_preference.MaxValue); } } if (pref_widget != null) { pref_widget.Sensitive = preference.Sensitive; pref_widget.Visible = preference.Visible; DescriptionLabel label = null; if (preference.ShowDescription) { VBox box = new VBox(); box.PackStart(pref_widget, false, false, 0); label = new DescriptionLabel(preference.Description); label.Visible = !String.IsNullOrEmpty(preference.Description); label.PackInto(box, false); widget = box; } preference.Changed += delegate(Root pref) { Banshee.Base.ThreadAssist.ProxyToMain(delegate { pref_widget.Sensitive = pref.Sensitive; pref_widget.Visible = pref.Visible; /*if (label != null) { * label.Text = pref.Description; * label.Visible = !String.IsNullOrEmpty (preference.Description); * }*/ if (pref_widget is PreferenceCheckButton) { (pref_widget as PreferenceCheckButton).Label = pref.Name; } }); }; } return(widget ?? pref_widget); }