[Monodevelop-patches-list] r615 - in trunk/MonoDevelop/src/Main/Base: Gui/Dialogs/OptionPanels Services/MenuService

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Thu Jan 22 04:39:32 EST 2004


Author: jba
Date: 2004-01-22 04:39:32 -0500 (Thu, 22 Jan 2004)
New Revision: 615

Modified:
   trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/OptionPanels/ExternalToolPanel.cs
   trunk/MonoDevelop/src/Main/Base/Services/MenuService/MenuService.cs
Log:
ported quick insert menu and used in external tool panel

Modified: trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/OptionPanels/ExternalToolPanel.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/OptionPanels/ExternalToolPanel.cs	2004-01-22 06:13:19 UTC (rev 614)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/OptionPanels/ExternalToolPanel.cs	2004-01-22 09:39:32 UTC (rev 615)
@@ -13,6 +13,7 @@
 using ICSharpCode.SharpDevelop.Internal.ExternalTool;
 using ICSharpCode.Core.Properties;
 using ICSharpCode.Core.Services;
+using ICSharpCode.SharpDevelop.Services;
 using ICSharpCode.Core.AddIns.Codons;
 
 namespace ICSharpCode.SharpDevelop.Gui.Dialogs.OptionPanels
@@ -89,8 +90,7 @@
 		StringParserService StringParserService = (StringParserService)ServiceManager.Services.GetService (typeof (StringParserService));
 		PropertyService PropertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));
 		MessageService MessageService = (MessageService)ServiceManager.Services.GetService(typeof(MessageService));
-// FIXME: when menu service is created
-//		MenuService MenuService = (MenuService)ServiceManager.Services.GetService(typeof(MenuService));
+		MenuService MenuService = (MenuService)ServiceManager.Services.GetService(typeof(MenuService));
 		
 		public override void LoadPanelContents()
 		{
@@ -115,15 +115,13 @@
 				0);
 			
 			
-// FIXME: when menu service is created
-//			MenuService.CreateQuickInsertMenu(argumentTextBox,
-//			                                  argumentQuickInsertButton,
-//			                                  argumentQuickInsertMenu);
+			MenuService.CreateQuickInsertMenu(argumentTextBox,
+			                                  argumentQuickInsertButton,
+			                                  argumentQuickInsertMenu);
 			
-// FIXME: when menu service is created
-//			MenuService.CreateQuickInsertMenu(workingDirTextBox,
-//			                                  workingDirQuickInsertButton,
-//			                                  workingDirInsertMenu);
+			MenuService.CreateQuickInsertMenu(workingDirTextBox,
+			                                  workingDirQuickInsertButton,
+			                                  workingDirInsertMenu);
 			
 			toolListBox.Selection.Changed += new EventHandler(selectEvent);
 			
@@ -206,7 +204,7 @@
 			vBox1.PackEnd(moveUpButton, false, false, 2);			
 			
 			HBox hBox1 = new HBox(false, 2);
-			hBox1.PackStart(toolListBox, false, true, 2);
+			hBox1.PackStart(toolListBox, false, true, 4);
 			hBox1.PackStart(vBox1, false, false, 2);
 			
 			Table table1 = new Table(4, 3, false);

Modified: trunk/MonoDevelop/src/Main/Base/Services/MenuService/MenuService.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/MenuService/MenuService.cs	2004-01-22 06:13:19 UTC (rev 614)
+++ trunk/MonoDevelop/src/Main/Base/Services/MenuService/MenuService.cs	2004-01-22 09:39:32 UTC (rev 615)
@@ -61,13 +61,13 @@
 			//CreateContextMenu(owner, addInTreePath).Show(parent, new Point(x, y));
 			CreateContextMenu(owner, addInTreePath).Popup(null, null, null, IntPtr.Zero, 0, Gtk.Global.CurrentEventTime);
 		}
-		/*
+		
 		class QuickInsertMenuHandler
 		{
-			TextBoxBase targetControl;
+			Gtk.Editable targetControl;
 			string      text;
 			
-			public QuickInsertMenuHandler(TextBoxBase targetControl, string text)
+			public QuickInsertMenuHandler(Gtk.Editable targetControl, string text)
 			{
 				this.targetControl = targetControl;
 				this.text          = text;
@@ -80,46 +80,55 @@
 			}
 			void PopupMenuHandler(object sender, EventArgs e)
 			{
-				targetControl.SelectedText += text;
+				// insert at current cursor position, deleting any selections
+				int tempInt = targetControl.Position;
+				targetControl.DeleteSelection();
+				targetControl.InsertText(text, ref tempInt);
 			}
 		}
 		
 		class QuickInsertHandler
 		{
-			Control               popupControl;
-			CommandBarContextMenu quickInsertMenu;
+			Gtk.Button               popupControl;
+			Gtk.Menu quickInsertMenu;
 			
-			public QuickInsertHandler(Control popupControl, CommandBarContextMenu quickInsertMenu)
+			//public QuickInsertHandler(Control popupControl, CommandBarContextMenu quickInsertMenu)
+			public QuickInsertHandler(Gtk.Button popupControl, Gtk.Menu quickInsertMenu)
 			{
 				this.popupControl    = popupControl;
 				this.quickInsertMenu = quickInsertMenu;
 				
-				popupControl.Click += new EventHandler(showQuickInsertMenu);
+				popupControl.Clicked += new EventHandler(showQuickInsertMenu);
 			}
 			
 			void showQuickInsertMenu(object sender, EventArgs e)
 			{
-				Point cords = new Point(popupControl.Width, 0);
-				quickInsertMenu.Show(popupControl, cords);
+				//Point cords = new Point(popupControl.Width, 0);
+				//quickInsertMenu.Show(popupControl, cords);
+				quickInsertMenu.Popup(null, null, null, IntPtr.Zero, 0, Gtk.Global.CurrentEventTime);
 			}
 		}
 		
-		public void CreateQuickInsertMenu(TextBoxBase targetControl, Control popupControl, string[,] quickInsertMenuItems)
+		//public void CreateQuickInsertMenu(TextBoxBase targetControl, Control popupControl, string[,] quickInsertMenuItems)		
+		public void CreateQuickInsertMenu(Gtk.Editable targetControl, Gtk.Button popupControl, string[,] quickInsertMenuItems)
 		{
 			StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService));
 			
-			CommandBarContextMenu contextMenu = new CommandBarContextMenu();
+			//CommandBarContextMenu contextMenu = new CommandBarContextMenu();
+			Gtk.Menu contextMenu = new Gtk.Menu();
 			for (int i = 0; i < quickInsertMenuItems.GetLength(0); ++i) {
 				if (quickInsertMenuItems[i, 0] == "-") {
-					contextMenu.Items.Add(new SdMenuSeparator());
+					contextMenu.Append(new SdMenuSeparator());
 				} else {
 					SdMenuCommand cmd = new SdMenuCommand(this,
 					                                      stringParserService.Parse(quickInsertMenuItems[i, 0]),
 					                                      new QuickInsertMenuHandler(targetControl, quickInsertMenuItems[i, 1]).EventHandler);
-					contextMenu.Items.Add(cmd);
+					contextMenu.Append(cmd);
 				}
 			}
 			new QuickInsertHandler(popupControl, contextMenu);
-		}*/
+			
+			contextMenu.ShowAll();
+		}
 	}
 }




More information about the Monodevelop-patches-list mailing list