コード例 #1
0
        /// <summary>
        /// Activated when the user clicks the "Disable" button. Disables the selected,
        /// previously active plugin
        /// </summary>
        /// <param name="sender">
        /// A <see cref="System.Object"/> -- not used
        /// </param>
        /// <param name="e">
        /// A <see cref="EventArgs"/> -- not used
        /// </param>
        void OnDisableButtonClicked(object sender, EventArgs e)
        {
            LiveRadioPluginListModel model  = plugin_view.Model as LiveRadioPluginListModel;
            ILiveRadioPlugin         plugin = model[plugin_view.Model.Selection.FocusedIndex];

            if (!plugin.Enabled)
            {
                return;
            }
            LiveRadioSource source = plugin.PluginSource.Parent as LiveRadioSource;

            if (source == null)
            {
                return;
            }
            source.RemovePlugin(plugin);
            enable_button.Sensitive  = true;
            disable_button.Sensitive = false;
            plugin_view.GrabFocus();
        }
コード例 #2
0
        /// <summary>
        /// Constructor -- builds a basic dialog structure and adds each plugins configuration widget into a notebook
        /// </summary>
        /// <param name="plugins">
        /// A <see cref="List<ILiveRadioPlugin>"/> -- the list of plugins
        /// </param>
        public LiveRadioConfigDialog (LiveRadioSource source, List<ILiveRadioPlugin> plugins)
        {
            this.plugins = plugins;
            this.source = source;
            enable_plugin_buttons = new Dictionary<string, CheckButton> ();

            preferences_image.Yalign = 0f;
            preferences_image.IconName = "gtk-preferences";
            preferences_image.IconSize = (int)IconSize.Dialog;
            preferences_image.Show ();
            header_label.Text = String.Format (AddinManager.CurrentLocalizer.GetString ("{0}LiveRadio configuration\n{1}"), "<span weight=\"bold\" size=\"larger\">", "</span>");
            header_label.UseMarkup = true;
            header_label.Wrap = true;
            header_label.Yalign = 0f;
            header_label.Xalign = 0f;

            description_label.Text = AddinManager.CurrentLocalizer.GetString ("Please set your preferences for your LiveRadio plugins\n");
            description_label.Yalign = 0f;
            description_label.Xalign = 0f;

            foreach (ILiveRadioPlugin plugin in plugins)
            {
                Widget plugin_widget = plugin.ConfigurationWidget;
                if (plugin_widget != null)
                {
                    VBox box = new VBox ();
                    CheckButton button = new CheckButton (AddinManager.CurrentLocalizer.GetString ("Enable this plugin"));
                    if (source.EnabledPlugins.Contains (plugin.Name))
                        button.Active = true;

                    enable_plugin_buttons.Add(plugin.Name, button);

                    box.PackStart (button, false, true, 5);
                    box.PackStart (plugin_widget, true, true, 5);

                    notebook.AppendPage(box, new Label (plugin.Name));
                }
            }
            cancel_button.Image = new Image ("gtk-cancel", IconSize.Button);
            apply_button.Image = new Image ("gtk-apply", IconSize.Button);
            save_button.Image = new Image ("gtk-save", IconSize.Button);

            HBox main_container = new HBox ();
            VBox action_container = new VBox ();

            main_container.Spacing = 12;
            main_container.BorderWidth = 6;

            action_container.PackStart (header_label, true, true, 0);
            action_container.PackStart (description_label, true, true, 0);

            main_container.PackStart (preferences_image, true, true, 5);
            main_container.PackEnd (action_container, true, true, 5);
            this.VBox.PackStart (main_container, true, true, 5);

            this.VBox.PackStart (notebook, true, true, 5);

            AddActionWidget (cancel_button, 0);
            AddActionWidget (apply_button, 0);
            AddActionWidget (save_button, 0);

            cancel_button.Clicked += new EventHandler (OnCancelButtonClicked);
            apply_button.Clicked += new EventHandler (OnApplyButtonClicked);
            save_button.Clicked += new EventHandler (OnSaveButtonClicked);

            Title = "LiveRadio configuration";
            IconName = "gtk-preferences";
            Resizable = false;
            BorderWidth = 6;
            HasSeparator = false;
            this.VBox.Spacing = 12;

            ShowAll ();
        }
コード例 #3
0
        /// <summary>
        /// Constructor -- builds a basic dialog structure and adds each plugins configuration widget into a notebook
        /// </summary>
        /// <param name="plugins">
        /// A <see cref="List<ILiveRadioPlugin>"/> -- the list of plugins
        /// </param>
        public LiveRadioConfigDialog(LiveRadioSource source, List <ILiveRadioPlugin> plugins)
        {
            this.plugins          = plugins;
            this.source           = source;
            enable_plugin_buttons = new Dictionary <string, CheckButton> ();

            preferences_image.Yalign   = 0f;
            preferences_image.IconName = "gtk-preferences";
            preferences_image.IconSize = (int)IconSize.Dialog;
            preferences_image.Show();
            header_label.Text      = String.Format(AddinManager.CurrentLocalizer.GetString("{0}LiveRadio configuration\n{1}"), "<span weight=\"bold\" size=\"larger\">", "</span>");
            header_label.UseMarkup = true;
            header_label.Wrap      = true;
            header_label.Yalign    = 0f;
            header_label.Xalign    = 0f;

            description_label.Text   = AddinManager.CurrentLocalizer.GetString("Please set your preferences for your LiveRadio plugins\n");
            description_label.Yalign = 0f;
            description_label.Xalign = 0f;

            foreach (ILiveRadioPlugin plugin in plugins)
            {
                Widget plugin_widget = plugin.ConfigurationWidget;
                if (plugin_widget != null)
                {
                    VBox        box    = new VBox();
                    CheckButton button = new CheckButton(AddinManager.CurrentLocalizer.GetString("Enable this plugin"));
                    if (source.EnabledPlugins.Contains(plugin.Name))
                    {
                        button.Active = true;
                    }

                    enable_plugin_buttons.Add(plugin.Name, button);

                    box.PackStart(button, false, true, 5);
                    box.PackStart(plugin_widget, true, true, 5);

                    notebook.AppendPage(box, new Label(plugin.Name));
                }
            }
            cancel_button.Image = new Image("gtk-cancel", IconSize.Button);
            apply_button.Image  = new Image("gtk-apply", IconSize.Button);
            save_button.Image   = new Image("gtk-save", IconSize.Button);

            HBox main_container   = new HBox();
            VBox action_container = new VBox();

            main_container.Spacing     = 12;
            main_container.BorderWidth = 6;

            action_container.PackStart(header_label, true, true, 0);
            action_container.PackStart(description_label, true, true, 0);

            main_container.PackStart(preferences_image, true, true, 5);
            main_container.PackEnd(action_container, true, true, 5);
            this.ContentArea.PackStart(main_container, true, true, 5);

            this.ContentArea.PackStart(notebook, true, true, 5);

            AddActionWidget(cancel_button, 0);
            AddActionWidget(apply_button, 0);
            AddActionWidget(save_button, 0);

            cancel_button.Clicked += new EventHandler(OnCancelButtonClicked);
            apply_button.Clicked  += new EventHandler(OnApplyButtonClicked);
            save_button.Clicked   += new EventHandler(OnSaveButtonClicked);

            Title       = "LiveRadio configuration";
            IconName    = "gtk-preferences";
            Resizable   = false;
            BorderWidth = 6;
            this.ContentArea.Spacing = 12;

            ShowAll();
        }