Пример #1
0
		public void RemoveMessageBar ()
		{
			if (messageBar != null) {
				if (messageBar.Parent == vbox)
					vbox.Remove (messageBar);
				messageBar.Destroy ();
				messageBar = null;
			}
			if (!TextEditor.Visible)
				TextEditor.Visible = true;
			if (messageOverlayWindow != null) {
				messageOverlayWindow.Destroy ();
				messageOverlayWindow = null;
			}
		}
Пример #2
0
		void ShowIncorretEolMarkers (string fileName, bool multiple)
		{
			RemoveMessageBar ();
			messageOverlayWindow = new OverlayMessageWindow ();

			var hbox = new HBox ();
			hbox.Spacing = 8;

			var image = new HoverCloseButton ();
			hbox.PackStart (image, false, false, 0);
			var label = new Label (string.Format ("This file has line endings ({0}) which differ from the policy settings ({1}).", GetEolString (DetectedEolMarker), GetEolString (textEditor.Options.DefaultEolMarker)));
			var color = (Mono.TextEditor.HslColor)textEditor.ColorStyle.NotificationText.Foreground;
			label.ModifyFg (StateType.Normal, color);

			int w, h;
			label.Layout.GetPixelSize (out w, out h);
			label.Ellipsize = Pango.EllipsizeMode.End;

			hbox.PackStart (label, true, true, 0);
			var okButton = new Button (Gtk.Stock.Ok);
			okButton.WidthRequest = 60;
			hbox.PackEnd (okButton, false, false, 0); 

			var list = new List<string> ();
			list.Add (string.Format ("Convert to {0} line endings", GetEolString (textEditor.Options.DefaultEolMarker)));
			if (multiple)
				list.Add (string.Format ("Convert all files to {0} line endings", GetEolString (textEditor.Options.DefaultEolMarker)));
			list.Add (string.Format ("Keep {0} line endings", GetEolString (DetectedEolMarker)));
			if (multiple)
				list.Add (string.Format ("Keep {0} line endings in all files", GetEolString (DetectedEolMarker)));
			var combo = new ComboBox (list.ToArray ());
			combo.Active = 0;
			hbox.PackEnd (combo, false, false, 0);
			var container = new HBox ();
			const int containerPadding = 8;
			container.PackStart (hbox, true, true, containerPadding); 
			messageOverlayWindow.Child = container; 
			messageOverlayWindow.ShowOverlay (this.TextEditor);

			messageOverlayWindow.SizeFunc = () => {
				return okButton.SizeRequest ().Width +
					combo.SizeRequest ().Width +
					image.SizeRequest ().Width +
					w +
					hbox.Spacing * 4 + 
					containerPadding * 2;
			};
			image.Clicked += delegate {
				UseIncorrectMarkers = true;
				view.WorkbenchWindow.ShowNotification = false;
				RemoveMessageBar ();
			};
			okButton.Clicked += delegate {
				if (multiple) {
					switch (combo.Active) {
					case 0:
						ConvertLineEndings ();
						view.WorkbenchWindow.ShowNotification = false;
						view.Save (fileName, view.SourceEncoding);
						break;
					case 1:
						FileRegistry.ConvertLineEndingsInAllFiles ();
						break;
					case 2:
						UseIncorrectMarkers = true;
						view.WorkbenchWindow.ShowNotification = false;
						break;
					case 3:
						FileRegistry.IgnoreLineEndingsInAllFiles ();
						break;
					}
				} else {
					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;
					}
				}
				RemoveMessageBar ();
			};
		}
		//TODO: Support multiple Overlays at once to display above each other
		internal void AddOverlay (Widget messageOverlayContent, Func<int> sizeFunc = null)
		{
			var messageOverlayWindow = new OverlayMessageWindow ();
			messageOverlayWindow.Child = messageOverlayContent;
			messageOverlayWindow.SizeFunc = sizeFunc;
			messageOverlayWindow.ShowOverlay (TextEditor);
			messageOverlayWindows.Add (messageOverlayWindow);
		}