Skip to content

Commit bbaff21

Browse files
committed
Add back the template folders preferences page
Implement the FolderListSelector in XWT since this UI widget no longer exists in VS Mac 17.0
1 parent c62b04a commit bbaff21

File tree

4 files changed

+375
-218
lines changed

4 files changed

+375
-218
lines changed
Lines changed: 53 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,57 @@
1-
////
2-
//// TemplateFoldersOptionsPanel.cs
3-
////
4-
//// Author:
5-
//// Matt Ward <matt.ward@xamarin.com>
6-
////
7-
//// Copyright (c) 2017 Xamarin Inc. (http://xamarin.com)
8-
////
9-
//// Permission is hereby granted, free of charge, to any person obtaining a copy
10-
//// of this software and associated documentation files (the "Software"), to deal
11-
//// in the Software without restriction, including without limitation the rights
12-
//// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13-
//// copies of the Software, and to permit persons to whom the Software is
14-
//// furnished to do so, subject to the following conditions:
15-
////
16-
//// The above copyright notice and this permission notice shall be included in
17-
//// all copies or substantial portions of the Software.
18-
////
19-
//// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20-
//// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21-
//// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22-
//// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23-
//// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24-
//// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25-
//// THE SOFTWARE.
1+
//
2+
// TemplateFoldersOptionsPanel.cs
3+
//
4+
// Author:
5+
// Matt Ward <matt.ward@xamarin.com>
6+
//
7+
// Copyright (c) 2017 Xamarin Inc. (http://xamarin.com)
8+
//
9+
// Permission is hereby granted, free of charge, to any person obtaining a copy
10+
// of this software and associated documentation files (the "Software"), to deal
11+
// in the Software without restriction, including without limitation the rights
12+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
// copies of the Software, and to permit persons to whom the Software is
14+
// furnished to do so, subject to the following conditions:
15+
//
16+
// The above copyright notice and this permission notice shall be included in
17+
// all copies or substantial portions of the Software.
18+
//
19+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
// THE SOFTWARE.
2626

27-
//using MonoDevelop.Components;
28-
//using MonoDevelop.Ide.Gui.Dialogs;
27+
using AppKit;
28+
using MonoDevelop.Components;
29+
using MonoDevelop.Ide.Gui.Dialogs;
2930

30-
//namespace MonoDevelop.Templating.Gui
31-
//{
32-
// class TemplateFoldersOptionsPanel : OptionsPanel
33-
// {
34-
// TemplateFoldersOptionsViewModel viewModel;
31+
namespace MonoDevelop.Templating.Gui
32+
{
33+
class TemplateFoldersOptionsPanel : OptionsPanel
34+
{
35+
TemplateFoldersOptionsViewModel viewModel;
3536

36-
// public override void ApplyChanges ()
37-
// {
38-
// viewModel.Save ();
39-
// }
37+
public override void ApplyChanges ()
38+
{
39+
viewModel.Save ();
40+
}
4041

41-
// public override Control CreatePanelWidget ()
42-
// {
43-
// viewModel = new TemplateFoldersOptionsViewModel ();
44-
// return new TemplateFoldersOptionsWidget (viewModel);
45-
// }
46-
// }
47-
//}
42+
public override Control CreatePanelWidget ()
43+
{
44+
viewModel = new TemplateFoldersOptionsViewModel ();
45+
var widget = new TemplateFoldersOptionsWidget (viewModel);
46+
47+
// Workaround the options panel not displaying by setting
48+
// an explicit height constraint.
49+
var view = (NSView)widget.Surface.NativeWidget;
50+
NSLayoutConstraint heightConstraint = view.HeightAnchor.ConstraintEqualTo (340f);
51+
heightConstraint.Priority = (int)NSLayoutPriority.DefaultLow;
52+
heightConstraint.Active = true;
53+
54+
return view;
55+
}
56+
}
57+
}
Lines changed: 104 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,104 @@
1-
////
2-
//// TemplateFoldersOptionsWidget.UI.cs
3-
////
4-
//// Author:
5-
//// Matt Ward <matt.ward@xamarin.com>
6-
////
7-
//// Copyright (c) 2017 Xamarin Inc. (http://xamarin.com)
8-
////
9-
//// Permission is hereby granted, free of charge, to any person obtaining a copy
10-
//// of this software and associated documentation files (the "Software"), to deal
11-
//// in the Software without restriction, including without limitation the rights
12-
//// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13-
//// copies of the Software, and to permit persons to whom the Software is
14-
//// furnished to do so, subject to the following conditions:
15-
////
16-
//// The above copyright notice and this permission notice shall be included in
17-
//// all copies or substantial portions of the Software.
18-
////
19-
//// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20-
//// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21-
//// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22-
//// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23-
//// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24-
//// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25-
//// THE SOFTWARE.
26-
27-
//using System;
28-
//using Gtk;
29-
//using MonoDevelop.Core;
30-
//using MonoDevelop.Components;
31-
32-
//namespace MonoDevelop.Templating.Gui
33-
//{
34-
// partial class TemplateFoldersOptionsWidget : Gtk.Bin
35-
// {
36-
// FolderListSelector folderSelector;
37-
38-
// void Build ()
39-
// {
40-
// Stetic.Gui.Initialize (this);
41-
// Stetic.BinContainer.Attach (this);
42-
43-
// var mainVBox = new VBox ();
44-
// mainVBox.Spacing = 6;
45-
// Add (mainVBox);
46-
47-
// var topLabel = new Label ();
48-
// topLabel.Xalign = 0;
49-
// topLabel.Text = GettextCatalog.GetString (
50-
// "Custom folders where {0} will look for project templates defined with a '.template.config/template.json' file.",
51-
// BrandingService.ApplicationName);
52-
// mainVBox.PackStart (topLabel, false, false, 0);
53-
54-
// folderSelector = new FolderListSelector ();
55-
// mainVBox.PackStart (folderSelector);
56-
57-
// Child.ShowAll ();
58-
// }
59-
// }
60-
//}
61-
62-
//// This file has been generated by the GUI designer. Do not modify.
63-
//namespace Stetic
64-
//{
65-
// static class Gui
66-
// {
67-
// static bool initialized;
68-
69-
// internal static void Initialize (Gtk.Widget iconRenderer)
70-
// {
71-
// if ((Stetic.Gui.initialized == false)) {
72-
// Stetic.Gui.initialized = true;
73-
// }
74-
// }
75-
// }
76-
77-
// internal class BinContainer
78-
// {
79-
// Gtk.Widget child;
80-
81-
// Gtk.UIManager uimanager;
82-
83-
// public static BinContainer Attach (Gtk.Bin bin)
84-
// {
85-
// BinContainer bc = new BinContainer ();
86-
// bin.SizeRequested += bc.OnSizeRequested;
87-
// bin.SizeAllocated += bc.OnSizeAllocated;
88-
// bin.Added += bc.OnAdded;
89-
// return bc;
90-
// }
91-
92-
// void OnSizeRequested (object sender, Gtk.SizeRequestedArgs args)
93-
// {
94-
// if ((child != null)) {
95-
// args.Requisition = child.SizeRequest ();
96-
// }
97-
// }
98-
99-
// void OnSizeAllocated (object sender, Gtk.SizeAllocatedArgs args)
100-
// {
101-
// if ((child != null)) {
102-
// child.Allocation = args.Allocation;
103-
// }
104-
// }
105-
106-
// void OnAdded (object sender, Gtk.AddedArgs args)
107-
// {
108-
// child = args.Widget;
109-
// }
110-
111-
// public void SetUiManager (UIManager uim)
112-
// {
113-
// uimanager = uim;
114-
// child.Realized += OnRealized;
115-
// }
116-
117-
// void OnRealized (object sender, EventArgs args)
118-
// {
119-
// if ((uimanager != null)) {
120-
// Gtk.Widget w;
121-
// w = child.Toplevel;
122-
// if (((w != null) && typeof(Gtk.Window).IsInstanceOfType (w))) {
123-
// ((Gtk.Window)(w)).AddAccelGroup (uimanager.AccelGroup);
124-
// uimanager = null;
125-
// }
126-
// }
127-
// }
128-
// }
129-
//}
1+
//
2+
// TemplateFoldersOptionsWidget.UI.cs
3+
//
4+
// Author:
5+
// Matt Ward <matt.ward@xamarin.com>
6+
//
7+
// Copyright (c) 2017 Xamarin Inc. (http://xamarin.com)
8+
//
9+
// Permission is hereby granted, free of charge, to any person obtaining a copy
10+
// of this software and associated documentation files (the S"oftware)", to deal
11+
// in the Software without restriction, including without limitation the rights
12+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
// copies of the Software, and to permit persons to whom the Software is
14+
// furnished to do so, subject to the following conditions:
15+
//
16+
// The above copyright notice and this permission notice shall be included in
17+
// all copies or substantial portions of the Software.
18+
//
19+
// THE SOFTWARE IS PROVIDED A"S IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
// THE SOFTWARE.
26+
27+
using MonoDevelop.Core;
28+
using Xwt;
29+
30+
namespace MonoDevelop.Templating.Gui
31+
{
32+
partial class TemplateFoldersOptionsWidget : Widget
33+
{
34+
//FolderListSelector folderSelector;
35+
TextEntry folderTextEntry;
36+
Button browseButton;
37+
Button addButton;
38+
Button removeButton;
39+
Button updateButton;
40+
Button upButton;
41+
Button downButton;
42+
ListView foldersListView;
43+
44+
void Build ()
45+
{
46+
var mainVBox = new VBox ();
47+
mainVBox.Spacing = 6;
48+
49+
Content = mainVBox;
50+
51+
var topLabel = new Label ();
52+
topLabel.Text = GettextCatalog.GetString (
53+
"Custom folders where {0} will look for project templates defined with a '.template.config/template.json' file.",
54+
BrandingService.ApplicationName);
55+
topLabel.Wrap = WrapMode.Word;
56+
mainVBox.PackStart (topLabel);
57+
58+
var hbox = new HBox ();
59+
mainVBox.PackStart (hbox, true, true);
60+
61+
var leftHandVBox = new VBox ();
62+
hbox.PackStart (leftHandVBox, true, true);
63+
64+
var folderHBox = new HBox ();
65+
folderHBox.MarginTop = 6;
66+
folderTextEntry = new TextEntry ();
67+
folderHBox.PackStart (folderTextEntry, true, true);
68+
69+
browseButton = new Button ();
70+
browseButton.Label = "\u2026";
71+
browseButton.HeightRequest = 10;
72+
73+
folderHBox.PackStart (browseButton);
74+
leftHandVBox.PackStart (folderHBox);
75+
76+
foldersListView = new ListView ();
77+
foldersListView.HeadersVisible = false;
78+
leftHandVBox.PackStart (foldersListView, true, true);
79+
80+
var rightHandVBox = new VBox ();
81+
hbox.PackStart (rightHandVBox, false, false);
82+
83+
addButton = new Button ();
84+
addButton.Label = GettextCatalog.GetString ("Add");
85+
rightHandVBox.PackStart (addButton);
86+
87+
removeButton = new Button ();
88+
removeButton.Label = GettextCatalog.GetString ("Remove");
89+
rightHandVBox.PackStart (removeButton);
90+
91+
updateButton = new Button ();
92+
updateButton.Label = GettextCatalog.GetString ("Update");
93+
rightHandVBox.PackStart (updateButton);
94+
95+
upButton = new Button ();
96+
upButton.Label = GettextCatalog.GetString ("Up");
97+
rightHandVBox.PackStart (upButton);
98+
99+
downButton = new Button ();
100+
downButton.Label = GettextCatalog.GetString ("Down");
101+
rightHandVBox.PackStart (downButton);
102+
}
103+
}
104+
}

0 commit comments

Comments
 (0)