[mono/monodevelop] eef2fab5: [SourceEditor] Worked on new message bar design (from Bug 15248 - CRNL

Mike Krüger ([email protected]) <[email protected]>
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <0000014197601790-2a004755-eb4a-4923-aae6-b91b1ed40a0c-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/monodevelop
  Compare: https://github.com/mono/monodevelop/compare/770903378793...eef2fab5c447

   Commit: eef2fab5c447b940972167e520d13a2e9ce4788e
   Author: Mike Krüger <[email protected]> (mkrueger)
     Date: 2013-10-08 09:21:14 GMT
      URL: https://github.com/mono/monodevelop/commit/eef2fab5c447b940972167e520d13a2e9ce4788e

[SourceEditor] Worked on new message bar design (from Bug 15248 - CRNL
vs NL policy setting warning is too obtrusive).

Changed paths:
  M main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj
  M main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/MessageBubbleTextMarker.cs
  M main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs
  M main/src/core/MonoDevelop.Ide/MonoDevelop.Components/InfoBar.cs
Added paths:
  A main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/OverlayMessageWindow.cs

Modified: main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj
===================================================================
@@ -27,9 +27,9 @@
     </CustomCommands>
     <AssemblyName>MonoDevelop.SourceEditor2</AssemblyName>
     <ConsolePause>False</ConsolePause>
-    <GenerateDocumentation>true</GenerateDocumentation>
     <DefineConstants>DEBUG</DefineConstants>
     <NoWarn>1591;1573</NoWarn>
+    <DocumentationFile>..\..\..\build\AddIns\DisplayBindings\SourceEditor\MonoDevelop.SourceEditor2.xml</DocumentationFile>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
@@ -43,8 +43,8 @@
       <Execution clr-version="Net_2_0" />
     </Execution>
     <DebugSymbols>true</DebugSymbols>
-    <GenerateDocumentation>true</GenerateDocumentation>
     <NoWarn>1591;1573</NoWarn>
+    <DocumentationFile>..\..\..\build\AddIns\DisplayBindings\SourceEditor\MonoDevelop.SourceEditor.xml</DocumentationFile>
   </PropertyGroup>
   <ItemGroup>
     <ProjectReference Include="..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj">
@@ -185,6 +185,7 @@
     <Compile Include="gtk-gui\MonoDevelop.SourceEditor.OptionPanels.CompletionAppearancePanel.cs" />
     <Compile Include="AddinInfo.cs" />
     <Compile Include="MonoDevelop.SourceEditor.OptionPanels\CompletionCharactersPanel.cs" />
+    <Compile Include="MonoDevelop.SourceEditor\OverlayMessageWindow.cs" />
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="gtk-gui\gui.stetic">

Modified: main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/MessageBubbleTextMarker.cs
===================================================================
@@ -374,7 +374,6 @@ public override void DrawAfterEol (TextEditor textEditor, Cairo.Context g, doubl
 			var sx = metrics.TextRenderEndPosition;
 			var width = LayoutWidth + errorCounterWidth + editor.LineHeight;
 			var drawLayout = layouts[0].Layout;
-			int ex = 0 , ey = 0;
 			bool customLayout = true; //sx + width > editor.Allocation.Width;
 			bool hideText = false;
 			bubbleIsReduced = customLayout;
@@ -440,7 +439,7 @@ public override void DrawAfterEol (TextEditor textEditor, Cairo.Context g, doubl
 				using (var lg = new Cairo.LinearGradient (errorCounterX, errorCounterY, errorCounterX, errorCounterY + errorCounterHeight)) {
 					lg.AddColorStop (0, CounterColor.Color);
 					lg.AddColorStop (1, CounterColor.Color.AddLight (-0.1));
-					g.Pattern = lg;
+					g.SetSource (lg);
 					g.Fill ();
 				}
 

Added: main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/OverlayMessageWindow.cs
===================================================================
@@ -0,0 +1,94 @@
+//
+// OverlayMessageWindow.cs
+//
+// Author:
+//       Mike Krüger <[email protected]>
+//
+// Copyright (c) 2013 Xamarin Inc. (http://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 Mono.TextEditor;
+using Gtk;
+using MonoDevelop.Components;
+using Gdk;
+
+namespace MonoDevelop.SourceEditor
+{
+	public class OverlayMessageWindow : Gtk.EventBox
+	{
+		ExtensibleTextEditor textEditor;
+
+		public OverlayMessageWindow ()
+		{
+			AppPaintable = true;
+		}
+
+		public void ShowOverlay (ExtensibleTextEditor textEditor)
+		{
+			this.textEditor = textEditor;
+			this.ShowAll (); 
+			textEditor.AddTopLevelWidget (this, 0, 0); 
+			textEditor.SizeAllocated += HandleSizeAllocated;
+			var child = (TextEditor.EditorContainerChild)textEditor [this];
+			child.FixedPosition = true;
+		}
+
+		protected override void OnDestroyed ()
+		{
+			base.OnDestroyed ();
+			if (textEditor != null) {
+				textEditor.SizeAllocated -= HandleSizeAllocated;
+				textEditor = null;
+			}
+		}
+
+		protected override void OnSizeAllocated (Gdk.Rectangle allocation)
+		{
+			base.OnSizeAllocated (allocation);
+			Resize (allocation);
+		}
+
+		void HandleSizeAllocated (object o, Gtk.SizeAllocatedArgs args)
+		{
+			Resize (Allocation);
+		}
+
+		void Resize (Gdk.Rectangle alloc)
+		{
+			textEditor.MoveTopLevelWidget (this, (textEditor.Allocation.Width - alloc.Width) / 2, textEditor.Allocation.Height - alloc.Height - 8);
+		}
+
+		protected override bool OnExposeEvent (Gdk.EventExpose evnt)
+		{
+			using (var cr = CairoHelper.Create (evnt.Window)) {
+				cr.Rectangle (0, 0, Allocation.Width, Allocation.Height);
+				cr.SetSourceColor (textEditor.ColorStyle.TooltipText.Background);
+				cr.FillPreserve ();
+
+				cr.SetSourceColor (textEditor.ColorStyle.TooltipBorder.Color);
+				cr.Stroke();
+			}
+
+			return base.OnExposeEvent (evnt);
+		}
+
+	}
+}
+

Modified: main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs
===================================================================
@@ -46,6 +46,7 @@
 using MonoDevelop.SourceEditor.QuickTasks;
 using ICSharpCode.NRefactory.Semantics;
 using ICSharpCode.NRefactory.Refactoring;
+using ICSharpCode.NRefactory;
 
 namespace MonoDevelop.SourceEditor
 {
@@ -918,12 +919,74 @@ internal void ConvertLineEndings ()
 			view.LoadSettings ();
 		}
 
+		static string GetEolString (string detectedEol)
+		{
+			switch (detectedEol) {
+			case "\n":
+				return "Unix";
+			case "\r\n":
+				return "Windows";
+			case "\r":
+				return "Mac";
+			}
+			return "Unknown";
+		}
+
+
 		void ShowIncorretEolMarkers (string fileName, bool multiple)
 		{
 			RemoveMessageBar ();
-			
-			if (messageBar == null) {
-				messageBar = new MonoDevelop.Components.InfoBar (MessageType.Warning);
+
+			Console.WriteLine ("SHOW EOL MARKER !!!!!");
+
+			var window = new OverlayMessageWindow ();
+
+			var hbox = new HBox ();
+			hbox.Spacing = 8;
+
+			hbox.PackStart (ImageService.GetImage ("gtk-dialog-warning", IconSize.Menu));
+			hbox.PackStart (new Label (string.Format ("This file has line endings ({0}) which differ from the policy settings ({1}).", GetEolString(DetectedEolMarker), GetEolString(textEditor.Options.DefaultEolMarker))), true, true, 0);
+			var okButton = new Button (Gtk.Stock.Ok);
+			hbox.PackEnd (okButton); 
+
+
+			var combo = new ComboBox(new [] {
+				string.Format ("Convert this file to {0} line endings", GetEolString(textEditor.Options.DefaultEolMarker)),
+				string.Format ("Keep {0} line endings", GetEolString(DetectedEolMarker)),
+				string.Format ("Convert all files to {0} line endings", GetEolString(textEditor.Options.DefaultEolMarker)),
+				string.Format ("Keep {0} line endings in all files", GetEolString(DetectedEolMarker))
+			});
+			combo.Active = 0;
+			hbox.PackEnd (combo);
+			var container = new HBox ();
+			container.PackStart (hbox, true, true, 8); 
+			window.Child = container; 
+			window.ShowOverlay (this.TextEditor);
+
+			okButton.Clicked += delegate {
+				switch (combo.Active) {
+				case 0:
+					ConvertLineEndings ();
+					view.WorkbenchWindow.ShowNotification = false;
+					view.Save (fileName, view.SourceEncoding);
+					break;
+				case 1:
+					UseIncorrectMarkers = true;
+					view.WorkbenchWindow.ShowNotification = false;
+					break;
+				case 2:
+					FileRegistry.ConvertLineEndingsInAllFiles ();
+					break;
+				case 3:
+					FileRegistry.IgnoreLineEndingsInAllFiles ();
+					break;
+				}
+				window.Destroy ();
+			};
+
+			/*
+			 if (messageBar == null) {
+				messageBar = new InfoBar (MessageType.Warning);
 				string detectedEol = DetectedEolMarker.Replace ("\n", "NL").Replace ("\r", "CR");
 				string defaultEol = textEditor.Options.DefaultEolMarker.Replace ("\n", "NL").Replace ("\r", "CR");
 				messageBar.SetMessageLabel (GettextCatalog.GetString (
@@ -973,13 +1036,7 @@ void ShowIncorretEolMarkers (string fileName, bool multiple)
 			vbox.ReorderChild (messageBar, 0);
 			messageBar.ShowAll ();
 
-			messageBar.QueueDraw ();
-//			view.WorkbenchWindow.ShowNotification = true;
-//			
-//			// Ensure that one file with incorret EOL markers is shown.
-//			var currentView = IdeApp.Workbench.ActiveDocument.PrimaryView.GetContent<SourceEditorView> ();
-//			if (currentView == null || !currentView.IsDirty || !currentView.SourceEditorWidget.HasIncorrectEolMarker || currentView.SourceEditorWidget.UseIncorrectMarkers)
-//				view.WorkbenchWindow.SelectWindow ();
+			messageBar.QueueDraw ();*/
 		}
 		#endregion
 		public void ShowAutoSaveWarning (string fileName)

Modified: main/src/core/MonoDevelop.Ide/MonoDevelop.Components/InfoBar.cs
===================================================================
@@ -140,10 +140,10 @@ public void SetMessageLabel (string markup)
 		protected override bool OnExposeEvent (Gdk.EventExpose evnt)
 		{
 			Style.PaintFlatBox (Style, evnt.Window, StateType.Normal, ShadowType.Out, evnt.Area, this, "tooltip", 
-			                    Allocation.X + 1, Allocation.Y + 1, Allocation.Width - 2, Allocation.Height - 2);
+				Allocation.X + 1, Allocation.Y + 1, Allocation.Width - 2, Allocation.Height - 2);
 			return base.OnExposeEvent (evnt);
 		}
-		
+
 		protected override void OnSizeAllocated (Gdk.Rectangle allocation)
 		{
 			var rect = Allocation.Union (allocation);
_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.