diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-11-25 18:18:24 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-11-25 18:18:24 +0400 |
commit | 15af14c23e1ac93d8443a2557dc7dea839e9c12d (patch) | |
tree | 4376d13ebbd3e05f8af56ed2b5b9798b443362e6 /main/src | |
parent | b2ac6f0813ef0fcba9eded48a89b6fa320412ea0 (diff) | |
parent | 2bd163987ccc1d712cf767075a6a0fa57b4984f1 (diff) |
Merge branch 'master' into newresolver
Diffstat (limited to 'main/src')
6 files changed, 121 insertions, 34 deletions
diff --git a/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.Commands/WebReferenceCommandHandler.cs b/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.Commands/WebReferenceCommandHandler.cs index 1900caa49a..9ea1aa29ab 100644 --- a/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.Commands/WebReferenceCommandHandler.cs +++ b/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.Commands/WebReferenceCommandHandler.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Linq; using MonoDevelop.Components.Commands; using MonoDevelop.Core; using MonoDevelop.Projects; @@ -8,12 +9,17 @@ using MonoDevelop.Ide.Gui.Components; using MonoDevelop.Ide; using System.Collections.Generic; using MonoDevelop.Core.Assemblies; +using System.Threading.Tasks; namespace MonoDevelop.WebReferences.Commands { /// <summary>Defines the properties and methods for the WebReferenceCommandHandler class.</summary> public class WebReferenceCommandHandler : NodeCommandHandler { + StatusBarContext UpdateReferenceContext { + get; set; + } + /// <summary>Execute the command for adding a new web reference to a project.</summary> [CommandHandler (MonoDevelop.WebReferences.WebReferenceCommands.Add)] public void NewWebReference() @@ -51,35 +57,61 @@ namespace MonoDevelop.WebReferences.Commands } } + [CommandUpdateHandler (MonoDevelop.WebReferences.WebReferenceCommands.Update)] + [CommandUpdateHandler (MonoDevelop.WebReferences.WebReferenceCommands.UpdateAll)] + void CanUpdateWebReferences (CommandInfo ci) + { + // This does not appear to work. + ci.Enabled = UpdateReferenceContext == null; + } + /// <summary>Execute the command for updating a web reference in a project.</summary> [CommandHandler (MonoDevelop.WebReferences.WebReferenceCommands.Update)] public void Update() { - using (StatusBarContext sbc = IdeApp.Workbench.StatusBar.CreateContext ()) { - sbc.BeginProgress (GettextCatalog.GetString ("Updating web reference")); - sbc.AutoPulse = true; - WebReferenceItem item = (WebReferenceItem) CurrentNode.DataItem; - DispatchService.BackgroundDispatchAndWait (item.Update); - IdeApp.ProjectOperations.Save (item.Project); - IdeApp.Workbench.StatusBar.ShowMessage("Updated Web Reference " + item.Name); - } + UpdateReferences (new [] { (WebReferenceItem) CurrentNode.DataItem }); } - + /// <summary>Execute the command for updating all web reference in a project.</summary> [CommandHandler (MonoDevelop.WebReferences.WebReferenceCommands.UpdateAll)] public void UpdateAll() { - using (StatusBarContext sbc = IdeApp.Workbench.StatusBar.CreateContext ()) { - sbc.BeginProgress (GettextCatalog.GetString ("Updating web references")); - sbc.AutoPulse = true; - DotNetProject project = ((WebReferenceFolder) CurrentNode.DataItem).Project; - List<WebReferenceItem> items = new List<WebReferenceItem> (WebReferencesService.GetWebReferenceItems (project)); - DispatchService.BackgroundDispatchAndWait (delegate { - foreach (var item in items) - item.Update(); + DotNetProject project = ((WebReferenceFolder) CurrentNode.DataItem).Project; + UpdateReferences (WebReferencesService.GetWebReferenceItems (project).ToArray ()); + } + + void UpdateReferences (IList<WebReferenceItem> items) + { + try { + UpdateReferenceContext = IdeApp.Workbench.StatusBar.CreateContext (); + UpdateReferenceContext.BeginProgress (GettextCatalog.GetPluralString ("Updating web reference", "Updating web references", items.Count)); + + DispatchService.ThreadDispatch (() => { + for (int i = 0; i < items.Count; i ++) { + DispatchService.GuiDispatch (() => UpdateReferenceContext.SetProgressFraction (Math.Max (0.1, (double)i / items.Count))); + items [i].Update(); + } + + DispatchService.GuiDispatch (() => { + // Make sure that we save all relevant projects, there should only be 1 though + foreach (var project in items.Select (i =>i.Project).Distinct ()) + IdeApp.ProjectOperations.Save (project); + + IdeApp.Workbench.StatusBar.ShowMessage(GettextCatalog.GetPluralString ("Updated Web Reference {0}", "Updated Web References", items.Count, items[0].Name)); + DisposeUpdateContext (); + }); }); - IdeApp.ProjectOperations.Save (project); - IdeApp.Workbench.StatusBar.ShowMessage("Updated all Web References"); + } catch { + DisposeUpdateContext (); + throw; + } + } + + void DisposeUpdateContext () + { + if (UpdateReferenceContext != null) { + UpdateReferenceContext.Dispose (); + UpdateReferenceContext = null; } } diff --git a/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences/WebReferencesService.cs b/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences/WebReferencesService.cs index ee4de272d8..275c328391 100644 --- a/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences/WebReferencesService.cs +++ b/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences/WebReferencesService.cs @@ -48,8 +48,18 @@ namespace MonoDevelop.WebReferences public static void NotifyWebReferencesChanged (DotNetProject project) { - if (WebReferencesChanged != null) - WebReferencesChanged (null, new WebReferencesChangedArgs (project)); + // This is called from a background thread when webreferences are being + // updated asynchronously, so lets keep things simple for the users of + // this event and just ensure we proxy it to the main thread. + if (MonoDevelop.Ide.DispatchService.IsGuiThread) { + if (WebReferencesChanged != null) + WebReferencesChanged (null, new WebReferencesChangedArgs (project)); + } else { + MonoDevelop.Ide.DispatchService.GuiDispatch (() => { + if (WebReferencesChanged != null) + WebReferencesChanged (null, new WebReferencesChangedArgs (project)); + }); + } } public static event EventHandler<WebReferencesChangedArgs> WebReferencesChanged; diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs index 32abc0088a..405f3a5f42 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs @@ -1972,11 +1972,12 @@ namespace Mono.TextEditor double xp = System.Math.Floor (area.X); if (textEditor.Options.ShowRuler) { - double divider = System.Math.Max (xp, System.Math.Min (x + TextStartPosition + rulerX + 0.5, xp + area.Width)); + double divider = System.Math.Max (area.X, System.Math.Min (x + TextStartPosition + rulerX + 0.5, area.X + area.Width)); if (divider < area.X + area.Width) { - cr.Rectangle (xp, area.Y, divider - xp, area.Height); + cr.Rectangle (xp, area.Y, divider - area.X, area.Height); cr.Fill (); - cr.Rectangle (divider, area.Y, xp + area.Width - divider + 1, area.Height); + + cr.Rectangle (divider, area.Y, area.X + area.Width - divider, area.Height); cr.Color = DimColor (color); cr.Fill (); cr.DrawLine (ColorStyle.Ruler, divider, area.Y, divider, area.Y + area.Height); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessArgumentBuilder.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessArgumentBuilder.cs index 4b6d595992..249e35d81c 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessArgumentBuilder.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessArgumentBuilder.cs @@ -35,9 +35,23 @@ namespace MonoDevelop.Core.Execution { System.Text.StringBuilder sb = new System.Text.StringBuilder (); + public string ProcessPath { + get; private set; + } + // .NET doesn't allow escaping chars other than " and \ inside " quotes static string escapeDoubleQuoteCharsStr = "\\\""; + public ProcessArgumentBuilder () + { + + } + + public ProcessArgumentBuilder (string processPath) + { + ProcessPath = processPath; + } + /// <summary> /// Adds an argument without escaping or quoting. /// </summary> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandMenu.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandMenu.cs index 644c35d095..dacd57d56a 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandMenu.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandMenu.cs @@ -71,6 +71,19 @@ namespace MonoDevelop.Components.Commands } } + bool populated; + void EnsurePopulated () + { + if (populated) + return; + populated = true; + if (commandEntrySet != null) { + manager.CreateMenu (commandEntrySet, this); + Update (); + commandEntrySet = null; + } + } + protected CommandMenu (IntPtr ptr): base (ptr) { } @@ -81,14 +94,17 @@ namespace MonoDevelop.Components.Commands manager.RegisterUserInteraction (); Update (); } + protected override void OnRealized () { base.OnRealized (); - if (commandEntrySet != null) { - manager.CreateMenu (commandEntrySet, this); - Update (); - commandEntrySet = null; - } + EnsurePopulated (); + } + + protected override void OnSizeRequested (ref Gtk.Requisition requisition) + { + EnsurePopulated (); + base.OnSizeRequested (ref requisition); } internal void Update () diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DragNotebook.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DragNotebook.cs index 367108f94b..e4b31349a7 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DragNotebook.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DragNotebook.cs @@ -57,17 +57,24 @@ namespace MonoDevelop.Ide.Gui int dragNotebookXRoot; int dragNotebookYRoot; - Widget page = GetNthPage (0); - int pageNumber = 0; + Widget page; + int pageNumber = CurrentPage; Widget tab; int tabMaxX; int tabMaxY; int tabMinX; int tabMinY; + int? direction = null; ParentWindow.GetOrigin (out dragNotebookXRoot, out dragNotebookYRoot); - - while (page != null) { + + // We cannot rely on the allocations being zero for tabs which are + // offscreen. If we write the logic to walk from page 0 til NPages, + // we can end up choosing the wrong page because pages which are + // offscreen will match the mouse coordinates. We can work around + // this by walking either up or down from the active page and choosing + // the first page which is within the mouse x/y coordinates. + while ((page = GetNthPage (pageNumber)) != null && pageNumber >= 0 && pageNumber <= NPages) { if ((tab = GetTabLabel (page)) == null) return -1; @@ -82,7 +89,14 @@ namespace MonoDevelop.Ide.Gui (tabMinY <= cursorY) && (cursorY <= tabMaxY)) return pageNumber; - page = GetNthPage (++pageNumber); + if (!direction.HasValue) { + if (TabPos == PositionType.Top || TabPos == PositionType.Bottom) + direction = cursorX > tabMaxX ? 1 : -1; + else + direction = cursorY > tabMaxY ? 1 : -1; + } + + pageNumber += direction.Value; } return -1; |