コード例 #1
0
        /// <summary>
        /// Builds a preference entry for the provided parent based on the provided XElement node
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="foundEntry">The found entry.</param>
        /// <returns></returns>
        private IPreferenceEntry BuildPreferenceEntry(IPreference parent, XElement foundEntry)
        {
            var name                = XElementHelper.ReadStringValue(foundEntry, "name");
            var friendlyName        = XElementHelper.ReadStringValue(foundEntry, "friendlyName");
            var description         = XElementHelper.ReadStringValue(foundEntry, "description", false);
            var isSelectedByDefault = XElementHelper.ReadBoolValue(foundEntry, "isDefault", false);

            if (isSelectedByDefault && parent.HasDirectlyEditableValue)
            {
                /*
                 * This preference has both a list of pre-defined entries - one of which are selected by default -
                 * and a default value specified in the config file. There is really no obvious way to know which
                 * the user actually wanted to be the default value, so log this as a warning, and let the
                 * pre-defined option override the directly specified default value.
                 */

                parent.Value = name;
            }

            var entry = new PreferenceEntry(name, friendlyName, description, parent)
            {
                IsSelected = isSelectedByDefault
            };

            return(entry);
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        /// <summary>
        /// Builds a preference entry for the provided parent based on the provided XElement node
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="foundEntry">The found entry.</param>
        /// <returns></returns>
        private IPreferenceEntry BuildPreferenceEntry(IPreference parent, XElement foundEntry)
        {
            var name = XElementHelper.ReadStringValue(foundEntry, "name");
            var friendlyName = XElementHelper.ReadStringValue(foundEntry, "friendlyName");
            var description = XElementHelper.ReadStringValue(foundEntry, "description", false);
            var isSelectedByDefault = XElementHelper.ReadBoolValue(foundEntry, "isDefault", false);

            if (isSelectedByDefault && parent.HasDirectlyEditableValue)
            {
                /*
                 * This preference has both a list of pre-defined entries - one of which are selected by default -
                 * and a default value specified in the config file. There is really no obvious way to know which
                 * the user actually wanted to be the default value, so log this as a warning, and let the
                 * pre-defined option override the directly specified default value.
                 */

                parent.Value = name;
            }

            var entry = new PreferenceEntry(name, friendlyName, description, parent) { IsSelected = isSelectedByDefault };

            return entry;
        }