root.node
[tfs.git] / tools / tf / ExploreView.cs
bloba1857d300b9db8d6893fee2fcc61bdba225e7b37
1 using System;
2 using Gtk;
4 public interface IExploreViewChild
6 void UpdatePath(string path);
9 public class ExploreView : Gtk.Window
11 private RepositoryView repositoryView;
12 private ChangesetView changesetView;
13 private DirectoryView directoryView;
14 private FileView fileView;
15 private Notebook viewChildren;
16 private string currentSelectedPath;
18 public ExploreView(Driver driver, int stopAfter) : base ("Explore")
20 int x, y, width, height, depth;
21 RootWindow.GetGeometry (out x, out y, out width, out height, out depth);
22 SetDefaultSize (width - 50, height - 40);
24 VBox vBox = new VBox(false, 1);
25 Add(vBox);
27 HPaned hPaned = new HPaned();
28 vBox.Add(hPaned);
30 ScrolledWindow scrolledWindow = new ScrolledWindow();
31 //scrolledWindow.SetDefaultSize (Convert.ToInt32((width - 50) * 0.4), height -40);
32 hPaned.Add1(scrolledWindow);
34 repositoryView = new RepositoryView(driver);
35 scrolledWindow.Add(repositoryView);
37 viewChildren = new Notebook ();
39 changesetView = new ChangesetView(driver, stopAfter);
40 viewChildren.AppendPage (changesetView, new Label ("Changeset View"));
42 directoryView = new DirectoryView(driver);
43 viewChildren.AppendPage (directoryView, new Label ("Directory View"));
45 fileView = new FileView(driver);
46 viewChildren.AppendPage (fileView, new Label ("File View"));
48 hPaned.Add2(viewChildren);
49 hPaned.Position = (width - 50) / 2;
51 // add status bar
52 Statusbar sb = new Statusbar ();
53 sb.HasResizeGrip = false;
54 vBox.PackEnd(sb, false, false, 1);
56 ShowAll();
58 repositoryView.Selection.Changed += OnPathSelectionChanged;
59 viewChildren.SwitchPage += OnSwitchPage;
62 void OnPathSelectionChanged (object o, EventArgs args)
64 TreeIter iter;
65 TreeModel model;
67 if (!((TreeSelection)o).GetSelected (out model, out iter)) return;
69 currentSelectedPath = (string) model.GetValue (iter, 1);
70 //Console.WriteLine ("{0} was selected", path);
72 IExploreViewChild child = viewChildren.CurrentPageWidget as IExploreViewChild;
73 UpdateChildPath(child);
76 public void OnSwitchPage (object o, SwitchPageArgs args)
78 IExploreViewChild child = viewChildren.GetNthPage((int)args.PageNum) as IExploreViewChild;
79 UpdateChildPath(child);
82 protected void UpdateChildPath(IExploreViewChild child)
84 GdkWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Watch);
85 child.UpdatePath(currentSelectedPath);
86 GdkWindow.Cursor = null;
89 protected override bool OnDeleteEvent (Gdk.Event ev)
91 Application.Quit ();
92 return true;