2 // WorkingFolderDialog.cs
5 // Joel Reed (joelwreed@gmail.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using Microsoft
.TeamFoundation
.Client
;
34 using Microsoft
.TeamFoundation
.VersionControl
.Common
;
35 using Microsoft
.TeamFoundation
.VersionControl
.Client
;
37 namespace Gtk
.TeamFoundation
39 public class WorkingFolderDialog
: DialogBase
41 private string serverPath
;
42 private Entry localPath
;
43 private Button browseButton
;
44 private Button okButton
;
45 private Button deleteButton
;
47 public string LocalPath
49 get { return localPath.Text; }
52 public string ServerPath
54 get { return serverPath; }
57 protected override bool OnKeyPressEvent(Gdk
.EventKey evnt
)
59 if (evnt
.Key
== Gdk
.Key
.Return
)
62 return base.OnKeyPressEvent(evnt
);
65 public WorkingFolderDialog(Workspace workspace
, string serverPath
) : base("Working Folder Mapping")
67 this.serverPath
= serverPath
;
68 Table table
= new Table(3, 3, false);
69 table
.RowSpacing
= ((uint)(6));
70 table
.ColumnSpacing
= ((uint)(6));
71 table
.BorderWidth
= ((uint)(12));
73 Label label
= new Label("_Server Path: ");
74 table
.Attach(label
, 0, 1, 1, 2);
75 Label labelPath
= new Label(serverPath
);
77 table
.Attach(labelPath
, 1, 2, 1, 2);
79 localPath
= AddLabeledEntry(table
, "_Local Path:", 2, 3);
80 localPath
.WidthChars
= 32;
82 browseButton
= new Button("Browse...");
83 table
.Attach(browseButton
, 2, 3, 2, 3);
85 string lpath
= workspace
.TryGetLocalItemForServerItem(serverPath
);
86 if (!String
.IsNullOrEmpty(lpath
))
88 localPath
.Text
= lpath
;
89 deleteButton
= new Button("Remove Working Folder Mapping");
90 table
.Attach(deleteButton
, 1, 2, 3, 4);
95 okButton
= AddButton("OK", ResponseType
.Ok
) as Button
;
96 browseButton
.Pressed
+= OnBrowseButtonPressed
;
98 AddCloseButton("Cancel");
99 DefaultResponse
= ResponseType
.Ok
;
103 void OnBrowseButtonPressed(object sender
, EventArgs e
)
105 Gtk
.FileChooserDialog dialog
=
106 new Gtk
.FileChooserDialog("Choose a directory",
108 FileChooserAction
.CreateFolder
,
109 "Cancel",ResponseType
.Cancel
,
110 "Open",ResponseType
.Ok
);
112 if (dialog
.Run() == (int)ResponseType
.Ok
)
113 localPath
.Text
= dialog
.Filename
;