private void OnVisualizationChanged(object o, ExtensionNodeEventArgs args)
        {
            VisualizationExtensionNode node =
                (VisualizationExtensionNode)args.ExtensionNode;

            if (args.Change == ExtensionChange.Add)
            {
                this.visualizationStore.AppendValues(node);

                if (this.visualizationStore.IterNChildren() == 1)
                {
                    this.visualizationList.Active = 0;
                }
            }
            else
            {
                TreeIter i;

                if (this.visualizationStore.GetIterFirst(out i))
                {
                    do
                    {
                        if (this.visualizationStore.GetValue(i, 0) == node)
                        {
                            this.visualizationStore.Remove(ref i);
                            break;
                        }
                    } while (this.visualizationStore.IterNext(ref i));
                }
            }
        }
        private void ConnectVisualization()
        {
            TreeIter i;

            this.DisposeRenderer();
            if (!this.visualizationList.GetActiveIter(out i))
            {
                return;
            }

            VisualizationExtensionNode node =
                (VisualizationExtensionNode)this.visualizationStore.GetValue(i, 0);

            this.renderer = node.CreateObject();
        }
        private void OnVisualizationChanged(object o, ExtensionNodeEventArgs args)
        {
            VisualizationExtensionNode node =
                (VisualizationExtensionNode) args.ExtensionNode;

            if (args.Change == ExtensionChange.Add) {
                RadioMenuItem group = visualizationMenu.Children.OfType<RadioMenuItem>().FirstOrDefault();
                RadioMenuItem menu = group != null ?
                    new RadioMenuItem(group, node.Label) :
                        new RadioMenuItem(node.Label);

                menu.Show();

                visualizationMenuMap[node] = menu;
                visualizationMenu.Add(menu);

                bool force = false;

                if (restoreFromSchema && node.IsSchemaSelected) {
                    restoreFromSchema = false;
                    force = true;
                }

                if (force || group == null) {
                    menu.Active = true;
                    activeVisualization = node;
                    ConnectVisualization();
                }

                menu.Activated += delegate {
                    if (!menu.Active)
                        return;

                    activeVisualization = node;
                    ConnectVisualization();

                    restoreFromSchema = false;
                    Banshee.OpenVP.Settings.SelectedVisualizationSchema.Set(node.Type.FullName);
                };

                noVisualizationsMenuItem.Hide();
            } else {
                RadioMenuItem menu;
                if (visualizationMenuMap.TryGetValue(node, out menu)) {
                    visualizationMenu.Remove(menu);
                    visualizationMenuMap.Remove(node);
                }

                bool haveVis = visualizationMenu.Children.Length != 1;

                if (node == activeVisualization) {
                    restoreFromSchema = true;

                    if (haveVis) {
                        ((MenuItem) visualizationMenu.Children[1]).Activate();
                    } else {
                        activeVisualization = null;
                    }

                    ConnectVisualization();
                }

                noVisualizationsMenuItem.Visible = !haveVis;
            }
        }
        private static void VisualizationCellDataFunc(CellLayout layout, CellRenderer r, TreeModel model, TreeIter iter)
        {
            VisualizationExtensionNode node = (VisualizationExtensionNode)model.GetValue(iter, 0);

            ((CellRendererText)r).Text = (node == null) ? "" : node.Label;
        }
Exemple #5
0
        private void OnVisualizationChanged(object o, ExtensionNodeEventArgs args)
        {
            VisualizationExtensionNode node =
                (VisualizationExtensionNode)args.ExtensionNode;

            if (args.Change == ExtensionChange.Add)
            {
                RadioMenuItem group = visualizationMenu.Children.OfType <RadioMenuItem>().FirstOrDefault();
                RadioMenuItem menu  = group != null ?
                                      new RadioMenuItem(group, node.Label) :
                                      new RadioMenuItem(node.Label);

                menu.Show();

                visualizationMenuMap[node] = menu;
                visualizationMenu.Add(menu);

                bool force = false;

                if (restoreFromSchema && node.IsSchemaSelected)
                {
                    restoreFromSchema = false;
                    force             = true;
                }

                if (force || group == null)
                {
                    menu.Active         = true;
                    activeVisualization = node;
                    ConnectVisualization();
                }

                menu.Activated += delegate {
                    if (!menu.Active)
                    {
                        return;
                    }

                    activeVisualization = node;
                    ConnectVisualization();

                    restoreFromSchema = false;
                    Banshee.OpenVP.Settings.SelectedVisualizationSchema.Set(node.Type.FullName);
                };

                noVisualizationsMenuItem.Hide();
            }
            else
            {
                RadioMenuItem menu;
                if (visualizationMenuMap.TryGetValue(node, out menu))
                {
                    visualizationMenu.Remove(menu);
                    visualizationMenuMap.Remove(node);
                }

                bool haveVis = visualizationMenu.Children.Length != 1;

                if (node == activeVisualization)
                {
                    restoreFromSchema = true;

                    if (haveVis)
                    {
                        ((MenuItem)visualizationMenu.Children[1]).Activate();
                    }
                    else
                    {
                        activeVisualization = null;
                    }

                    ConnectVisualization();
                }

                noVisualizationsMenuItem.Visible = !haveVis;
            }
        }