diff options
author | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2015-02-14 01:38:05 +0300 |
---|---|---|
committer | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2015-02-14 01:57:48 +0300 |
commit | 0a13c957cb6565a916f6433d8d5bca8dc43ceb31 (patch) | |
tree | d76b8d19fbf5d662ad1167c8778b17f695a2c853 /main/src | |
parent | c0ee83571ab4143fc1589f52c6a307c953f22161 (diff) |
[Toolbar] Introduce MainToolbarController and IMainToolbarView.
Diffstat (limited to 'main/src')
9 files changed, 124 insertions, 11 deletions
diff --git a/main/src/addins/MacPlatform/MacPlatform.cs b/main/src/addins/MacPlatform/MacPlatform.cs index bd5a6e1479..a1982015b5 100644 --- a/main/src/addins/MacPlatform/MacPlatform.cs +++ b/main/src/addins/MacPlatform/MacPlatform.cs @@ -750,7 +750,7 @@ namespace MonoDevelop.MacIntegration w.HasShadow = false; } - internal override MainToolbar CreateMainToolbar (Gtk.Window window) + internal override IMainToolbarView CreateMainToolbar (Gtk.Window window) { NSWindow w = GtkQuartz.GetWindow (window); w.IsOpaque = false; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/IMainToolbarView.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/IMainToolbarView.cs new file mode 100644 index 0000000000..a54d11045f --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/IMainToolbarView.cs @@ -0,0 +1,43 @@ +// +// IMainToolbarView.cs +// +// Author: +// Marius Ungureanu <marius.ungureanu@xamarin.com> +// +// Copyright (c) 2015 Xamarin, Inc (http://www.xamarin.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 +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// 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 MonoDevelop.Ide; + +namespace MonoDevelop.Components.MainToolbar +{ + public interface IMainToolbarView + { + #region StatusBar + StatusBar StatusBar { get; } + #endregion + + #region CommandBar + void ShowCommandBar (string barId); + void HideCommandBar (string barId); + #endregion + } +} + diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbar.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbar.cs index 7aa6afe54e..18a224efb1 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbar.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbar.cs @@ -49,7 +49,7 @@ using System.Text; namespace MonoDevelop.Components.MainToolbar { - class MainToolbar: Gtk.EventBox, ICommandBar + class MainToolbar: Gtk.EventBox, ICommandBar, IMainToolbarView { const string ToolbarExtensionPath = "/MonoDevelop/Ide/CommandBar"; const string TargetsMenuPath = "/MonoDevelop/Ide/TargetSelectorCommands"; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs new file mode 100644 index 0000000000..b26a2ed4bc --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs @@ -0,0 +1,58 @@ +// +// MainToolbarController.cs +// +// Author: +// Marius Ungureanu <marius.ungureanu@xamarin.com> +// +// Copyright (c) 2015 Xamarin, Inc (http://www.xamarin.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 +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// 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 MonoDevelop.Ide; + +namespace MonoDevelop.Components.MainToolbar +{ + class MainToolbarController + { + internal IMainToolbarView ToolbarView { + get; + private set; + } + + internal StatusBar StatusBar { + get { return ToolbarView.StatusBar; } + } + + public MainToolbarController (IMainToolbarView toolbarView) + { + ToolbarView = toolbarView; + } + + public void ShowCommandBar (string barId) + { + ToolbarView.ShowCommandBar (barId); + } + + public void HideCommandBar (string barId) + { + ToolbarView.HideCommandBar (barId); + } + } +} + diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs index 9194e06694..b7aa9a8826 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs @@ -445,11 +445,18 @@ namespace MonoDevelop.Ide.Desktop { } - internal virtual MainToolbar CreateMainToolbar (Gtk.Window window) + internal virtual IMainToolbarView CreateMainToolbar (Gtk.Window window) { return new MainToolbar (); } + internal virtual void AttachMainToolbar (Gtk.VBox parent, IMainToolbarView toolbar) + { + var toolbarBox = new Gtk.HBox (); + parent.PackStart (toolbarBox, false, false, 0); + toolbarBox.PackStart ((MainToolbar)toolbar, true, true, 0); + } + public virtual bool GetIsFullscreen (Gtk.Window window) { return ((bool?) window.Data ["isFullScreen"]) ?? false; 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 ae143e90d9..b6ff23ea40 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs @@ -89,7 +89,7 @@ namespace MonoDevelop.Ide.Gui Gtk.MenuBar topMenu; Gtk.VBox fullViewVBox; DockItem documentDockItem; - MainToolbar toolbar; + MainToolbarController toolbar; MonoDevelopStatusBar bottomBar; #if DUMMY_STRINGS_FOR_TRANSLATION_DO_NOT_COMPILE @@ -108,7 +108,7 @@ namespace MonoDevelop.Ide.Gui } } - public MainToolbar Toolbar { + public MainToolbarController Toolbar { get { return toolbar; } @@ -786,8 +786,7 @@ namespace MonoDevelop.Ide.Gui Realize (); toolbar = DesktopService.CreateMainToolbar (this); DesktopService.SetMainWindowDecorations (this); - var toolbarBox = new HBox (); - fullViewVBox.PackStart (toolbarBox, false, false, 0); + DesktopService.AttachMainToolbar (fullViewVBox, toolbar); toolbarFrame = new CommandFrame (IdeApp.CommandService); fullViewVBox.PackStart (toolbarFrame, true, true, 0); @@ -828,7 +827,6 @@ namespace MonoDevelop.Ide.Gui bottomBar = new MonoDevelopStatusBar (); fullViewVBox.PackEnd (bottomBar, false, true, 0); bottomBar.ShowAll (); - toolbarBox.PackStart (this.toolbar, true, true, 0); // In order to get the correct bar height we need to calculate the tab size using the // correct style (the style of the window). At this point the widget is not yet a child 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 2dadadf773..83a13f11a1 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs @@ -264,7 +264,7 @@ namespace MonoDevelop.Ide.Gui workbench.Toolbar.HideCommandBar (barId); } - internal MonoDevelop.Components.MainToolbar.MainToolbar Toolbar { + internal MonoDevelop.Components.MainToolbar.MainToolbarController Toolbar { get { return workbench.Toolbar; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj index 49419b68f9..11a75899ed 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj @@ -3026,6 +3026,8 @@ <Compile Include="MonoDevelop.Components\EventBoxTooltip.cs" /> <Compile Include="MonoDevelop.Ide.Templates\ProjectTemplateCreateInformation.cs" /> <Compile Include="MonoDevelop.Ide.Execution\TargetedExecutionHandler.cs" /> + <Compile Include="MonoDevelop.Components.MainToolbar\IMainToolbarView.cs" /> + <Compile Include="MonoDevelop.Components.MainToolbar\MainToolbarController.cs" /> </ItemGroup> <ItemGroup> <None Include="Makefile.am" /> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs index fc85eedd82..c88b97d274 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs @@ -313,9 +313,14 @@ namespace MonoDevelop.Ide PlatformService.SetMainWindowDecorations (window); } - internal static MainToolbar CreateMainToolbar (Gtk.Window window) + internal static MainToolbarController CreateMainToolbar (Gtk.Window window) { - return PlatformService.CreateMainToolbar (window); + return new MainToolbarController (PlatformService.CreateMainToolbar (window)); + } + + internal static void AttachMainToolbar (Gtk.VBox parent, MainToolbarController toolbar) + { + PlatformService.AttachMainToolbar (parent, toolbar.ToolbarView); } public static bool GetIsFullscreen (Gtk.Window window) |