3 using System
.Collections
;
4 using System
.Collections
.Generic
;
8 using Microsoft
.TeamFoundation
.Client
;
9 using Microsoft
.TeamFoundation
.VersionControl
.Common
;
10 using Microsoft
.TeamFoundation
.VersionControl
.Client
;
12 namespace Gtk
.TeamFoundation
14 public interface IChangesetViewChild
16 void UpdateCid(VersionControlServer vcs
, int cid
);
19 public class ChangesetView
: ScrolledWindow
, IExploreViewChild
21 private Gtk
.ListStore changesetListStore
;
22 private Gtk
.TreeView changesetList
;
23 private int stopAfter
;
24 private int currentCid
= 0;
25 private SortableColumns sortableColumns
;
26 private VersionControlServer currentVcs
;
28 private TreeViewColumn
AppendColumn(string name
, int indx
)
30 TreeViewColumn column
= changesetList
.AppendColumn (name
, new Gtk
.CellRendererText (), "text", indx
);
32 column
.Clickable
= true;
33 column
.Resizable
= true;
34 column
.SortColumnId
= indx
;
35 column
.Clicked
+= new EventHandler (sortableColumns
.OnColumnClick
);
40 public void InitializeChangesetList()
42 changesetListStore
= new Gtk
.ListStore (typeof(int), typeof(string), typeof(string), typeof(string));
43 changesetList
= new Gtk
.TreeView(changesetListStore
);
44 sortableColumns
= new SortableColumns(changesetList
, changesetListStore
);
46 TreeViewColumn id
= AppendColumn("Id", 0);
47 id
.SortIndicator
= true;
48 id
.SortOrder
= SortType
.Descending
;
50 AppendColumn("Owner", 1);
51 AppendColumn("Date", 2);
52 AppendColumn("Comment", 3);
54 changesetList
.Selection
.Mode
= SelectionMode
.Multiple
;
55 changesetList
.Selection
.Changed
+= OnSelectionChanged
;
56 changesetList
.KeyReleaseEvent
+= MyKeyReleaseEventHandler
;
58 #if HAVE_ATLEAST_GTK_210
59 changesetList
.EnableGridLines
= TreeViewGridLines
.Vertical
;
63 public ChangesetView(int stopAfter
)
65 this.stopAfter
= stopAfter
;
66 InitializeChangesetList();
70 protected void UpdateChildCid(IChangesetViewChild child
)
72 if (child
== null) return;
73 GdkWindow
.Cursor
= new Gdk
.Cursor(Gdk
.CursorType
.Watch
);
74 child
.UpdateCid(currentVcs
, currentCid
);
75 GdkWindow
.Cursor
= null;
78 void OnSelectionChanged (object o
, EventArgs args
)
83 TreeSelection treeSelection
= o
as TreeSelection
;
84 int count
= treeSelection
.CountSelectedRows();
85 if (count
== 0 || count
> 1) return;
87 TreePath
[] paths
= treeSelection
.GetSelectedRows(out model
);
88 foreach (TreePath path
in paths
)
90 model
.GetIter(out iter
, path
);
91 currentCid
= Convert
.ToInt32(model
.GetValue (iter
, 0));
95 public void UpdatePath(VersionControlServer vcs
, string path
)
97 if (String
.IsNullOrEmpty(path
)) return;
100 changesetListStore
.Clear();
102 bool detailed
= false;
103 IEnumerable changeSets
= vcs
.QueryHistory(path
, VersionSpec
.Latest
, 0, RecursionType
.Full
, null,
104 null, null, stopAfter
, detailed
, false, false);
106 foreach (Changeset changeSet
in changeSets
)
108 changesetListStore
.AppendValues(changeSet
.ChangesetId
,
110 changeSet
.CreationDate
.ToString("d"),
114 // this would be nice be seems to cause a segfault
115 //changesetList.ColumnsAutosize();
118 public void MyKeyReleaseEventHandler (object o
, KeyReleaseEventArgs args
)
120 if ((Gdk
.Key
.c
== args
.Event
.Key
) && ((args
.Event
.State
& Gdk
.ModifierType
.ControlMask
) != 0))
122 TreeIter iter
; TreeModel model
;
123 TreePath
[] paths
= changesetList
.Selection
.GetSelectedRows(out model
);
125 StringBuilder sb
= new StringBuilder();
126 foreach (TreePath path
in paths
)
128 model
.GetIter(out iter
, path
);
129 sb
.Append(String
.Format("{0} {1} {2} {3}\n",
130 Convert
.ToInt32(model
.GetValue (iter
, 0)),
131 Convert
.ToString(model
.GetValue (iter
, 1)),
132 Convert
.ToString(model
.GetValue (iter
, 2)),
133 Convert
.ToString(model
.GetValue (iter
, 3)) ));
136 Clipboard primary
= Clipboard
.Get(Gdk
.Atom
.Intern ("PRIMARY", false));
137 primary
.Text
= sb
.ToString();