public LogView(string filepath, bool isDirectory, RevisionDescription[] history, VersionControlSystem vc) : base(Path.GetFileName(filepath) + " Log") { this.vc = vc; this.filepath = filepath; ScrolledWindow scroller = new ScrolledWindow(); Viewport viewport = new Viewport(); VBox box = new VBox(false, 5); viewport.Add(box); scroller.Add(viewport); widget = scroller; foreach (RevisionDescription d in history) { RevItem revitem = new RevItem(); revitem.Path = d.RepositoryPath; revitem.Rev = d.Revision; VBox item = new VBox(false, 1); HBox header_row = new HBox(false, 2); item.PackStart(header_row, false, false, 0); Label header = new Label(d.Revision + " -- " + d.Time + " -- " + d.Author); header.Xalign = 0; header_row.Add(header); if (!isDirectory) { Button viewdiff = new Button("View Changes"); viewdiff.Clicked += new EventHandler(DiffButtonClicked); header_row.Add(viewdiff); buttons[viewdiff] = revitem; Button viewtext = new Button("View File"); viewtext.Clicked += new EventHandler(ViewTextButtonClicked); header_row.Add(viewtext); buttons[viewtext] = revitem; } TextView message = new TextView(); message.Editable = false; message.WrapMode = Gtk.WrapMode.WordChar; message.Buffer.Text = d.Message == "" ? "No message." : d.Message; item.PackStart(message, false, false, 0); box.PackStart(item, false, false, 0); } widget.ShowAll(); }
private void Update() { showRemoteStatus.Sensitive = !remoteStatus; if (statuses.Length == 0) { if (!remoteStatus) this.status.Text = "No files have local modifications."; else this.status.Text = "No files have local or remote modifications."; return; } buttonsShowLog = new Hashtable(); buttonsShowDiff = new Hashtable(); box.Remove(this.status); this.status = null; if (vc.CanCommit(filepath)) buttonCommit.Sensitive = true; checkCommit = new Hashtable(); table = new Table((uint)statuses.Length+1, (uint)5 + (uint)(remoteStatus ? 2 : 0), false); box.Add(table); uint row = 0; table.Attach(new HeaderLabel("Status"), 0, 3, row, row+1, AttachOptions.Shrink, AttachOptions.Shrink, 2, 2); table.Attach(new HeaderLabel("Path"), 3, 4, row, row+1, AttachOptions.Shrink, AttachOptions.Shrink, 2, 2); if (remoteStatus) table.Attach(new HeaderLabel("Remote Status"), 4, 6, row, row+1, AttachOptions.Shrink, AttachOptions.Shrink, 2, 2); for (int i = 0; i < statuses.Length; i++) { Node n = statuses[i]; RevItem item = new RevItem(); item.Path = n.LocalPath; item.BaseRev = n.BaseRevision; uint col = 0; row++; CheckButton check = new CheckButton(); checkCommit[check] = item; table.Attach(check, col, ++col, row, row+1, AttachOptions.Shrink, AttachOptions.Shrink, 2, 2); check.Visible = false; Gdk.Pixbuf statusicon = VersionControlService.LoadIconForStatus(n.Status); if (n.Status == NodeStatus.Modified) { Button b = new Button(); if (statusicon != null) { Image img = new Image(statusicon); img.Show(); b.Add(img); } else { b.Label = "Diff"; } b.Relief = ReliefStyle.Half; buttonsShowDiff[b] = item; table.Attach(b, col, ++col, row, row+1, AttachOptions.Shrink, AttachOptions.Shrink, 2, 2); b.Clicked += new EventHandler(OnShowDiffClicked); b.Show(); } else if (statusicon != null) { Image img = new Image(statusicon); img.Show(); table.Attach(img, col, ++col, row, row+1, AttachOptions.Shrink, AttachOptions.Fill, 2, 2); } else { ++col; } Label status = new Label(n.Status.ToString()); status.Show(); table.Attach(status, col, ++col, row, row+1, AttachOptions.Shrink, AttachOptions.Shrink, 2, 2); Label name = new Label(); // I can't get this to left align! name.Justify = Justification.Left; name.Layout.Alignment = Pango.Alignment.Left; name.Xalign = 0; string localpath = n.LocalPath.Substring(filepath.Length); if (localpath.Length > 0 && localpath[0] == Path.DirectorySeparatorChar) localpath = localpath.Substring(1); if (localpath == "") { localpath = "."; } // not sure if this happens name.Text = localpath; name.Show(); table.Attach(name, col, ++col, row, row+1, AttachOptions.Expand, AttachOptions.Shrink, 2, 2); if (remoteStatus) { Label rstatus = new Label(n.RemoteStatus.ToString()); rstatus.Show(); table.Attach(rstatus, col, ++col, row, row+1, AttachOptions.Shrink, AttachOptions.Shrink, 2, 2); if (n.RemoteStatus == NodeStatus.Modified) { Button b = new Button("View"); b.Relief = ReliefStyle.Half; buttonsShowLog[b] = item; table.Attach(b, col, ++col, row, row+1, AttachOptions.Shrink, AttachOptions.Shrink, 2, 2); b.Clicked += new EventHandler(OnShowLogClicked); b.Show(); } } } table.Show(); }