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 public class ChangesetView
: Gtk
.VPaned
, IExploreViewChild
14 private Gtk
.ListStore changesetListStore
;
15 private Gtk
.ListStore changesetDetailStore
;
16 private Driver driver
;
17 private Gtk
.TextBuffer textBuffer
;
18 private Gtk
.TreeView changesetList
;
19 private Gtk
.TreeView changesetDetail
;
20 private int stopAfter
;
22 public void InitializeChangesetList()
24 changesetList
= new Gtk
.TreeView();
26 changesetList
.AppendColumn ("Id", new Gtk
.CellRendererText (), "text", 0);
27 changesetList
.AppendColumn ("Owner", new Gtk
.CellRendererText (), "text", 1);
28 changesetList
.AppendColumn ("Date", new Gtk
.CellRendererText (), "text", 2);
29 changesetList
.AppendColumn ("Comment", new Gtk
.CellRendererText (), "text", 3);
31 changesetListStore
= new Gtk
.ListStore (typeof(string), typeof(string), typeof(string), typeof(string));
32 changesetList
.Model
= changesetListStore
;
33 changesetList
.Selection
.Changed
+= OnSelectionChanged
;
36 public void InitializeChangesetDetail()
38 changesetDetail
= new Gtk
.TreeView();
40 changesetDetail
.AppendColumn ("Type", new Gtk
.CellRendererText (), "text", 0);
41 changesetDetail
.AppendColumn ("File", new Gtk
.CellRendererText (), "text", 1);
43 changesetDetailStore
= new Gtk
.ListStore (typeof(string), typeof(string));
44 changesetDetail
.Model
= changesetDetailStore
;
47 public ChangesetView(Driver driver
, int stopAfter
)
50 this.stopAfter
= stopAfter
;
52 InitializeChangesetList();
53 InitializeChangesetDetail();
55 #if HAVE_ATLEAST_GTK_210
56 changesetList
.EnableGridLines
= TreeViewGridLines
.Vertical
;
57 changesetDetail
.EnableGridLines
= TreeViewGridLines
.Horizontal
;
60 ScrolledWindow scrolledWindow1
= new ScrolledWindow();
61 scrolledWindow1
.Add(changesetList
);
63 Add1(scrolledWindow1
);
65 ScrolledWindow scrolledWindow2
= new ScrolledWindow();
66 Add2(scrolledWindow2
);
68 int x
, y
, width
, height
, depth
;
69 RootWindow
.GetGeometry (out x
, out y
, out width
, out height
, out depth
);
70 Position
= Convert
.ToInt32((height
- 40) * 0.4);
72 scrolledWindow2
.Add(changesetDetail
);
75 protected DiffOptions
GetDiffOptions(StreamWriter writer
)
77 DiffOptions options
= new DiffOptions();
78 options
.UseThirdPartyTool
= false;
79 options
.Flags
= DiffOptionFlags
.EnablePreambleHandling
;
80 options
.OutputType
= DiffOutputType
.Unified
;
81 options
.TargetEncoding
= Encoding
.UTF8
;
82 options
.SourceEncoding
= Encoding
.UTF8
;
83 options
.StreamWriter
= writer
;
84 options
.StreamWriter
.AutoFlush
= true;
89 void OnSelectionChanged (object o
, EventArgs args
)
94 TreeSelection treeSelection
= o
as TreeSelection
;
95 if (!(treeSelection
.GetSelected (out model
, out iter
))) return;
97 changesetDetailStore
.Clear();
99 int cid
= Convert
.ToInt32(model
.GetValue (iter
, 0));
100 Changeset changeset
= driver
.VersionControlServer
.GetChangeset(cid
, true, false);
102 foreach (Change change
in changeset
.Changes
)
104 changesetDetailStore
.AppendValues(Command
.ChangeTypeToString(change
.ChangeType
), change
.Item
.ServerItem
);
108 void OnSelectionChanged2 (object o
, EventArgs args
)
113 TreeSelection treeSelection
= o
as TreeSelection
;
114 if (!(treeSelection
.GetSelected (out model
, out iter
))) return;
116 string cid
= (string) model
.GetValue (iter
, 0);
117 ChangesetVersionSpec versionSpec
= new ChangesetVersionSpec(cid
);
119 Toplevel
.GdkWindow
.Cursor
= new Gdk
.Cursor(Gdk
.CursorType
.Watch
);
121 string tname
= System
.IO
.Path
.GetTempFileName();
122 using (StreamWriter sw
= new StreamWriter(tname
))
124 DiffHelper
.ShowChangeset(driver
.VersionControlServer
, versionSpec
,
125 false, GetDiffOptions(sw
));
128 using (StreamReader sr
= new StreamReader(tname
))
130 textBuffer
.Text
= sr
.ReadToEnd();
133 Toplevel
.GdkWindow
.Cursor
= new Gdk
.Cursor(Gdk
.CursorType
.LeftPtr
);
137 public void UpdatePath(string path
)
139 if (String
.IsNullOrEmpty(path
)) return;
141 changesetListStore
.Clear();
142 changesetDetailStore
.Clear();
144 bool detailed
= false;
145 IEnumerable changeSets
= driver
.VersionControlServer
.QueryHistory(path
, VersionSpec
.Latest
, 0, RecursionType
.Full
, null,
146 null, null, stopAfter
, detailed
, false, false);
148 foreach (Changeset changeSet
in changeSets
)
150 changesetListStore
.AppendValues(changeSet
.ChangesetId
.ToString(),
152 changeSet
.CreationDate
.ToString("d"),
156 // this would be nice be seems to cause a segfault
157 //changesetList.ColumnsAutosize();