view.cleanups
[tfs.git] / class / Gtk.TeamFoundation / DirectoryView.cs
blob5981b5a6e691d42a1fb9ad0e2a59898d091e2135
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);
39 private TreeViewColumn AppendColumn(string name, int indx)
41 TreeViewColumn column = directoryList.AppendColumn (name, new Gtk.CellRendererText (), "text", indx);
43 column.Clickable = true;
44 column.Resizable = true;
45 column.SortColumnId = indx;
46 column.Clicked += new EventHandler (sortableColumns.OnColumnClick);
48 return column;
51 public void UpdatePath(VersionControlServer vcs, string path)
53 if (String.IsNullOrEmpty(path)) return;
54 directoryListStore.Clear();
56 ExtendedItem[] items = vcs.GetExtendedItems (path, DeletedState.NonDeleted, ItemType.Any);
58 foreach (ExtendedItem item in items)
60 string latest = item.IsLatest ? "Yes" : "No";
62 string status = item.LockStatus.ToString();
63 if (status == "None") status = String.Empty;
65 string shortPath = item.TargetServerItem.Substring(item.TargetServerItem.LastIndexOf('/') + 1);
66 if (item.ItemType == ItemType.Folder) shortPath += "/";
68 directoryListStore.AppendValues(shortPath, status, item.LockOwner, latest);
71 // this would be nice be seems to cause a segfault
72 //changesetList.ColumnsAutosize();