From 6c739360cb99b3a702ec88a86928cea8c60be4fd Mon Sep 17 00:00:00 2001 From: "Joel W. Reed" Date: Tue, 27 Nov 2007 22:25:19 -0500 Subject: [PATCH] gui.control.q.and.WorkingFolderDialog --- class/Gtk.TeamFoundation/DirectoryView.cs | 16 +++--- class/Gtk.TeamFoundation/Gtk.TeamFoundation.csproj | 3 +- class/Gtk.TeamFoundation/RepositoryDialog.cs | 2 + class/Gtk.TeamFoundation/RepositoryMenu.cs | 32 ++++++++---- class/Gtk.TeamFoundation/RepositoryView.cs | 2 +- ...{RepositoryDialog.cs => WorkingFolderDialog.cs} | 59 ++++++++++++++-------- tools/opentf/ExploreCommand.cs | 14 +++-- 7 files changed, 80 insertions(+), 48 deletions(-) copy class/Gtk.TeamFoundation/{RepositoryDialog.cs => WorkingFolderDialog.cs} (59%) diff --git a/class/Gtk.TeamFoundation/DirectoryView.cs b/class/Gtk.TeamFoundation/DirectoryView.cs index d620c78..cce2e6d 100644 --- a/class/Gtk.TeamFoundation/DirectoryView.cs +++ b/class/Gtk.TeamFoundation/DirectoryView.cs @@ -69,9 +69,9 @@ namespace Gtk.TeamFoundation column.AddAttribute(crp, "pixbuf", 0); column.AddAttribute(crt, "text", 1); directoryList.AppendColumn(column); - AppendColumn("Status", 1); - AppendColumn("Owner", 2); - AppendColumn("Latest", 3); + AppendColumn("Status", 2); + AppendColumn("Owner", 3); + AppendColumn("Latest", 4); directoryList.Selection.Mode = SelectionMode.Multiple; directoryList.KeyReleaseEvent += MyKeyReleaseEventHandler; @@ -130,18 +130,14 @@ namespace Gtk.TeamFoundation foreach (ExtendedItem item in items) { + string shortPath = item.TargetServerItem.Substring(item.TargetServerItem.LastIndexOf('/') + 1); string latest = item.IsLatest ? "Yes" : "No"; + string status = item.LockStatus.ToString(); if (status == "None") status = String.Empty; - string shortPath = item.TargetServerItem.Substring(item.TargetServerItem.LastIndexOf('/') + 1); Gdk.Pixbuf pixbuf = Images.File; - - if (item.ItemType == ItemType.Folder) - { - shortPath += "/"; - pixbuf = Images.Folder; - } + if (item.ItemType == ItemType.Folder) pixbuf = Images.Folder; directoryListStore.AppendValues(pixbuf, shortPath, status, item.LockOwner, latest, item.TargetServerItem); } diff --git a/class/Gtk.TeamFoundation/Gtk.TeamFoundation.csproj b/class/Gtk.TeamFoundation/Gtk.TeamFoundation.csproj index 862a2e7..f559e92 100644 --- a/class/Gtk.TeamFoundation/Gtk.TeamFoundation.csproj +++ b/class/Gtk.TeamFoundation/Gtk.TeamFoundation.csproj @@ -51,6 +51,7 @@ + @@ -81,4 +82,4 @@ - + diff --git a/class/Gtk.TeamFoundation/RepositoryDialog.cs b/class/Gtk.TeamFoundation/RepositoryDialog.cs index 87799ff..57fedfc 100644 --- a/class/Gtk.TeamFoundation/RepositoryDialog.cs +++ b/class/Gtk.TeamFoundation/RepositoryDialog.cs @@ -83,6 +83,8 @@ namespace Gtk.TeamFoundation name.Text = workspace.Name; server.Text = workspace.VersionControlServer.TeamFoundationServer.Uri.Host.ToString(); } + + ShowAll(); } } } \ No newline at end of file diff --git a/class/Gtk.TeamFoundation/RepositoryMenu.cs b/class/Gtk.TeamFoundation/RepositoryMenu.cs index 501eda0..5711be1 100644 --- a/class/Gtk.TeamFoundation/RepositoryMenu.cs +++ b/class/Gtk.TeamFoundation/RepositoryMenu.cs @@ -41,11 +41,13 @@ namespace Gtk.TeamFoundation { //MenuItem MenuItem getLatestItem; - MenuItem setWorkingFolderItem; + MenuItem workingFolderItem; MenuItem addRepoItem; MenuItem editRepoItem; MenuItem deleteRepoItem; + Workspace currentWorkspace; + string currentPath; public MenuItem GetLatestItem { @@ -56,15 +58,15 @@ namespace Gtk.TeamFoundation { getLatestItem = AddImageMenuItem("Get Latest", Images.Update); - setWorkingFolderItem = AddImageMenuItem("Set Working Folder", Images.Folder); - setWorkingFolderItem.Activated += SetWorkingFolderHandler; + workingFolderItem = AddImageMenuItem("Working Folder...", Images.Folder); + workingFolderItem.Activated += WorkingFolderHandler; Append(new SeparatorMenuItem()); - addRepoItem = AddImageMenuItem("Add Repository", Stock.Add); + addRepoItem = AddImageMenuItem("Add Repository...", Stock.Add); addRepoItem.Activated += AddRepositoryHandler; - editRepoItem = AddImageMenuItem("Edit Repository", Stock.Edit); + editRepoItem = AddImageMenuItem("Edit Repository...", Stock.Edit); editRepoItem.Activated += EditRepositoryHandler; deleteRepoItem = AddImageMenuItem("Delete Repository", Stock.Delete); @@ -75,22 +77,23 @@ namespace Gtk.TeamFoundation public void Show(Workspace workspace, string path) { bool root_folder = (path == VersionControlPath.RootFolder); + bool path_mapped = workspace.IsServerPathMapped(path); - getLatestItem.Sensitive = !root_folder; - setWorkingFolderItem.Sensitive = !root_folder; + getLatestItem.Sensitive = (path_mapped && !root_folder); + workingFolderItem.Sensitive = !root_folder; editRepoItem.Sensitive = root_folder; deleteRepoItem.Sensitive = root_folder; currentWorkspace = workspace; + currentPath = path; + Popup(); } public void AddRepositoryHandler(object sender, EventArgs e) { RepositoryDialog dialog = new RepositoryDialog(null); - - dialog.ShowAll(); dialog.Run(); dialog.Destroy(); } @@ -99,13 +102,20 @@ namespace Gtk.TeamFoundation { RepositoryDialog dialog = new RepositoryDialog(currentWorkspace); - dialog.ShowAll(); dialog.Run(); dialog.Destroy(); } - public void SetWorkingFolderHandler(object sender, EventArgs e) + public void WorkingFolderHandler(object sender, EventArgs e) { + WorkingFolderDialog dialog = new WorkingFolderDialog(currentWorkspace, currentPath); + + if (dialog.Run() == (int)ResponseType.Ok) + { + Console.WriteLine(dialog.LocalPath); + } + + dialog.Destroy(); } } } diff --git a/class/Gtk.TeamFoundation/RepositoryView.cs b/class/Gtk.TeamFoundation/RepositoryView.cs index dbb1939..0038a64 100644 --- a/class/Gtk.TeamFoundation/RepositoryView.cs +++ b/class/Gtk.TeamFoundation/RepositoryView.cs @@ -159,7 +159,7 @@ namespace Gtk.TeamFoundation if (!workspace.IsServerPathMapped(path)) { - (cell as Gtk.CellRendererText).Foreground = "darkgrey"; + (cell as Gtk.CellRendererText).Foreground = "dark grey"; } } diff --git a/class/Gtk.TeamFoundation/RepositoryDialog.cs b/class/Gtk.TeamFoundation/WorkingFolderDialog.cs similarity index 59% copy from class/Gtk.TeamFoundation/RepositoryDialog.cs copy to class/Gtk.TeamFoundation/WorkingFolderDialog.cs index 87799ff..06dda8b 100644 --- a/class/Gtk.TeamFoundation/RepositoryDialog.cs +++ b/class/Gtk.TeamFoundation/WorkingFolderDialog.cs @@ -1,5 +1,5 @@ // -// RepositoryDialog.cs +// WorkingFolderDialog.cs // // Authors: // Joel Reed (joelwreed@gmail.com) @@ -36,18 +36,16 @@ using Microsoft.TeamFoundation.VersionControl.Client; namespace Gtk.TeamFoundation { - public class RepositoryDialog : DialogBase + public class WorkingFolderDialog : DialogBase { - private Entry name; - private Entry server; - private Entry username; - private Entry password; + private Entry localPath; + private Button browseButton; private Button okButton; - public string Login + public string LocalPath { get { - return username.Text + "," + password.Text; + return localPath.Text; } } @@ -59,30 +57,49 @@ namespace Gtk.TeamFoundation return base.OnKeyPressEvent(evnt); } - public RepositoryDialog(Workspace workspace) : base((workspace == null)? "Add Repository" : "Edit Repository") + public WorkingFolderDialog(Workspace workspace, string path) : base("Working Folder Configuration") { - Table table = new Table(3, 2, false); + Table table = new Table(2, 3, false); table.RowSpacing = ((uint)(6)); table.ColumnSpacing = ((uint)(6)); table.BorderWidth = ((uint)(12)); - name = AddLabeledEntry(table, "_Name:", 1, 2); - server = AddLabeledEntry(table, "_Server:", 2, 3); - table.Attach(new Gtk.HSeparator(), 0, 2, 3, 4); + Label label = new Label("_Server Path: "); + table.Attach(label, 0, 1, 1, 2); + Label labelPath = new Label(path); + labelPath.Xalign = 0; + table.Attach(labelPath, 1, 2, 1, 2); + + localPath = AddLabeledEntry(table, "_Local Path:", 2, 3); + localPath.WidthChars = 32; + localPath.Text = workspace.TryGetLocalItemForServerItem(path); + + browseButton = new Button ("Browse..."); + table.Attach(browseButton, 2, 3, 2, 3); - username = AddLabeledEntry(table, "_Username:", 4, 5); - password = AddLabeledEntry(table, "_Password:", 5, 6); VBox.Add(table); okButton = AddButton ("OK", ResponseType.Ok) as Button; + browseButton.Pressed += OnBrowseButtonPressed; + AddCloseButton("Cancel"); DefaultResponse = ResponseType.Ok; - - if (workspace != null) - { - name.Text = workspace.Name; - server.Text = workspace.VersionControlServer.TeamFoundationServer.Uri.Host.ToString(); - } + ShowAll(); } + + void OnBrowseButtonPressed(object sender, EventArgs e) + { + Gtk.FileChooserDialog dialog = + new Gtk.FileChooserDialog("Choose a directory", + this, + FileChooserAction.CreateFolder, + "Cancel",ResponseType.Cancel, + "Open",ResponseType.Ok); + + if (dialog.Run() == (int)ResponseType.Ok) + localPath.Text = dialog.Filename; + + dialog.Destroy(); + } } } \ No newline at end of file diff --git a/tools/opentf/ExploreCommand.cs b/tools/opentf/ExploreCommand.cs index b712ae4..3d3bf8c 100644 --- a/tools/opentf/ExploreCommand.cs +++ b/tools/opentf/ExploreCommand.cs @@ -52,7 +52,7 @@ class ExploreCommand : Command public override void Run() { - Application.Init (); + Application.Init(); Gtk.Window frame = new Gtk.Window("OpenTF Explorer"); @@ -62,14 +62,14 @@ class ExploreCommand : Command frame.Add(view); frame.DeleteEvent += new DeleteEventHandler(DeleteEvent); + frame.KeyReleaseEvent += MyKeyReleaseHandler; int x, y, width, height, depth; frame.RootWindow.GetGeometry (out x, out y, out width, out height, out depth); frame.SetDefaultSize(Convert.ToInt32(width*.9), Convert.ToInt32(height*.9)); frame.ShowAll(); - - Application.Run (); + Application.Run(); } void MyShowChangesetEventHandler(object sender, ShowChangesetEventArgs args) @@ -100,8 +100,14 @@ class ExploreCommand : Command dialog.Destroy(); } - static void DeleteEvent (object obj, DeleteEventArgs args) + static void DeleteEvent(object obj, DeleteEventArgs args) { Application.Quit (); } + + void MyKeyReleaseHandler(object o, KeyReleaseEventArgs args) + { + if ((Gdk.Key.q == args.Event.Key) && ((args.Event.State & Gdk.ModifierType.ControlMask) != 0)) + Application.Quit (); + } } -- 2.11.4.GIT