[Monodevelop-patches-list] r567 - in trunk/MonoDevelop/src: Libraries/MonoDevelop.Gui/Tree Main/Base/Gui/Pads/ProjectBrowser Main/Base/Gui/Pads/ProjectBrowser/BrowserNode

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Mon Jan 19 01:00:57 EST 2004


Author: benm
Date: 2004-01-19 01:00:57 -0500 (Mon, 19 Jan 2004)
New Revision: 567

Modified:
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Tree/TreeNode.cs
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Tree/TreeView.cs
   trunk/MonoDevelop/src/Main/Base/Gui/Pads/ProjectBrowser/BrowserNode/FileNode.cs
   trunk/MonoDevelop/src/Main/Base/Gui/Pads/ProjectBrowser/ProjectBrowserView.cs
Log:
rename files from the treeview

Modified: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Tree/TreeNode.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Tree/TreeNode.cs	2004-01-19 05:04:41 UTC (rev 566)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Tree/TreeNode.cs	2004-01-19 06:00:57 UTC (rev 567)
@@ -66,6 +66,12 @@
 			}
 		}
 		
+		public void UpdateBacking ()
+		{
+			TreeView.Model.SetValue (TreeIter, 0, text);
+			TreeView.Model.SetValue (TreeIter, 1, image);
+		}
+		
 		public TreeNodeCollection Nodes {
 			get {
 				return nodes;
@@ -157,5 +163,11 @@
 				return iter;
 			}
 		}
+		
+		public virtual void BeginEdit ()
+		{
+			TreeView.SetCursor (new Gtk.TreePath (TreePath), TreeView.complete_column, true);
+			TreeView.GrabFocus ();
+		}
 	}
 }

Modified: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Tree/TreeView.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Tree/TreeView.cs	2004-01-19 05:04:41 UTC (rev 566)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Tree/TreeView.cs	2004-01-19 06:00:57 UTC (rev 567)
@@ -8,6 +8,7 @@
 		private TreeNodeCollection nodes;
 		private bool updating = false;
 		private bool canEdit = false;
+		internal Gtk.TreeViewColumn complete_column;
 		
 		public TreeView () : this (false)
 		{
@@ -21,7 +22,7 @@
 			HeadersVisible = false;
 			SearchColumn = 0;
 			EnableSearch = true;
-			Gtk.TreeViewColumn complete_column = new Gtk.TreeViewColumn ();
+			complete_column = new Gtk.TreeViewColumn ();
 			complete_column.Title = "column";
 
 			Gtk.CellRendererPixbuf pix_render = new Gtk.CellRendererPixbuf ();
@@ -29,10 +30,10 @@
 			complete_column.AddAttribute (pix_render, "pixbuf", 1);
 			
 			Gtk.CellRendererText text_render = new Gtk.CellRendererText ();
-			//text_render.Editable = canEdit;
-			//if (canEdit) {
-			//	text_render.Edited += new GtkSharp.EditedHandler (OnEdit);
-			//}
+			text_render.Editable = canEdit;
+			if (canEdit) {
+				text_render.Edited += new GtkSharp.EditedHandler (HandleOnEdit);
+			}
 			complete_column.PackStart (text_render, true);
 			complete_column.AddAttribute (text_render, "text", 0);
 	
@@ -40,16 +41,26 @@
 
 			nodes = new TreeNodeCollection();
 			nodes.TreeNodeCollectionChanged += new TreeNodeCollectionChangedHandler(OnTreeChanged);
-            nodes.NodeInserted += new NodeInsertedHandler(OnNodeInserted);
+			nodes.NodeInserted += new NodeInsertedHandler(OnNodeInserted);
 			nodes.NodeRemoved += new NodeRemovedHandler(OnNodeRemoved);
 			
 			TestExpandRow += new GtkSharp.TestExpandRowHandler(OnTestExpandRow);
 		}
 
-		public virtual void OnEdit (object o, GtkSharp.EditedArgs e)
+		void HandleOnEdit (object o, GtkSharp.EditedArgs e)
 		{
 			
+			Gtk.TreeIter iter;
+			if (! Model.GetIterFromString (out iter, e.Path))
+				throw new Exception("Error calculating iter for path " + e.Path);
+			
+			OnEdit ((TreeNode) store.GetValue (iter, 2), e.NewText);
 		}
+		
+		protected virtual void OnEdit (TreeNode node, string new_text)
+		{
+		}
+		
 
 		public TreeNodeCollection Nodes {
 			get {

Modified: trunk/MonoDevelop/src/Main/Base/Gui/Pads/ProjectBrowser/BrowserNode/FileNode.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Pads/ProjectBrowser/BrowserNode/FileNode.cs	2004-01-19 05:04:41 UTC (rev 566)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Pads/ProjectBrowser/BrowserNode/FileNode.cs	2004-01-19 06:00:57 UTC (rev 567)
@@ -98,7 +98,7 @@
 		public override void AfterLabelEdit(string newName)
 		{
 			if (newName != null && newName.Trim().Length > 0) {
-				if (userData == null || !(userData is ProjectFile)) {
+				if (userData == null || !(userData is ProjectFile)) {
 					return;
 				}
 				string oldname = ((ProjectFile)userData).Name;
@@ -110,16 +110,16 @@
 				}
 				
 				string newname = Path.GetDirectoryName(oldname) + Path.DirectorySeparatorChar + newName;
-				
 				if (oldname != newname) {
 					ResourceService resourceService = (ResourceService)ServiceManager.Services.GetService(typeof(IResourceService));
 					try {
 						IFileService fileService = (IFileService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IFileService));
-						FileUtilityService fileUtilityService = (FileUtilityService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(FileUtilityService));
+						FileUtilityService fileUtilityService = (FileUtilityService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(FileUtilityService));
 						if (fileUtilityService.IsValidFileName(newname)) {
 							fileService.RenameFile(oldname, newname);
 							SetNodeLabel();
-							SetNodeIcon();
+							SetNodeIcon();
+							UpdateBacking ();
 						}
 					} catch (System.IO.IOException) {   // assume duplicate file
 						IMessageService messageService =(IMessageService)ServiceManager.Services.GetService(typeof(IMessageService));

Modified: trunk/MonoDevelop/src/Main/Base/Gui/Pads/ProjectBrowser/ProjectBrowserView.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Pads/ProjectBrowser/ProjectBrowserView.cs	2004-01-19 05:04:41 UTC (rev 566)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Pads/ProjectBrowser/ProjectBrowserView.cs	2004-01-19 06:00:57 UTC (rev 567)
@@ -175,11 +175,18 @@
 			}
 		}
 
-		public override void OnEdit (object o, GtkSharp.EditedArgs e)
-		{
-			//FIXME: We need to change the filename and refresh the view here
-			//FIXME: We should also be checking to make sure the filename *actually* changed
-			Console.WriteLine ("Filename needs to be changed here");
+		
+		protected override void OnEdit (TreeNode node, string new_text)
+		{
+			// we set the label ourself
+			((AbstractBrowserNode) node).AfterLabelEdit (new_text);
+			
+			if (node.Parent != null)
+				SortUtility.QuickSort (node.Parent.Nodes, TreeNodeComparer.ProjectNode);
+			
+			// save changes
+			IProjectService projectService = (IProjectService) ServiceManager.Services.GetService (typeof(IProjectService));
+			projectService.SaveCombine();
 		}
 
 		void DisposeProjectNodes()
@@ -251,8 +258,7 @@
 			AbstractBrowserNode selectedNode = (AbstractBrowserNode)SelectedNode;
 			if (selectedNode != null && selectedNode.CanLabelEdited) {
 				//LabelEdit = true;
-				//selectedNode.BeforeLabelEdit();
-				//selectedNode.BeginEdit();
+				selectedNode.BeginEdit ();
 			}
 		}
 




More information about the Monodevelop-patches-list mailing list