[Monodevelop-patches-list] r1798 - in trunk/MonoDevelop/src/Main/Base: . Gui/Pads

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Mon Jun 21 16:12:46 EDT 2004


Author: jluke
Date: 2004-06-21 16:12:46 -0400 (Mon, 21 Jun 2004)
New Revision: 1798

Modified:
   trunk/MonoDevelop/src/Main/Base/ChangeLog
   trunk/MonoDevelop/src/Main/Base/Gui/Pads/OpenTaskView.cs
Log:
* Gui/Pads/OpenTaskView.cs: implement a popup menu for copying
+       a task to the clipboard, bug #56817


Modified: trunk/MonoDevelop/src/Main/Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/src/Main/Base/ChangeLog	2004-06-21 19:36:27 UTC (rev 1797)
+++ trunk/MonoDevelop/src/Main/Base/ChangeLog	2004-06-21 20:12:46 UTC (rev 1798)
@@ -1,3 +1,8 @@
+2004-06-21  John Luke <jluke at cfl.rr.com>
+
+	* Gui/Pads/OpenTaskView.cs: implement a popup menu for copying
+	a task to the clipboard, bug #56817
+
 2004-06-20  Todd Berman  <tberman at off.net>
 
 	* Services/ParserService/CodeCompletionDatabase.cs: fix nullref in

Modified: trunk/MonoDevelop/src/Main/Base/Gui/Pads/OpenTaskView.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Pads/OpenTaskView.cs	2004-06-21 19:36:27 UTC (rev 1797)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Pads/OpenTaskView.cs	2004-06-21 20:12:46 UTC (rev 1798)
@@ -11,21 +11,23 @@
 using System.Collections;
 using System.IO;
 using System.Diagnostics;
+
 using MonoDevelop.Core.Services;
 using MonoDevelop.Services;
+using MonoDevelop.Core.Properties;
 
 using Gtk;
-using GtkSharp;
 
-using MonoDevelop.Core.Properties;
+namespace MonoDevelop.Gui.Pads
+{
+	public class OpenTaskView : IPadContent
+	{
+		ResourceService resourceService = (ResourceService) ServiceManager.Services.GetService (typeof (IResourceService));
 
-namespace MonoDevelop.Gui.Pads {
-	public class OpenTaskView : IPadContent {
-		
-		ResourceService resourceService = (ResourceService) ServiceManager.Services.GetService (typeof (IResourceService));
-		Gtk.ScrolledWindow sw;
+		ScrolledWindow sw;
 		Gtk.TreeView view;
-		Gtk.ListStore store;
+		ListStore store;
+		Clipboard clipboard;
 		
 		public Gtk.Widget Control {
 			get {
@@ -57,9 +59,6 @@
 			TaskService taskService        = (TaskService) ServiceManager.Services.GetService (typeof(TaskService));
 			IProjectService projectService = (IProjectService) ServiceManager.Services.GetService (typeof(IProjectService));
 			
-
-			
-			
 			store = new Gtk.ListStore (
 				typeof (Gdk.Pixbuf), // image
 				typeof (int),        // line
@@ -73,6 +72,8 @@
 				
 			view = new Gtk.TreeView (store);
 			view.RulesHint = true;
+			view.PopupMenu += OnPopupMenu;
+			view.ButtonPressEvent += OnButtonPressed;
 			AddColumns ();
 			
 			sw = new Gtk.ScrolledWindow ();
@@ -85,6 +86,51 @@
 			projectService.CombineClosed += new CombineEventHandler (OnCombineClosed);
 			view.RowActivated            += new RowActivatedHandler (OnRowActivated);
 		}
+
+		[GLib.ConnectBefore]
+		void OnButtonPressed (object o, ButtonPressEventArgs args)
+		{
+			if (args.Event.Button == 3)
+				ShowPopup ();
+		}
+
+		void OnPopupMenu (object o, PopupMenuArgs args)
+		{
+			ShowPopup ();
+		}
+
+		void ShowPopup ()
+		{
+			Menu menu = new Menu ();
+			menu.AccelGroup = new AccelGroup ();
+                        ImageMenuItem copy = new ImageMenuItem (Gtk.Stock.Copy, menu.AccelGroup);
+                        copy.Activated += OnTaskCopied;
+			menu.Append (copy);
+			menu.Popup (null, null, null, IntPtr.Zero, 3, Global.CurrentEventTime);
+			menu.ShowAll ();
+		}
+
+		void OnTaskCopied (object o, EventArgs args)
+		{
+			Task task;
+			TreeModel model;
+			TreeIter iter;
+
+			if (view.Selection.GetSelected (out model, out iter))
+			{
+				task = (Task) model.GetValue (iter, 5);
+			}
+			else
+			{
+				// no selection
+				return;
+			}
+
+			clipboard = Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
+			clipboard.SetText (task.ToString ());
+			clipboard = Clipboard.Get (Gdk.Atom.Intern ("PRIMARY", false));
+			clipboard.SetText (task.ToString ());
+		}
 		
 		void MarkupCol (Gtk.TreeViewColumn col)
 		{




More information about the Monodevelop-patches-list mailing list