first.working.version
[tfs.git] / class / Gtk.TeamFoundation / DirectoryView.cs
blobb421443acbb02ba022c8d4f50095b5e43531d195
1 using System;
2 using System.IO;
3 using System.Collections;
4 using System.Collections.Generic;
5 using System.Net;
6 using System.Text;
7 using Gtk;
8 using Microsoft.TeamFoundation.Client;
9 using Microsoft.TeamFoundation.VersionControl.Common;
10 using Microsoft.TeamFoundation.VersionControl.Client;
12 namespace Gtk.TeamFoundation
14 public class DirectoryView : Gtk.ScrolledWindow, IExploreViewChild
16 private Gtk.TreeView directoryList;
17 private Gtk.ListStore directoryListStore;
18 private SortableColumns sortableColumns;
20 public DirectoryView()
22 directoryList = new Gtk.TreeView();
24 directoryListStore = new Gtk.ListStore (typeof(string), typeof(string), typeof(string), typeof(string));
25 directoryList.Model = directoryListStore;
26 sortableColumns = new SortableColumns(directoryList, directoryListStore);
28 #if HAVE_ATLEAST_GTK_210
29 directoryList.EnableGridLines = TreeViewGridLines.Vertical;
30 #endif
31 AppendColumn ("Name", 0);
32 AppendColumn ("Status", 1);
33 AppendColumn ("Owner", 2);
34 AppendColumn ("Latest", 3);
36 Add(directoryList);
38 int x, y, width, height, depth;
39 RootWindow.GetGeometry (out x, out y, out width, out height, out depth);
42 private TreeViewColumn AppendColumn(string name, int indx)
44 TreeViewColumn column = directoryList.AppendColumn (name, new Gtk.CellRendererText (), "text", indx);
46 column.Clickable = true;
47 column.Resizable = true;
48 column.SortColumnId = indx;
49 column.Clicked += new EventHandler (sortableColumns.OnColumnClick);
51 return column;
54 public void UpdatePath(VersionControlServer vcs, string path)
56 if (String.IsNullOrEmpty(path)) return;
57 directoryListStore.Clear();
59 ExtendedItem[] items = vcs.GetExtendedItems (path, DeletedState.NonDeleted, ItemType.Any);
61 foreach (ExtendedItem item in items)
63 string latest = item.IsLatest ? "Yes" : "No";
65 string status = item.LockStatus.ToString();
66 if (status == "None") status = String.Empty;
68 string shortPath = item.TargetServerItem.Substring(item.TargetServerItem.LastIndexOf('/') + 1);
69 if (item.ItemType == ItemType.Folder) shortPath += "/";
71 directoryListStore.AppendValues(shortPath, status, item.LockOwner, latest);
74 // this would be nice be seems to cause a segfault
75 //changesetList.ColumnsAutosize();