diff options
author | Lluis Sanchez <lluis@novell.com> | 2010-03-18 19:39:00 +0300 |
---|---|---|
committer | Lluis Sanchez <lluis@novell.com> | 2010-03-18 19:39:00 +0300 |
commit | 099e20cde3ae001638e366215885f110cc69ea16 (patch) | |
tree | 442be83e80fd12ea5fcc984db5b1117910ceacd1 /main | |
parent | a53e9d46686838f9ab224f2f7e64a9d5f542dd62 (diff) |
* Makefile.am:
* MonoDevelop.Ide.csproj: Updated.
* MonoDevelop.Ide/Ide.cs:
* MonoDevelop.Ide.Gui/StatusProgressMonitor.cs: Use the new status bar
model.
* MonoDevelop.Ide/ImageService.cs:
* MonoDevelop.Ide.Gui.Pads/ErrorListPad.cs: Show error and warning
icons in grayscale when there are no errors/warnings.
* MonoDevelop.Ide.Commands/ViewCommands.cs: Don't sort layouts by
name. Use the order in the extension point.
* MonoDevelop.Components.Docking/DockGroup.cs:
* MonoDevelop.Components.Docking/DockObject.cs:
* MonoDevelop.Components.Docking/DockGroupItem.cs: Impoved the logic
that selects a dock bar where to show an autohide item by default.
* MonoDevelop.Components.Docking/DockItem.cs:
* MonoDevelop.Components.Docking/DockFrame.cs:
* MonoDevelop.Components.Docking/DockContainer.cs: Allow setting the
dock location of an item.
* MonoDevelop.Ide.addin.xml:
* MonoDevelop.Ide.Extensions/LayoutExtensionNode.cs: Added extension
point for registering stock layous. Assigned default layouts for
existing pads.
* gtk-gui/objects.xml:
* gtk-gui/MonoDevelop.Ide.Gui.OptionPanels.KeyBindingsPanel.cs: Flush.
* MonoDevelop.Ide.Gui/InternalLog.cs:
* MonoDevelop.Ide.Gui/AddinUpdateHandler.cs:
* MonoDevelop.Ide.Gui/MonoDevelopStatusBar.cs:
* MonoDevelop.Ide.Gui/BackgroundProgressMonitor.cs: New status bar
model. The status bar widget is hidden behind an interface. Added
support for status bar contexts. Status information displayed
through a context is cleaned up when the context is disposed.
* MonoDevelop.Ide.Gui/Pad.cs:
* MonoDevelop.Ide.Gui/Workbench.cs:
* MonoDevelop.Ide.Gui/IPadContainer.cs:
* MonoDevelop.Ide.Gui/WorkbenchMemento.cs:
* MonoDevelop.Ide.Gui/DefaultWorkbench.cs:
* MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs:
* MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs: Merged SdiWorkspaceLayout
into DefaultWorkbench. Removed support for workbench contexts.
* MonoDevelop.Ide.Codons/PadCodon.cs: Allow setting the default layout
of a pad.
* MonoDevelop.Ide.Codons/WorkbenchContextCondition.cs: Not required
anymore.
* MonoDevelop.Ide.Tasks/TaskStore.cs: Show a better status message
when the end of the task list is reached.
svn path=/trunk/monodevelop/; revision=153851
Diffstat (limited to 'main')
31 files changed, 1417 insertions, 1286 deletions
diff --git a/main/src/core/MonoDevelop.Ide/ChangeLog b/main/src/core/MonoDevelop.Ide/ChangeLog index f414f55783..b5df9de993 100644 --- a/main/src/core/MonoDevelop.Ide/ChangeLog +++ b/main/src/core/MonoDevelop.Ide/ChangeLog @@ -1,3 +1,68 @@ +2010-03-18 Lluis Sanchez Gual <lluis@novell.com> + + * Makefile.am: + * MonoDevelop.Ide.csproj: Updated. + + * MonoDevelop.Ide/Ide.cs: + * MonoDevelop.Ide.Gui/StatusProgressMonitor.cs: Use the new + status bar model. + + * MonoDevelop.Ide/ImageService.cs: + * MonoDevelop.Ide.Gui.Pads/ErrorListPad.cs: Show error and + warning icons in grayscale when there are no + errors/warnings. + + * MonoDevelop.Ide.Commands/ViewCommands.cs: Don't sort layouts + by name. Use the order in the extension point. + + * MonoDevelop.Components.Docking/DockGroup.cs: + * MonoDevelop.Components.Docking/DockObject.cs: + * MonoDevelop.Components.Docking/DockGroupItem.cs: Impoved the + logic that selects a dock bar where to show an autohide item + by default. + + * MonoDevelop.Components.Docking/DockItem.cs: + * MonoDevelop.Components.Docking/DockFrame.cs: + * MonoDevelop.Components.Docking/DockContainer.cs: Allow + setting the dock location of an item. + + * MonoDevelop.Ide.addin.xml: + * MonoDevelop.Ide.Extensions/LayoutExtensionNode.cs: Added + extension point for registering stock layous. Assigned + default layouts for existing pads. + + * gtk-gui/objects.xml: + * gtk-gui/MonoDevelop.Ide.Gui.OptionPanels.KeyBindingsPanel.cs: + Flush. + + * MonoDevelop.Ide.Gui/InternalLog.cs: + * MonoDevelop.Ide.Gui/AddinUpdateHandler.cs: + * MonoDevelop.Ide.Gui/MonoDevelopStatusBar.cs: + * MonoDevelop.Ide.Gui/BackgroundProgressMonitor.cs: New status + bar model. The status bar widget is hidden behind an + interface. Added support for status bar contexts. Status + information displayed through a context is cleaned up when + the context is disposed. + + * MonoDevelop.Ide.Gui/Pad.cs: + * MonoDevelop.Ide.Gui/Workbench.cs: + * MonoDevelop.Ide.Gui/IPadContainer.cs: + * MonoDevelop.Ide.Gui/WorkbenchMemento.cs: + * MonoDevelop.Ide.Gui/DefaultWorkbench.cs: + * MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs: + * MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs: Merged + SdiWorkspaceLayout into DefaultWorkbench. Removed support + for workbench contexts. + + * MonoDevelop.Ide.Codons/PadCodon.cs: Allow setting the + default layout of a pad. + + * MonoDevelop.Ide.Codons/WorkbenchContextCondition.cs: Not + required anymore. + + * MonoDevelop.Ide.Tasks/TaskStore.cs: Show a better status + message when the end of the task list is reached. + 2010-03-18 Levi Bard <levi@unity3d.com> * MonoDevelop.Ide/Ide.cs: diff --git a/main/src/core/MonoDevelop.Ide/Makefile.am b/main/src/core/MonoDevelop.Ide/Makefile.am index a3d4028306..a99e3b00d3 100644 --- a/main/src/core/MonoDevelop.Ide/Makefile.am +++ b/main/src/core/MonoDevelop.Ide/Makefile.am @@ -308,7 +308,6 @@ FILES = \ MonoDevelop.Ide.Codons/SolutionPadCodon.cs \ MonoDevelop.Ide.Codons/TaskListViewCodon.cs \ MonoDevelop.Ide.Codons/WorkbenchContextCodon.cs \ - MonoDevelop.Ide.Codons/WorkbenchContextCondition.cs \ MonoDevelop.Ide.Commands/CustomStringTagProvider.cs \ MonoDevelop.Ide.Commands/EditCommands.cs \ MonoDevelop.Ide.Commands/FileCommands.cs \ @@ -346,6 +345,7 @@ FILES = \ MonoDevelop.Ide.Extensions/CustomToolExtensionNode.cs \ MonoDevelop.Ide.Extensions/IAddFileDialogHandler.cs \ MonoDevelop.Ide.Extensions/IOpenFileDialogHandler.cs \ + MonoDevelop.Ide.Extensions/LayoutExtensionNode.cs \ MonoDevelop.Ide.Extensions/MimeTypeNode.cs \ MonoDevelop.Ide.Extensions/MimeTypeOptionsPanelNode.cs \ MonoDevelop.Ide.Extensions/OptionsDialogSection.cs \ @@ -537,7 +537,6 @@ FILES = \ MonoDevelop.Ide.Gui/Pad.cs \ MonoDevelop.Ide.Gui/PadFontChanger.cs \ MonoDevelop.Ide.Gui/ProgressMonitors.cs \ - MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs \ MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs \ MonoDevelop.Ide.Gui/StartupInfo.cs \ MonoDevelop.Ide.Gui/StatusProgressMonitor.cs \ diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockContainer.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockContainer.cs index cba733da8e..6a7281fe2a 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockContainer.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockContainer.cs @@ -434,7 +434,8 @@ namespace MonoDevelop.Components.Docking public IEnumerable<Rectangle> GetShadedAreas () { List<Gdk.Rectangle> rects = new List<Gdk.Rectangle> (); - layout.DrawSeparators (Allocation, currentHandleGrp, currentHandleIndex, true, rects); + if (layout != null) + layout.DrawSeparators (Allocation, currentHandleGrp, currentHandleIndex, true, rects); return rects; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockFrame.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockFrame.cs index f372dd4245..7b17598626 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockFrame.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockFrame.cs @@ -444,6 +444,15 @@ namespace MonoDevelop.Components.Docking container.RelayoutWidgets (); } + internal void SetDockLocation (DockItem item, string placement) + { + bool vis = item.Visible; + DockItemStatus stat = item.Status; + item.ResetMode (); + container.Layout.RemoveItemRec (item); + AddItemAtLocation (container.Layout, item, placement, vis, stat); + } + DockLayout GetDefaultLayout () { DockLayout group = new DockLayout (this); @@ -486,7 +495,12 @@ namespace MonoDevelop.Components.Docking DockGroupItem AddDefaultItem (DockGroup grp, DockItem it) { - string[] positions = it.DefaultLocation.Split (';'); + return AddItemAtLocation (grp, it, it.DefaultLocation, it.DefaultVisible, it.DefaultStatus); + } + + DockGroupItem AddItemAtLocation (DockGroup grp, DockItem it, string location, bool visible, DockItemStatus status) + { + string[] positions = location.Split (';'); foreach (string pos in positions) { int i = pos.IndexOf ('/'); if (i == -1) continue; @@ -501,8 +515,8 @@ namespace MonoDevelop.Components.Docking continue; } DockGroupItem dgt = g.AddObject (it, dpos, id); - dgt.SetVisible (it.DefaultVisible); - dgt.Status = it.DefaultStatus; + dgt.SetVisible (visible); + dgt.Status = status; return dgt; } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockGroup.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockGroup.cs index 6fc5396660..abc72d3b47 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockGroup.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockGroup.cs @@ -637,7 +637,7 @@ namespace MonoDevelop.Components.Docking } else boundTabStrip.CurrentTab = 0; } - if (Frame.CompactGuiLevel == 3 && IsNextToMargin (PositionType.Bottom)) + if (Frame.CompactGuiLevel == 3 && IsNextToMargin (PositionType.Bottom, true)) boundTabStrip.BottomPadding = 3; else boundTabStrip.BottomPadding = 0; @@ -1097,26 +1097,26 @@ namespace MonoDevelop.Components.Docking reader.ReadEndElement (); } - public bool IsChildNextToMargin (Gtk.PositionType margin, DockObject obj) + public bool IsChildNextToMargin (Gtk.PositionType margin, DockObject obj, bool visibleOnly) { if (type == DockGroupType.Tabbed) return true; else if (type == DockGroupType.Horizontal) { if (margin == PositionType.Top || margin == PositionType.Bottom) return true; - int i = VisibleObjects.IndexOf (obj); + int i = visibleOnly ? VisibleObjects.IndexOf (obj) : Objects.IndexOf (obj); if (margin == PositionType.Left && i == 0) return true; - if (margin == PositionType.Right && i == VisibleObjects.Count - 1) + if (margin == PositionType.Right && i == (visibleOnly ? VisibleObjects.Count - 1 : Objects.Count - 1)) return true; } else if (type == DockGroupType.Vertical) { if (margin == PositionType.Left || margin == PositionType.Right) return true; - int i = VisibleObjects.IndexOf (obj); + int i = visibleOnly ? VisibleObjects.IndexOf (obj) : Objects.IndexOf (obj); if (margin == PositionType.Top && i == 0) return true; - if (margin == PositionType.Bottom && i == VisibleObjects.Count - 1) + if (margin == PositionType.Bottom && i == (visibleOnly ? VisibleObjects.Count - 1 : Objects.Count - 1)) return true; } return false; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockGroupItem.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockGroupItem.cs index 89e01c2b90..2134d9b9eb 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockGroupItem.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockGroupItem.cs @@ -259,6 +259,39 @@ namespace MonoDevelop.Components.Docking // Determine the best position for docking the item if (Allocation.IsEmpty) { + int uniqueTrue = -1; + int uniqueFalse = -1; + for (int n=0; n<4; n++) { + bool inMargin = IsNextToMargin ((PositionType) n, false); + if (inMargin) { + if (uniqueTrue == -1) + uniqueTrue = n; + else + uniqueTrue = -2; + } else { + if (uniqueFalse == -1) + uniqueFalse = n; + else + uniqueFalse = -2; + } + } + + if (uniqueTrue >= 0) { + barDocPosition = (PositionType) uniqueTrue; + autoHideSize = 200; + return; + } else if (uniqueFalse >= 0) { + barDocPosition = (PositionType) uniqueFalse; + switch (barDocPosition) { + case PositionType.Left: barDocPosition = PositionType.Right; break; + case PositionType.Right: barDocPosition = PositionType.Left; break; + case PositionType.Top: barDocPosition = PositionType.Bottom; break; + case PositionType.Bottom: barDocPosition = PositionType.Top; break; + } + autoHideSize = 200; + return; + } + // If the item is in a group, use the dock location of other items DockObject current = this; do { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItem.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItem.cs index dd47a99572..12eb78e67c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItem.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItem.cs @@ -294,6 +294,11 @@ namespace MonoDevelop.Components.Docking return widget.Parent != null && widget.Visible; } } + + public void SetDockLocation (string location) + { + frame.SetDockLocation (this, location); + } internal void SetFocus () { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockObject.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockObject.cs index f909bf3542..e6954f9351 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockObject.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockObject.cs @@ -272,13 +272,13 @@ namespace MonoDevelop.Components.Docking prefSize = obj.prefSize; } - public virtual bool IsNextToMargin (Gtk.PositionType margin) + public virtual bool IsNextToMargin (Gtk.PositionType margin, bool visibleOnly) { if (ParentGroup == null) return true; - if (!ParentGroup.IsNextToMargin (margin)) + if (!ParentGroup.IsNextToMargin (margin, visibleOnly)) return false; - return ParentGroup.IsChildNextToMargin (margin, this); + return ParentGroup.IsChildNextToMargin (margin, this, visibleOnly); } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Codons/PadCodon.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Codons/PadCodon.cs index 8d98e73746..d81cc75735 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Codons/PadCodon.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Codons/PadCodon.cs @@ -36,6 +36,7 @@ using MonoDevelop.Core; using Mono.Addins; using MonoDevelop.Ide.Gui; using MonoDevelop.Components.Docking; +using System.Collections.Generic; namespace MonoDevelop.Ide.Codons { @@ -72,7 +73,9 @@ namespace MonoDevelop.Ide.Codons "is docked in auto-hide mode.")] string dockLabelProvider = null; - string[] contexts; + [NodeAttribute ("defaultLayout", "Name of the layouts (comma separated list) on which this pad should be visible by default")] + string[] defaultLayouts; + IDockItemLabelProvider cachedDockLabelProvider; bool initializeCalled; @@ -104,13 +107,17 @@ namespace MonoDevelop.Ide.Codons } public IconId Icon { - get { return icon; } + get { return !string.IsNullOrEmpty (icon) ? icon : "md-output-icon"; } } public string ClassName { get { return className; } } + public IList<string> DefaultLayouts { + get { return this.defaultLayouts; } + } + /// <summary> /// Returns the default placement of the pad: left, right, top, bottom. /// Relative positions can be used, for example: "ProjectPad/left" @@ -127,10 +134,6 @@ namespace MonoDevelop.Ide.Codons get { return defaultStatus; } } - public string[] Contexts { - get { return contexts; } - } - public bool Initialized { get { return content != null; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs index 284764603d..3975f6d13a 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs @@ -120,7 +120,6 @@ namespace MonoDevelop.Ide.Commands protected override void Update (CommandArrayInfo info) { string[] layouts = IdeApp.Workbench.Layouts; - Array.Sort<string> (layouts, StringComparer.CurrentCultureIgnoreCase); for (int i = 0; i < layouts.Length; i++) { string name = layouts[i]; CommandInfo item = new CommandInfo(GettextCatalog.GetString (name)); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Codons/WorkbenchContextCondition.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Extensions/LayoutExtensionNode.cs index 29e7f243ac..771b843ace 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Codons/WorkbenchContextCondition.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Extensions/LayoutExtensionNode.cs @@ -1,20 +1,21 @@ -// WorkbenchContextCondition.cs -// +// +// LayoutExtensionNode.cs +// // Author: -// Lluis Sanchez Gual <lluis@novell.com> -// -// Copyright (c) 2007 Novell, Inc (http://www.novell.com) -// +// Lluis Sanchez Gual <lluis@novell.com> +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -22,29 +23,43 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -// -// using System; -using System.Xml; - using Mono.Addins; -using MonoDevelop.Ide.Gui; +using MonoDevelop.Components.Docking; -namespace MonoDevelop.Ide.Codons +namespace MonoDevelop.Ide.Extensions { - internal class WorkbenchContextCondition : ConditionType + [ExtensionNodeChild (typeof(LayoutPadExtensionNode), "LayoutPad")] + class LayoutExtensionNode: ExtensionNode { - public override bool Evaluate (NodeElement condition) - { - string context = condition.GetAttribute ("value"); - if (context == "*") - return true; - - if (context == IdeApp.Workbench.Context.Id) - return true; + [NodeAttribute (Required=true)] + protected string _name; + + public string Name { + get { return _name; } + } + } + + class LayoutPadExtensionNode: ExtensionNode + { + [NodeAttribute] + protected string placement; + + [NodeAttribute] + protected DockItemStatus status = (DockItemStatus) (-1); + + public string Placement { + get { return this.placement; } + } - return false; + public DockItemStatus Status { + get { return this.status; } + } + + public bool StatusSet { + get { return status != (DockItemStatus) (-1); } } } } + diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/ErrorListPad.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/ErrorListPad.cs index bc055d4f5e..215f8180b8 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/ErrorListPad.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/ErrorListPad.cs @@ -830,11 +830,19 @@ namespace MonoDevelop.Ide.Gui.Pads box = new VBox (); box.Spacing = 3; - box.PackStart (ImageService.GetImage (MonoDevelop.Ide.Gui.Stock.Error, IconSize.Menu), false, false, 0); + Gdk.Pixbuf errorIcon = ImageService.GetPixbuf (MonoDevelop.Ide.Gui.Stock.Error, IconSize.Menu); + Gdk.Pixbuf noErrorIcon = ImageService.MakeGrayscale (errorIcon); + Gdk.Pixbuf warningIcon = ImageService.GetPixbuf (MonoDevelop.Ide.Gui.Stock.Warning, IconSize.Menu); + Gdk.Pixbuf noWarningIcon = ImageService.MakeGrayscale (warningIcon); + + Gtk.Image errorImage = new Gtk.Image (errorIcon); + Gtk.Image warningImage = new Gtk.Image (warningIcon); + + box.PackStart (errorImage, false, false, 0); Label errors = new Gtk.Label (); box.PackStart (errors, false, false, 0); - box.PackStart (ImageService.GetImage (MonoDevelop.Ide.Gui.Stock.Warning, IconSize.Menu), false, false, 0); + box.PackStart (warningImage, false, false, 0); Label warnings = new Gtk.Label (); box.PackStart (warnings, false, false, 0); @@ -847,7 +855,9 @@ namespace MonoDevelop.Ide.Gui.Pads wc++; } errors.Text = ec.ToString (); + errorImage.Pixbuf = ec > 0 ? errorIcon : noErrorIcon; warnings.Text = wc.ToString (); + warningImage.Pixbuf = wc > 0 ? warningIcon : noWarningIcon; }; updateHandler (null, null); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/AddinUpdateHandler.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/AddinUpdateHandler.cs index b35c9c63f5..402ca5dab4 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/AddinUpdateHandler.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/AddinUpdateHandler.cs @@ -44,7 +44,7 @@ namespace MonoDevelop.Ide.Gui { public static AggregatedProgressMonitor UpdateMonitor; AddinRepositoryEntry[] updates; - static MonoDevelopStatusBar.StatusIcon updateIcon; + static StatusBarIcon updateIcon; public static void HideAlert () { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/BackgroundProgressMonitor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/BackgroundProgressMonitor.cs index 22bf45ec39..768c770e22 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/BackgroundProgressMonitor.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/BackgroundProgressMonitor.cs @@ -38,7 +38,7 @@ namespace MonoDevelop.Ide.Gui internal class BackgroundProgressMonitor: SimpleProgressMonitor { string title; - MonoDevelopStatusBar.StatusIcon icon; + StatusBarIcon icon; public BackgroundProgressMonitor (string title, IconId iconName) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs index ba0a5558c1..751bf9ae96 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs @@ -29,6 +29,7 @@ using System.Collections.ObjectModel; using System.Collections.Generic; using System.Drawing; using System.Diagnostics; +using System.Linq; using MonoDevelop.Projects; using Mono.Addins; @@ -36,8 +37,13 @@ using MonoDevelop.Core; using MonoDevelop.Ide.Gui.Dialogs; using MonoDevelop.Ide.Codons; using MonoDevelop.Components.Commands; +using MonoDevelop.Components.Docking; using GLib; +using MonoDevelop.Components.DockToolbars; +using Gtk; +using MonoDevelop.Components; +using MonoDevelop.Ide.Extensions; namespace MonoDevelop.Ide.Gui { @@ -49,30 +55,41 @@ namespace MonoDevelop.Ide.Gui readonly static string mainMenuPath = "/MonoDevelop/Ide/MainMenu"; readonly static string viewContentPath = "/MonoDevelop/Ide/Pads"; readonly static string toolbarsPath = "/MonoDevelop/Ide/Toolbar"; + readonly static string stockLayoutsPath = "/MonoDevelop/Ide/WorkbenchLayouts"; + + static string configFile = System.IO.Path.Combine (PropertyService.ConfigPath, "EditingLayout2.xml"); + const string fullViewModeTag = "[FullViewMode]"; + const int MAX_LASTACTIVEWINDOWS = 10; + + // list of layout names for the current context, without the context prefix + List<string> layouts = new List<string> (); List<PadCodon> padContentCollection = new List<PadCodon> (); List<IViewContent> viewContentCollection = new List<IViewContent> (); + Dictionary<PadCodon, IPadWindow> padWindows = new Dictionary<PadCodon, IPadWindow> (); + Dictionary<IPadWindow, PadCodon> padCodons = new Dictionary<IPadWindow, PadCodon> (); + + IWorkbenchWindow lastActive; + LinkedList<IWorkbenchWindow> lastActiveWindows = new LinkedList<IWorkbenchWindow> (); - bool closeAll = false; + bool closeAll; + bool ignorePageSwitch; + bool isInFullViewMode; bool fullscreen; Rectangle normalBounds = new Rectangle(0, 0, 640, 480); - private SdiWorkbenchLayout layout = null; - internal static GType gtype; - Gtk.MenuBar topMenu = null; - private Gtk.Toolbar[] toolbars = null; + Gtk.Container rootWidget; + DockToolbarFrame toolbarFrame; + DockFrame dock; + SdiDragNotebook tabControl; + Gtk.MenuBar topMenu; + Gtk.Toolbar[] toolbars; MonoDevelopStatusBar statusBar; - - public MonoDevelopStatusBar StatusBar { - get { - if (statusBar == null) - statusBar = new MonoDevelop.Ide.MonoDevelopStatusBar (); - return statusBar; - } - } + Gtk.VBox fullViewVBox; + DockItem documentDockItem; enum TargetList { UriList = 100 @@ -82,10 +99,41 @@ namespace MonoDevelop.Ide.Gui new Gtk.TargetEntry ("text/uri-list", 0, (uint)TargetList.UriList) }; +#if DUMMY_STRINGS_FOR_TRANSLATION_DO_NOT_COMPILE + private void DoNotCompile () + { + //The default layout, translated indirectly because it's used as an ID + GettextCatalog.GetString ("Default"); + } +#endif + + public event EventHandler ActiveWorkbenchWindowChanged; + + public MonoDevelopStatusBar StatusBar { + get { + if (statusBar == null) + statusBar = new MonoDevelop.Ide.MonoDevelopStatusBar (); + return statusBar; + } + } + public Gtk.MenuBar TopMenu { get { return topMenu; } } + public IWorkbenchWindow ActiveWorkbenchWindow { + get { + if (tabControl == null || tabControl.CurrentPage < 0 || tabControl.CurrentPage >= tabControl.NPages) { + return null; + } + return (IWorkbenchWindow) tabControl.CurrentPageWidget; + } + } + + public DockFrame DockFrame { + get { return dock; } + } + public bool FullScreen { get { return fullscreen; @@ -99,49 +147,49 @@ namespace MonoDevelop.Ide.Gui } } } - - /* - public string Title { - get { - return Text; - } - set { - Text = value; - } - }*/ - - EventHandler windowChangeEventHandler; - - public SdiWorkbenchLayout WorkbenchLayout { + + public string[] Layouts { get { - //FIXME: i added this, we need to fix this shit - // if (layout == null) { - // layout = new SdiWorkbenchLayout (); - // layout.Attach(this); - //} - return layout; + return layouts.ToArray (); } } - public ReadOnlyCollection<PadCodon> PadContentCollection { + public string CurrentLayout { get { - Debug.Assert(padContentCollection != null); - return padContentCollection.AsReadOnly (); + if (dock != null && dock.CurrentLayout != null) { + string s = dock.CurrentLayout; + s = s.Substring (s.IndexOf (".") + 1); + if (s.EndsWith (fullViewModeTag)) + return s.Substring (0, s.Length - fullViewModeTag.Length); + return s; + } + else + return ""; + } + set { + // Leave dragging mode, to avoid problems due to widget relocating + tabControl.LeaveDragMode (0); + isInFullViewMode = false; + + InitializeLayout (value); + dock.CurrentLayout = value; + toolbarFrame.CurrentLayout = value; + + // persist the selected layout + PropertyService.Set ("MonoDevelop.Core.Gui.CurrentWorkbenchLayout", value); } } - public List<PadCodon> ActivePadContentCollection { - get { - if (layout == null) - return new List<PadCodon> (); - return layout.PadContentCollection; - } + public void DeleteLayout (string name) + { + string layout = name; + layouts.Remove (name); + dock.DeleteLayout (layout); } - public ReadOnlyCollection<IViewContent> ViewContentCollection { + public List<PadCodon> PadContentCollection { get { - Debug.Assert(viewContentCollection != null); - return viewContentCollection.AsReadOnly (); + return padContentCollection; } } @@ -152,22 +200,11 @@ namespace MonoDevelop.Ide.Gui } } - public IWorkbenchWindow ActiveWorkbenchWindow { - get { - if (layout == null) { - return null; - } - return layout.ActiveWorkbenchwindow; - } - } - public DefaultWorkbench() { Title = "MonoDevelop"; LoggingService.LogInfo ("Creating DefaultWorkbench"); - windowChangeEventHandler = new EventHandler(OnActiveWindowChanged); - WidthRequest = normalBounds.Width; HeightRequest = normalBounds.Height; @@ -177,10 +214,10 @@ namespace MonoDevelop.Ide.Gui Gtk.Window.DefaultIconName = "monodevelop"; else this.IconList = new Gdk.Pixbuf[] { - ImageService.GetPixbuf (Stock.MonoDevelop, Gtk.IconSize.Menu), - ImageService.GetPixbuf (Stock.MonoDevelop, Gtk.IconSize.Button), - ImageService.GetPixbuf (Stock.MonoDevelop, Gtk.IconSize.Dnd), - ImageService.GetPixbuf (Stock.MonoDevelop, Gtk.IconSize.Dialog) + ImageService.GetPixbuf (MonoDevelop.Ide.Gui.Stock.MonoDevelop, Gtk.IconSize.Menu), + ImageService.GetPixbuf (MonoDevelop.Ide.Gui.Stock.MonoDevelop, Gtk.IconSize.Button), + ImageService.GetPixbuf (MonoDevelop.Ide.Gui.Stock.MonoDevelop, Gtk.IconSize.Dnd), + ImageService.GetPixbuf (MonoDevelop.Ide.Gui.Stock.MonoDevelop, Gtk.IconSize.Dialog) }; //this.WindowPosition = Gtk.WindowPosition.None; @@ -244,27 +281,48 @@ namespace MonoDevelop.Ide.Gui void OnExtensionChanged (object s, ExtensionEventArgs args) { - bool changed = false; - if (args.PathChanged (mainMenuPath)) { if (DesktopService.SetGlobalMenu (IdeApp.CommandService, mainMenuPath)) return; + UninstallMenuBar (); topMenu = IdeApp.CommandService.CreateMenuBar (mainMenuPath); - changed = true; + InstallMenuBar (); } if (args.PathChanged (toolbarsPath)) { toolbars = IdeApp.CommandService.CreateToolbarSet (toolbarsPath); - foreach (Gtk.Toolbar t in toolbars) - t.ToolbarStyle = Gtk.ToolbarStyle.Icons; - changed = true; + string cl = toolbarFrame.CurrentLayout; + DockToolbarFrameStatus mem = toolbarFrame.GetStatus (); + toolbarFrame.ClearToolbars (); + foreach (DockToolbar tb in toolbars) { + tb.ToolbarStyle = Gtk.ToolbarStyle.Icons; + tb.ShowAll (); + toolbarFrame.AddBar (tb); + } + toolbarFrame.SetStatus (mem); + toolbarFrame.CurrentLayout = cl; + } + } + + void InstallMenuBar () + { + if (topMenu != null) { + ((VBox)rootWidget).PackStart (topMenu, false, false, 0); + ((Gtk.Box.BoxChild) rootWidget [topMenu]).Position = 0; + topMenu.ShowAll (); } - - if (changed && layout != null) - layout.RedrawAllComponents(); } + void UninstallMenuBar () + { + if (topMenu == null) + return; + + rootWidget.Remove (topMenu); + topMenu = null; + } + public void CloseContent (IViewContent content) { if (viewContentCollection.Contains(content)) { @@ -283,15 +341,15 @@ namespace MonoDevelop.Ide.Gui } } finally { closeAll = false; - OnActiveWindowChanged(null, null); + OnActiveWindowChanged (null, null); } } public virtual void ShowView (IViewContent content, bool bringToFront) { - Debug.Assert(layout != null); - viewContentCollection.Add(content); - if (PropertyService.Get("SharpDevelop.LoadDocumentProperties", true) && content is IMementoCapable) { + viewContentCollection.Add (content); + + if (PropertyService.Get ("SharpDevelop.LoadDocumentProperties", true) && content is IMementoCapable) { try { Properties memento = GetStoredMemento(content); if (memento != null) { @@ -302,7 +360,25 @@ namespace MonoDevelop.Ide.Gui } } - layout.ShowView(content); + Gtk.Image mimeimage = null; + + if (content.StockIconId != null ) { + mimeimage = new Gtk.Image ((IconId) content.StockIconId, IconSize.Menu ); + } + else if (content.IsUntitled && content.UntitledName == null) { + mimeimage = new Gtk.Image (DesktopService.GetPixbufForType ("gnome-fs-regular", Gtk.IconSize.Menu)); + } else { + mimeimage = new Gtk.Image (DesktopService.GetPixbufForFile (content.ContentName ?? content.UntitledName, Gtk.IconSize.Menu)); + } + + TabLabel tabLabel = new TabLabel (new Label (), mimeimage != null ? mimeimage : new Gtk.Image ("")); + tabLabel.CloseClicked += new EventHandler (closeClicked); + tabLabel.ClearFlag (WidgetFlags.CanFocus); + SdiWorkspaceWindow sdiWorkspaceWindow = new SdiWorkspaceWindow (this, content, tabControl, tabLabel); + sdiWorkspaceWindow.TitleChanged += delegate { SetWorkbenchTitle (); }; + sdiWorkspaceWindow.Closed += CloseWindowEvent; + tabControl.InsertPage (sdiWorkspaceWindow, tabLabel, -1); + tabLabel.Show (); if (bringToFront) content.WorkbenchWindow.SelectWindow(); @@ -312,14 +388,7 @@ namespace MonoDevelop.Ide.Gui { if (node is PadCodon) { PadCodon pad = (PadCodon) node; - ShowPad (pad); - if (layout != null) { - IPadWindow win = WorkbenchLayout.GetPadWindow (pad); - if (pad.Label != null) - win.Title = pad.Label; - if (!pad.Icon.IsNull) - win.Icon = pad.Icon; - } + RegisterPad (pad); } else if (node is CategoryNode) { foreach (ExtensionNode cn in node.ChildNodes) @@ -347,11 +416,8 @@ namespace MonoDevelop.Ide.Gui AddPad (content, false); } - void AddPad (PadCodon content, bool show) + void RegisterPad (PadCodon content) { - if (padContentCollection.Contains (content)) - return; - if (content.HasId) { ActionCommand cmd = new ActionCommand ("Pad|" + content.PadId, GettextCatalog.GetString (content.Label), null); cmd.DefaultHandler = new PadActivationHandler (this, content); @@ -360,12 +426,24 @@ namespace MonoDevelop.Ide.Gui IdeApp.CommandService.RegisterCommand (cmd); } padContentCollection.Add (content); + } + + void AddPad (PadCodon content, bool show) + { + DockItem item = GetDockItem (content); + if (padContentCollection.Contains (content)) { + if (show && item != null) + item.Visible = true; + return; + } + + RegisterPad (content); - if (layout != null) { + if (item != null) { if (show) - layout.ShowPad (content); - else - layout.AddPad (content); + item.Visible = true; + } else { + AddPad (content, content.DefaultPlacement, content.DefaultStatus); } } @@ -378,8 +456,16 @@ namespace MonoDevelop.Ide.Gui } padContentCollection.Remove (codon); - if (layout != null) - layout.RemovePad (codon); + PadWindow win = (PadWindow) padWindows [codon]; + win.NotifyDestroyed (); + + DockItem item = GetDockItem (codon); + if (item != null) + dock.RemoveItem (item); + padWindows.Remove (codon); + padCodons.Remove (win); + + Counters.PadsLoaded--; } public void BringToFront (PadCodon content) @@ -389,24 +475,47 @@ namespace MonoDevelop.Ide.Gui public virtual void BringToFront (PadCodon content, bool giveFocus) { - if (!layout.IsVisible (content)) - layout.ShowPad (content); + if (!IsVisible (content)) + ShowPad (content); - layout.ActivatePad (content, giveFocus); + ActivatePad (content, giveFocus); } - public void RedrawAllComponents() + void SetWorkbenchTitle () { - foreach (IViewContent content in viewContentCollection) { - content.RedrawContent(); - } - foreach (PadCodon content in padContentCollection) { - if (content.Initialized) { - content.PadContent.RedrawContent(); + try { + IWorkbenchWindow window = ActiveWorkbenchWindow; + if (window != null) { + if (window.ViewContent.IsUntitled) { + SetDefaultTitle (); + } else { + string post = String.Empty; + if (window.ViewContent.IsDirty) { + post = "*"; + } + if (window.ViewContent.Project != null) { + Title = window.ViewContent.Project.Name + " - " + window.ViewContent.PathRelativeToProject + post + " - MonoDevelop"; + } else { + Title = window.ViewContent.ContentName + post + " - MonoDevelop"; + } + } + } else { + SetDefaultTitle (); + if (isInFullViewMode) + this.ToggleFullViewMode (); } + } catch (Exception) { + SetDefaultTitle (); + } + } + + void SetDefaultTitle () + { + if (IdeApp.ProjectOperations.CurrentSelectedProject != null) { + Title = IdeApp.ProjectOperations.CurrentSelectedProject.Name + " - MonoDevelop"; + } else { + Title = "MonoDevelop"; } - layout.RedrawAllComponents(); - //statusBarManager.RedrawStatusbar(); } public Properties GetStoredMemento(IViewContent content) @@ -439,8 +548,7 @@ namespace MonoDevelop.Ide.Gui } memento.WindowState = GdkWindow.State; memento.FullScreen = fullscreen; - if (layout != null) - memento.LayoutMemento = (Properties)layout.Memento; + memento.ToolbarStatus = toolbarFrame.GetStatus (); return memento.ToProperties (); } set { @@ -457,9 +565,7 @@ namespace MonoDevelop.Ide.Gui } //GdkWindow.State = memento.WindowState; FullScreen = memento.FullScreen; - - if (layout != null && memento.LayoutMemento != null) - layout.Memento = memento.LayoutMemento; + toolbarFrame.SetStatus (memento.ToolbarStatus); } Decorated = true; } @@ -468,15 +574,15 @@ namespace MonoDevelop.Ide.Gui void CheckRemovedFile(object sender, FileEventArgs e) { if (e.IsDirectory) { - IViewContent[] views = new IViewContent [ViewContentCollection.Count]; - ViewContentCollection.CopyTo (views, 0); + IViewContent[] views = new IViewContent [viewContentCollection.Count]; + viewContentCollection.CopyTo (views, 0); foreach (IViewContent content in views) { if (content.ContentName.StartsWith(e.FileName)) { content.WorkbenchWindow.CloseWindow(true, true, 0); } } } else { - foreach (IViewContent content in ViewContentCollection) { + foreach (IViewContent content in viewContentCollection) { if (content.ContentName != null && content.ContentName == e.FileName) { content.WorkbenchWindow.CloseWindow(true, true, 0); @@ -489,13 +595,13 @@ namespace MonoDevelop.Ide.Gui void CheckRenamedFile(object sender, FileCopyEventArgs e) { if (e.IsDirectory) { - foreach (IViewContent content in ViewContentCollection) { + foreach (IViewContent content in viewContentCollection) { if (content.ContentName != null && content.ContentName.StartsWith(e.SourceFile)) { content.ContentName = e.TargetFile + content.ContentName.Substring(e.SourceFile.Length); } } } else { - foreach (IViewContent content in ViewContentCollection) { + foreach (IViewContent content in viewContentCollection) { if (content.ContentName != null && content.ContentName == e.SourceFile) { content.ContentName = e.TargetFile; @@ -516,11 +622,13 @@ namespace MonoDevelop.Ide.Gui protected /*override*/ void OnClosed(EventArgs e) { - layout.Detach(); + dock.SaveLayouts (configFile); + UninstallMenuBar (); + Remove (rootWidget); + foreach (PadCodon content in PadContentCollection) { - if (content.Initialized) { + if (content.Initialized) content.PadContent.Dispose(); - } } } @@ -534,7 +642,7 @@ namespace MonoDevelop.Ide.Gui bool showDirtyDialog = false; - foreach (IViewContent content in ViewContentCollection) + foreach (IViewContent content in viewContentCollection) { if (content.IsDirty) { showDirtyDialog = true; @@ -562,11 +670,23 @@ namespace MonoDevelop.Ide.Gui void SetProjectTitle(object sender, ProjectEventArgs e) { - layout.SetWorkbenchTitle (); + SetWorkbenchTitle (); } - void OnActiveWindowChanged(object sender, EventArgs e) + void OnActiveWindowChanged (object sender, EventArgs e) { + if (ignorePageSwitch) + return; + + if (lastActive == ActiveWorkbenchWindow) + return; + + if (lastActiveWindows.Count > MAX_LASTACTIVEWINDOWS) + lastActiveWindows.RemoveFirst (); + lastActiveWindows.AddLast (lastActive); + lastActive = ActiveWorkbenchWindow; + SetWorkbenchTitle (); + if (!closeAll && ActiveWorkbenchWindowChanged != null) { ActiveWorkbenchWindowChanged(this, e); } @@ -596,21 +716,15 @@ namespace MonoDevelop.Ide.Gui return null; } - public void InitializeLayout (SdiWorkbenchLayout workbenchLayout) + public void InitializeLayout () { - ExtensionNodeList padCodons = AddinManager.GetExtensionNodes (viewContentPath); + AddinManager.AddExtensionNodeHandler (stockLayoutsPath, OnLayoutsExtensionChanged); + ExtensionNodeList padCodons = AddinManager.GetExtensionNodes (viewContentPath); foreach (ExtensionNode node in padCodons) ShowPadNode (node); - layout = workbenchLayout; - layout.Attach(this); - layout.ActiveWorkbenchWindowChanged += windowChangeEventHandler; - - foreach (ExtensionNode node in padCodons) - ShowPadNode (node); - - RedrawAllComponents (); + CreateComponents (); // Subscribe to changes in the extension initializing = true; @@ -618,9 +732,229 @@ namespace MonoDevelop.Ide.Gui initializing = false; } + void CreateComponents () + { + fullViewVBox = new VBox (false, 0); + rootWidget = fullViewVBox; + + InstallMenuBar (); + + toolbarFrame = new CommandFrame (IdeApp.CommandService); + fullViewVBox.PackStart (toolbarFrame, true, true, 0); + + foreach (DockToolbar t in toolbars) + toolbarFrame.AddBar (t); + + // Create the docking widget and add it to the window. + dock = new DockFrame (); + + dock.CompactGuiLevel = ((int)IdeApp.Preferences.WorkbenchCompactness) + 1; + IdeApp.Preferences.WorkbenchCompactnessChanged += delegate { + dock.CompactGuiLevel = ((int)IdeApp.Preferences.WorkbenchCompactness) + 1; + }; + + /* Side bar is experimental. Disabled for now + HBox hbox = new HBox (); + VBox sideBox = new VBox (); + sideBox.PackStart (new SideBar (workbench, Orientation.Vertical), false, false, 0); + hbox.PackStart (sideBox, false, false, 0); + hbox.ShowAll (); + sideBox.NoShowAll = true; + hbox.PackStart (dock, true, true, 0); + DockBar bar = dock.ExtractDockBar (PositionType.Left); + bar.AlwaysVisible = true; + sideBox.PackStart (bar, true, true, 0); + toolbarFrame.AddContent (hbox); + */ + + toolbarFrame.AddContent (dock); + + // Create the notebook for the various documents. + tabControl = new SdiDragNotebook (dock.ShadedContainer); + tabControl.Scrollable = true; + tabControl.SwitchPage += OnActiveWindowChanged; + tabControl.PageAdded += delegate { OnActiveWindowChanged (null, null); }; + tabControl.PageRemoved += delegate { OnActiveWindowChanged (null, null); }; + + tabControl.ButtonPressEvent += delegate(object sender, ButtonPressEventArgs e) { + int tab = tabControl.FindTabAtPosition (e.Event.XRoot, e.Event.YRoot); + if (tab < 0) + return; + tabControl.CurrentPage = tab; + if (e.Event.Type == Gdk.EventType.TwoButtonPress) + ToggleFullViewMode (); + }; + + this.tabControl.PopupMenu += delegate { + ShowPopup (); + }; + this.tabControl.ButtonReleaseEvent += delegate (object sender, Gtk.ButtonReleaseEventArgs e) { + int tab = tabControl.FindTabAtPosition (e.Event.XRoot, e.Event.YRoot); + if (tab < 0) + return; + if (e.Event.Button == 3) + ShowPopup (); + }; + + tabControl.TabsReordered += new TabsReorderedHandler (OnTabsReordered); + + // The main document area + documentDockItem = dock.AddItem ("Documents"); + documentDockItem.Behavior = DockItemBehavior.Locked; + documentDockItem.Expand = true; + documentDockItem.DrawFrame = false; + documentDockItem.Label = GettextCatalog.GetString ("Documents"); + documentDockItem.Content = tabControl; + + // Add some hiden items to be used as position reference + DockItem dit = dock.AddItem ("__left"); + dit.DefaultLocation = "Documents/Left"; + dit.Behavior = DockItemBehavior.Locked; + dit.DefaultVisible = false; + + dit = dock.AddItem ("__right"); + dit.DefaultLocation = "Documents/Right"; + dit.Behavior = DockItemBehavior.Locked; + dit.DefaultVisible = false; + + dit = dock.AddItem ("__top"); + dit.DefaultLocation = "Documents/Top"; + dit.Behavior = DockItemBehavior.Locked; + dit.DefaultVisible = false; + + dit = dock.AddItem ("__bottom"); + dit.DefaultLocation = "Documents/Bottom"; + dit.Behavior = DockItemBehavior.Locked; + dit.DefaultVisible = false; + + Add (fullViewVBox); + fullViewVBox.ShowAll (); + + fullViewVBox.PackEnd (this.StatusBar, false, true, 0); + + // the Mac has a resize grip by default, and the GTK+ one breaks it +// if (MonoDevelop.Core.PropertyService.IsMac) + this.StatusBar.HasResizeGrip = false; +/* else { + if (wbWindow.GdkWindow != null && wbWindow.GdkWindow.State == Gdk.WindowState.Maximized) + IdeApp.Workbench.StatusBar.HasResizeGrip = false; + wbWindow.SizeAllocated += delegate { + if (wbWindow.GdkWindow != null) + IdeApp.Workbench.StatusBar.HasResizeGrip = wbWindow.GdkWindow.State != Gdk.WindowState.Maximized; + }; + } + IdeApp.Workbench.StatusBar.HasResizeGrip = false; + */ + + // create DockItems for all the pads + foreach (PadCodon content in padContentCollection) + AddPad (content, content.DefaultPlacement, content.DefaultStatus); + + try { + if (System.IO.File.Exists (configFile)) { + dock.LoadLayouts (configFile); + foreach (string layout in dock.Layouts) { + if (!layouts.Contains (layout)) + layouts.Add (layout); + } + } + } catch (Exception ex) { + LoggingService.LogError (ex.ToString ()); + } + CurrentLayout = "Default"; + } + + void InitializeLayout (string name) + { + if (!layouts.Contains (name)) + layouts.Add (name); + + if (dock.Layouts.Contains (name)) + return; + + dock.CreateLayout (name, true); + dock.CurrentLayout = name; + documentDockItem.Visible = true; + + LayoutExtensionNode stockLayout = null; + foreach (LayoutExtensionNode node in AddinManager.GetExtensionNodes (stockLayoutsPath)) { + if (node.Name == name) { + stockLayout = node; + break; + } + } + + if (stockLayout == null) + return; + + HashSet<string> visible = new HashSet<string> (); + + foreach (LayoutPadExtensionNode pad in stockLayout.ChildNodes) { + DockItem it = dock.GetItem (pad.Id); + if (it != null) { + it.Visible = true; + string loc = pad.Placement ?? it.DefaultLocation; + if (!string.IsNullOrEmpty (loc)) + it.SetDockLocation (ToDockLocation (loc)); + DockItemStatus stat = pad.StatusSet ? pad.Status : it.DefaultStatus; + it.Status = stat; + visible.Add (pad.Id); + } + } + + foreach (PadCodon node in padContentCollection) { + if (!visible.Contains (node.Id) && node.DefaultLayouts != null && (node.DefaultLayouts.Contains (stockLayout.Id) || node.DefaultLayouts.Contains ("*"))) { + DockItem it = dock.GetItem (node.Id); + if (it != null) { + it.Visible = true; + if (!string.IsNullOrEmpty (node.DefaultPlacement)) + it.SetDockLocation (ToDockLocation (node.DefaultPlacement)); + it.Status = node.DefaultStatus; + visible.Add (node.Id); + } + } + } + + foreach (DockItem it in dock.GetItems ()) { + if (!visible.Contains (it.Id) && ((it.Behavior & DockItemBehavior.Sticky) == 0) && it != documentDockItem) + it.Visible = false; + } + } + + void ShowPopup () + { + Gtk.Menu contextMenu = IdeApp.CommandService.CreateMenu ("/MonoDevelop/Ide/ContextMenu/DocumentTab"); + if (contextMenu != null) + contextMenu.Popup (); + } + + void OnTabsReordered (Widget widget, int oldPlacement, int newPlacement) + { + IdeApp.Workbench.ReorderDocuments (oldPlacement, newPlacement); + } + public void ResetToolbars () { - layout.ResetToolbars (); + toolbarFrame.ResetToolbarPositions (); + } + + public void ToggleFullViewMode () + { + isInFullViewMode = !isInFullViewMode; + this.tabControl.LeaveDragMode (0); + + if (isInFullViewMode) { + string fullViewLayout = "Edit." + CurrentLayout + fullViewModeTag; + if (!dock.HasLayout (fullViewLayout)) + dock.CreateLayout (fullViewLayout, true); + dock.CurrentLayout = fullViewLayout; + foreach (DockItem it in dock.GetItems ()) { + if (it.Behavior != DockItemBehavior.Locked && it.Visible) + it.Status = DockItemStatus.AutoHide; + } + } else { + dock.CurrentLayout = "Edit." + CurrentLayout; + } } protected override bool OnKeyPressEvent (Gdk.EventKey evnt) @@ -696,31 +1030,252 @@ namespace MonoDevelop.Ide.Gui if (args.Change == ExtensionChange.Add) { ShowPadNode (args.ExtensionNode); - RedrawAllComponents (); } else { RemovePadNode (args.ExtensionNode); } } - // Handle keyboard shortcuts + void OnLayoutsExtensionChanged (object s, ExtensionNodeEventArgs args) + { + if (args.Change == ExtensionChange.Add) + layouts.Add (((LayoutExtensionNode)args.ExtensionNode).Name); + else + layouts.Remove (((LayoutExtensionNode)args.ExtensionNode).Name); + } + + #region View management + + bool SelectLastActiveWindow (IWorkbenchWindow cur) + { + if (lastActiveWindows.Count == 0) + return false; + IWorkbenchWindow last = null; + do { + last = lastActiveWindows.Last.Value; + lastActiveWindows.RemoveLast (); + } while (lastActiveWindows.Count > 0 && (last == cur || last == null || (last != null && last.ViewContent == null))); + if (last != null) { + last.SelectWindow (); + return true; + } + return false; + } + + void CloseWindowEvent (object sender, WorkbenchWindowEventArgs e) + { + SdiWorkspaceWindow f = (SdiWorkspaceWindow) sender; + + // Unsubscribe events to avoid memory leaks + f.TabLabel.CloseClicked -= new EventHandler (closeClicked); + + if (f.ViewContent != null) { + CloseContent (f.ViewContent); + if (e.WasActive && !SelectLastActiveWindow (f)) + OnActiveWindowChanged(this, null); + } + lastActiveWindows.Remove (f); + } + + void closeClicked (object o, EventArgs e) + { + Widget tabLabel = ((Widget)o); + foreach (Widget child in tabControl.Children) { + if (tabControl.GetTabLabel (child) == tabLabel) { + int pageNum = tabControl.PageNum (child); + ((SdiWorkspaceWindow)child).CloseWindow (false, false, pageNum); + break; + } + } + } + internal void RemoveTab (int pageNum) { + try { + // Weird switch page events are fired when a tab is removed. + // This flag avoids unneeded events. + ignorePageSwitch = true; + IWorkbenchWindow w = ActiveWorkbenchWindow; + tabControl.RemovePage (pageNum); + ignorePageSwitch = false; + if (w != ActiveWorkbenchWindow) + OnActiveWindowChanged (null, null); + } finally { + ignorePageSwitch = false; + } + } + + #endregion - public event EventHandler ActiveWorkbenchWindowChanged; + #region Dock Item management + + public IPadWindow GetPadWindow (PadCodon content) + { + IPadWindow w; + padWindows.TryGetValue (content, out w); + return w; + } + + public bool IsVisible (PadCodon padContent) + { + DockItem item = GetDockItem (padContent); + if (item != null) + return item.Visible; + return false; + } + + public bool IsContentVisible (PadCodon padContent) + { + DockItem item = GetDockItem (padContent); + if (item != null) + return item.ContentVisible; + return false; + } + + public void HidePad (PadCodon padContent) + { + DockItem item = GetDockItem (padContent); + if (item != null) + item.Visible = false; + } + + public void ActivatePad (PadCodon padContent, bool giveFocus) + { + DockItem item = GetDockItem (padContent); + if (item != null) + item.Present (giveFocus); + } + + public bool IsSticky (PadCodon padContent) + { + DockItem item = GetDockItem (padContent); + return item != null && (item.Behavior & DockItemBehavior.Sticky) != 0; + } - /// Context switching specific parts - WorkbenchContext context = WorkbenchContext.Edit; + public void SetSticky (PadCodon padContent, bool sticky) + { + DockItem item = GetDockItem (padContent); + if (item != null) { + if (sticky) + item.Behavior |= DockItemBehavior.Sticky; + else + item.Behavior &= ~DockItemBehavior.Sticky; + } + } - public WorkbenchContext Context { - get { return context; } - set { - context = value; - if (ContextChanged != null) - ContextChanged (this, new EventArgs()); + internal DockItem GetDockItem (PadCodon content) + { + if (padContentCollection.Contains (content)) { + DockItem item = dock.GetItem (content.PadId); + return item; } + return null; } + + void CreatePadContent (bool force, PadCodon padCodon, PadWindow window, DockItem item) + { + if (force || item.Content == null) { + IPadContent newContent = padCodon.InitializePadContent (window); - public event EventHandler ContextChanged; + Gtk.Widget pcontent; + if (newContent is Widget) { + pcontent = newContent.Control; + } else { + PadCommandRouterContainer crc = new PadCommandRouterContainer (window, newContent.Control, newContent, true); + crc.Show (); + pcontent = crc; + } + + PadCommandRouterContainer router = new PadCommandRouterContainer (window, pcontent, toolbarFrame, false); + router.Show (); + item.Content = router; + } + } + + string ToDockLocation (string loc) + { + string location = ""; + foreach (string s in loc.Split (' ')) { + if (string.IsNullOrEmpty (s)) + continue; + if (location.Length > 0) + location += ";"; + if (s.IndexOf ('/') == -1) + location += "__" + s.ToLower () + "/CenterBefore"; + else + location += s; + } + return location; + } + + void AddPad (PadCodon padCodon, string placement, DockItemStatus defaultStatus) + { + PadWindow window = new PadWindow (this, padCodon); + window.Icon = padCodon.Icon; + padWindows [padCodon] = window; + padCodons [window] = padCodon; + + window.StatusChanged += new EventHandler (UpdatePad); + + string location = ToDockLocation (placement); + + DockItem item = dock.AddItem (padCodon.PadId); + item.Label = GettextCatalog.GetString (padCodon.Label); + item.Icon = ImageService.GetPixbuf (padCodon.Icon, IconSize.Menu); + item.DefaultLocation = location; + item.DefaultVisible = false; + item.DefaultStatus = defaultStatus; + item.DockLabelProvider = padCodon; + window.Item = item; + + if (padCodon.Initialized) { + CreatePadContent (true, padCodon, window, item); + } else { + item.ContentRequired += delegate { + CreatePadContent (false, padCodon, window, item); + }; + } + + item.VisibleChanged += delegate { + if (item.Visible) + window.NotifyShown (); + else + window.NotifyHidden (); + }; + + item.ContentVisibleChanged += delegate { + if (item.ContentVisible) + window.NotifyContentShown (); + else + window.NotifyContentHidden (); + }; + + if (!padContentCollection.Contains (padCodon)) + padContentCollection.Add (padCodon); + } + + void UpdatePad (object source, EventArgs args) + { + IPadWindow window = (IPadWindow) source; + if (!padCodons.ContainsKey (window)) + return; + PadCodon codon = padCodons [window]; + DockItem item = GetDockItem (codon); + if (item != null) { + string windowTitle = GettextCatalog.GetString (window.Title); + if (String.IsNullOrEmpty (windowTitle)) + windowTitle = GettextCatalog.GetString (codon.Label); + if (window.IsWorking) + windowTitle = "<span foreground='blue'>" + windowTitle + "</span>"; + else if (window.HasErrors && !window.ContentVisible) + windowTitle = "<span foreground='red'>" + windowTitle + "</span>"; + else if (window.HasNewData && !window.ContentVisible) + windowTitle = "<b>" + windowTitle + "</b>"; + item.Label = windowTitle; + item.Icon = ImageService.GetPixbuf (window.Icon, IconSize.Menu); + } + } + + #endregion } class PadActivationHandler: CommandHandler @@ -739,5 +1294,44 @@ namespace MonoDevelop.Ide.Gui wb.BringToFront (pad, true); } } + + class PadCommandRouterContainer: CommandRouterContainer + { + public PadCommandRouterContainer (PadWindow window, Gtk.Widget child, object target, bool continueToParent): base (child, target, continueToParent) + { + } + } + + // The SdiDragNotebook class allows redirecting the command route to the ViewCommandHandler + // object of the selected document, which implement some default commands. + + class SdiDragNotebook: DragNotebook, ICommandDelegatorRouter + { + ShadedContainer shadedContainer; + + public SdiDragNotebook (ShadedContainer shadedContainer) + { + this.shadedContainer = shadedContainer; + shadedContainer.Add (this); + } + + public object GetNextCommandTarget () + { + return Parent; + } + + public object GetDelegatedCommandTarget () + { + SdiWorkspaceWindow win = (SdiWorkspaceWindow) CurrentPageWidget; + return win != null ? win.CommandHandler : null; + } + + protected override bool OnExposeEvent (Gdk.EventExpose evnt) + { + shadedContainer.DrawBackground (this); + return base.OnExposeEvent (evnt); + } + + } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IPadContainer.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IPadContainer.cs index 71b79d820f..10673fd113 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IPadContainer.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IPadContainer.cs @@ -144,13 +144,13 @@ namespace MonoDevelop.Ide.Gui bool hasNewData; IPadContent content; PadCodon codon; - SdiWorkbenchLayout layout; + DefaultWorkbench workbench; internal DockItem Item { get; set; } - internal PadWindow (SdiWorkbenchLayout layout, PadCodon codon) + internal PadWindow (DefaultWorkbench workbench, PadCodon codon) { - this.layout = layout; + this.workbench = workbench; this.codon = codon; this.title = GettextCatalog.GetString (codon.Label); this.icon = codon.Icon; @@ -247,15 +247,15 @@ namespace MonoDevelop.Ide.Gui } public bool ContentVisible { - get { return layout.IsContentVisible (codon); } + get { return workbench.IsContentVisible (codon); } } public bool Sticky { get { - return layout.IsSticky (codon); + return workbench.IsSticky (codon); } set { - layout.SetSticky (codon, value); + workbench.SetSticky (codon, value); } } @@ -267,7 +267,7 @@ namespace MonoDevelop.Ide.Gui public void Activate (bool giveFocus) { CreateContent (); - layout.ActivatePad (codon, giveFocus); + workbench.ActivatePad (codon, giveFocus); } void CreateContent () diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/InternalLog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/InternalLog.cs index a1a354e0d8..36aa769d93 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/InternalLog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/InternalLog.cs @@ -36,7 +36,7 @@ namespace MonoDevelop.Ide.Gui { static class InternalLog { - static MonoDevelopStatusBar.StatusIcon errorIcon; + static StatusBarIcon errorIcon; static bool errorNotificationEnabled; static InternalLogger logger; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopStatusBar.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopStatusBar.cs index b80aa87b1d..e4be96f7bb 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopStatusBar.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopStatusBar.cs @@ -31,15 +31,15 @@ using MonoDevelop.Core; using Gtk; using MonoDevelop.Ide.CodeCompletion; using MonoDevelop.Ide.Gui; +using System.Collections.Generic; namespace MonoDevelop.Ide { - public class MonoDevelopStatusBar : Gtk.Statusbar + class MonoDevelopStatusBar : Gtk.Statusbar, StatusBar { ProgressBar progressBar = new ProgressBar (); Frame textStatusBarPanel = new Frame (); - Label statusLabel; Label modeLabel; Label cursorLabel; @@ -47,8 +47,20 @@ namespace MonoDevelop.Ide HBox statusBox; Image currentStatusImage; EventBox eventBox; + List<StatusBarContextImpl> contexts = new List<StatusBarContextImpl> (); + MainStatusBarContextImpl mainContext; + StatusBarContextImpl activeContext; + + public StatusBar MainContext { + get { return mainContext; } + } + internal MonoDevelopStatusBar() { + mainContext = new MainStatusBarContextImpl (this); + activeContext = mainContext; + contexts.Add (mainContext); + Frame originalFrame = (Frame)Children[0]; // originalFrame.WidthRequest = 8; // originalFrame.Shadow = ShadowType.In; @@ -57,7 +69,7 @@ namespace MonoDevelop.Ide BorderWidth = 0; DefaultWorkbench wb = (DefaultWorkbench) IdeApp.Workbench.RootWindow; - Gtk.Widget dockBar = wb.WorkbenchLayout.DockFrame.ExtractDockBar (PositionType.Bottom); + Gtk.Widget dockBar = wb.DockFrame.ExtractDockBar (PositionType.Bottom); dockBar.NoShowAll = true; PackStart (dockBar, false, false, 0); @@ -115,18 +127,67 @@ namespace MonoDevelop.Ide originalFrame.HideAll (); progressBar.Visible = false; + StatusBarContext completionStatus = null; + // todo: Move this to the CompletionWindowManager when it's possible. CompletionWindowManager.WindowShown += delegate { CompletionListWindow wnd = CompletionWindowManager.Wnd; - if (wnd != null && wnd.List != null && wnd.List.CategoryCount > 1) - ShowMessage (string.Format (GettextCatalog.GetString ("To toggle categorized completion mode press {0}."), IdeApp.CommandService.GetCommandInfo (Commands.TextEditorCommands.ShowCompletionWindow, null).AccelKey)); + if (wnd != null && wnd.List != null && wnd.List.CategoryCount > 1) { + if (completionStatus == null) + completionStatus = CreateContext (); + completionStatus.ShowMessage (string.Format (GettextCatalog.GetString ("To toggle categorized completion mode press {0}."), IdeApp.CommandService.GetCommandInfo (Commands.TextEditorCommands.ShowCompletionWindow, null).AccelKey)); + } }; CompletionWindowManager.WindowClosed += delegate { - ShowReady (); + if (completionStatus != null) { + completionStatus.Dispose (); + completionStatus = null; + } }; } + internal bool IsCurrentContext (StatusBarContextImpl ctx) + { + return ctx == activeContext; + } + + internal void Remove (StatusBarContextImpl ctx) + { + if (ctx == mainContext) + return; + + StatusBarContextImpl oldActive = activeContext; + contexts.Remove (ctx); + UpdateActiveContext (); + if (oldActive != activeContext) { + // Removed the active context. Update the status bar. + activeContext.Update (); + } + } + + internal void UpdateActiveContext () + { + for (int n = contexts.Count - 1; n >= 0; n--) { + StatusBarContextImpl ctx = contexts [n]; + if (ctx.StatusChanged) { + if (ctx != activeContext) { + activeContext = ctx; + activeContext.Update (); + } + return; + } + } + throw new InvalidOperationException (); // There must be at least the main context + } + + public StatusBarContext CreateContext () + { + StatusBarContextImpl ctx = new StatusBarContextImpl (this); + contexts.Add (ctx); + return ctx; + } + public void ShowCaretState (int line, int column, int selectedChars, bool isInInsertMode) { DispatchService.AssertGuiThread (); @@ -177,7 +238,7 @@ namespace MonoDevelop.Ide ShowMessage (image, message, false); } string lastText = null; - void ShowMessage (Image image, string message, bool isMarkup) + public void ShowMessage (Image image, string message, bool isMarkup) { if (message == lastText) return; @@ -203,7 +264,7 @@ namespace MonoDevelop.Ide } } - public StatusIcon ShowStatusIcon (Gdk.Pixbuf pixbuf) + public StatusBarIcon ShowStatusIcon (Gdk.Pixbuf pixbuf) { DispatchService.AssertGuiThread (); @@ -261,7 +322,7 @@ namespace MonoDevelop.Ide } #endregion - public class StatusIcon : IDisposable + public class StatusIcon : StatusBarIcon { MonoDevelopStatusBar statusBar; internal EventBox box; @@ -326,7 +387,7 @@ namespace MonoDevelop.Ide } } - public bool AnimateIcon () + bool AnimateIcon () { box.Remove (box.Child); @@ -348,4 +409,279 @@ namespace MonoDevelop.Ide } } } + + /// <summary> + /// The MonoDevelop status bar. + /// </summary> + public interface StatusBar: StatusBarContext + { + /// <summary> + /// Show caret state information + /// </summary> + void ShowCaretState (int line, int column, int selectedChars, bool isInInsertMode); + + /// <summary> + /// Hides the caret state information + /// </summary> + void ClearCaretState (); + + /// <summary> + /// Shows a status icon in the toolbar. The icon can be removed by disposing + /// the StatusBarIcon instance. + /// </summary> + StatusBarIcon ShowStatusIcon (Gdk.Pixbuf pixbuf); + + /// <summary> + /// Creates a status bar context. The returned context can be used to show status information + /// which will be cleared when the context is disposed. When several contexts are created, + /// the status bar will show the status of the latest created context. + /// </summary> + StatusBarContext CreateContext (); + + // Clears the status bar information + void ShowReady (); + } + + public interface StatusBarContext: IDisposable + { + /// <summary> + /// Shows a message with an error icon + /// </summary> + void ShowError (string error); + + /// <summary> + /// Shows a message with a warning icon + /// </summary> + void ShowWarning (string warning); + + /// <summary> + /// Shows a message in the status bar + /// </summary> + void ShowMessage (string message); + + /// <summary> + /// Shows a message in the status bar + /// </summary> + void ShowMessage (string message, bool isMarkup); + + /// <summary> + /// Shows a message in the status bar + /// </summary> + void ShowMessage (Image image, string message); + + /// <summary> + /// Shows a progress bar, with the provided label next to it + /// </summary> + void BeginProgress (string name); + + /// <summary> + /// Shows a progress bar, with the provided label and icon next to it + /// </summary> + void BeginProgress (Image image, string name); + + /// <summary> + /// Sets the progress fraction. It can only be used after calling BeginProgress. + /// </summary> + void SetProgressFraction (double work); + + /// <summary> + /// Hides the progress bar shown with BeginProgress + /// </summary> + void EndProgress (); + + /// <summary> + /// Pulses the progress bar shown with BeginProgress + /// </summary> + void Pulse (); + } + + public interface StatusBarIcon : IDisposable + { + /// <summary> + /// Tooltip of the status icon + /// </summary> + string ToolTip { get; set; } + + /// <summary> + /// Event box which can be used to subscribe mouse events on the icon + /// </summary> + EventBox EventBox { get; } + + /// <summary> + /// The icon + /// </summary> + Gdk.Pixbuf Image { get; set; } + + /// <summary> + /// Sets alert mode. The icon will flash for the provided number of seconds. + /// </summary> + void SetAlertMode (int seconds); + } + + class StatusBarContextImpl: StatusBarContext + { + Image image; + string message; + bool isMarkup; + double progressFraction; + bool showProgress; + protected MonoDevelopStatusBar statusBar; + + internal bool StatusChanged { get; set; } + + internal StatusBarContextImpl (MonoDevelopStatusBar statusBar) + { + this.statusBar = statusBar; + } + + public void Dispose () + { + statusBar.Remove (this); + } + + public void ShowError (string error) + { + ShowMessage (new Image (MonoDevelop.Ide.Gui.Stock.Error, IconSize.Menu), error); + } + + public void ShowWarning (string warning) + { + ShowMessage (new Gtk.Image (MonoDevelop.Ide.Gui.Stock.Warning, IconSize.Menu), warning); + } + + public void ShowMessage (string message) + { + ShowMessage (null, message, false); + } + + public void ShowMessage (string message, bool isMarkup) + { + ShowMessage (null, message, isMarkup); + } + + public void ShowMessage (Image image, string message) + { + ShowMessage (image, message, false); + } + + bool InitialSetup () + { + if (!StatusChanged) { + StatusChanged = true; + statusBar.UpdateActiveContext (); + return true; + } else + return false; + } + + public void ShowMessage (Image image, string message, bool isMarkup) + { + this.image = image; + this.message = message; + this.isMarkup = isMarkup; + if (InitialSetup ()) + return; + if (statusBar.IsCurrentContext (this)) + statusBar.ShowMessage (image, message, isMarkup); + } + + public void BeginProgress (string name) + { + image = null; + isMarkup = false; + progressFraction = 0; + message = name; + showProgress = true; + if (InitialSetup ()) + return; + if (statusBar.IsCurrentContext (this)) + statusBar.BeginProgress (name); + } + + public void BeginProgress (Image image, string name) + { + this.image = image; + isMarkup = false; + progressFraction = 0; + message = name; + showProgress = true; + if (InitialSetup ()) + return; + if (statusBar.IsCurrentContext (this)) + statusBar.BeginProgress (name); + } + + public void SetProgressFraction (double work) + { + progressFraction = work; + if (InitialSetup ()) + return; + if (statusBar.IsCurrentContext (this)) + statusBar.SetProgressFraction (work); + } + + public void EndProgress () + { + showProgress = false; + message = string.Empty; + progressFraction = 0; + if (InitialSetup ()) + return; + if (statusBar.IsCurrentContext (this)) + statusBar.EndProgress (); + } + + public void Pulse () + { + showProgress = true; + if (InitialSetup ()) + return; + if (statusBar.IsCurrentContext (this)) + statusBar.Pulse (); + } + + internal void Update () + { + if (showProgress) { + statusBar.BeginProgress (image, message); + statusBar.SetProgressFraction (progressFraction); + } else { + statusBar.EndProgress (); + statusBar.ShowMessage (image, message, isMarkup); + } + } + } + + class MainStatusBarContextImpl: StatusBarContextImpl, StatusBar + { + public MainStatusBarContextImpl (MonoDevelopStatusBar statusBar): base (statusBar) + { + StatusChanged = true; + } + + public void ShowCaretState (int line, int column, int selectedChars, bool isInInsertMode) + { + statusBar.ShowCaretState (line, column, selectedChars, isInInsertMode); + } + + public void ClearCaretState () + { + statusBar.ClearCaretState (); + } + + public StatusBarIcon ShowStatusIcon (Gdk.Pixbuf pixbuf) + { + return statusBar.ShowStatusIcon (pixbuf); + } + + public StatusBarContext CreateContext () + { + return statusBar.CreateContext (); + } + + public void ShowReady () + { + statusBar.ShowReady (); + } + } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Pad.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Pad.cs index ce6788cd32..1ac60ded6d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Pad.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Pad.cs @@ -45,7 +45,7 @@ namespace MonoDevelop.Ide.Gui internal Pad (DefaultWorkbench workbench, PadCodon content) { - this.window = workbench.WorkbenchLayout.GetPadWindow (content); + this.window = workbench.GetPadWindow (content); this.window.PadHidden += delegate { IsOpenedAutomatically = false; }; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs deleted file mode 100644 index ddf15051a2..0000000000 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs +++ /dev/null @@ -1,937 +0,0 @@ -// SdiWorkspaceLayout.cs -// -// Author: -// Mike Krüger -// Lluis Sanchez Gual -// -// This file was derived from a file from #Develop 2.0 -// -// Copyright (C) 2001-2007 Mike Krüger <mkrueger@novell.com> -// Copyright (C) 2006 Novell, Inc (http://www.novell.com) -// -// This library is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 2.1 of the -// License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Collections; -using System.IO; -using System.Collections.Generic; -using System.Drawing; -using System.Xml; -using System.Xml.Serialization; -using System.Linq; -using MonoDevelop.Core; - -using Gtk; -using MonoDevelop.Components; -using Mono.Addins; -using MonoDevelop.Ide.Commands; -using MonoDevelop.Ide.Codons; -using MonoDevelop.Components.Commands; -using MonoDevelop.Components.DockToolbars; -using MonoDevelop.Components.Docking; - -namespace MonoDevelop.Ide.Gui -{ - /// <summary> - /// This is the a Workspace with a single document interface. - /// </summary> - internal class SdiWorkbenchLayout - { - static string configFile = Path.Combine (PropertyService.ConfigPath, "EditingLayout.xml"); - const string fullViewModeTag = "[FullViewMode]"; - - readonly string[] defaultVisiblePads = new string [] { - "MonoDevelop.Ide.Gui.Pads.FileScout", - "ClassPad", - "ProjectPad" - }; - -#if DUMMY_STRINGS_FOR_TRANSLATION_DO_NOT_COMPILE - private void DoNotCompile () - { - //The default layout, translated indirectly because it's used as an ID - GettextCatalog.GetString ("Default"); - } -#endif - - // list of layout names for the current context, without the context prefix - List<string> layouts = new List<string> (); - - DefaultWorkbench workbench; - - // current workbench context - WorkbenchContext workbenchContext; - - Window wbWindow; - Container rootWidget; - DockToolbarFrame toolbarFrame; - DockFrame dock; - SdiDragNotebook tabControl; - EventHandler contextChangedHandler; - Dictionary<PadCodon, IPadWindow> padWindows = new Dictionary<PadCodon, IPadWindow> (); - Dictionary<IPadWindow, PadCodon> padCodons = new Dictionary<IPadWindow, PadCodon> (); - - bool initialized; - IWorkbenchWindow lastActive; - const int MAX_LASTACTIVEWINDOWS = 10; - LinkedList<IWorkbenchWindow> lastActiveWindows = new LinkedList<IWorkbenchWindow> (); - bool ignorePageSwitch; - bool isInFullViewMode = false; - - Gtk.Toolbar[] toolBars; - Gtk.MenuBar menubar; - - public SdiWorkbenchLayout () { - contextChangedHandler = new EventHandler (OnContextChanged); - } - - public IWorkbenchWindow ActiveWorkbenchwindow { - get { - if (tabControl == null || tabControl.CurrentPage < 0 || tabControl.CurrentPage >= tabControl.NPages) { - return null; - } - return (IWorkbenchWindow) tabControl.CurrentPageWidget; - } - } - - public DockFrame DockFrame { - get { return dock; } - } - - Gtk.VBox fullViewVBox = new VBox (false, 0); - DockItem documentDockItem; - - public void Attach (DefaultWorkbench workbench) - { - this.workbench = workbench; - wbWindow = (Window) workbench; - - rootWidget = fullViewVBox; - - InstallMenuBar (); - - toolbarFrame = new CommandFrame (IdeApp.CommandService); - fullViewVBox.PackStart (toolbarFrame, true, true, 0); - - if (workbench.ToolBars != null) { - for (int i = 0; i < workbench.ToolBars.Length; i++) { - toolbarFrame.AddBar ((DockToolbar)workbench.ToolBars[i]); - } - } - - toolBars = workbench.ToolBars; - - // Create the docking widget and add it to the window. - dock = new DockFrame (); - - dock.CompactGuiLevel = ((int)IdeApp.Preferences.WorkbenchCompactness) + 1; - IdeApp.Preferences.WorkbenchCompactnessChanged += delegate { - dock.CompactGuiLevel = ((int)IdeApp.Preferences.WorkbenchCompactness) + 1; - }; - - HBox hbox = new HBox (); - VBox sideBox = new VBox (); - - - /* Side bar is experimental. Disabled for now - sideBox.PackStart (new SideBar (workbench, Orientation.Vertical), false, false, 0); - hbox.PackStart (sideBox, false, false, 0); - hbox.ShowAll (); - sideBox.NoShowAll = true; - hbox.PackStart (dock, true, true, 0); - DockBar bar = dock.ExtractDockBar (PositionType.Left); - bar.AlwaysVisible = true; - sideBox.PackStart (bar, true, true, 0); - toolbarFrame.AddContent (hbox); - */ - - toolbarFrame.AddContent (dock); - - // Create the notebook for the various documents. - tabControl = new SdiDragNotebook (dock.ShadedContainer); - tabControl.Scrollable = true; - tabControl.SwitchPage += new SwitchPageHandler (ActiveMdiChanged); - tabControl.PageAdded += delegate { ActiveMdiChanged (null, null); }; - tabControl.PageRemoved += delegate { ActiveMdiChanged (null, null); }; - - tabControl.ButtonPressEvent += delegate(object sender, ButtonPressEventArgs e) { - int tab = tabControl.FindTabAtPosition (e.Event.XRoot, e.Event.YRoot); - if (tab < 0) - return; - tabControl.CurrentPage = tab; - if (e.Event.Type == Gdk.EventType.TwoButtonPress) - ToggleFullViewMode (); - }; - - this.tabControl.PopupMenu += delegate { - ShowPopup (); - }; - this.tabControl.ButtonReleaseEvent += delegate (object sender, Gtk.ButtonReleaseEventArgs e) { - int tab = tabControl.FindTabAtPosition (e.Event.XRoot, e.Event.YRoot); - if (tab < 0) - return; - if (e.Event.Button == 3) - ShowPopup (); - }; - - tabControl.TabsReordered += new TabsReorderedHandler (OnTabsReordered); - - // The main document area - documentDockItem = dock.AddItem ("Documents"); - documentDockItem.Behavior = DockItemBehavior.Locked; - documentDockItem.Expand = true; - documentDockItem.DrawFrame = false; - documentDockItem.Label = GettextCatalog.GetString ("Documents"); - documentDockItem.Content = tabControl; - - // Add some hiden items to be used as position reference - DockItem dit = dock.AddItem ("__left"); - dit.DefaultLocation = "Documents/Left"; - dit.Behavior = DockItemBehavior.Locked; - dit.DefaultVisible = false; - - dit = dock.AddItem ("__right"); - dit.DefaultLocation = "Documents/Right"; - dit.Behavior = DockItemBehavior.Locked; - dit.DefaultVisible = false; - - dit = dock.AddItem ("__top"); - dit.DefaultLocation = "Documents/Top"; - dit.Behavior = DockItemBehavior.Locked; - dit.DefaultVisible = false; - - dit = dock.AddItem ("__bottom"); - dit.DefaultLocation = "Documents/Bottom"; - dit.Behavior = DockItemBehavior.Locked; - dit.DefaultVisible = false; - - workbench.Add (fullViewVBox); - fullViewVBox.ShowAll (); - - fullViewVBox.PackEnd (IdeApp.Workbench.StatusBar, false, true, 0); - - // the Mac has a resize grip by default, and the GTK+ one breaks it - if (MonoDevelop.Core.PropertyService.IsMac) - IdeApp.Workbench.StatusBar.HasResizeGrip = false; - else { - if (wbWindow.GdkWindow != null && wbWindow.GdkWindow.State == Gdk.WindowState.Maximized) - IdeApp.Workbench.StatusBar.HasResizeGrip = false; - wbWindow.SizeAllocated += delegate { - if (wbWindow.GdkWindow != null) - IdeApp.Workbench.StatusBar.HasResizeGrip = wbWindow.GdkWindow.State != Gdk.WindowState.Maximized; - }; - } - IdeApp.Workbench.StatusBar.HasResizeGrip = false; - - foreach (IViewContent content in workbench.ViewContentCollection) - ShowView (content); - - // by default, the active pad collection is the full set - // will be overriden in CreateDefaultLayout() below - activePadCollection = new List<MonoDevelop.Ide.Codons.PadCodon> (workbench.PadContentCollection); - - // create DockItems for all the pads - foreach (PadCodon content in workbench.PadContentCollection) - { - AddPad (content, content.DefaultPlacement, content.DefaultStatus); - } - - - CreateDefaultLayout(); - - workbench.ContextChanged += contextChangedHandler; - } - - public void ResetToolbars () - { - toolbarFrame.ResetToolbarPositions (); - } - - void ShowPopup () - { - Gtk.Menu contextMenu = IdeApp.CommandService.CreateMenu ("/MonoDevelop/Ide/ContextMenu/DocumentTab"); - if (contextMenu != null) - contextMenu.Popup (); - } - - public void ToggleFullViewMode () - { - isInFullViewMode = !isInFullViewMode; - this.tabControl.LeaveDragMode (0); - - if (isInFullViewMode) { - string fullViewLayout = workbench.Context.Id + "." + CurrentLayout + fullViewModeTag; - if (!dock.HasLayout (fullViewLayout)) - dock.CreateLayout (fullViewLayout, true); - dock.CurrentLayout = fullViewLayout; - foreach (DockItem it in dock.GetItems ()) { - if (it.Behavior != DockItemBehavior.Locked && it.Visible) - it.Status = DockItemStatus.AutoHide; - } - } else { - dock.CurrentLayout = workbench.Context.Id + "." + CurrentLayout; - } - } - - public ICustomXmlSerializer Memento { - get { - return new SdiWorkbenchLayoutMemento (initialized ? toolbarFrame.GetStatus () : new DockToolbarFrameStatus ()).ToProperties (); - } - set { - initialized = true; - SdiWorkbenchLayoutMemento m = new SdiWorkbenchLayoutMemento ((Properties)value); - toolbarFrame.SetStatus (m.Status); - } - } - - void OnTabsReordered (Widget widget, int oldPlacement, int newPlacement) - { - IdeApp.Workbench.ReorderDocuments (oldPlacement, newPlacement); - } - - void OnContextChanged (object o, EventArgs e) - { - SwitchContext (workbench.Context); - } - - void SwitchContext (WorkbenchContext ctxt) - { - List<PadCodon> old = activePadCollection; - - // switch pad collections - if (padCollections [ctxt] != null) - activePadCollection = padCollections [ctxt]; - else - // this is so, for unkwown contexts, we get the full set of pads - activePadCollection = new List<MonoDevelop.Ide.Codons.PadCodon> (workbench.PadContentCollection); - - workbenchContext = ctxt; - - // get the list of layouts - string ctxtPrefix = ctxt.Id + "."; - - layouts.Clear (); - foreach (string name in dock.Layouts) { - if (name.StartsWith (ctxtPrefix) && !name.EndsWith (fullViewModeTag)) { - layouts.Add (name.Substring (ctxtPrefix.Length)); - } - } - - // get the default layout for the new context from the property service - CurrentLayout = PropertyService.Get - ("MonoDevelop.Core.Gui.SdiWorkbenchLayout." + ctxt.Id, "Default"); - - // make sure invalid pads for the new context are not visible - foreach (PadCodon content in old) - { - if (!activePadCollection.Contains (content)) - { - DockItem item = dock.GetItem (content.PadId); - if (item != null) - item.Visible = false; - } - } - } - - public Gtk.Widget LayoutWidget { - get { return rootWidget; } - } - - public string CurrentLayout { - get { - if (dock != null && dock.CurrentLayout != null) { - string s = dock.CurrentLayout; - s = s.Substring (s.IndexOf (".") + 1); - if (s.EndsWith (fullViewModeTag)) - return s.Substring (0, s.Length - fullViewModeTag.Length); - return s; - } - else - return ""; - } - set { - // Leave dragging mode, to avoid problems due to widget relocating - tabControl.LeaveDragMode (0); - isInFullViewMode = false; - - string newLayout = workbench.Context.Id + "." + value; - if (!((IList)dock.Layouts).Contains (newLayout)) { - dock.CreateLayout (newLayout, true); - layouts.Add (value); - } - dock.CurrentLayout = newLayout; - toolbarFrame.CurrentLayout = newLayout; - - // persist the selected layout for the current context - PropertyService.Set ("MonoDevelop.Core.Gui.SdiWorkbenchLayout." + - workbenchContext.Id, - value); - } - } - - public string[] Layouts { - get { - string[] result = new string [layouts.Count]; - layouts.CopyTo (result); - return result; - } - } - - public void DeleteLayout (string name) - { - string layout = workbench.Context.Id + "." + name; - layouts.Remove (name); - dock.DeleteLayout (layout); - } - - - // pad collection for the current workbench context - List<PadCodon> activePadCollection; - - // set of PadContentCollection objects for the different workbench contexts - Dictionary<WorkbenchContext, List<PadCodon>> padCollections = new Dictionary<WorkbenchContext, List<PadCodon>> (); - - public List<PadCodon> PadContentCollection { - get { - return activePadCollection; - } - } - - internal DockItem GetDockItem (PadCodon content) - { - if (activePadCollection.Contains (content)) - { - DockItem item = dock.GetItem (content.PadId); - return item; - } - return null; - } - - void CreateDefaultLayout() - { - AddinManager.AddExtensionNodeHandler ("/MonoDevelop/Ide/WorkbenchContexts", OnExtensionChanged); - - try { - if (System.IO.File.Exists (configFile)) { - dock.LoadLayouts (configFile); - } else if (System.IO.File.Exists ("../data/options/DefaultEditingLayout2.xml")) { - dock.LoadLayouts ("../data/options/DefaultEditingLayout2.xml"); - } else { - dock.CreateLayout ("Edit.Default", true); - dock.CurrentLayout = "Edit.Default"; - DockItem it = null; - foreach (string s in defaultVisiblePads) { - it = dock.GetItem (s); - if (it != null) - it.Visible = true; - } - it.Present (false); - } - } catch (Exception ex) { - LoggingService.LogError (ex.ToString ()); - } - } - - void OnExtensionChanged (object s, ExtensionNodeEventArgs args) - { - if (args.Change == ExtensionChange.Add) { - WorkbenchContextCodon codon = (WorkbenchContextCodon) args.ExtensionNode; - List<PadCodon> collection = new List<PadCodon> (); - WorkbenchContext ctx = WorkbenchContext.GetContext (codon.Id); - padCollections [ctx] = collection; - - foreach (ContextPadCodon padCodon in codon.Pads) { - PadCodon pad = workbench.GetPad (padCodon.Id); - if (pad != null) - collection.Add (pad); - } - } - else { - WorkbenchContextCodon codon = (WorkbenchContextCodon) args.ExtensionNode; - WorkbenchContext ctx = WorkbenchContext.GetContext (codon.Id); - padCollections.Remove (ctx); - } - } - - public void Detach() - { - workbench.ContextChanged -= contextChangedHandler; - - dock.SaveLayouts (configFile); - UninstallMenuBar (); - wbWindow.Remove(rootWidget); - activePadCollection = null; - } - - public void CreatePadContent (bool force, PadCodon padCodon, PadWindow window, DockItem item) - { - if (force || item.Content == null) { - IPadContent newContent = padCodon.InitializePadContent (window); - - Gtk.Widget pcontent; - if (newContent is Widget) { - pcontent = newContent.Control; - } else { - PadCommandRouterContainer crc = new PadCommandRouterContainer (window, newContent.Control, newContent, true); - crc.Show (); - pcontent = crc; - } - - PadCommandRouterContainer router = new PadCommandRouterContainer (window, pcontent, toolbarFrame, false); - router.Show (); - item.Content = router; - } - } - - void AddPad (PadCodon padCodon, string placement, DockItemStatus defaultStatus) - { - PadWindow window = new PadWindow (this, padCodon); - window.Icon = "md-output-icon"; - padWindows [padCodon] = window; - padCodons [window] = padCodon; - - window.StatusChanged += new EventHandler (UpdatePad); - - string location = ""; - foreach (string s in placement.Split (' ')) { - if (string.IsNullOrEmpty (s)) - continue; - if (location.Length > 0) - location += ";"; - if (s.IndexOf ('/') == -1) - location += "__" + s.ToLower () + "/CenterBefore"; - else - location += s; - } - - string windowTitle = GettextCatalog.GetString (padCodon.Label); - DockItem item = dock.AddItem (padCodon.PadId); - item.Label = windowTitle; - item.Icon = ImageService.GetPixbuf (window.Icon, IconSize.Menu); - item.DefaultLocation = location; - item.DefaultVisible = false; - item.DefaultStatus = defaultStatus; - item.DockLabelProvider = padCodon; - window.Item = item; - - if (padCodon.Initialized) { - CreatePadContent (true, padCodon, window, item); - } else { - item.ContentRequired += delegate { - CreatePadContent (false, padCodon, window, item); - }; - } - - item.VisibleChanged += delegate { - if (item.Visible) - window.NotifyShown (); - else - window.NotifyHidden (); - }; - - item.ContentVisibleChanged += delegate { - if (item.ContentVisible) - window.NotifyContentShown (); - else - window.NotifyContentHidden (); - }; - - if (!activePadCollection.Contains (padCodon)) - activePadCollection.Add (padCodon); - } - - void UpdatePad (object source, EventArgs args) - { - IPadWindow window = (IPadWindow) source; - if (!padCodons.ContainsKey (window)) - return; - PadCodon codon = padCodons [window]; - DockItem item = GetDockItem (codon); - if (item != null) { - string windowTitle = GettextCatalog.GetString (window.Title); - if (String.IsNullOrEmpty (windowTitle)) - windowTitle = GettextCatalog.GetString (codon.Label); - if (window.IsWorking) - windowTitle = "<span foreground='blue'>" + windowTitle + "</span>"; - else if (window.HasErrors && !window.ContentVisible) - windowTitle = "<span foreground='red'>" + windowTitle + "</span>"; - else if (window.HasNewData && !window.ContentVisible) - windowTitle = "<b>" + windowTitle + "</b>"; - item.Label = windowTitle; - item.Icon = ImageService.GetPixbuf (window.Icon, IconSize.Menu); - } - } - - public void ShowPad (PadCodon content) - { - DockItem item = GetDockItem (content); - if (item != null) - item.Visible = true; - else - AddPad (content, content.DefaultPlacement, content.DefaultStatus); - } - - public void AddPad (PadCodon content) - { - DockItem item = GetDockItem (content); - if (item == null) - AddPad (content, content.DefaultPlacement, content.DefaultStatus); - } - - public void RemovePad (PadCodon content) - { - PadWindow win = (PadWindow) padWindows [content]; - win.NotifyDestroyed (); - - DockItem item = GetDockItem (content); - if (item != null) - dock.RemoveItem (item); - padWindows.Remove (content); - padCodons.Remove (win); - - foreach (List<PadCodon> pads in padCollections.Values) - pads.Remove (content); - - Counters.PadsLoaded--; - } - - public bool IsVisible (PadCodon padContent) - { - DockItem item = GetDockItem (padContent); - if (item != null) - return item.Visible; - return false; - } - - public bool IsContentVisible (PadCodon padContent) - { - DockItem item = GetDockItem (padContent); - if (item != null) - return item.ContentVisible; - return false; - } - - public void HidePad (PadCodon padContent) - { - DockItem item = GetDockItem (padContent); - if (item != null) - item.Visible = false; - } - - public void ActivatePad (PadCodon padContent, bool giveFocus) - { - DockItem item = GetDockItem (padContent); - if (item != null) - item.Present (giveFocus); - } - - public bool IsSticky (PadCodon padContent) - { - DockItem item = GetDockItem (padContent); - return item != null && (item.Behavior & DockItemBehavior.Sticky) != 0; - } - - public void SetSticky (PadCodon padContent, bool sticky) - { - DockItem item = GetDockItem (padContent); - if (item != null) { - if (sticky) - item.Behavior |= DockItemBehavior.Sticky; - else - item.Behavior &= ~DockItemBehavior.Sticky; - } - } - - public void RedrawAllComponents() - { - // If the toolbar or menubar has changed, replace it in the layout - - DefaultWorkbench wb = (DefaultWorkbench) workbench; - if (wb.ToolBars != toolBars) { - string cl = toolbarFrame.CurrentLayout; - DockToolbarFrameStatus mem = toolbarFrame.GetStatus (); - toolBars = wb.ToolBars; - toolbarFrame.ClearToolbars (); - if (toolBars != null) { - foreach (DockToolbar tb in toolBars) { - tb.ShowAll (); - toolbarFrame.AddBar (tb); - } - } - toolbarFrame.SetStatus (mem); - toolbarFrame.CurrentLayout = cl; - } - - InstallMenuBar (); - } - - void InstallMenuBar () - { - DefaultWorkbench wb = (DefaultWorkbench) workbench; - - if (wb.TopMenu == menubar) - return; - - if (menubar != null) - rootWidget.Remove (menubar); - - if (wb.TopMenu != null) { - ((VBox)rootWidget).PackStart (wb.TopMenu, false, false, 0); - ((Gtk.Box.BoxChild) rootWidget [wb.TopMenu]).Position = 0; - wb.TopMenu.ShowAll (); - } - - menubar = wb.TopMenu; - } - - void UninstallMenuBar () - { - if (menubar == null) - return; - - rootWidget.Remove(((DefaultWorkbench)workbench).TopMenu); - menubar = null; - } - - public IPadWindow GetPadWindow (PadCodon content) - { - IPadWindow w; - padWindows.TryGetValue (content, out w); - return w; - } - - bool SelectLastActiveWindow (IWorkbenchWindow cur) - { - if (lastActiveWindows.Count == 0) - return false; - IWorkbenchWindow last = null; - do { - last = lastActiveWindows.Last.Value; - lastActiveWindows.RemoveLast (); - } while (lastActiveWindows.Count > 0 && (last == cur || last == null || (last != null && last.ViewContent == null))); - if (last != null) { - last.SelectWindow (); - return true; - } - return false; - } - - public void CloseWindowEvent (object sender, WorkbenchWindowEventArgs e) - { - SdiWorkspaceWindow f = (SdiWorkspaceWindow) sender; - - // Unsubscribe events to avoid memory leaks - f.TabLabel.CloseClicked -= new EventHandler (closeClicked); - - if (f.ViewContent != null) { - ((DefaultWorkbench)wbWindow).CloseContent (f.ViewContent); - if (e.WasActive && !SelectLastActiveWindow (f)) - ActiveMdiChanged(this, null); - } - lastActiveWindows.Remove (f); - } - - public IWorkbenchWindow ShowView (IViewContent content) - { - Gtk.Image mimeimage = null; - - if (content.StockIconId != null ) { - mimeimage = new Gtk.Image ((IconId) content.StockIconId, IconSize.Menu ); - } - else if (content.IsUntitled && content.UntitledName == null) { - mimeimage = new Gtk.Image (DesktopService.GetPixbufForType ("gnome-fs-regular", Gtk.IconSize.Menu)); - } else { - mimeimage = new Gtk.Image (DesktopService.GetPixbufForFile (content.ContentName ?? content.UntitledName, Gtk.IconSize.Menu)); - } - - TabLabel tabLabel = new TabLabel (new Label (), mimeimage != null ? mimeimage : new Gtk.Image ("")); - tabLabel.CloseClicked += new EventHandler (closeClicked); - tabLabel.ClearFlag (WidgetFlags.CanFocus); - SdiWorkspaceWindow sdiWorkspaceWindow = new SdiWorkspaceWindow (workbench, content, tabControl, tabLabel); - sdiWorkspaceWindow.TitleChanged += delegate { SetWorkbenchTitle (); }; - sdiWorkspaceWindow.Closed += CloseWindowEvent; - tabControl.InsertPage (sdiWorkspaceWindow, tabLabel, -1); - tabLabel.Show (); - return sdiWorkspaceWindow; - } - - void closeClicked (object o, EventArgs e) - { - Widget tabLabel = ((Widget)o); - foreach (Widget child in tabControl.Children) { - if (tabControl.GetTabLabel (child) == tabLabel) { - int pageNum = tabControl.PageNum (child); - ((SdiWorkspaceWindow)child).CloseWindow (false, false, pageNum); - break; - } - } - } - - public void RemoveTab (int pageNum) { - try { - // Weird switch page events are fired when a tab is removed. - // This flag avoids unneeded events. - ignorePageSwitch = true; - IWorkbenchWindow w = ActiveWorkbenchwindow; - tabControl.RemovePage (pageNum); - ignorePageSwitch = false; - if (w != ActiveWorkbenchwindow) - ActiveMdiChanged (null, null); - } finally { - ignorePageSwitch = false; - } - } - - /// <summary> - /// Moves to the next tab. - /// </summary> - public void NextTab() - { - this.tabControl.NextPage (); - } - - /// <summary> - /// Moves to the previous tab. - /// </summary> - public void PreviousTab() - { - this.tabControl.PrevPage (); - } - - public void ActiveMdiChanged (object sender, SwitchPageArgs e) - { - if (ignorePageSwitch) - return; - - if (lastActive == ActiveWorkbenchwindow) - return; - - if (lastActiveWindows.Count > MAX_LASTACTIVEWINDOWS) - lastActiveWindows.RemoveFirst (); - lastActiveWindows.AddLast (lastActive); - lastActive = ActiveWorkbenchwindow; - SetWorkbenchTitle (); - if (ActiveWorkbenchWindowChanged != null) { - ActiveWorkbenchWindowChanged(this, e); - } - } - - public void SetWorkbenchTitle () - { - try { - IWorkbenchWindow window = ActiveWorkbenchwindow; - if (window != null) { - if (window.ViewContent.IsUntitled) { - SetDefaultTitle (); - } else { - string post = String.Empty; - if (window.ViewContent.IsDirty) { - post = "*"; - } - if (window.ViewContent.Project != null) { - ((Gtk.Window)workbench).Title = window.ViewContent.Project.Name + " - " + window.ViewContent.PathRelativeToProject + post + " - MonoDevelop"; - } else { - ((Gtk.Window)workbench).Title = window.ViewContent.ContentName + post + " - MonoDevelop"; - } - } - } else { - SetDefaultTitle (); - if (isInFullViewMode) - this.ToggleFullViewMode (); - } - } catch (Exception) { - SetDefaultTitle (); - } - } - - void SetDefaultTitle () - { - if (IdeApp.ProjectOperations.CurrentSelectedProject != null) { - ((Gtk.Window)workbench).Title = IdeApp.ProjectOperations.CurrentSelectedProject.Name + " - MonoDevelop"; - } else { - ((Gtk.Window)workbench).Title = "MonoDevelop"; - } - } - public event EventHandler ActiveWorkbenchWindowChanged; - - - internal class SdiWorkbenchLayoutMemento - { - Properties properties = new Properties (); - - public DockToolbarFrameStatus Status { - get { - return properties.Get ("status", new DockToolbarFrameStatus ()); - } - set { - properties.Set ("status", value); - } - } - - public Properties ToProperties () - { - return properties; - } - - public SdiWorkbenchLayoutMemento (Properties properties) - { - this.properties = properties; - } - public SdiWorkbenchLayoutMemento (DockToolbarFrameStatus status) - { - Status = status; - } - } - } - - class PadCommandRouterContainer: CommandRouterContainer - { - public PadCommandRouterContainer (PadWindow window, Gtk.Widget child, object target, bool continueToParent): base (child, target, continueToParent) - { - } - } - - // The SdiDragNotebook class allows redirecting the command route to the ViewCommandHandler - // object of the selected document, which implement some default commands. - - class SdiDragNotebook: DragNotebook, ICommandDelegatorRouter - { - ShadedContainer shadedContainer; - - public SdiDragNotebook (ShadedContainer shadedContainer) - { - this.shadedContainer = shadedContainer; - shadedContainer.Add (this); - } - - public object GetNextCommandTarget () - { - return Parent; - } - - public object GetDelegatedCommandTarget () - { - SdiWorkspaceWindow win = (SdiWorkspaceWindow) CurrentPageWidget; - return win != null ? win.CommandHandler : null; - } - - protected override bool OnExposeEvent (Gdk.EventExpose evnt) - { - shadedContainer.DrawBackground (this); - return base.OnExposeEvent (evnt); - } - - } -} diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs index 1d34970b5b..8e6ffe0387 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs @@ -254,7 +254,7 @@ namespace MonoDevelop.Ide.Gui myUntitledTitle = baseName + System.IO.Path.GetExtension (content.UntitledName); while (found) { found = false; - foreach (IViewContent windowContent in workbench.ViewContentCollection) { + foreach (IViewContent windowContent in workbench.InternalViewContentCollection) { string title = windowContent.WorkbenchWindow.Title; if (title.EndsWith("*") || title.EndsWith("+")) { title = title.Substring(0, title.Length - 1); @@ -296,16 +296,16 @@ namespace MonoDevelop.Ide.Gui public bool CloseWindow (bool force, bool fromMenu, int pageNum) { - bool wasActive = workbench.WorkbenchLayout.ActiveWorkbenchwindow == this; + bool wasActive = workbench.ActiveWorkbenchWindow == this; WorkbenchWindowEventArgs args = new WorkbenchWindowEventArgs (force, wasActive); args.Cancel = false; OnClosing (args); if (args.Cancel) return false; if (fromMenu == true) { - workbench.WorkbenchLayout.RemoveTab (tabControl.PageNum(this)); + workbench.RemoveTab (tabControl.PageNum(this)); } else { - workbench.WorkbenchLayout.RemoveTab (pageNum); + workbench.RemoveTab (pageNum); } content.ContentNameChanged -= new EventHandler(SetTitleEvent); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusProgressMonitor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusProgressMonitor.cs index 78acc52022..83b7ffd3d0 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusProgressMonitor.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusProgressMonitor.cs @@ -40,8 +40,7 @@ namespace MonoDevelop.Ide.Gui bool showTaskTitles; bool lockGui; string title; - - static List<StatusProgressMonitor> monitorQueue = new List<StatusProgressMonitor> (); + StatusBarContext statusBar; public StatusProgressMonitor (string title, string iconName, bool showErrorDialogs, bool showTaskTitles, bool lockGui) { @@ -50,34 +49,31 @@ namespace MonoDevelop.Ide.Gui this.showTaskTitles = showTaskTitles; this.title = title; icon = ImageService.GetImage (iconName, Gtk.IconSize.Menu); - IdeApp.Workbench.StatusBar.BeginProgress (title); - IdeApp.Workbench.StatusBar.ShowMessage (icon, title); + statusBar = IdeApp.Workbench.StatusBar.CreateContext (); + statusBar.BeginProgress (icon, title); if (lockGui) IdeApp.Workbench.LockGui (); - monitorQueue.Add (this); } protected override void OnProgressChanged () { - if (monitorQueue [monitorQueue.Count - 1] != this) - return; if (showTaskTitles) - IdeApp.Workbench.StatusBar.ShowMessage (icon, CurrentTask); + statusBar.ShowMessage (icon, CurrentTask); if (!UnknownWork) - IdeApp.Workbench.StatusBar.SetProgressFraction (GlobalWork); + statusBar.SetProgressFraction (GlobalWork); DispatchService.RunPendingEvents (); } public void UpdateStatusBar () { if (showTaskTitles) - IdeApp.Workbench.StatusBar.ShowMessage (icon, CurrentTask); + statusBar.ShowMessage (icon, CurrentTask); else - IdeApp.Workbench.StatusBar.ShowMessage (icon, title); + statusBar.ShowMessage (icon, title); if (!UnknownWork) - IdeApp.Workbench.StatusBar.SetProgressFraction (GlobalWork); + statusBar.SetProgressFraction (GlobalWork); else - IdeApp.Workbench.StatusBar.SetProgressFraction (0); + statusBar.SetProgressFraction (0); } protected override void OnCompleted () @@ -85,25 +81,15 @@ namespace MonoDevelop.Ide.Gui if (lockGui) IdeApp.Workbench.UnlockGui (); - int i = monitorQueue.IndexOf (this); - bool uniqueMonitor = monitorQueue.Count == 1; - - if (uniqueMonitor) - IdeApp.Workbench.StatusBar.EndProgress (); - else if (i == monitorQueue.Count - 1) - monitorQueue [i - 1].UpdateStatusBar (); - - monitorQueue.RemoveAt (i); + statusBar.Dispose (); if (Errors.Count > 0 || Warnings.Count > 0) { - if (uniqueMonitor) { - if (Errors.Count > 0) { - Gtk.Image img = ImageService.GetImage (Stock.Error, Gtk.IconSize.Menu); - IdeApp.Workbench.StatusBar.ShowMessage (img, Errors [Errors.Count - 1]); - } else if (SuccessMessages.Count == 0) { - Gtk.Image img = ImageService.GetImage (Stock.Warning, Gtk.IconSize.Menu); - IdeApp.Workbench.StatusBar.ShowMessage (img, Warnings [Warnings.Count - 1]); - } + if (Errors.Count > 0) { + Gtk.Image img = ImageService.GetImage (Stock.Error, Gtk.IconSize.Menu); + IdeApp.Workbench.StatusBar.ShowMessage (img, Errors [Errors.Count - 1]); + } else if (SuccessMessages.Count == 0) { + Gtk.Image img = ImageService.GetImage (Stock.Warning, Gtk.IconSize.Menu); + IdeApp.Workbench.StatusBar.ShowMessage (img, Warnings [Warnings.Count - 1]); } base.OnCompleted (); @@ -120,13 +106,9 @@ namespace MonoDevelop.Ide.Gui } return; } - - if (uniqueMonitor) { - if (SuccessMessages.Count > 0) - IdeApp.Workbench.StatusBar.ShowMessage (SuccessMessages [SuccessMessages.Count - 1]); - else - IdeApp.Workbench.StatusBar.ShowReady (); - } + + if (SuccessMessages.Count > 0) + IdeApp.Workbench.StatusBar.ShowMessage (SuccessMessages [SuccessMessages.Count - 1]); base.OnCompleted (); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs index 977aeaba29..74a02eecb1 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs @@ -77,12 +77,11 @@ namespace MonoDevelop.Ide.Gui monitor.Step (1); Counters.Initialization.Trace ("Initializing Layout"); - workbench.InitializeLayout (new SdiWorkbenchLayout ()); + workbench.InitializeLayout (); monitor.Step (1); ((Gtk.Window)workbench).Visible = false; workbench.ActiveWorkbenchWindowChanged += new EventHandler (OnDocumentChanged); - PropertyService.PropertyChanged += new EventHandler<PropertyChangedEventArgs> (TrackPropertyChanges); FileService.FileRemoved += (EventHandler<FileEventArgs>) DispatchService.GuiDispatch (new EventHandler<FileEventArgs> (IdeApp.Workbench.RecentOpen.InformFileRemoved)); FileService.FileRenamed += (EventHandler<FileCopyEventArgs>) DispatchService.GuiDispatch (new EventHandler<FileCopyEventArgs> (IdeApp.Workbench.RecentOpen.InformFileRenamed)); IdeApp.Workspace.StoringUserPreferences += OnStoringWorkspaceUserPreferences; @@ -102,21 +101,6 @@ namespace MonoDevelop.Ide.Gui } } - /// <remarks> - /// This method handles the redraw all event for specific changed IDE properties - /// </remarks> - void TrackPropertyChanges(object sender, MonoDevelop.Core.PropertyChangedEventArgs e) - { - if (e.OldValue != e.NewValue) { - switch (e.Key) { - case "MonoDevelop.Core.Gui.VisualStyle": - case "CoreProperties.UILanguage": - workbench.RedrawAllComponents(); - break; - } - } - } - internal void Show (string workbenchMemento) { Counters.Initialization.Trace ("Realizing Root Window"); @@ -127,7 +111,6 @@ namespace MonoDevelop.Ide.Gui workbench.Memento = memento; Counters.Initialization.Trace ("Making Visible"); RootWindow.Visible = true; - workbench.Context = WorkbenchContext.Edit; // now we have an layout set notify it Counters.Initialization.Trace ("Setting layout"); @@ -159,7 +142,7 @@ namespace MonoDevelop.Ide.Gui public Document ActiveDocument { get { - if (workbench == null || workbench.ActiveWorkbenchWindow == null) + if (workbench.ActiveWorkbenchWindow == null) return null; return WrapDocument (workbench.ActiveWorkbenchWindow); } @@ -178,7 +161,7 @@ namespace MonoDevelop.Ide.Gui get { if (pads == null) { pads = new List<Pad> (); - foreach (PadCodon pc in workbench.ActivePadContentCollection) + foreach (PadCodon pc in workbench.PadContentCollection) WrapPad (pc); } return pads; @@ -212,28 +195,17 @@ namespace MonoDevelop.Ide.Gui if (!PropertyService.IsMac) RootWindow.Present (); } - - public WorkbenchContext Context { - get { return workbench.Context; } - set { - if (workbench.Context != value) { - workbench.Context = value; - pads = null; - } - } - } - + public bool FullScreen { get { return workbench.FullScreen; } set { workbench.FullScreen = value; } } public string CurrentLayout { - get { return workbench != null && workbench.WorkbenchLayout != null ? workbench.WorkbenchLayout.CurrentLayout : ""; } + get { return workbench.CurrentLayout; } set { - if (value != workbench.WorkbenchLayout.CurrentLayout) - { - workbench.WorkbenchLayout.CurrentLayout = value; + if (value != workbench.CurrentLayout) { + workbench.CurrentLayout = value; if (LayoutChanged != null) LayoutChanged (this, EventArgs.Empty); } @@ -241,16 +213,16 @@ namespace MonoDevelop.Ide.Gui } public string[] Layouts { - get { return workbench.WorkbenchLayout != null ? workbench.WorkbenchLayout.Layouts : new string[0]; } + get { return workbench.Layouts; } } public ProgressMonitorManager ProgressMonitors { get { return monitors; } } - public MonoDevelopStatusBar StatusBar { + public StatusBar StatusBar { get { - return workbench.StatusBar; + return workbench.StatusBar.MainContext; } } @@ -264,7 +236,7 @@ namespace MonoDevelop.Ide.Gui public void DeleteLayout (string name) { - workbench.WorkbenchLayout.DeleteLayout (name); + workbench.DeleteLayout (name); if (LayoutChanged != null) LayoutChanged (this, EventArgs.Empty); } @@ -464,9 +436,7 @@ namespace MonoDevelop.Ide.Gui public void ToggleMaximize () { - SdiWorkbenchLayout sdiLayout = this.workbench.WorkbenchLayout as SdiWorkbenchLayout; - if (sdiLayout != null) - sdiLayout.ToggleFullViewMode (); + workbench.ToggleFullViewMode (); } public Document NewDocument (string defaultName, string mimeType, string content) @@ -873,7 +843,7 @@ namespace MonoDevelop.Ide.Gui internal void ReorderDocuments (int oldPlacement, int newPlacement) { - IViewContent content = workbench.ViewContentCollection[oldPlacement]; + IViewContent content = workbench.InternalViewContentCollection[oldPlacement]; workbench.InternalViewContentCollection.RemoveAt (oldPlacement); workbench.InternalViewContentCollection.Insert (newPlacement, content); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/WorkbenchMemento.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/WorkbenchMemento.cs index ce34d78088..30841c09a5 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/WorkbenchMemento.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/WorkbenchMemento.cs @@ -34,6 +34,7 @@ using System.Xml; using MonoDevelop.Core; using MonoDevelop.Core.Serialization; +using MonoDevelop.Components.DockToolbars; namespace MonoDevelop.Ide.Gui { @@ -86,6 +87,15 @@ namespace MonoDevelop.Ide.Gui } } + public DockToolbarFrameStatus ToolbarStatus { + get { + return properties.Get ("toolbarStatus", new DockToolbarFrameStatus ()); + } + set { + properties.Set ("toolbarStatus", value); + } + } + /// <summary> /// Creates a new instance of the <code>MdiWorkspaceMemento</code>. /// </summary> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/TaskStore.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/TaskStore.cs index 1ddd89a75d..285707b0cf 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/TaskStore.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/TaskStore.cs @@ -398,7 +398,7 @@ namespace MonoDevelop.Ide.Tasks return new TextFileNavigationPoint (currentLocationTask.FileName, currentLocationTask.Line, currentLocationTask.Column); } else { - IdeApp.Workbench.StatusBar.ShowReady (); + IdeApp.Workbench.StatusBar.ShowMessage (GettextCatalog.GetString ("End of list")); return null; } } @@ -444,7 +444,7 @@ namespace MonoDevelop.Ide.Tasks return new TextFileNavigationPoint (currentLocationTask.FileName, currentLocationTask.Line, currentLocationTask.Column); } else { - IdeApp.Workbench.StatusBar.ShowReady (); + IdeApp.Workbench.StatusBar.ShowMessage (GettextCatalog.GetString ("End of list")); return null; } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml index bfd951a283..0ac7b8753e 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml @@ -23,7 +23,6 @@ <ConditionType id="combineopen" type="MonoDevelop.Ide.Codons.CombineOpenCondition" /> <ConditionType id="activeproject" type="MonoDevelop.Ide.Codons.ProjectActiveCondition" /> <ConditionType id="activelanguage" type="MonoDevelop.Ide.Codons.LanguageActiveCondition" /> - <ConditionType id="activecontext" type="MonoDevelop.Ide.Codons.WorkbenchContextCondition" /> <ExtensionNodeSet id="MonoDevelop.Ide.OptionsDialogSection"> <ExtensionNode name="Section" type="MonoDevelop.Ide.Extensions.OptionsDialogSection" /> @@ -282,6 +281,11 @@ <ExtensionNode name="Resolver" type="MonoDevelop.Ide.Gui.Content.TextEditorResolverProviderCodon"/> </ExtensionPoint> + <ExtensionPoint path = "/MonoDevelop/Ide/WorkbenchLayouts" name = "Workbench Layouts"> + <Description>This extension point allows registering layouts and pads to be shown in each layout</Description> + <ExtensionNode name="Layout" type="MonoDevelop.Ide.Extensions.LayoutExtensionNode"/> + </ExtensionPoint> + <ExtensionPoint path = "/MonoDevelop/Ide/CustomTools" name = "Custom code generation tools"> <Description>Extensions to the text editor. Classes must be a subclass of TextEditorExtension.</Description> <ExtensionNode name="Tool" type="MonoDevelop.Ide.Extensions.CustomToolExtensionNode"/> @@ -289,7 +293,6 @@ <!-- Extensions --> - <Extension path = "/MonoDevelop/Core/Applications"> <Application id = "gsetup" description = "Graphical add-in setup utility" @@ -1676,12 +1679,38 @@ </Extension> <Extension path = "/MonoDevelop/Ide/Pads"> - <Pad id = "MonoDevelop.Ide.Gui.Pads.FileScout" _label = "Files" icon="system-file-manager" class = "MonoDevelop.Ide.Gui.Pads.FileScout"/> - <Pad id = "MonoDevelop.Ide.Gui.Pads.ErrorListPad" defaultPlacement = "Bottom" defaultStatus="AutoHide" _label = "Error List" icon="gtk-dialog-error" class = "MonoDevelop.Ide.Gui.Pads.ErrorListPad" dockLabelProvider="MonoDevelop.Ide.Gui.Pads.ErrorPadLabelProvider"/> - <Pad id = "MonoDevelop.Ide.Gui.Pads.TaskListPad" defaultPlacement = "Bottom" _label = "Task List" icon="md-task-list-icon" class = "MonoDevelop.Ide.Gui.Pads.TaskListPad"/> - <Pad id = "MonoDevelop.Ide.Gui.Pads.HelpTree" defaultPlacement = "Left" _label = "Help" icon="gtk-help" class = "MonoDevelop.Ide.Gui.Pads.HelpTree"/> + <Pad id = "MonoDevelop.Ide.Gui.Pads.FileScout" + _label = "Files" + icon="system-file-manager" + class = "MonoDevelop.Ide.Gui.Pads.FileScout" + defaultPlacement="Left" + defaultStatus="AutoHide" + defaultLayout="*" /> + + <Pad id = "MonoDevelop.Ide.Gui.Pads.ErrorListPad" + _label = "Error List" + icon="gtk-dialog-error" + class = "MonoDevelop.Ide.Gui.Pads.ErrorListPad" + dockLabelProvider="MonoDevelop.Ide.Gui.Pads.ErrorPadLabelProvider" + defaultPlacement = "Bottom" + defaultStatus="AutoHide" + defaultLayout="*"/> + + <Pad id = "MonoDevelop.Ide.Gui.Pads.TaskListPad" + _label = "Task List" + icon="md-task-list-icon" + class = "MonoDevelop.Ide.Gui.Pads.TaskListPad" + defaultPlacement = "Bottom" + defaultStatus="AutoHide" + defaultLayout="*"/> + + <Pad id = "MonoDevelop.Ide.Gui.Pads.HelpTree" + defaultPlacement = "Left" + _label = "Help" + icon="gtk-help" + class = "MonoDevelop.Ide.Gui.Pads.HelpTree"/> - <SolutionPad id = "ProjectPad" defaultPlacement = "Left" _label = "Solution" icon = "md-solution" class = "MonoDevelop.Ide.Gui.Pads.ProjectPad.ProjectSolutionPad"> + <SolutionPad id = "ProjectPad" _label = "Solution" icon = "md-solution" class = "MonoDevelop.Ide.Gui.Pads.ProjectPad.ProjectSolutionPad" defaultLayout="*" defaultPlacement = "Left"> <ContextMenu path="/MonoDevelop/Ide/ContextMenu/ProjectPad" /> <PadOption id = "ShowAllFiles" _label = "Show All Files" defaultValue = "False" /> <NodeBuilder class = "MonoDevelop.Ide.Gui.Pads.ProjectPad.WorkspaceNodeBuilder"/> @@ -1698,7 +1727,7 @@ <NodeBuilder class = "MonoDevelop.Ide.Gui.Pads.ProjectPad.UnknownEntryNodeBuilder"/> </SolutionPad> - <SolutionPad id = "ClassPad" defaultPlacement = "Left" _label = "Classes" icon = "md-class" class = "MonoDevelop.Ide.Gui.Pads.ClassBrowser.ClassBrowserPad"> + <SolutionPad id = "ClassPad" _label = "Classes" icon = "md-class" class = "MonoDevelop.Ide.Gui.Pads.ClassBrowser.ClassBrowserPad" defaultLayout="Solution" defaultPlacement = "Left" defaultStatus="AutoHide"> <PadOption id = "NestedNamespaces" _label = "Nested namespaces" defaultValue = "True" /> <PadOption id = "ShowProjects" _label = "Show project structure" defaultValue = "True" /> <PadOption id = "GroupByAccess" _label = "Group members by access" defaultValue = "False" /> @@ -1724,25 +1753,11 @@ </Category> </Extension> - <Extension path = "/MonoDevelop/Ide/WorkbenchContexts"> - <WorkbenchContext id = "Edit"> - <ContextPad id = "ProjectPad" /> - <ContextPad id = "ClassPad" /> - <ContextPad id = "MonoDevelop.Ide.Gui.Pads.FileScout" /> - <ContextPad id = "MonoDevelop.Ide.Gui.Pads.HelpTree" /> - <ContextPad id = "MonoDevelop.Ide.Gui.Pads.ErrorListPad"/> - <ContextPad id = "MonoDevelop.Ide.Gui.Pads.InternalLogPad"/> - <ContextPad id = "MonoDevelop.Ide.Gui.Pads.TaskListPad"/> - </WorkbenchContext> - <WorkbenchContext id = "Debug"> - <ContextPad id = "ProjectPad"/> - <ContextPad id = "ClassPad" defaultVisible = "False"/> - <ContextPad id = "MonoDevelop.Ide.Gui.Pads.FileScout" defaultVisible = "False"/> - <ContextPad id = "MonoDevelop.Ide.Gui.Pads.HelpTree" defaultVisible = "False"/> - <ContextPad id = "MonoDevelop.Ide.Gui.Pads.ErrorListPad"/> - <ContextPad id = "MonoDevelop.Ide.Gui.Pads.InternalLogPad"/> - <ContextPad id = "MonoDevelop.Ide.Gui.Pads.TaskListPad" defaultVisible = "False"/> - </WorkbenchContext> + <Extension path="/MonoDevelop/Ide/WorkbenchLayouts"> + <Layout id="Default" _name="Default"> + <LayoutPad id="ProjectPad" status="AutoHide" /> + </Layout> + <Layout id="Solution" _name="Solution" /> </Extension> <Extension path = "/MonoDevelop/Ide/GlobalOptionsDialog"> @@ -1981,19 +1996,18 @@ </ItemSet> <ItemSet id = "View" _label = "_View"> + <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.LayoutList" /> + <SeparatorItem id = "ViewSeparator1" /> + <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.NewLayout" /> + <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.DeleteCurrentLayout" /> + <SeparatorItem id = "ViewSeparator2" /> + <ItemSet id = "ViewPads" _label = "Pads"> + <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.ViewList" /> + </ItemSet> <ItemSet id = "ViewToolbars" _label = "Toolbars"> <CommandItem id = "MonoDevelop.Components.Commands.CommandSystemCommands.ToolbarList" /> </ItemSet> - <SeparatorItem id = "ViewItemsSeparator0" /> - <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.ViewList" /> <SeparatorItem id = "ViewItemsSeparator" /> - <ItemSet id = "ViewLayouts" _label = "_Layouts"> - <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.LayoutList" /> - <SeparatorItem id = "ViewItemsSeparator" /> - <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.NewLayout" /> - <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.DeleteCurrentLayout" /> - </ItemSet> - <SeparatorItem id = "ViewItemsSeparator2" /> <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.ZoomIn" /> <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.ZoomOut" /> <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.ZoomReset" /> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj index 8ae2f84b0f..53a22b9e12 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj @@ -748,7 +748,6 @@ <Compile Include="MonoDevelop.Ide.Codons\CombineOpenCondition.cs" /> <Compile Include="MonoDevelop.Ide.Codons\LanguageActiveCondition.cs" /> <Compile Include="MonoDevelop.Ide.Codons\ProjectActiveCondition.cs" /> - <Compile Include="MonoDevelop.Ide.Codons\WorkbenchContextCondition.cs" /> <Compile Include="MonoDevelop.Ide.ExternalTools\ExternalTool.cs" /> <Compile Include="MonoDevelop.Ide.CodeTemplates\CodeTemplate.cs" /> <Compile Include="MonoDevelop.Ide.CodeTemplates\CodeTemplateService.cs" /> @@ -807,7 +806,6 @@ <Compile Include="MonoDevelop.Ide.Gui.Pads\TreeViewPad.cs" /> <Compile Include="MonoDevelop.Ide.Gui\DefaultWorkbench.cs" /> <Compile Include="MonoDevelop.Ide.Gui\WorkbenchMemento.cs" /> - <Compile Include="MonoDevelop.Ide.Gui\SdiWorkspaceLayout.cs" /> <Compile Include="MonoDevelop.Ide.Gui\SdiWorkspaceWindow.cs" /> <Compile Include="MonoDevelop.Ide.Codons\DisplayBindingCodon.cs" /> <Compile Include="MonoDevelop.Ide.Codons\IDisplayBinding.cs" /> @@ -1018,6 +1016,7 @@ <Compile Include="MonoDevelop.Ide.Gui\DockItemToolbarLoader.cs" /> <Compile Include="MonoDevelop.Ide.Gui.Components\LogView.cs" /> <Compile Include="MonoDevelop.Ide.Gui\WorkbenchContext.cs" /> + <Compile Include="MonoDevelop.Ide.Extensions\LayoutExtensionNode.cs" /> <Compile Include="MonoDevelop.Ide.Extensions\CustomToolExtensionNode.cs" /> <Compile Include="MonoDevelop.Ide.CustomTools\CustomTool.cs" /> <Compile Include="MonoDevelop.Ide.CustomTools\CustomToolService.cs" /> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs index 2fcb1d2ceb..ec14dc1831 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs @@ -350,6 +350,8 @@ namespace MonoDevelop.Ide } } + static StatusBarContext menuDescriptionContext; + static void OnCommandSelected (object s, CommandSelectedEventArgs args) { string msg = args.CommandInfo.Description; @@ -361,13 +363,19 @@ namespace MonoDevelop.Ide idx = msg.Length; msg = msg.Substring (0, idx).Replace ("_", "") + msg.Substring (idx); } - if (!string.IsNullOrEmpty (msg)) - Workbench.StatusBar.ShowMessage (msg, args.CommandInfo.UseMarkup); + if (!string.IsNullOrEmpty (msg)) { + if (menuDescriptionContext == null) + menuDescriptionContext = Workbench.StatusBar.CreateContext (); + menuDescriptionContext.ShowMessage (msg, args.CommandInfo.UseMarkup); + } } static void OnCommandDeselected (object s, EventArgs args) { - Workbench.StatusBar.ShowReady (); + if (menuDescriptionContext != null) { + menuDescriptionContext.Dispose (); + menuDescriptionContext = null; + } } public static void Run () @@ -450,7 +458,7 @@ namespace MonoDevelop.Ide commandTimeCounter.End (); } - static MonoDevelop.Ide.MonoDevelopStatusBar.StatusIcon instrumentationStatusIcon; + static StatusBarIcon instrumentationStatusIcon; static void UpdateInstrumentationIcon () { if (IdeApp.Preferences.EnableInstrumentation) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ImageService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ImageService.cs index 2da8a0af1d..ff617e8c53 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ImageService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ImageService.cs @@ -112,6 +112,13 @@ namespace MonoDevelop.Ide return result; } + public static Gdk.Pixbuf MakeGrayscale (Gdk.Pixbuf icon) + { + Gdk.Pixbuf copy = icon.Copy (); + copy.SaturateAndPixelate (copy, 0, false); + return copy; + } + public static Gdk.Pixbuf GetPixbuf (string name) { return GetPixbuf (name, Gtk.IconSize.Button); diff --git a/main/src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Gui.OptionPanels.KeyBindingsPanel.cs b/main/src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Gui.OptionPanels.KeyBindingsPanel.cs index b89ec40516..a08b2e0c98 100644 --- a/main/src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Gui.OptionPanels.KeyBindingsPanel.cs +++ b/main/src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Gui.OptionPanels.KeyBindingsPanel.cs @@ -176,8 +176,8 @@ namespace MonoDevelop.Ide.Gui.OptionPanels this.conflicButton = new global::MonoDevelop.Components.MenuButton (); this.conflicButton.CanFocus = true; this.conflicButton.Name = "conflicButton"; - this.conflicButton.Label = "View Conflicts"; this.conflicButton.UseMarkup = false; + this.conflicButton.Label = "View Conflicts"; this.warningBox.Add (this.conflicButton); global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(this.warningBox[this.conflicButton])); w12.Position = 2; diff --git a/main/src/core/MonoDevelop.Ide/gtk-gui/objects.xml b/main/src/core/MonoDevelop.Ide/gtk-gui/objects.xml index 717fd3427f..8ad2071023 100644 --- a/main/src/core/MonoDevelop.Ide/gtk-gui/objects.xml +++ b/main/src/core/MonoDevelop.Ide/gtk-gui/objects.xml @@ -12,14 +12,6 @@ </itemgroups> <signals /> </object> - <object type="MonoDevelop.Ide.Projects.OptionPanels.BaseDirectoryPanelWidget" palette-category="MonoDevelop.Projects.Gui" allow-children="false" base-type="Gtk.Bin"> - <itemgroups> - <itemgroup label="BaseDirectoryPanelWidget Properties"> - <property name="BaseDirectory" /> - </itemgroup> - </itemgroups> - <signals /> - </object> <object type="MonoDevelop.Ide.FindInFiles.SearchResultWidget" palette-category="General" allow-children="false" base-type="Gtk.Bin"> <itemgroups> <itemgroup label="SearchResultWidget Properties"> @@ -167,4 +159,16 @@ </itemgroup> </signals> </object> + <object type="MonoDevelop.Ide.Projects.OptionPanels.BaseDirectoryPanelWidget" palette-category="MonoDevelop.Projects.Gui" allow-children="false" base-type="Gtk.Bin"> + <itemgroups> + <itemgroup label="BaseDirectoryPanelWidget Properties"> + <property name="BaseDirectory" /> + </itemgroup> + </itemgroups> + <signals /> + </object> + <object type="MonoDevelop.Ide.CodeFormatting.CodeFormattingPolicyPanelWidget" palette-category="General" allow-children="false" base-type="Gtk.Bin"> + <itemgroups /> + <signals /> + </object> </objects>
\ No newline at end of file |