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

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Sat Jan 10 17:02:17 EST 2004


Author: pedroas
Date: 2004-01-10 17:02:17 -0500 (Sat, 10 Jan 2004)
New Revision: 423

Removed:
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Tree/ListView.cs
Modified:
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Tree/TreeView.cs
   trunk/MonoDevelop/src/Main/Base/Gui/Pads/UnixFileScout.cs
Log:
The file scout is usable, but not very pretty.


Deleted: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Tree/ListView.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Tree/ListView.cs	2004-01-10 20:02:04 UTC (rev 422)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Tree/ListView.cs	2004-01-10 22:02:17 UTC (rev 423)
@@ -1,94 +0,0 @@
-using System;
-using System.Collections;
-
-namespace MonoDevelop.Gui {
-	public class ListView {
-		private Gtk.TreeView treeview;
-		private ListViewItemCollection items = new ListViewItemCollection();
-		private ColumnHeaderCollection columns = new ColumnHeaderCollection();
-		
-		public ListView() {
-			treeview = new Gtk.TreeView();
-		}
-		
-		public Gtk.Widget Control {
-			get {
-				return treeview;
-			}
-		}
-		
-		public ListViewItemCollection Items {
-			get {
-				return items;
-			}
-		}
-		
-		public ColumnHeaderCollection Columns {
-			get {
-				return columns;
-			}
-		}
-		
-		public ListViewItemCollection SelectedItems {
-			get {
-				return items; // TODO
-			}
-		}
-		
-		public void BeginUpdate() {
-			// TODO
-		}
-		
-		public void EndUpdate() {
-			// TODO
-		}
-	}
-	
-	public class ListViewItem {
-		private string text;
-		private ListViewItemCollection subItems = new ListViewItemCollection();
-		
-		public ListViewItem(string text) {
-			this.text = text;
-		}
-		
-		public ListViewItemCollection SubItems {
-			get {
-				return subItems;
-			}
-		}
-		
-		public string Text {
-			get {
-				return text;
-			}
-			set {
-				text = value;
-			}
-		}
-	}
-	
-	public class ColumnHeaderCollection {
-		public void Add(string title, int width, HorizontalAlignment align) {
-			// TODO
-		}
-	}
-	
-	public class ListViewItemCollection: ArrayList {
-		public ListViewItem Add(ListViewItem it) {
-			return null; //TODO
-		}
-		
-		public new ListViewItem this[int index] {
-			get {
-				return null; // TODO
-			}
-		}
-
-	}
-	
-	public enum HorizontalAlignment {
-		Left,
-		Right
-	}
-}

Modified: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Tree/TreeView.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Tree/TreeView.cs	2004-01-10 20:02:04 UTC (rev 422)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Tree/TreeView.cs	2004-01-10 22:02:17 UTC (rev 423)
@@ -30,6 +30,8 @@
 			nodes.TreeNodeCollectionChanged += new TreeNodeCollectionChangedHandler(OnTreeChanged);
             nodes.NodeInserted += new NodeInsertedHandler(OnNodeInserted);
 			nodes.NodeRemoved += new NodeRemovedHandler(OnNodeRemoved);
+			
+			TestExpandRow += new GtkSharp.TestExpandRowHandler(OnTestExpandRow);
 		}
 
 		public TreeNodeCollection Nodes {
@@ -78,7 +80,7 @@
 			updating = false;
 */
 		}
-		
+				
 		internal void OnTreeChanged() {
 			if (updating == false) {
 				UpdateStore(store);
@@ -128,5 +130,49 @@
 			node.parent = null;
 			node.treeView = null;
 		}
+		
+		private TreeNode GetNodeByIter(Gtk.TreeIter iter) {
+			TreeNode ret = (TreeNode)store.GetValue(iter, 2);
+			return ret;
+		}
+		
+		private void OnTestExpandRow(object sender, GtkSharp.TestExpandRowArgs args) {
+			TreeNode node = GetNodeByIter(args.Iter);
+			TreeViewCancelEventArgs e = new TreeViewCancelEventArgs(node);
+			OnBeforeExpand(e);
+			if (e.Cancel == true || node.Nodes.Count == 0) {
+				args.RetVal = true;
+			} else {
+				args.RetVal = false;
+			}
+		}
+		
+		protected virtual void OnBeforeExpand(TreeViewCancelEventArgs e) {
+			// Nothing
+		}
 	}
+	
+	public class TreeViewCancelEventArgs {
+		private TreeNode node;
+		private bool cancel = false;
+		
+		public TreeViewCancelEventArgs(TreeNode node) {
+			this.node = node;
+		}
+		
+		public TreeNode Node {
+			get {
+				return node;
+			}
+		}
+		
+		public bool Cancel {
+			get {
+				return cancel;
+			}
+			set {
+				cancel = value;
+			}
+		}
+	}
 }

Modified: trunk/MonoDevelop/src/Main/Base/Gui/Pads/UnixFileScout.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Pads/UnixFileScout.cs	2004-01-10 20:02:04 UTC (rev 422)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Pads/UnixFileScout.cs	2004-01-10 22:02:17 UTC (rev 423)
@@ -25,21 +25,56 @@
 
 namespace ICSharpCode.SharpDevelop.Gui.Pads
 {
-	public class FileList : ListView
+	public class FileList : Gtk.TreeView
 	{
 		private FileSystemWatcher watcher;
+		private ItemCollection Items;
+		private Gtk.ListStore store;
 		
 //		private MagicMenus.PopupMenu menu = null;
 		
 		public FileList()
 		{
+			Items = new ItemCollection(this);
 			ResourceManager resources = new ResourceManager("ProjectComponentResources", this.GetType().Module.Assembly);
 			FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.Services.GetService(typeof(FileUtilityService));
 			
-			Columns.Add("File", 100, HorizontalAlignment.Left);
-			Columns.Add("Size", -2, HorizontalAlignment.Right);
-			Columns.Add("Last modified", -2, HorizontalAlignment.Left);
+			//Columns.Add("File", 100, HorizontalAlignment.Left);
+			//Columns.Add("Size", -2, HorizontalAlignment.Right);
+			//Columns.Add("Last modified", -2, HorizontalAlignment.Left);
 			
+			store = new Gtk.ListStore (typeof (string), typeof (string), typeof(string), typeof(FileListItem));
+			Model = store;
+
+			HeadersVisible = true;
+
+			Gtk.TreeViewColumn name_column = new Gtk.TreeViewColumn ();
+			name_column.Title = "File";
+			
+			Gtk.TreeViewColumn size_column = new Gtk.TreeViewColumn ();
+			size_column.Title = "Size";
+
+			Gtk.TreeViewColumn modi_column = new Gtk.TreeViewColumn ();
+			modi_column.Title = "Last modified";
+
+			Gtk.CellRendererText render1 = new Gtk.CellRendererText ();
+			name_column.PackStart (render1, false);
+			name_column.AddAttribute (render1, "text", 0);
+			
+			Gtk.CellRendererText render2 = new Gtk.CellRendererText ();
+			size_column.PackStart (render2, false);
+			size_column.AddAttribute (render2, "text", 1);
+			
+			Gtk.CellRendererText render3 = new Gtk.CellRendererText ();
+			modi_column.PackStart (render3, false);
+			modi_column.AddAttribute (render3, "text", 2);
+				
+			//listView.AppendColumn (complete_column);
+			AppendColumn(name_column);
+			AppendColumn(size_column);
+			AppendColumn(modi_column);
+
+			
 //			menu = new MagicMenus.PopupMenu();
 //			menu.MenuCommands.Add(new MagicMenus.MenuCommand("Delete file", new EventHandler(deleteFiles)));
 //			menu.MenuCommands.Add(new MagicMenus.MenuCommand("Rename", new EventHandler(renameFile)));
@@ -67,6 +102,18 @@
 			//Alignment		= ListViewAlignment.Left;
 		}
 		
+		void ItemAdded(FileListItem item) {
+			store.AppendValues(System.IO.Path.GetFileName(item.FullName), item.Size, item.LastModified, item);
+		}
+		
+		void ItemRemoved(FileListItem item) {
+			// TODO
+		}
+		
+		void Clear() {
+			store.Clear();
+		}
+		
 		void fileDeleted(object sender, FileSystemEventArgs e)
 		{
 			foreach(FileListItem fileItem in Items)
@@ -86,8 +133,8 @@
 					
 					FileInfo info = new FileInfo(e.FullPath);
 					
-					fileItem.SubItems[1].Text = Math.Round((double)info.Length / 1024).ToString() + " KB";
-					fileItem.SubItems[2].Text = info.LastWriteTime.ToString();
+					fileItem.Size = Math.Round((double)info.Length / 1024).ToString() + " KB";
+					fileItem.LastModified = info.LastWriteTime.ToString();
 					break;
 				}
 			}
@@ -97,11 +144,12 @@
 		{
 			FileInfo info = new FileInfo(e.FullPath);
 			
-			ListViewItem fileItem = Items.Add(new FileListItem(e.FullPath));
-			fileItem.SubItems.Add(Math.Round((double)info.Length / 1024).ToString() + " KB");
-			fileItem.SubItems.Add(info.LastWriteTime.ToString());
+			FileListItem fileItem = Items.Add(new FileListItem(e.FullPath,
+				Math.Round((double)info.Length / 1024).ToString() + " KB",
+				info.LastWriteTime.ToString())
+			);
 			
-			Items.Add(fileItem);
+			//Items.Add(fileItem);
 		}
 		
 		void fileRenamed(object sender, RenamedEventArgs e)
@@ -110,7 +158,7 @@
 			{
 				if(fileItem.FullName.ToLower() == e.OldFullPath.ToLower()) {
 					fileItem.FullName = e.FullPath;
-					fileItem.Text = e.Name;
+					//fileItem.Text = e.Name;
 					break;
 				}
 			}
@@ -118,14 +166,16 @@
 		
 		void renameFile(object sender, EventArgs e)
 		{
+		/*
 			if(SelectedItems.Count == 1) {
 				//SelectedItems[0].BeginEdit();
 			}
+		*/
 		}
 		
 		void deleteFiles(object sender, EventArgs e)
 		{
-			IMessageService messageService =(IMessageService)ServiceManager.Services.GetService(typeof(IMessageService));
+/*			IMessageService messageService =(IMessageService)ServiceManager.Services.GetService(typeof(IMessageService));
 			
 			if (messageService.AskQuestion("Are you sure ?", "Delete files")) {
 				foreach(FileListItem fileItem in SelectedItems)
@@ -138,6 +188,7 @@
 					}
 				}
 			}
+*/
 		}
 		
 /*		protected override void OnMouseUp(MouseEventArgs e)
@@ -189,31 +240,86 @@
 			
 			foreach (string file in files) {
 				FileInfo info = new FileInfo(file);
-				ListViewItem fileItem = Items.Add(new FileListItem(file));
-				fileItem.SubItems.Add(Math.Round((double)info.Length / 1024).ToString() + " KB");
-				fileItem.SubItems.Add(info.LastWriteTime.ToString());
+				FileListItem fileItem = Items.Add(new FileListItem(file,
+					Math.Round((double)info.Length / 1024).ToString() + " KB",
+					info.LastWriteTime.ToString()
+				));
 			}
 			
-			EndUpdate();
+			//EndUpdate();
 		}
 		
-		public class FileListItem : ListViewItem
+		public class FileListItem
 		{
 			string fullname;
+			string size;
+			string lastModified;
+			
 			public string FullName {
 				get {
 					return fullname;
-				} set {
+				} 
+				set {
 					fullname = value;
 				}
 			}
 			
-			public FileListItem(string fullname) : base(Path.GetFileName(fullname))
+			public string Size {
+				get {
+					return size;
+				}
+				set {
+					size = value;
+				}
+			}
+			
+			public string LastModified {
+				get {
+					return lastModified;
+				}
+				set {
+					lastModified = value;
+				}
+			}
+			
+			public FileListItem(string fullname, string size, string lastModified) 
 			{
 				this.fullname = fullname;
+				this.size = size;
+				this.lastModified = lastModified;
 				//ImageIndex = IconManager.GetIndexForFile(fullname);
 			}
 		}
+		
+		class ItemCollection {
+			FileList parent;
+			ArrayList list = new ArrayList();
+			
+			public ItemCollection(FileList parent) {
+				this.parent = parent;
+			}
+			
+			public FileListItem Add(FileListItem item) {
+				list.Add(item);
+				parent.ItemAdded(item);
+				return item;
+			}
+			
+			public void Remove(FileListItem item) {
+				parent.ItemRemoved(item);
+				list.Remove(item);
+			}
+			
+			public void Clear() {
+				list.Clear();
+				parent.Clear();
+			}
+			
+			public IEnumerator GetEnumerator() {
+				ArrayList copy = (ArrayList)list.Clone();
+				return copy.GetEnumerator();
+			}
+		}
 	}
 	
 	public class FileScout : Gtk.VPaned, IPadContent
@@ -262,6 +368,7 @@
 			//filetree.Size = new System.Drawing.Size(184, 157);
 			//filetree.TabIndex = 1;
 			//filetree.AfterSelect += new TreeViewEventHandler(DirectorySelected);
+			filetree.RowActivated += new GtkSharp.RowActivatedHandler(OnRowActivated);
 			//ImageList imglist = new ImageList();
 			//imglist.ColorDepth = ColorDepth.Depth32Bit;
 			/*imglist.Images.Add(resourceService.GetBitmap("Icons.16x16.ClosedFolderBitmap"));
@@ -284,6 +391,8 @@
 			//filelister.Size = new System.Drawing.Size(184, 450);
 			//filelister.TabIndex = 3;
 			//filelister.ItemActivate += new EventHandler(FileSelected);
+			filelister.RowActivated += new GtkSharp.RowActivatedHandler(FileSelected);
+
 			
 			//splitter1.Dock = DockStyle.Top;
 			//splitter1.Location = new System.Drawing.Point(0, 179);
@@ -303,7 +412,7 @@
 			treef.Add(treesw);
 			
 			Gtk.ScrolledWindow listsw = new Gtk.ScrolledWindow ();
-			listsw.Add(filelister.Control);
+			listsw.Add(filelister);
 			Gtk.Frame listf  = new Gtk.Frame();
 			listf.Add(listsw);
 			
@@ -312,20 +421,28 @@
 			Pack2(listf, true, true);
 		}
 		
-/*		void DirectorySelected(object sender, TreeViewEventArgs e)
+		void OnRowActivated(object sender, GtkSharp.RowActivatedArgs args) 
+/*		void DirectorySelected(object sender, TreeViewEventArgs e)*/
 		{
-			filelister.ShowFilesInPath(filetree.NodePath + Path.DirectorySeparatorChar);
+			filelister.ShowFilesInPath(filetree.NodePath + System.IO.Path.DirectorySeparatorChar);
 		}
-		
-		void FileSelected(object sender, EventArgs e)
+
+//		void FileSelected(object sender, EventArgs e)
+		void FileSelected(object sender, GtkSharp.RowActivatedArgs e)
 		{
 			IProjectService projectService = (IProjectService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IProjectService));
 			IFileService    fileService    = (IFileService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IFileService));
 			FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.Services.GetService(typeof(FileUtilityService));
+
 			
-			foreach (FileList.FileListItem item in filelister.SelectedItems) {
-				
-				switch (Path.GetExtension(item.FullName)) {
+			//foreach (FileList.FileListItem item in filelister.SelectedItems) {
+			Gtk.TreeIter iter;
+			for (filelister.Model.GetIterFirst(out iter); filelister.Model.IterNext(out iter) == true;) {
+				if (filelister.Selection.IterIsSelected(iter) == false) {
+					continue;
+				} 
+				FileList.FileListItem item = (FileList.FileListItem)filelister.Model.GetValue(iter, 3);
+				switch (System.IO.Path.GetExtension(item.FullName)) {
 					case ".cmbx":
 					case ".prjx":
 						projectService.OpenCombine(item.FullName);
@@ -336,6 +453,7 @@
 				}
 			}
 		}
+/*
 		protected virtual void OnTitleChanged(EventArgs e)
 		{
 			if (TitleChanged != null) {
@@ -532,28 +650,24 @@
 			}
 		}
 
-/*
 		protected override void OnBeforeExpand(TreeViewCancelEventArgs e)
 		{
-			Cursor.Current = Cursors.WaitCursor;
-			
+			//Cursor.Current = Cursors.WaitCursor;
 			try {
 				// do not populate if the "My Cpmputer" node is expaned
-				if(e.Node.Parent != null && e.Node.Parent.Parent != null) {
-					PopulateSubDirectory(e.Node, 2);
-					Cursor.Current = Cursors.Default;
-				} else {
+//				if(e.Node.Parent != null && e.Node.Parent.Parent != null) {
+//					PopulateSubDirectory(e.Node, 2);
+					//Cursor.Current = Cursors.Default;
+//				} else {
 					PopulateSubDirectory(e.Node, 1);
-					Cursor.Current = Cursors.Default;
-				}
+					//Cursor.Current = Cursors.Default;
+//				}
 			} catch (Exception excpt) {
 				IMessageService messageService =(IMessageService)ServiceManager.Services.GetService(typeof(IMessageService));
 				messageService.ShowError(excpt, "Device error");
 				e.Cancel = true;
 			}
-			
-			Cursor.Current = Cursors.Default;
+			//Cursor.Current = Cursors.Default;
 		}
-*/
 	}
 }




More information about the Monodevelop-patches-list mailing list