Esempio n. 1
0
        IEnumerable <Widget> IOutlinedDocument.GetToolbarWidgets()
        {
            if (toolbarWidgets != null)
            {
                return(toolbarWidgets);
            }

            var groupToggleButton = new ToggleButton {
                Image       = new ImageView(Ide.Gui.Stock.GroupByCategory, IconSize.Menu),
                TooltipText = GettextCatalog.GetString("Group entries by type"),
                Active      = settings.IsGrouped,
            };

            groupToggleButton.Toggled += delegate {
                if (groupToggleButton.Active == settings.IsGrouped)
                {
                    return;
                }
                settings.IsGrouped = groupToggleButton.Active;
                UpdateSorting();
            };

            var sortAlphabeticallyToggleButton = new ToggleButton {
                Image       = new ImageView(Ide.Gui.Stock.SortAlphabetically, IconSize.Menu),
                TooltipText = GettextCatalog.GetString("Sort entries alphabetically"),
                Active      = settings.IsSorted,
            };

            sortAlphabeticallyToggleButton.Toggled += delegate {
                if (sortAlphabeticallyToggleButton.Active == settings.IsSorted)
                {
                    return;
                }
                settings.IsSorted = sortAlphabeticallyToggleButton.Active;
                UpdateSorting();
            };

            var preferencesButton = new DockToolButton(Ide.Gui.Stock.Options)
            {
                TooltipText = GettextCatalog.GetString("Open preferences dialog"),
            };

            preferencesButton.Clicked += delegate {
                using (var dialog = new OutlineSortingPreferencesDialog(settings)) {
                    if (MonoDevelop.Ide.MessageService.ShowCustomDialog(dialog) == (int)Gtk.ResponseType.Ok)
                    {
                        dialog.SaveSettings();
                        comparer = new OutlineNodeComparer(new AstAmbience(IdeApp.TypeSystemService.Workspace.Options), settings, outlineTreeModelSort);
                        UpdateSorting();
                    }
                }
            };

            return(toolbarWidgets = new Widget [] {
                groupToggleButton,
                sortAlphabeticallyToggleButton,
                new VSeparator(),
                preferencesButton,
            });
        }
        void IOutlinedDocument.ReleaseOutlineWidget()
        {
            if (outlineTreeView == null)
            {
                return;
            }
            var w = (ScrolledWindow)outlineTreeView.Parent;

            w.Destroy();
            if (outlineTreeModelSort != null)
            {
                outlineTreeModelSort.Dispose();
                outlineTreeModelSort = null;
            }
            if (outlineTreeStore != null)
            {
                outlineTreeStore.Dispose();
                outlineTreeStore = null;
            }
            outlineTreeView = null;
            settings        = null;
            foreach (var tw in toolbarWidgets)
            {
                tw.Destroy();
            }
            toolbarWidgets = null;
            comparer       = null;
        }
Esempio n. 3
0
        Widget IOutlinedDocument.GetOutlineWidget()
        {
            if (outlineTreeView != null)
            {
                return(outlineTreeView);
            }

            outlineTreeStore     = new TreeStore(typeof(object));
            outlineTreeModelSort = new TreeModelSort(outlineTreeStore);

            settings = OutlineSettings.Load();
            comparer = new OutlineNodeComparer(new AstAmbience(IdeApp.TypeSystemService.Workspace.Options), settings, outlineTreeModelSort);

            outlineTreeModelSort.SetSortFunc(0, comparer.CompareNodes);
            outlineTreeModelSort.SetSortColumnId(0, SortType.Ascending);

            outlineTreeView = new MonoDevelop.Ide.Gui.Components.PadTreeView(outlineTreeStore);

            var pixRenderer = new CellRendererImage();

            pixRenderer.Xpad = 0;
            pixRenderer.Ypad = 0;

            outlineTreeView.TextRenderer.Xpad = 0;
            outlineTreeView.TextRenderer.Ypad = 0;

            TreeViewColumn treeCol = new TreeViewColumn();

            treeCol.PackStart(pixRenderer, false);

            treeCol.SetCellDataFunc(pixRenderer, new TreeCellDataFunc(OutlineTreeIconFunc));
            treeCol.PackStart(outlineTreeView.TextRenderer, true);

            treeCol.SetCellDataFunc(outlineTreeView.TextRenderer, new TreeCellDataFunc(OutlineTreeTextFunc));
            outlineTreeView.AppendColumn(treeCol);

            outlineTreeView.HeadersVisible = false;

            outlineTreeView.Selection.Changed += delegate {
                JumpToDeclaration(false);
            };

            outlineTreeView.RowActivated += delegate {
                JumpToDeclaration(true);
            };

            UpdateDocumentOutline(this, EventArgs.Empty);
            outlineTreeView.Realized += delegate { RefillOutlineStore(); };
            UpdateSorting();

            var sw = new CompactScrolledWindow();

            sw.Add(outlineTreeView);
            sw.ShowAll();
            return(sw);
        }
Esempio n. 4
0
 public override void Dispose()
 {
     if (disposed)
     {
         return;
     }
     disposed = true;
     if (DocumentContext != null)
     {
         DocumentContext.DocumentParsed -= UpdateDocumentOutline;
     }
     RemoveRefillOutlineStoreTimeout();
     lastCU   = null;
     settings = null;
     comparer = null;
     base.Dispose();
 }
        void IOutlinedDocument.ReleaseOutlineWidget()
        {
            if (outlineTreeView == null)
            {
                return;
            }
            var w = (ScrolledWindow)outlineTreeView.Parent;

            w.Destroy();
            outlineTreeView = null;
            settings        = null;
            foreach (var tw in toolbarWidgets)
            {
                tw.Destroy();
            }
            toolbarWidgets = null;
            comparer       = null;
        }
Esempio n. 6
0
        public override void Dispose()
        {
            if (disposed)
            {
                return;
            }
            disposed = true;
            if (DocumentContext != null)
            {
                DocumentContext.DocumentParsed -= UpdateDocumentOutline;
            }
            RemoveRefillOutlineStoreTimeout();
            lastCU   = null;
            settings = null;
            comparer = null;

            // also, unsubscribe from text view events, if we're in the new editor
            TextView_Closed(this, null);

            base.Dispose();
        }