Tab CreateTab(GtkShellDocumentViewItem view) { var tab = GtkShellDocumentViewContainerTabs.CreateTab(tabstrip, view); tab.Activated += TabActivated; return(tab); }
public void SetCurrentMode(DocumentViewContainerMode mode, GtkShellDocumentViewItem newActive) { if (this.currentMode == mode) { return; } // Save current split sizes if (currentContainer is GtkShellDocumentViewContainerSplit split) { splitSizes = split.GetRelativeSplitSizes(); } this.currentMode = mode; GtkShellDocumentViewItem activeView = null; List <GtkShellDocumentViewItem> allViews = null; if (currentContainer != null) { activeView = currentContainer.ActiveView; currentContainer.ActiveViewChanged -= Container_ActiveViewChanged; allViews = currentContainer.GetAllViews().ToList(); currentContainer.Widget.Hide(); currentContainer.RemoveAllViews(); } if (mode == DocumentViewContainerMode.Tabs) { if (tabsContainer == null) { tabsContainer = new GtkShellDocumentViewContainerTabs(); rootTabsBox.PackStart(tabsContainer.Widget, true, true, 0); } currentContainer = tabsContainer; } else { if (splitContainer == null) { splitContainer = new GtkShellDocumentViewContainerSplit(mode); rootTabsBox.PackStart(splitContainer.Widget, true, true, 0); } currentContainer = splitContainer; if (hasSplit) { tabstrip.ActiveTab = tabstrip.TabCount - 1; } } if (allViews != null) { currentContainer.AddViews(allViews); } // Restore current split sizes if (splitSizes != null && currentContainer is GtkShellDocumentViewContainerSplit newSplit) { newSplit.SetRelativeSplitSizes(splitSizes); } currentContainer.ActiveView = newActive ?? activeView; currentContainer.ActiveViewChanged += Container_ActiveViewChanged; currentContainer.Widget.Show(); if (newActive != activeView) { ActiveViewChanged?.Invoke(this, EventArgs.Empty); } CurrentModeChanged?.Invoke(this, EventArgs.Empty); }