public ProfileComboBoxConfigurable(MediaProfileManager manager, string configurationId, Box parent) { HBox editor = new HBox(); configuration_id = configurationId; combo = new ProfileComboBox(manager); combo.Show(); button = new ProfileConfigureButton(configurationId); button.ComboBox = combo; button.Show(); editor.Spacing = 5; editor.PackStart(combo, true, true, 0); editor.PackStart(button, false, false, 0); editor.Show(); ProfileConfiguration config = manager.GetActiveProfileConfiguration(configurationId); if (config != null) { Combo.SetActiveProfile(config.Profile); } description = new DescriptionLabel(delegate { var profile = Combo.ActiveProfile; return(profile != null ? profile.Description : ""); }); Combo.Changed += delegate { if (Combo.ActiveProfile != null) { Hyena.Log.DebugFormat("Setting active encoding profile: {0} (saved to {1})", Combo.ActiveProfile.Name, configurationId); ProfileConfiguration.SaveActiveProfile(Combo.ActiveProfile, configurationId); description.Update(); } }; Combo.StateChanged += delegate { if (Combo.State == StateType.Insensitive && description.Parent != null) { ((Container)parent ?? this).Remove(description); } else if (description.Parent == null) { description.PackInto(parent ?? this, parent != null); } }; Spacing = 5; PackStart(editor, true, true, 0); description.PackInto(parent ?? this, parent != null); }
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; }
public ProfileComboBoxConfigurable(MediaProfileManager manager, string configurationId, Box parent) { HBox editor = new HBox(); configuration_id = configurationId; combo = new ProfileComboBox(manager); combo.Show(); button = new ProfileConfigureButton(configurationId); button.ComboBox = combo; button.Show(); editor.Spacing = 5; editor.PackStart(combo, true, true, 0); editor.PackStart(button, false, false, 0); editor.Show(); ProfileConfiguration config = manager.GetActiveProfileConfiguration (configurationId); if (config != null) { Combo.SetActiveProfile(config.Profile); } description = new DescriptionLabel (delegate { var profile = Combo.ActiveProfile; return profile != null ? profile.Description : ""; }); Combo.Changed += delegate { if(Combo.ActiveProfile != null) { Hyena.Log.DebugFormat ("Setting active encoding profile: {0} (saved to {1})", Combo.ActiveProfile.Name, configurationId); ProfileConfiguration.SaveActiveProfile (Combo.ActiveProfile, configurationId); description.Update (); } }; Combo.StateChanged += delegate { if (Combo.State == StateType.Insensitive && description.Parent != null) { ((Container)parent ?? this).Remove (description); } else if (description.Parent == null) { description.PackInto (parent ?? this, parent != null); } }; Spacing = 5; PackStart (editor, true, true, 0); description.PackInto (parent ?? this, parent != null); }