[Monodevelop-patches-list] r771 - in trunk/MonoDevelop/src: Libraries/MonoDevelop.Gui.Widgets/FileBrowser Main/Base/Gui/Pads
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Tue Feb 3 19:49:57 EST 2004
Author: jluke
Date: 2004-02-03 19:49:57 -0500 (Tue, 03 Feb 2004)
New Revision: 771
Modified:
trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/FileBrowser/FileBrowser.cs
trunk/MonoDevelop/src/Main/Base/Gui/Pads/FileScout.cs
Log:
use this in the FileScout
please test it, seems to work well for me
Modified: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/FileBrowser/FileBrowser.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/FileBrowser/FileBrowser.cs 2004-02-04 00:34:04 UTC (rev 770)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Widgets/FileBrowser/FileBrowser.cs 2004-02-04 00:49:57 UTC (rev 771)
@@ -41,6 +41,21 @@
set { ignoreHidden = value; }
}
+ public Gtk.TreeView TreeView
+ {
+ get { return tv; }
+ }
+
+ public string CurrentDir
+ {
+ get { return System.IO.Path.GetFullPath (currentDir); }
+ }
+
+ public string[] Files
+ {
+ get { return files; }
+ }
+
public static new GLib.GType GType
{
get
Modified: trunk/MonoDevelop/src/Main/Base/Gui/Pads/FileScout.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Pads/FileScout.cs 2004-02-04 00:34:04 UTC (rev 770)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Pads/FileScout.cs 2004-02-04 00:49:57 UTC (rev 771)
@@ -8,15 +8,9 @@
using System;
using System.IO;
using System.Text;
-using System.Runtime.InteropServices;
-using System.ComponentModel;
using System.Drawing;
-using System.Drawing.Drawing2D;
using System.Collections;
-using System.Reflection;
using System.Resources;
-using System.Threading;
-using System.Xml;
using ICSharpCode.Core.Properties;
using ICSharpCode.Core.Services;
@@ -104,17 +98,9 @@
watcher.Created += new FileSystemEventHandler(fileCreated);
watcher.Changed += new FileSystemEventHandler(fileChanged);
}
-
- //HideSelection = false;
- //GridLines = true;
- //LabelEdit = true;
- //SmallImageList = IconManager.List;
- //HeaderStyle = ColumnHeaderStyle.Nonclickable;
- //View = View.Details;
- //Alignment = ListViewAlignment.Left;
}
- void ItemAdded(FileListItem item) {
+ internal void ItemAdded(FileListItem item) {
store.AppendValues(item.Text, item.Size, item.LastModified, item, item.Icon);
}
@@ -262,8 +248,6 @@
info.LastWriteTime.ToString()
));
}
-
- //EndUpdate();
}
public class FileListItem
@@ -325,6 +309,14 @@
FullName = fullname.Substring (1);
icon = FileIconLoader.GetPixbufForFile (FullName, 24, 24);
}
+
+ public FileListItem (string name)
+ {
+ FileInfo fi = new FileInfo (name);
+ this.size = Math.Round ((double) fi.Length / 1024).ToString () + " KB";
+ this.lastModified = fi.LastWriteTime.ToString ();
+ FullName = System.IO.Path.GetFullPath (name);
+ }
}
class ItemCollection {
@@ -392,83 +384,38 @@
//Splitter splitter1 = new Splitter();
FileList filelister = new FileList();
- ShellTree filetree = new ShellTree();
-
+ FileBrowser fb = new FileBrowser ();
+
public FileScout()
{
- //Dock = DockStyle.Fill;
-
- //filetree.Dock = DockStyle.Top;
- //filetree.BorderStyle = BorderStyle.Fixed3D;
- //filetree.Location = new System.Drawing.Point(0, 22);
- //filetree.Size = new System.Drawing.Size(184, 157);
- //filetree.TabIndex = 1;
- //filetree.AfterSelect += new TreeViewEventHandler(DirectorySelected);
- filetree.Selection.Changed += new EventHandler(OnDirChanged);
- //ImageList imglist = new ImageList();
- //imglist.ColorDepth = ColorDepth.Depth32Bit;
- /*imglist.Images.Add(resourceService.GetBitmap("Icons.16x16.ClosedFolderBitmap"));
- imglist.Images.Add(resourceService.GetBitmap("Icons.16x16.OpenFolderBitmap"));
- imglist.Images.Add(resourceService.GetBitmap("Icons.16x16.FLOPPY"));
- imglist.Images.Add(resourceService.GetBitmap("Icons.16x16.DRIVE"));
- imglist.Images.Add(resourceService.GetBitmap("Icons.16x16.CDROM"));
- imglist.Images.Add(resourceService.GetBitmap("Icons.16x16.NETWORK"));
- imglist.Images.Add(resourceService.GetBitmap("Icons.16x16.Desktop"));
- imglist.Images.Add(resourceService.GetBitmap("Icons.16x16.PersonalFiles"));
- imglist.Images.Add(resourceService.GetBitmap("Icons.16x16.MyComputer"));*/
-
- //filetree.ImageList = imglist;
-
- //filelister.Dock = DockStyle.Fill;
- //filelister.BorderStyle = BorderStyle.Fixed3D;
- //filelister.Location = new System.Drawing.Point(0, 184);
-
- //filelister.Sorting = SortOrder.Ascending;
- //filelister.Size = new System.Drawing.Size(184, 450);
- //filelister.TabIndex = 3;
- //filelister.ItemActivate += new EventHandler(FileSelected);
+ fb.TreeView.Selection.Changed += new EventHandler (OnDirChanged);
filelister.RowActivated += new GtkSharp.RowActivatedHandler(FileSelected);
-
- //splitter1.Dock = DockStyle.Top;
- //splitter1.Location = new System.Drawing.Point(0, 179);
- //splitter1.Size = new System.Drawing.Size(184, 5);
- //splitter1.TabIndex = 2;
- //splitter1.TabStop = false;
- //splitter1.MinSize = 50;
- //splitter1.MinExtra = 50;
-
- //this.Controls.Add(filelister);
- //this.Controls.Add(splitter1);
- //this.Controls.Add(filetree);
-
- Gtk.ScrolledWindow treesw = new Gtk.ScrolledWindow ();
- treesw.Add(filetree);
Gtk.Frame treef = new Gtk.Frame();
- treef.Add(treesw);
+ treef.Add(fb);
Gtk.ScrolledWindow listsw = new Gtk.ScrolledWindow ();
listsw.Add(filelister);
Gtk.Frame listf = new Gtk.Frame();
listf.Add(listsw);
-
Pack1(treef, true, true);
Pack2(listf, true, true);
}
void OnDirChanged(object sender, EventArgs args)
-/* void DirectorySelected(object sender, TreeViewEventArgs e)*/
{
- //filelister.ShowFilesInPath(filetree.NodePath + System.IO.Path.DirectorySeparatorChar);
- if (filetree.NodePath.Length == 0) return;
- if (filetree.NodePath[filetree.NodePath.Length - 1] == System.IO.Path.DirectorySeparatorChar)
- filelister.ShowFilesInPath(filetree.NodePath);
- else
- filelister.ShowFilesInPath(filetree.NodePath + System.IO.Path.DirectorySeparatorChar);
+ foreach (string f in fb.Files)
+ {
+ //FIXME: hack to ignore . files
+ if (!(System.IO.Path.GetFileName (f)).StartsWith ("."))
+ {
+ FileList.FileListItem it = new FileList.FileListItem (f);
+ filelister.ItemAdded (it);
+ }
+ }
}
-// void FileSelected(object sender, EventArgs e)
void FileSelected(object sender, GtkSharp.RowActivatedArgs e)
{
IProjectService projectService = (IProjectService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IProjectService));
@@ -490,6 +437,7 @@
projectService.OpenCombine(item.FullName);
break;
default:
+ Console.WriteLine (item.FullName);
fileService.OpenFile(item.FullName);
break;
}
@@ -512,210 +460,4 @@
public event EventHandler TitleChanged;
public event EventHandler IconChanged;
}
-
- public class ShellTree : TreeView
- {
- public string NodePath {
- get {
- if (SelectedNode == null) {
- return "";
- }
- return (string)SelectedNode.Tag;
- }
- set {
- PopulateShellTree(value);
- }
- }
-
- public ShellTree()
- {
- //Sorted = true;
- TreeNode rootNode = Nodes.Add("/");
- rootNode.Tag = "/";
- //rootNode.ImageIndex = 6;
- //rootNode.SelectedImageIndex = 6;
- //rootNode.Tag = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
- rootNode.Nodes.Add("");
- PopulateSubDirectory(rootNode, 1);
-
-
-
- //TreeNode myFilesNode = rootNode.Nodes.Add("My Documents");
- //myFilesNode.ImageIndex = 7;
- //myFilesNode.SelectedImageIndex = 7;
- //myFilesNode.Tag = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
- //myFilesNode.Nodes.Add("");
-
- //TreeNode computerNode = rootNode.Nodes.Add("My Computer");
- //computerNode.ImageIndex = 8;
- //computerNode.SelectedImageIndex = 8;
- //computerNode.Tag = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
- /*
- foreach (string driveName in Environment.GetLogicalDrives()) {
- DriveObject drive = new DriveObject(driveName);
-
- TreeNode node = new TreeNode(drive.ToString());
- node.Nodes.Add(new TreeNode(""));
- node.Tag = driveName.Substring(0, driveName.Length - 1);
- computerNode.Nodes.Add(node);
-
- FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.Services.GetService(typeof(FileUtilityService));
-
- switch(DriveObject.GetDriveType(driveName)) {
- case DriveType.Removeable:
- node.ImageIndex = node.SelectedImageIndex = 2;
- break;
- case DriveType.Fixed:
- node.ImageIndex = node.SelectedImageIndex = 3;
- break;
- case DriveType.Cdrom:
- node.ImageIndex = node.SelectedImageIndex = 4;
- break;
- case DriveType.Remote:
- node.ImageIndex = node.SelectedImageIndex = 5;
- break;
- default:
- node.ImageIndex = node.SelectedImageIndex = 3;
- break;
- }
- }
-
- foreach (string directory in Directory.GetDirectories(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))) {
- TreeNode node = rootNode.Nodes.Add(Path.GetFileName(directory));
- node.Tag = directory;
- node.ImageIndex = node.SelectedImageIndex = 0;
- node.Nodes.Add(new TreeNode(""));
- }
-
- rootNode.Expand();
- computerNode.Expand();
- */
- InitializeComponent();
- }
-
- int getNodeLevel(TreeNode node)
- {
- TreeNode parent = node;
- int depth = 0;
-
- while(true)
- {
- parent = parent.Parent;
- if(parent == null) {
- return depth;
- }
- depth++;
- }
- }
-
- void InitializeComponent ()
- {
- //BeforeSelect += new TreeViewCancelEventHandler(SetClosedIcon);
- //AfterSelect += new TreeViewEventHandler(SetOpenedIcon);
- }
-
-/*
- void SetClosedIcon(object sender, TreeViewCancelEventArgs e) // Set icon as closed
- {
- if (SelectedNode != null) {
- if(getNodeLevel(SelectedNode) > 2) {
- SelectedNode.ImageIndex = SelectedNode.SelectedImageIndex = 0;
- }
- }
- }
-
- void SetOpenedIcon(object sender, TreeViewEventArgs e) // Set icon as opened
- {
- if(getNodeLevel(e.Node) > 2) {
- if (e.Node.Parent != null && e.Node.Parent.Parent != null) {
- e.Node.ImageIndex = e.Node.SelectedImageIndex = 1;
- }
- }
- }
-*/
- void PopulateShellTree(string path)
- {
- string[] pathlist = path.Split(new char[] { System.IO.Path.DirectorySeparatorChar });
-
- TreeNodeCollection curnode = Nodes;
-
- foreach(string dir in pathlist) {
- foreach(TreeNode childnode in curnode) {
- if (((string)childnode.Tag).ToUpper().Equals(dir.ToUpper())) {
- SelectedNode = childnode;
-
- PopulateSubDirectory(childnode, 2);
- childnode.Expand();
-
- curnode = childnode.Nodes;
- break;
- }
- }
- }
- }
-
- void PopulateSubDirectory(TreeNode curNode, int depth)
- {
- if (--depth < 0) {
- return;
- }
-
- if (curNode.Nodes.Count == 1 && curNode.Nodes[0].Text.Equals("")) {
-
- string[] directories = null;
- try {
- directories = Directory.GetDirectories(curNode.Tag.ToString() + System.IO.Path.DirectorySeparatorChar);
- } catch (Exception) {
- return;
- }
-
- curNode.Nodes.Clear();
-
- foreach (string fulldir in directories) {
- try {
- string dir = System.IO.Path.GetFileName(fulldir);
-
- if (dir == null || dir.Length == 0 || dir[0] == '.') {
- continue;
- }
- FileAttributes attr = File.GetAttributes(fulldir);
- if ((attr & FileAttributes.Hidden) == 0) {
- TreeNode node = curNode.Nodes.Add(dir);
- node.Tag = curNode.Tag.ToString() + System.IO.Path.DirectorySeparatorChar + dir;
- //node.ImageIndex = node.SelectedImageIndex = 0;
-
- node.Nodes.Add(""); // Add dummy child node to make node expandable
-
- PopulateSubDirectory(node, depth);
- }
- } catch (Exception) {
- }
- }
- } else {
- foreach (TreeNode node in curNode.Nodes) {
- PopulateSubDirectory(node, depth); // Populate sub directory
- }
- }
- }
-
- protected override void OnBeforeExpand(TreeViewCancelEventArgs e)
- {
- //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 {
- PopulateSubDirectory(e.Node, 1);
- //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;
- }
- }
}
More information about the Monodevelop-patches-list
mailing list