~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
using MonoDevelop.Components;
46
46
using MonoDevelop.Ide.Extensions;
47
47
using Mono.TextEditor;
 
48
using MonoDevelop.Components.MainToolbar;
48
49
 
49
50
namespace MonoDevelop.Ide.Gui
50
51
{
51
52
        /// <summary>
52
53
        /// This is the a Workspace with a multiple document interface.
53
54
        /// </summary>
54
 
        internal class DefaultWorkbench : WorkbenchWindow, ICommandDelegatorRouter
 
55
        internal class DefaultWorkbench : WorkbenchWindow, ICommandRouter
55
56
        {
56
57
                readonly static string mainMenuPath    = "/MonoDevelop/Ide/MainMenu";
 
58
                readonly static string appMenuPath    = "/MonoDevelop/Ide/AppMenu";
57
59
                readonly static string viewContentPath = "/MonoDevelop/Ide/Pads";
58
 
                readonly static string toolbarsPath    = "/MonoDevelop/Ide/Toolbar";
 
60
//              readonly static string toolbarsPath    = "/MonoDevelop/Ide/Toolbar";
59
61
                readonly static string stockLayoutsPath    = "/MonoDevelop/Ide/WorkbenchLayouts";
60
62
                
61
63
                static string configFile = UserProfile.Current.ConfigDir.Combine ("EditingLayout.xml");
62
64
                const string fullViewModeTag = "[FullViewMode]";
63
65
                const int MAX_LASTACTIVEWINDOWS = 10;
 
66
                const int MinimumWidth = 1000;
 
67
                const int MinimumHeight = 600;
64
68
                
65
69
                // list of layout names for the current context, without the context prefix
66
70
                List<string> layouts = new List<string> ();
77
81
                bool ignorePageSwitch;
78
82
 
79
83
                bool fullscreen;
80
 
                Rectangle normalBounds = new Rectangle(0, 0, 640, 480);
 
84
                Rectangle normalBounds = new Rectangle(0, 0, MinimumWidth, MinimumHeight);
81
85
                
82
86
                Gtk.Container rootWidget;
83
87
                DockToolbarFrame toolbarFrame;
84
88
                DockFrame dock;
85
89
                SdiDragNotebook tabControl;
86
90
                Gtk.MenuBar topMenu;
87
 
                Gtk.Toolbar[] toolbars;
88
 
                MonoDevelopStatusBar statusBar;
89
91
                Gtk.VBox fullViewVBox;
90
92
                DockItem documentDockItem;
91
 
                
 
93
                MainToolbar toolbar;
 
94
                MonoDevelopStatusBar bottomBar;
 
95
 
92
96
                enum TargetList {
93
97
                        UriList = 100
94
98
                }
107
111
                
108
112
                public event EventHandler ActiveWorkbenchWindowChanged;
109
113
                
110
 
                public MonoDevelopStatusBar StatusBar {
111
 
                        get {
112
 
                                if (statusBar == null)
113
 
                                        statusBar = new MonoDevelop.Ide.MonoDevelopStatusBar ();
114
 
                                return statusBar;
115
 
                        }
116
 
                }
117
 
                
 
114
                public MonoDevelop.Ide.StatusBar StatusBar {
 
115
                        get {
 
116
                                return toolbar.StatusBar;
 
117
                        }
 
118
                }
 
119
 
 
120
                public MainToolbar Toolbar {
 
121
                        get {
 
122
                                return toolbar;
 
123
                        }
 
124
                }
 
125
 
118
126
                public Gtk.MenuBar TopMenu {
119
127
                        get { return topMenu; }
120
128
                }
 
129
 
 
130
                public MonoDevelopStatusBar BottomBar {
 
131
                        get { return bottomBar; }
 
132
                }
121
133
                
122
 
                public IWorkbenchWindow ActiveWorkbenchWindow {
 
134
                internal IWorkbenchWindow ActiveWorkbenchWindow {
123
135
                        get {
124
 
                                if (tabControl == null || tabControl.CurrentPage < 0 || tabControl.CurrentPage >= tabControl.NPages)  {
 
136
                                if (tabControl == null || tabControl.CurrentTabIndex < 0 || tabControl.CurrentTabIndex >= tabControl.TabCount)  {
125
137
                                        return null;
126
138
                                }
127
 
                                return (IWorkbenchWindow) tabControl.CurrentPageWidget;
 
139
                                return (IWorkbenchWindow) tabControl.CurrentTab.Content;
128
140
                        }
129
141
                }
130
142
                
134
146
                
135
147
                public bool FullScreen {
136
148
                        get {
137
 
                                return fullscreen;
 
149
                                return DesktopService.GetIsFullscreen (this);
138
150
                        }
139
151
                        set {
140
 
                                fullscreen = value;
141
 
                                if (fullscreen) {
142
 
                                        this.Fullscreen ();
143
 
                                } else {
144
 
                                        this.Unfullscreen ();
145
 
                                }
 
152
                                DesktopService.SetIsFullscreen (this, value);
146
153
                        }
147
154
                }
148
155
 
165
172
                                        return "";
166
173
                        }
167
174
                        set {
168
 
                                // Leave dragging mode, to avoid problems due to widget relocating
169
 
                                tabControl.LeaveDragMode (0);
170
 
                                
171
175
                                var oldLayout = dock.CurrentLayout;
172
176
                                
173
177
                                InitializeLayout (value);
229
233
                                Gtk.Window.DefaultIconName = appIconName;
230
234
                                return;
231
235
                        }
232
 
                        
233
 
                        //branded icons
234
 
                        var iconsEl = BrandingService.GetElement ("ApplicationIcons");
235
 
                        if (iconsEl != null) {
236
 
                                try {
237
 
                                        this.IconList = iconsEl.Elements ("Icon")
238
 
                                                .Select (el => new Gdk.Pixbuf (BrandingService.GetFile ((string)el))).ToArray ();
239
 
                                        return;
240
 
                                } catch (Exception ex) {
241
 
                                        LoggingService.LogError ("Could not load app icons", ex);
 
236
 
 
237
                        if (!Platform.IsMac) {
 
238
                                //branded icons
 
239
                                var iconsEl = BrandingService.GetElement ("ApplicationIcons");
 
240
                                if (iconsEl != null) {
 
241
                                        try {
 
242
                                                this.IconList = iconsEl.Elements ("Icon")
 
243
                                                        .Select (el => new Gdk.Pixbuf (BrandingService.GetFile ((string)el))).ToArray ();
 
244
                                                return;
 
245
                                        } catch (Exception ex) {
 
246
                                                LoggingService.LogError ("Could not load app icons", ex);
 
247
                                        }
242
248
                                }
243
249
                        }
244
250
                        
285
291
//                      TopMenu.Selected   += new CommandHandler(OnTopMenuSelected);
286
292
//                      TopMenu.Deselected += new CommandHandler(OnTopMenuDeselected);
287
293
                        
288
 
                        if (!DesktopService.SetGlobalMenu (IdeApp.CommandService, mainMenuPath))
289
 
                                topMenu = IdeApp.CommandService.CreateMenuBar (mainMenuPath);
290
 
                        
291
 
                        toolbars = IdeApp.CommandService.CreateToolbarSet (toolbarsPath);
292
 
                        foreach (Gtk.Toolbar t in toolbars) {
293
 
                                t.ToolbarStyle = Gtk.ToolbarStyle.Icons;
294
 
                                t.IconSize = IdeApp.Preferences.ToolbarSize;
 
294
                        if (!DesktopService.SetGlobalMenu (IdeApp.CommandService, mainMenuPath, appMenuPath)) {
 
295
                                CreateMenuBar ();
295
296
                        }
296
 
                        IdeApp.Preferences.ToolbarSizeChanged += delegate {
297
 
                                foreach (Gtk.Toolbar t in toolbars) {
298
 
                                        t.IconSize = IdeApp.Preferences.ToolbarSize;
299
 
                                }
300
 
                        };
301
 
                                
 
297
                        
302
298
                        AddinManager.ExtensionChanged += OnExtensionChanged;
303
299
                }
304
300
                
305
301
                void OnExtensionChanged (object s, ExtensionEventArgs args)
306
302
                {
307
 
                        if (args.PathChanged (mainMenuPath)) {
308
 
                                if (DesktopService.SetGlobalMenu (IdeApp.CommandService, mainMenuPath))
 
303
                        if (args.PathChanged (mainMenuPath) || args.PathChanged (appMenuPath)) {
 
304
                                if (DesktopService.SetGlobalMenu (IdeApp.CommandService, mainMenuPath, appMenuPath))
309
305
                                        return;
310
306
                                
311
307
                                UninstallMenuBar ();
312
 
                                topMenu = IdeApp.CommandService.CreateMenuBar (mainMenuPath);
 
308
                                CreateMenuBar ();
313
309
                                InstallMenuBar ();
314
310
                        }
315
 
                        
316
 
                        if (args.PathChanged (toolbarsPath)) {
317
 
                                toolbars = IdeApp.CommandService.CreateToolbarSet (toolbarsPath);
318
 
                                string cl = toolbarFrame.CurrentLayout;
319
 
                                DockToolbarFrameStatus mem = toolbarFrame.GetStatus ();
320
 
                                toolbarFrame.ClearToolbars ();
321
 
                                foreach (DockToolbar tb in toolbars) {
322
 
                                        tb.ToolbarStyle = Gtk.ToolbarStyle.Icons;
323
 
                                        tb.ShowAll ();
324
 
                                        toolbarFrame.AddBar (tb);
325
 
                                }
326
 
                                toolbarFrame.SetStatus (mem);
327
 
                                toolbarFrame.CurrentLayout = cl;
 
311
                }
 
312
 
 
313
                void CreateMenuBar ()
 
314
                {
 
315
                        topMenu = IdeApp.CommandService.CreateMenuBar (mainMenuPath);
 
316
                        var appMenu = IdeApp.CommandService.CreateMenu (appMenuPath);
 
317
                        if (appMenu != null && appMenu.Children.Length > 0) {
 
318
                                var item = new MenuItem (BrandingService.ApplicationName);
 
319
                                item.Submenu = appMenu;
 
320
                                topMenu.Insert (item, 0);
328
321
                        }
329
322
                }
330
323
                
363
356
                                foreach (IViewContent content in fullList) {
364
357
                                        IWorkbenchWindow window = content.WorkbenchWindow;
365
358
                                        if (window != null)
366
 
                                                window.CloseWindow(true, true, 0);
 
359
                                                window.CloseWindow(true);
367
360
                                }
368
361
                        } finally {
369
362
                                closeAll = false;
386
379
                                }
387
380
                        }
388
381
                        
389
 
                        Gtk.Image mimeimage = null;
 
382
                        Gdk.Pixbuf mimeimage = null;
390
383
                        
391
384
                        if (content.StockIconId != null ) {
392
 
                                mimeimage = new Gtk.Image ((IconId) content.StockIconId, IconSize.Menu );
 
385
                                mimeimage = ImageService.GetPixbuf (content.StockIconId, IconSize.Menu);
393
386
                        }
394
387
                        else if (content.IsUntitled && content.UntitledName == null) {
395
 
                                mimeimage = new Gtk.Image (DesktopService.GetPixbufForType ("gnome-fs-regular", Gtk.IconSize.Menu));
 
388
                                mimeimage = DesktopService.GetPixbufForType ("gnome-fs-regular", Gtk.IconSize.Menu);
396
389
                        } else {
397
 
                                mimeimage = new Gtk.Image (DesktopService.GetPixbufForFile (content.ContentName ?? content.UntitledName, Gtk.IconSize.Menu));
 
390
                                mimeimage = DesktopService.GetPixbufForFile (content.ContentName ?? content.UntitledName, Gtk.IconSize.Menu);
398
391
                        }                       
399
392
 
400
 
                        TabLabel tabLabel = new TabLabel (new Label (), mimeimage != null ? mimeimage : new Gtk.Image (""));
401
 
                        tabLabel.CloseClicked += new EventHandler (closeClicked);                       
402
 
                        tabLabel.ClearFlag (WidgetFlags.CanFocus);
403
 
                        tabLabel.Show ();
404
 
                        
405
 
                        SdiWorkspaceWindow sdiWorkspaceWindow = new SdiWorkspaceWindow (this, content, tabControl, tabLabel);
 
393
                        var tab = tabControl.InsertTab (-1);
 
394
 
 
395
                        SdiWorkspaceWindow sdiWorkspaceWindow = new SdiWorkspaceWindow (this, content, tabControl, tab);
406
396
                        sdiWorkspaceWindow.TitleChanged += delegate { SetWorkbenchTitle (); };
407
397
                        sdiWorkspaceWindow.Closed += CloseWindowEvent;
408
398
                        sdiWorkspaceWindow.Show ();
409
 
                        
410
 
                        tabControl.InsertPage (sdiWorkspaceWindow, tabLabel, -1);
411
 
                        
 
399
 
 
400
                        tab.Content = sdiWorkspaceWindow;
 
401
                        if (mimeimage != null)
 
402
                                tab.Icon = mimeimage;
 
403
 
412
404
                        if (content.Project != null)
413
405
                                content.Project.NameChanged += HandleProjectNameChanged;
414
406
                        
415
407
                        if (bringToFront)
416
408
                                content.WorkbenchWindow.SelectWindow();
 
409
 
 
410
                        // The insertion of the tab may have changed the active view (or maybe not, this is checked in OnActiveWindowChanged)
 
411
                        OnActiveWindowChanged (null, null);
417
412
                }
418
413
 
419
414
                void HandleProjectNameChanged (object sender, SolutionItemRenamedEventArgs e)
456
451
                void RegisterPad (PadCodon content)
457
452
                {
458
453
                        if (content.HasId) {
459
 
                                ActionCommand cmd = new ActionCommand ("Pad|" + content.PadId, GettextCatalog.GetString (content.Label), null);
 
454
                                string lab = content.Label.Length > 0 ? GettextCatalog.GetString (content.Label) : "";
 
455
                                ActionCommand cmd = new ActionCommand ("Pad|" + content.PadId, lab, null);
460
456
                                cmd.DefaultHandler = new PadActivationHandler (this, content);
461
457
                                cmd.Category = GettextCatalog.GetString ("View");
462
458
                                cmd.Description = GettextCatalog.GetString ("Show {0}", cmd.Text);
614
610
                        }
615
611
                }
616
612
                
617
 
                void CheckRemovedFile(object sender, FileEventArgs args)
 
613
                void CheckRemovedFile (object sender, FileEventArgs args)
618
614
                {
619
615
                        foreach (FileEventInfo e in args) {
620
616
                                if (e.IsDirectory) {
621
617
                                        IViewContent[] views = new IViewContent [viewContentCollection.Count];
622
618
                                        viewContentCollection.CopyTo (views, 0);
623
619
                                        foreach (IViewContent content in views) {
624
 
                                                if (content.ContentName.StartsWith(e.FileName)) {
625
 
                                                        content.WorkbenchWindow.CloseWindow(true, true, 0);
 
620
                                                if (content.ContentName.StartsWith (e.FileName)) {
 
621
                                                        ((SdiWorkspaceWindow)content.WorkbenchWindow).CloseWindow (true, true);
626
622
                                                }
627
623
                                        }
628
624
                                } else {
629
625
                                        foreach (IViewContent content in viewContentCollection) {
630
626
                                                if (content.ContentName != null &&
631
 
                                                    content.ContentName == e.FileName) {
632
 
                                                        content.WorkbenchWindow.CloseWindow(true, true, 0);
 
627
                                                        content.ContentName == e.FileName) {
 
628
                                                        // Don't close files that are removed (potential data loss) see #11380.
 
629
                                                        ((SdiWorkspaceWindow)content.WorkbenchWindow).ViewContent.IsDirty = true;
633
630
                                                        return;
634
631
                                                }
635
632
                                        }
643
640
                                if (e.IsDirectory) {
644
641
                                        foreach (IViewContent content in viewContentCollection) {
645
642
                                                if (content.ContentName != null && ((FilePath)content.ContentName).IsChildPathOf (e.SourceFile)) {
646
 
                                                        content.ContentName = e.TargetFile + content.ContentName.Substring(e.SourceFile.FileName.Length);
 
643
                                                        content.ContentName = e.TargetFile.Combine (((FilePath) content.ContentName).FileName);
647
644
                                                }
648
645
                                        }
649
646
                                } else {
737
734
                        
738
735
                        if (lastActive == ActiveWorkbenchWindow)
739
736
                                return;
740
 
                        
 
737
 
 
738
                        WelcomePage.WelcomePageService.HideWelcomePage ();
 
739
 
 
740
                        if (lastActive != null)
 
741
                                ((SdiWorkspaceWindow)lastActive).OnDeactivated ();
 
742
 
741
743
                        if (lastActiveWindows.Count > MAX_LASTACTIVEWINDOWS)
742
744
                                lastActiveWindows.RemoveFirst ();
743
 
                        
 
745
 
 
746
                        lastActiveWindows.Remove (lastActive);
744
747
                        lastActiveWindows.AddLast (lastActive);
745
748
                        lastActive = ActiveWorkbenchWindow;
746
749
                        SetWorkbenchTitle ();
747
 
                        
 
750
 
 
751
                        if (!closeAll && ActiveWorkbenchWindow != null)
 
752
                                ((SdiWorkspaceWindow)ActiveWorkbenchWindow).OnActivated ();
 
753
 
748
754
                        if (!closeAll && ActiveWorkbenchWindowChanged != null) {
749
755
                                ActiveWorkbenchWindowChanged(this, e);
750
756
                        }
751
757
                }
752
758
                
753
 
                public Gtk.Toolbar[] ToolBars {
754
 
                        get { return toolbars; }
755
 
                }
756
 
                
757
759
                public PadCodon GetPad(Type type)
758
760
                {
759
761
                        foreach (PadCodon pad in PadContentCollection) {
789
791
                        AddinManager.AddExtensionNodeHandler (viewContentPath, OnExtensionChanged);
790
792
                        initializing = false;
791
793
                }
792
 
                
 
794
 
793
795
                void CreateComponents ()
794
796
                {
795
797
                        fullViewVBox = new VBox (false, 0);
796
798
                        rootWidget = fullViewVBox;
797
799
                        
798
800
                        InstallMenuBar ();
799
 
                        
 
801
                        Realize ();
 
802
                        toolbar = DesktopService.CreateMainToolbar (this);
 
803
                        DesktopService.SetMainWindowDecorations (this);
 
804
                        var toolbarBox = new HBox ();
 
805
                        fullViewVBox.PackStart (toolbarBox, false, false, 0);
800
806
                        toolbarFrame = new CommandFrame (IdeApp.CommandService);
 
807
 
801
808
                        fullViewVBox.PackStart (toolbarFrame, true, true, 0);
802
 
                        
803
 
                        foreach (DockToolbar t in toolbars)
804
 
                                toolbarFrame.AddBar (t);
805
 
                        
 
809
 
806
810
                        // Create the docking widget and add it to the window.
807
811
                        dock = new DockFrame ();
808
812
                        
828
832
                        toolbarFrame.AddContent (dock);
829
833
                        
830
834
                        // Create the notebook for the various documents.
831
 
                        tabControl = new SdiDragNotebook (dock.ShadedContainer);
832
 
                        tabControl.Scrollable = true;
 
835
                        tabControl = new SdiDragNotebook ();
833
836
                        tabControl.SwitchPage += OnActiveWindowChanged;
834
 
                        tabControl.PageAdded += OnActiveWindowChanged;
835
837
                        tabControl.PageRemoved += OnActiveWindowChanged;
 
838
                        tabControl.TabClosed += CloseClicked;
836
839
                
837
 
                        tabControl.ButtonPressEvent += delegate(object sender, ButtonPressEventArgs e) {
838
 
                                int tab = tabControl.FindTabAtPosition (e.Event.XRoot, e.Event.YRoot);
839
 
                                if (tab < 0)
840
 
                                        return;
841
 
                                tabControl.CurrentPage = tab;
842
 
                                if (e.Event.Type == Gdk.EventType.TwoButtonPress)
843
 
                                        ToggleFullViewMode ();
 
840
                        tabControl.TabActivated += delegate(object sender, TabEventArgs e) {
 
841
                                ToggleFullViewMode ();
844
842
                        };
845
 
                        
 
843
 
846
844
                        this.tabControl.DoPopupMenu = ShowPopup;
847
845
                        
848
846
                        tabControl.TabsReordered += new TabsReorderedHandler (OnTabsReordered);
849
847
 
 
848
                        Add (fullViewVBox);
 
849
                        fullViewVBox.ShowAll ();
 
850
                        bottomBar = new MonoDevelopStatusBar ();
 
851
                        fullViewVBox.PackEnd (bottomBar, false, true, 0);
 
852
                        bottomBar.ShowAll ();
 
853
                        toolbarBox.PackStart (this.toolbar, true, true, 0);
 
854
 
 
855
                        // In order to get the correct bar height we need to calculate the tab size using the
 
856
                        // correct style (the style of the window). At this point the widget is not yet a child
 
857
                        // of the window, so its style is not yet the correct one.
 
858
                        tabControl.InitSize (this);
 
859
                        var barHeight = tabControl.BarHeight;
 
860
 
850
861
                        // The main document area
851
862
                        documentDockItem = dock.AddItem ("Documents");
852
863
                        documentDockItem.Behavior = DockItemBehavior.Locked;
854
865
                        documentDockItem.DrawFrame = false;
855
866
                        documentDockItem.Label = GettextCatalog.GetString ("Documents");
856
867
                        documentDockItem.Content = tabControl;
857
 
                        
 
868
 
 
869
                        DockVisualStyle style = new DockVisualStyle ();
 
870
                        style.PadTitleLabelColor = Styles.PadLabelColor;
 
871
                        style.PadBackgroundColor = Styles.PadBackground;
 
872
                        style.InactivePadBackgroundColor = Styles.InactivePadBackground;
 
873
                        style.PadTitleHeight = barHeight;
 
874
                        dock.DefaultVisualStyle = style;
 
875
 
 
876
                        style = new DockVisualStyle ();
 
877
                        style.PadTitleLabelColor = Styles.PadLabelColor;
 
878
                        style.PadTitleHeight = barHeight;
 
879
                        style.ShowPadTitleIcon = false;
 
880
                        style.UppercaseTitles = false;
 
881
                        style.ExpandedTabs = true;
 
882
                        style.PadBackgroundColor = Styles.BrowserPadBackground;
 
883
                        style.InactivePadBackgroundColor = Styles.InactiveBrowserPadBackground;
 
884
                        style.TreeBackgroundColor = Styles.BrowserPadBackground;
 
885
                        dock.SetDockItemStyle ("ProjectPad", style);
 
886
                        dock.SetDockItemStyle ("ClassPad", style);
 
887
 
 
888
//                      dock.SetRegionStyle ("Documents/Left", style);
 
889
                        //dock.SetRegionStyle ("Documents/Right", style);
 
890
 
 
891
//                      style = new DockVisualStyle ();
 
892
//                      style.SingleColumnMode = true;
 
893
//                      dock.SetRegionStyle ("Documents/Left;Documents/Right", style);
 
894
//                      dock.SetDockItemStyle ("Documents", style);
 
895
 
858
896
                        // Add some hiden items to be used as position reference
859
897
                        DockItem dit = dock.AddItem ("__left");
860
898
                        dit.DefaultLocation = "Documents/Left";
876
914
                        dit.Behavior = DockItemBehavior.Locked;
877
915
                        dit.DefaultVisible = false;
878
916
 
879
 
                        Add (fullViewVBox);
880
 
                        fullViewVBox.ShowAll ();
881
 
                        
882
 
                        fullViewVBox.PackEnd (this.StatusBar, false, true, 0);
883
 
                        
884
917
                        if (MonoDevelop.Core.Platform.IsMac)
885
 
                                this.StatusBar.HasResizeGrip = true;
 
918
                                bottomBar.HasResizeGrip = true;
886
919
                        else {
887
920
                                if (GdkWindow != null && GdkWindow.State == Gdk.WindowState.Maximized)
888
 
                                        IdeApp.Workbench.StatusBar.HasResizeGrip = false;
 
921
                                        bottomBar.HasResizeGrip = false;
889
922
                                SizeAllocated += delegate {
890
923
                                        if (GdkWindow != null)
891
 
                                                IdeApp.Workbench.StatusBar.HasResizeGrip = GdkWindow.State != Gdk.WindowState.Maximized;
 
924
                                                bottomBar.HasResizeGrip = GdkWindow.State != Gdk.WindowState.Maximized;
892
925
                                };
893
926
                        }
894
927
 
968
1001
                
969
1002
                void ShowPopup (int tabIndex, Gdk.EventButton evt)
970
1003
                {
971
 
                        this.tabControl.Page = tabIndex;
 
1004
                        this.tabControl.CurrentTabIndex = tabIndex;
972
1005
                        IdeApp.CommandService.ShowContextMenu (this.tabControl, evt, "/MonoDevelop/Ide/ContextMenu/DocumentTab");
973
1006
                }
974
1007
                
1000
1033
                
1001
1034
                public void ToggleFullViewMode ()
1002
1035
                {
1003
 
                        this.tabControl.LeaveDragMode (0);
1004
 
                        
1005
1036
                        if (IsInFullViewMode) {
1006
1037
                                var oldLayout = dock.CurrentLayout;
1007
1038
                                toolbarFrame.CurrentLayout = dock.CurrentLayout = CurrentLayout;
1115
1146
                                last = lastActiveWindows.Last.Value;
1116
1147
                                lastActiveWindows.RemoveLast ();
1117
1148
                        } while (lastActiveWindows.Count > 0 && (last == cur || last == null || (last != null && last.ViewContent == null)));
1118
 
                        if (last != null) {
 
1149
 
 
1150
                        if (last != null && last != cur) {
1119
1151
                                last.SelectWindow ();
1120
1152
                                return true;
1121
1153
                        }
1125
1157
                void CloseWindowEvent (object sender, WorkbenchWindowEventArgs e)
1126
1158
                {
1127
1159
                        SdiWorkspaceWindow f = (SdiWorkspaceWindow) sender;
1128
 
                        
1129
 
                        // Unsubscribe events to avoid memory leaks
1130
 
                        f.TabLabel.CloseClicked -= new EventHandler (closeClicked);
1131
 
                        
 
1160
                        lastActiveWindows.Remove (f);
 
1161
 
1132
1162
                        if (f.ViewContent != null) {
1133
1163
                                CloseContent (f.ViewContent);
1134
1164
                                if (e.WasActive && !SelectLastActiveWindow (f))
1137
1167
                        lastActiveWindows.Remove (f);
1138
1168
                }
1139
1169
                
1140
 
                void closeClicked (object o, EventArgs e)
 
1170
                void CloseClicked (object o, TabEventArgs e)
1141
1171
                {
1142
 
                        Widget tabLabel = ((Widget)o);
1143
 
                        foreach (Widget child in tabControl.Children) {
1144
 
                                if (tabControl.GetTabLabel (child) == tabLabel) {
1145
 
                                        int pageNum = tabControl.PageNum (child);
1146
 
                                        ((SdiWorkspaceWindow)child).CloseWindow (false, false, pageNum);
1147
 
                                        break;
1148
 
                                }
1149
 
                        }
 
1172
                        ((SdiWorkspaceWindow)e.Tab.Content).CloseWindow (false, true);
1150
1173
                }
1151
1174
 
1152
 
                internal void RemoveTab (int pageNum) {
 
1175
                internal void RemoveTab (int pageNum, bool animate)
 
1176
                {
1153
1177
                        try {
1154
1178
                                // Weird switch page events are fired when a tab is removed.
1155
1179
                                // This flag avoids unneeded events.
1156
1180
                                ignorePageSwitch = true;
1157
1181
                                IWorkbenchWindow w = ActiveWorkbenchWindow;
1158
 
                                tabControl.RemovePage (pageNum);
 
1182
                                tabControl.RemoveTab (pageNum, animate);
1159
1183
                                ignorePageSwitch = false;
1160
1184
                                if (w != ActiveWorkbenchWindow)
1161
1185
                                        OnActiveWindowChanged (null, null);
1200
1224
                
1201
1225
                public void ActivatePad (PadCodon padContent, bool giveFocus)
1202
1226
                {
 
1227
                        WelcomePage.WelcomePageService.HideWelcomePage ();
 
1228
 
1203
1229
                        DockItem item = GetDockItem (padContent);
1204
1230
                        if (item != null)
1205
1231
                                item.Present (giveFocus);
1324
1350
                                string windowTitle = GettextCatalog.GetString (window.Title); 
1325
1351
                                if (String.IsNullOrEmpty (windowTitle)) 
1326
1352
                                        windowTitle = GettextCatalog.GetString (codon.Label);
1327
 
                                if (window.IsWorking)
1328
 
                                        windowTitle = "<span foreground='blue'>" + windowTitle + "</span>";
1329
 
                                else if (window.HasErrors && !window.ContentVisible)
 
1353
                                if (window.HasErrors && !window.ContentVisible)
1330
1354
                                        windowTitle = "<span foreground='red'>" + windowTitle + "</span>";
1331
1355
                                else if (window.HasNewData && !window.ContentVisible)
1332
1356
                                        windowTitle = "<b>" + windowTitle + "</b>";
1337
1361
                
1338
1362
                #endregion
1339
1363
 
1340
 
                #region ICommandDelegatorRouter implementation
1341
 
                
1342
 
                // The command route is redirected here to the active document view.
1343
 
                // This is done to make the view commands available even when the
1344
 
                // view has not the active focus, especially when the focus is
1345
 
                // on a pad. Although it may seem a bit inconsistent (because
1346
 
                // MD will not have active commands which don't directly apply to
1347
 
                // the active widget) in general it makes sense, views are the
1348
 
                // main working areas of the IDE and users often expect view commands
1349
 
                // to be available even if the focus is in a secondary Pad window.
1350
 
                //
1351
 
                // This change also fixes some issues with the property and outline
1352
 
                // pads, which depend on the current selection, and were being reset
1353
 
                // when the main view lost focus.
1354
 
                
1355
 
                object ICommandDelegatorRouter.GetNextCommandTarget ()
1356
 
                {
1357
 
                        // This is the last object of the chain
1358
 
                        return null;
1359
 
                }
1360
 
 
1361
 
                object ICommandDelegatorRouter.GetDelegatedCommandTarget ()
1362
 
                {
1363
 
                        // The command manager checks if an object has already been visited
1364
 
                        // while scanning the command route, so if the active command
1365
 
                        // route already includes the active workbench view, it won't be
1366
 
                        // visited again
1367
 
                        return ActiveWorkbenchWindow;
1368
 
                }
 
1364
                #region ICommandRouter implementation
 
1365
 
 
1366
                object ICommandRouter.GetNextCommandTarget ()
 
1367
                {
 
1368
                        return toolbar;
 
1369
                }
 
1370
 
1369
1371
                #endregion
1370
1372
        }
1371
1373
 
1396
1398
        // The SdiDragNotebook class allows redirecting the command route to the ViewCommandHandler
1397
1399
        // object of the selected document, which implement some default commands.
1398
1400
        
1399
 
        class SdiDragNotebook: DragNotebook, ICommandDelegatorRouter, IShadedWidget
 
1401
        class SdiDragNotebook: DockNotebook, ICommandDelegatorRouter, ICommandBar
1400
1402
        {
1401
 
                ShadedContainer shadedContainer;
1402
 
                
1403
 
                public SdiDragNotebook (ShadedContainer shadedContainer)
 
1403
                public SdiDragNotebook ()
1404
1404
                {
1405
 
                        this.shadedContainer = shadedContainer;
1406
 
                        shadedContainer.Add (this);
1407
 
                        
1408
 
                        PageAdded += delegate {
1409
 
                                if (AreasChanged != null)
1410
 
                                        AreasChanged (this, EventArgs.Empty);
1411
 
                        };
1412
 
                        PageRemoved += delegate {
1413
 
                                if (AreasChanged != null)
1414
 
                                        AreasChanged (this, EventArgs.Empty);
1415
 
                        };
 
1405
                        NextButtonClicked += delegate {
 
1406
                                IdeApp.CommandService.DispatchCommand (Ide.Commands.NavigationCommands.NavigateForward);
 
1407
                        };
 
1408
                        PreviousButtonClicked += delegate {
 
1409
                                IdeApp.CommandService.DispatchCommand (Ide.Commands.NavigationCommands.NavigateBack);
 
1410
                        };
 
1411
                        IdeApp.CommandService.RegisterCommandBar (this);
1416
1412
                }
1417
1413
                
1418
1414
                public object GetNextCommandTarget ()
1422
1418
 
1423
1419
                public object GetDelegatedCommandTarget ()
1424
1420
                {
1425
 
                        SdiWorkspaceWindow win = (SdiWorkspaceWindow) CurrentPageWidget;
 
1421
                        SdiWorkspaceWindow win = CurrentTab != null ? (SdiWorkspaceWindow) CurrentTab.Content : null;
1426
1422
                        return win != null ? win.CommandHandler : null;
1427
1423
                }
1428
1424
                
1429
 
                protected override bool OnExposeEvent (Gdk.EventExpose evnt)
1430
 
                {
1431
 
                        shadedContainer.DrawBackground (this);
1432
 
                        return base.OnExposeEvent (evnt);
1433
 
                }
1434
 
 
1435
 
                public event EventHandler AreasChanged;
1436
 
                
1437
 
                public IEnumerable<Gdk.Rectangle> GetShadedAreas ()
1438
 
                {
1439
 
                        Gdk.Rectangle rect = Allocation;
1440
 
                        if (CurrentPageWidget != null && CurrentPageWidget.Visible)
1441
 
                                rect.Height -= CurrentPageWidget.Allocation.Height;
1442
 
                        yield return rect;
1443
 
                }
1444
 
                
1445
 
                public Action<int,Gdk.EventButton> DoPopupMenu { get; set; }
1446
 
                
1447
 
                protected override bool OnButtonPressEvent (Gdk.EventButton evnt)
1448
 
                {
1449
 
                        if (DoPopupMenu != null && evnt.TriggersContextMenu ()) {
1450
 
                                int tab = FindTabAtPosition (evnt.XRoot, evnt.YRoot);
1451
 
                                if (tab >= 0) {
1452
 
                                        DoPopupMenu (tab, evnt);
1453
 
                                        return true;
1454
 
                                }
1455
 
                        }
1456
 
                        return base.OnButtonPressEvent (evnt);
1457
 
                }
1458
 
                
1459
 
                protected override bool OnPopupMenu ()
1460
 
                {
1461
 
                        if (DoPopupMenu != null) {
1462
 
                                DoPopupMenu (this.Page, null);
1463
 
                                return true;
1464
 
                        }
1465
 
                        return base.OnPopupMenu ();
1466
 
                }
 
1425
                #region ICommandBar implementation
 
1426
                bool isEnabled = true;
 
1427
 
 
1428
                void ICommandBar.Update (object activeTarget)
 
1429
                {
 
1430
                        var ci = IdeApp.CommandService.GetCommandInfo (Ide.Commands.NavigationCommands.NavigateForward);
 
1431
                        NextButtonEnabled = isEnabled && ci.Enabled && ci.Visible;
 
1432
 
 
1433
                        ci = IdeApp.CommandService.GetCommandInfo (Ide.Commands.NavigationCommands.NavigateBack);
 
1434
                        PreviousButtonEnabled = isEnabled && ci.Enabled && ci.Visible;
 
1435
                }
 
1436
 
 
1437
                void ICommandBar.SetEnabled (bool enabled)
 
1438
                {
 
1439
                        isEnabled = enabled;
 
1440
                }
 
1441
                #endregion
1467
1442
        }
1468
1443
}
 
 
b'\\ No newline at end of file'