New Add dialog for Mac too
This commit is contained in:
parent
8f65bac832
commit
8330d65ee4
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -39,3 +39,4 @@ po/sparkleshare.pot
|
||||||
SparkleShare/Nautilus/sparkleshare-nautilus-extension.py
|
SparkleShare/Nautilus/sparkleshare-nautilus-extension.py
|
||||||
gnome-doc-utils.make
|
gnome-doc-utils.make
|
||||||
/sparkleshare-*
|
/sparkleshare-*
|
||||||
|
data/plugins/*.xml
|
||||||
|
|
|
@ -28,6 +28,12 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public class SparkleController : SparkleControllerBase {
|
public class SparkleController : SparkleControllerBase {
|
||||||
|
|
||||||
|
public override string PluginsPath {
|
||||||
|
get {
|
||||||
|
return Path.Combine (NSBundle.MainBundle.ResourcePath, "Plugins");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// We have to use our own custom made folder watcher, as
|
// We have to use our own custom made folder watcher, as
|
||||||
// System.IO.FileSystemWatcher fails watching subfolders on Mac
|
// System.IO.FileSystemWatcher fails watching subfolders on Mac
|
||||||
private SparkleMacWatcher watcher;
|
private SparkleMacWatcher watcher;
|
||||||
|
|
|
@ -20,6 +20,8 @@ using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using Mono.Unix;
|
using Mono.Unix;
|
||||||
using MonoMac.Foundation;
|
using MonoMac.Foundation;
|
||||||
using MonoMac.AppKit;
|
using MonoMac.AppKit;
|
||||||
|
@ -45,16 +47,17 @@ namespace SparkleShare {
|
||||||
private NSForm UserInfoForm;
|
private NSForm UserInfoForm;
|
||||||
private NSProgressIndicator ProgressIndicator;
|
private NSProgressIndicator ProgressIndicator;
|
||||||
private NSTextField AddressTextField;
|
private NSTextField AddressTextField;
|
||||||
private NSTextField FolderNameTextField;
|
private NSTextField PathTextField;
|
||||||
private NSTextField ServerTypeLabel;
|
|
||||||
private NSTextField AddressLabel;
|
private NSTextField AddressLabel;
|
||||||
private NSTextField FolderNameLabel;
|
private NSTextField PathLabel;
|
||||||
private NSTextField FolderNameHelpLabel;
|
private NSTextField PathHelpLabel;
|
||||||
private NSTextField AddProjectTextField;
|
private NSTextField AddProjectTextField;
|
||||||
private NSButtonCell ButtonCellProto;
|
|
||||||
private NSMatrix Matrix;
|
|
||||||
private int ServerType;
|
|
||||||
private Timer timer;
|
private Timer timer;
|
||||||
|
private NSTableView TableView;
|
||||||
|
private NSScrollView ScrollView;
|
||||||
|
private NSTableColumn IconColumn;
|
||||||
|
private NSTableColumn DescriptionColumn;
|
||||||
|
private SparkleDataSource DataSource;
|
||||||
|
|
||||||
|
|
||||||
public SparkleSetup () : base ()
|
public SparkleSetup () : base ()
|
||||||
|
@ -124,122 +127,140 @@ namespace SparkleShare {
|
||||||
|
|
||||||
case PageType.Add: {
|
case PageType.Add: {
|
||||||
|
|
||||||
Header = "Where is your project?";
|
Header = "Where's your project hosted?";
|
||||||
Description = "";
|
Description = "";
|
||||||
|
|
||||||
ServerTypeLabel = new NSTextField () {
|
|
||||||
Alignment = NSTextAlignment.Right,
|
|
||||||
BackgroundColor = NSColor.WindowBackground,
|
|
||||||
Bordered = false,
|
|
||||||
Editable = false,
|
|
||||||
Frame = new RectangleF (150, Frame.Height - 159 , 160, 17),
|
|
||||||
StringValue = "Host Type:",
|
|
||||||
Font = SparkleUI.Font
|
|
||||||
};
|
|
||||||
|
|
||||||
AddressLabel = new NSTextField () {
|
AddressLabel = new NSTextField () {
|
||||||
Alignment = NSTextAlignment.Right,
|
Alignment = NSTextAlignment.Left,
|
||||||
BackgroundColor = NSColor.WindowBackground,
|
BackgroundColor = NSColor.WindowBackground,
|
||||||
Bordered = false,
|
Bordered = false,
|
||||||
Editable = false,
|
Editable = false,
|
||||||
Frame = new RectangleF (150, Frame.Height - 257 , 160, 17),
|
Frame = new RectangleF (190, Frame.Height - 308, 160, 17),
|
||||||
StringValue = "Address:",
|
StringValue = "Address:",
|
||||||
Font = SparkleUI.Font
|
Font = SparkleUI.Font
|
||||||
};
|
};
|
||||||
|
|
||||||
FolderNameLabel = new NSTextField () {
|
AddressTextField = new NSTextField () {
|
||||||
Alignment = NSTextAlignment.Right,
|
Frame = new RectangleF (190, Frame.Height - 336, 196, 22),
|
||||||
|
Font = SparkleUI.Font,
|
||||||
|
StringValue = Controller.PreviousAddress,
|
||||||
|
Enabled = (Controller.SelectedPlugin.Address == null)
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
PathLabel = new NSTextField () {
|
||||||
|
Alignment = NSTextAlignment.Left,
|
||||||
BackgroundColor = NSColor.WindowBackground,
|
BackgroundColor = NSColor.WindowBackground,
|
||||||
Bordered = false,
|
Bordered = false,
|
||||||
Editable = false,
|
Editable = false,
|
||||||
Frame = new RectangleF (150, Frame.Height - 284 , 160, 17),
|
Frame = new RectangleF (190 + 196 + 16, Frame.Height - 308, 160, 17),
|
||||||
StringValue = "Folder Name:",
|
StringValue = "Remote Path:",
|
||||||
Font = SparkleUI.Font
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
AddressTextField = new NSTextField () {
|
|
||||||
Frame = new RectangleF (320, Frame.Height - 260 , 256, 22),
|
|
||||||
Font = SparkleUI.Font,
|
Font = SparkleUI.Font,
|
||||||
StringValue = Controller.PreviousServer
|
Enabled = (Controller.SelectedPlugin.Path == null)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PathTextField = new NSTextField () {
|
||||||
|
Frame = new RectangleF (190 + 196 + 16, Frame.Height - 336, 196, 22),
|
||||||
|
StringValue = Controller.PreviousPath
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;
|
AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;
|
||||||
|
PathTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;
|
||||||
|
|
||||||
FolderNameTextField = new NSTextField () {
|
|
||||||
Frame = new RectangleF (320, Frame.Height - (260 + 22 + 4) , 256, 22),
|
|
||||||
StringValue = Controller.PreviousFolder
|
|
||||||
};
|
|
||||||
|
|
||||||
FolderNameTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;
|
PathHelpLabel = new NSTextField () {
|
||||||
|
|
||||||
FolderNameHelpLabel = new NSTextField () {
|
|
||||||
BackgroundColor = NSColor.WindowBackground,
|
BackgroundColor = NSColor.WindowBackground,
|
||||||
Bordered = false,
|
Bordered = false,
|
||||||
TextColor = NSColor.DisabledControlText,
|
TextColor = NSColor.DisabledControlText,
|
||||||
Editable = false,
|
Editable = false,
|
||||||
Frame = new RectangleF (320, Frame.Height - 305 , 200, 17),
|
Frame = new RectangleF (190 + 196 + 16, Frame.Height - 355, 204, 17),
|
||||||
StringValue = "e.g. ‘rupert/website-design’"
|
StringValue = "e.g. ‘rupert/website-design’",
|
||||||
|
Font = NSFontManager.SharedFontManager.FontWithFamily
|
||||||
|
("Lucida Grande", NSFontTraitMask.Condensed, 0, 11)
|
||||||
};
|
};
|
||||||
|
|
||||||
ServerType = 0;
|
|
||||||
|
|
||||||
ButtonCellProto = new NSButtonCell ();
|
TableView = new NSTableView () {
|
||||||
ButtonCellProto.SetButtonType (NSButtonType.Radio) ;
|
Frame = new RectangleF (0, 0, 0, 0),
|
||||||
|
RowHeight = 30,
|
||||||
|
IntercellSpacing = new SizeF (0, 12),
|
||||||
|
HeaderView = null
|
||||||
|
};
|
||||||
|
|
||||||
Matrix = new NSMatrix (new RectangleF (315, Frame.Height - 220, 256, 78),
|
ScrollView = new NSScrollView () {
|
||||||
NSMatrixMode.Radio, ButtonCellProto, 4, 1);
|
Frame = new RectangleF (190, Frame.Height - 280, 408, 175),
|
||||||
|
DocumentView = TableView,
|
||||||
|
HasVerticalScroller = true,
|
||||||
|
BorderType = NSBorderType.BezelBorder
|
||||||
|
};
|
||||||
|
|
||||||
Matrix.CellSize = new SizeF (256, 18);
|
IconColumn = new NSTableColumn (new NSImage ()) {
|
||||||
|
Width = 42,
|
||||||
|
HeaderToolTip = "Icon",
|
||||||
|
DataCell = new NSImageCell ()
|
||||||
|
};
|
||||||
|
|
||||||
Matrix.Cells [0].Title = "My own server";
|
DescriptionColumn = new NSTableColumn () {
|
||||||
Matrix.Cells [1].Title = "Github";
|
Width = 350,
|
||||||
Matrix.Cells [2].Title = "Gitorious";
|
HeaderToolTip = "Description",
|
||||||
Matrix.Cells [3].Title = "The GNOME Project";
|
Editable = false
|
||||||
|
};
|
||||||
|
|
||||||
|
DescriptionColumn.DataCell.Font =
|
||||||
|
NSFontManager.SharedFontManager.FontWithFamily (
|
||||||
|
"Lucida Grande", NSFontTraitMask.Condensed, 0, 11);
|
||||||
|
|
||||||
|
TableView.AddColumn (IconColumn);
|
||||||
|
TableView.AddColumn (DescriptionColumn);
|
||||||
|
|
||||||
|
DataSource = new SparkleDataSource ();
|
||||||
|
|
||||||
|
foreach (SparklePlugin plugin in Controller.Plugins)
|
||||||
|
DataSource.Items.Add (plugin);
|
||||||
|
|
||||||
|
TableView.DataSource = DataSource;
|
||||||
|
TableView.ReloadData ();
|
||||||
|
|
||||||
|
|
||||||
|
Controller.ChangeAddressFieldEvent += delegate (string text,
|
||||||
|
string example_text, FieldState state) {
|
||||||
|
|
||||||
|
InvokeOnMainThread (delegate {
|
||||||
|
AddressTextField.StringValue = text;
|
||||||
|
AddressTextField.Enabled = (state == FieldState.Enabled);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Controller.ChangePathFieldEvent += delegate (string text,
|
||||||
|
string example_text, FieldState state) {
|
||||||
|
|
||||||
|
InvokeOnMainThread (delegate {
|
||||||
|
PathTextField.StringValue = text;
|
||||||
|
PathTextField.Enabled = (state == FieldState.Enabled);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty (example_text))
|
||||||
|
PathHelpLabel.StringValue = "e.g. " + example_text;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
TableView.SelectRow (Controller.SelectedPluginIndex, false);
|
||||||
|
|
||||||
foreach (NSCell cell in Matrix.Cells)
|
|
||||||
cell.Font = SparkleUI.Font;
|
|
||||||
|
|
||||||
// TODO: Ugly hack, do properly with events
|
|
||||||
timer = new Timer () {
|
timer = new Timer () {
|
||||||
Interval = 50
|
Interval = 50
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: Use an event
|
||||||
timer.Elapsed += delegate {
|
timer.Elapsed += delegate {
|
||||||
|
if (TableView.SelectedRow != Controller.SelectedPluginIndex)
|
||||||
|
Controller.SelectedPluginChanged (TableView.SelectedRow);
|
||||||
|
|
||||||
InvokeOnMainThread (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
if (Matrix.SelectedRow != ServerType) {
|
// TODO: Move checking logic to controller
|
||||||
ServerType = Matrix.SelectedRow;
|
if (!string.IsNullOrWhiteSpace (AddressTextField.StringValue) &&
|
||||||
|
!string.IsNullOrWhiteSpace (PathTextField.StringValue)) {
|
||||||
AddressTextField.Enabled = (ServerType == 0);
|
|
||||||
|
|
||||||
switch (ServerType) {
|
|
||||||
case 0:
|
|
||||||
AddressTextField.StringValue = "";
|
|
||||||
FolderNameHelpLabel.StringValue = "e.g. ‘rupert/website-design’";
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
AddressTextField.StringValue = "ssh://git@github.com/";
|
|
||||||
FolderNameHelpLabel.StringValue = "e.g. ‘rupert/website-design’";
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
AddressTextField.StringValue = "ssh://git@gitorious.org/";
|
|
||||||
FolderNameHelpLabel.StringValue = "e.g. ‘project/website-design’";
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
AddressTextField.StringValue = "ssh://git@gnome.org/git/";
|
|
||||||
FolderNameHelpLabel.StringValue = "e.g. ‘gnome-icon-theme’";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (ServerType == 0 && !AddressTextField.StringValue.Trim ().Equals ("")
|
|
||||||
&& !FolderNameTextField.StringValue.Trim ().Equals ("")) {
|
|
||||||
|
|
||||||
SyncButton.Enabled = true;
|
|
||||||
|
|
||||||
} else if (ServerType != 0 &&
|
|
||||||
!FolderNameTextField.StringValue.Trim ().Equals ("")) {
|
|
||||||
|
|
||||||
SyncButton.Enabled = true;
|
SyncButton.Enabled = true;
|
||||||
|
|
||||||
|
@ -247,20 +268,17 @@ namespace SparkleShare {
|
||||||
SyncButton.Enabled = false;
|
SyncButton.Enabled = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
timer.Start ();
|
timer.Start ();
|
||||||
|
|
||||||
ContentView.AddSubview (ServerTypeLabel);
|
|
||||||
ContentView.AddSubview (Matrix);
|
|
||||||
|
|
||||||
|
ContentView.AddSubview (ScrollView);
|
||||||
ContentView.AddSubview (AddressLabel);
|
ContentView.AddSubview (AddressLabel);
|
||||||
ContentView.AddSubview (AddressTextField);
|
ContentView.AddSubview (AddressTextField);
|
||||||
|
ContentView.AddSubview (PathLabel);
|
||||||
ContentView.AddSubview (FolderNameLabel);
|
ContentView.AddSubview (PathTextField);
|
||||||
ContentView.AddSubview (FolderNameTextField);
|
ContentView.AddSubview (PathHelpLabel);
|
||||||
ContentView.AddSubview (FolderNameHelpLabel);
|
|
||||||
|
|
||||||
SyncButton = new NSButton () {
|
SyncButton = new NSButton () {
|
||||||
Title = "Add",
|
Title = "Add",
|
||||||
|
@ -271,9 +289,10 @@ namespace SparkleShare {
|
||||||
timer.Stop ();
|
timer.Stop ();
|
||||||
timer = null;
|
timer = null;
|
||||||
|
|
||||||
string folder_name = FolderNameTextField.StringValue;
|
Controller.AddPageCompleted (
|
||||||
string server = AddressTextField.StringValue;
|
AddressTextField.StringValue,
|
||||||
Controller.AddPageCompleted (server, folder_name);
|
PathTextField.StringValue
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
Buttons.Add (SyncButton);
|
Buttons.Add (SyncButton);
|
||||||
|
@ -560,4 +579,46 @@ namespace SparkleShare {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Register("SparkleDataSource")]
|
||||||
|
public class SparkleDataSource : NSTableViewDataSource {
|
||||||
|
|
||||||
|
public List<object> Items ;
|
||||||
|
|
||||||
|
|
||||||
|
public SparkleDataSource ()
|
||||||
|
{
|
||||||
|
Items = new List<object> ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Export("numberOfRowsInTableView:")]
|
||||||
|
public int numberOfRowsInTableView (NSTableView table_view)
|
||||||
|
{
|
||||||
|
if (Items == null)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return Items.Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Export("tableView:objectValueForTableColumn:row:")]
|
||||||
|
public NSObject objectValueForTableColumn (NSTableView table_view,
|
||||||
|
NSTableColumn table_column, int row_index)
|
||||||
|
{
|
||||||
|
// TODO: Style text nicely: "<b>Name</b>\n<grey>Description</grey>"
|
||||||
|
if (table_column.HeaderToolTip.Equals ("Description")) {
|
||||||
|
return new NSString (
|
||||||
|
(Items [row_index] as SparklePlugin).Name + "\n" +
|
||||||
|
(Items [row_index] as SparklePlugin).Description
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return new NSImage ((Items [row_index] as SparklePlugin).ImagePath) {
|
||||||
|
Size = new SizeF (24, 24)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,9 @@
|
||||||
<Link>SparkleExtensions.cs</Link>
|
<Link>SparkleExtensions.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="SparkleController.cs" />
|
<Compile Include="SparkleController.cs" />
|
||||||
|
<Compile Include="..\SparklePlugin.cs">
|
||||||
|
<Link>SparklePlugin.cs</Link>
|
||||||
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Page Include="MainMenu.xib" />
|
<Page Include="MainMenu.xib" />
|
||||||
|
@ -282,10 +285,41 @@
|
||||||
<Content Include="..\..\data\tutorial-slide-4.png">
|
<Content Include="..\..\data\tutorial-slide-4.png">
|
||||||
<Link>Pixmaps\tutorial-slide-4.png</Link>
|
<Link>Pixmaps\tutorial-slide-4.png</Link>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="..\..\data\plugins\bitbucket.xml">
|
||||||
|
<Link>Plugins\bitbucket.xml</Link>
|
||||||
|
</Content>
|
||||||
|
<Content Include="..\..\data\plugins\github.xml">
|
||||||
|
<Link>Plugins\github.xml</Link>
|
||||||
|
</Content>
|
||||||
|
<Content Include="..\..\data\plugins\gitorious.xml">
|
||||||
|
<Link>Plugins\gitorious.xml</Link>
|
||||||
|
</Content>
|
||||||
|
<Content Include="..\..\data\plugins\gnome.xml">
|
||||||
|
<Link>Plugins\gnome.xml</Link>
|
||||||
|
</Content>
|
||||||
|
<Content Include="..\..\data\plugins\own-server.xml">
|
||||||
|
<Link>Plugins\own-server.xml</Link>
|
||||||
|
</Content>
|
||||||
|
<Content Include="..\..\data\plugins\bitbucket.png">
|
||||||
|
<Link>Plugins\bitbucket.png</Link>
|
||||||
|
</Content>
|
||||||
|
<Content Include="..\..\data\plugins\github.png">
|
||||||
|
<Link>Plugins\github.png</Link>
|
||||||
|
</Content>
|
||||||
|
<Content Include="..\..\data\plugins\gitorious.png">
|
||||||
|
<Link>Plugins\gitorious.png</Link>
|
||||||
|
</Content>
|
||||||
|
<Content Include="..\..\data\plugins\gnome.png">
|
||||||
|
<Link>Plugins\gnome.png</Link>
|
||||||
|
</Content>
|
||||||
|
<Content Include="..\..\data\plugins\own-server.png">
|
||||||
|
<Link>Plugins\own-server.png</Link>
|
||||||
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Pixmaps\" />
|
<Folder Include="Pixmaps\" />
|
||||||
<Folder Include="HTML\" />
|
<Folder Include="HTML\" />
|
||||||
<Folder Include="Translations\" />
|
<Folder Include="Translations\" />
|
||||||
|
<Folder Include="Plugins\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -30,6 +30,14 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public class SparkleController : SparkleControllerBase {
|
public class SparkleController : SparkleControllerBase {
|
||||||
|
|
||||||
|
|
||||||
|
public override string PluginsPath {
|
||||||
|
get {
|
||||||
|
return SparkleHelpers.CombineMore (Defines.DATAROOTDIR, "sparkleshare", "plugins");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public SparkleController () : base ()
|
public SparkleController () : base ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,8 @@ namespace SparkleShare {
|
||||||
public delegate void NotificationRaisedEventHandler (string user_name, string user_email,
|
public delegate void NotificationRaisedEventHandler (string user_name, string user_email,
|
||||||
string message, string repository_path);
|
string message, string repository_path);
|
||||||
|
|
||||||
|
public abstract string PluginsPath { get; }
|
||||||
|
|
||||||
private SparkleFetcherBase fetcher;
|
private SparkleFetcherBase fetcher;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,13 +49,16 @@ namespace SparkleShare {
|
||||||
public delegate void ChangePathFieldEventHandler (string text,
|
public delegate void ChangePathFieldEventHandler (string text,
|
||||||
string example_text, FieldState state);
|
string example_text, FieldState state);
|
||||||
|
|
||||||
public event SelectListPluginEventHandler SelectListPluginEvent;
|
|
||||||
public delegate void SelectListPluginEventHandler (int index);
|
|
||||||
|
|
||||||
public readonly List<SparklePlugin> Plugins = new List<SparklePlugin> ();
|
public readonly List<SparklePlugin> Plugins = new List<SparklePlugin> ();
|
||||||
public SparklePlugin SelectedPlugin;
|
public SparklePlugin SelectedPlugin;
|
||||||
|
|
||||||
|
|
||||||
|
public int SelectedPluginIndex {
|
||||||
|
get {
|
||||||
|
return Plugins.IndexOf (SelectedPlugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int TutorialPageNumber {
|
public int TutorialPageNumber {
|
||||||
get {
|
get {
|
||||||
return this.tutorial_page_number;
|
return this.tutorial_page_number;
|
||||||
|
@ -68,15 +71,15 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string PreviousServer {
|
public string PreviousAddress {
|
||||||
get {
|
get {
|
||||||
return this.previous_server;
|
return this.previous_address;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string PreviousFolder {
|
public string PreviousPath {
|
||||||
get {
|
get {
|
||||||
return this.previous_folder;
|
return this.previous_path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,8 +111,8 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private string previous_server = "";
|
private string previous_address = "";
|
||||||
private string previous_folder = "";
|
private string previous_path = "";
|
||||||
private string previous_url = "";
|
private string previous_url = "";
|
||||||
private string syncing_folder = "";
|
private string syncing_folder = "";
|
||||||
private int tutorial_page_number = 1;
|
private int tutorial_page_number = 1;
|
||||||
|
@ -122,15 +125,12 @@ namespace SparkleShare {
|
||||||
Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData),
|
Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData),
|
||||||
"sparkleshare", "plugins");
|
"sparkleshare", "plugins");
|
||||||
|
|
||||||
string plugins_path = SparkleHelpers.CombineMore (
|
|
||||||
Defines.DATAROOTDIR, "sparkleshare", "plugins");
|
|
||||||
|
|
||||||
if (Directory.Exists (local_plugins_path))
|
if (Directory.Exists (local_plugins_path))
|
||||||
foreach (string xml_file_path in Directory.GetFiles (local_plugins_path, "*.xml"))
|
foreach (string xml_file_path in Directory.GetFiles (local_plugins_path, "*.xml"))
|
||||||
Plugins.Add (new SparklePlugin (xml_file_path));
|
Plugins.Add (new SparklePlugin (xml_file_path));
|
||||||
|
|
||||||
if (Directory.Exists (plugins_path)) {
|
if (Directory.Exists (Program.Controller.PluginsPath)) {
|
||||||
foreach (string xml_file_path in Directory.GetFiles (plugins_path, "*.xml")) {
|
foreach (string xml_file_path in Directory.GetFiles (Program.Controller.PluginsPath, "*.xml")) {
|
||||||
if (xml_file_path.EndsWith ("own-server.xml"))
|
if (xml_file_path.EndsWith ("own-server.xml"))
|
||||||
Plugins.Insert (0, new SparklePlugin (xml_file_path));
|
Plugins.Insert (0, new SparklePlugin (xml_file_path));
|
||||||
else
|
else
|
||||||
|
@ -138,31 +138,14 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SelectedPlugin = Plugins [0];
|
||||||
|
|
||||||
ChangePageEvent += delegate (PageType page) {
|
ChangePageEvent += delegate (PageType page) {
|
||||||
this.previous_page = page;
|
this.previous_page = page;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void ShowAddPage ()
|
|
||||||
{
|
|
||||||
if (ChangePageEvent != null)
|
|
||||||
ChangePageEvent (PageType.Add);
|
|
||||||
|
|
||||||
int index;
|
|
||||||
if (SelectedPlugin == null)
|
|
||||||
index = 0;
|
|
||||||
else
|
|
||||||
index = Plugins.IndexOf (SelectedPlugin);
|
|
||||||
|
|
||||||
if (SelectListPluginEvent != null)
|
|
||||||
SelectListPluginEvent (index);
|
|
||||||
|
|
||||||
SelectedPluginChanged (index);
|
|
||||||
SelectedPlugin = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void ShowSetupPage ()
|
public void ShowSetupPage ()
|
||||||
{
|
{
|
||||||
if (ChangePageEvent != null)
|
if (ChangePageEvent != null)
|
||||||
|
@ -201,11 +184,26 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void AddPageCompleted (string server, string folder_name)
|
public void ShowAddPage ()
|
||||||
{
|
{
|
||||||
this.syncing_folder = Path.GetFileNameWithoutExtension (folder_name);
|
if (ChangePageEvent != null)
|
||||||
this.previous_server = server;
|
ChangePageEvent (PageType.Add);
|
||||||
this.previous_folder = folder_name;
|
|
||||||
|
int index;
|
||||||
|
if (SelectedPlugin == null)
|
||||||
|
index = 0;
|
||||||
|
else
|
||||||
|
index = Plugins.IndexOf (SelectedPlugin);
|
||||||
|
|
||||||
|
SelectedPluginChanged (SelectedPluginIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void AddPageCompleted (string address, string path)
|
||||||
|
{
|
||||||
|
this.syncing_folder = Path.GetFileNameWithoutExtension (path);
|
||||||
|
this.previous_address = address;
|
||||||
|
this.previous_path = path;
|
||||||
|
|
||||||
if (ChangePageEvent != null)
|
if (ChangePageEvent != null)
|
||||||
ChangePageEvent (PageType.Syncing);
|
ChangePageEvent (PageType.Syncing);
|
||||||
|
@ -214,7 +212,10 @@ namespace SparkleShare {
|
||||||
if (ChangePageEvent != null)
|
if (ChangePageEvent != null)
|
||||||
ChangePageEvent (PageType.Finished);
|
ChangePageEvent (PageType.Finished);
|
||||||
|
|
||||||
|
this.previous_address = "";
|
||||||
this.syncing_folder = "";
|
this.syncing_folder = "";
|
||||||
|
this.previous_url = "";
|
||||||
|
SelectedPlugin = Plugins [0];
|
||||||
};
|
};
|
||||||
|
|
||||||
Program.Controller.FolderFetchError += delegate (string remote_url) {
|
Program.Controller.FolderFetchError += delegate (string remote_url) {
|
||||||
|
@ -231,7 +232,7 @@ namespace SparkleShare {
|
||||||
UpdateProgressBarEvent (percentage);
|
UpdateProgressBarEvent (percentage);
|
||||||
};
|
};
|
||||||
|
|
||||||
Program.Controller.FetchFolder (server, folder_name);
|
Program.Controller.FetchFolder (address, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -253,8 +254,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public void FinishedPageCompleted ()
|
public void FinishedPageCompleted ()
|
||||||
{
|
{
|
||||||
this.previous_server = "";
|
this.previous_address = "";
|
||||||
this.previous_folder = "";
|
this.previous_path = "";
|
||||||
Program.Controller.UpdateState ();
|
Program.Controller.UpdateState ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,27 +266,27 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (SelectedPlugin.Address != null) {
|
if (SelectedPlugin.Address != null) {
|
||||||
if (ChangeAddressFieldEvent != null)
|
if (ChangeAddressFieldEvent != null)
|
||||||
ChangeAddressFieldEvent (SelectedPlugin.Address, null, FieldState.Disabled);
|
ChangeAddressFieldEvent (SelectedPlugin.Address, "", FieldState.Disabled);
|
||||||
|
|
||||||
} else if (SelectedPlugin.AddressExample != null) {
|
} else if (SelectedPlugin.AddressExample != null) {
|
||||||
if (ChangeAddressFieldEvent != null)
|
if (ChangeAddressFieldEvent != null)
|
||||||
ChangeAddressFieldEvent (PreviousServer, SelectedPlugin.AddressExample, FieldState.Enabled);
|
ChangeAddressFieldEvent ("", SelectedPlugin.AddressExample, FieldState.Enabled);
|
||||||
} else {
|
} else {
|
||||||
if (ChangeAddressFieldEvent != null)
|
if (ChangeAddressFieldEvent != null)
|
||||||
ChangeAddressFieldEvent (PreviousServer, SelectedPlugin.AddressExample, FieldState.Enabled);
|
ChangeAddressFieldEvent ("", "", FieldState.Enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SelectedPlugin.Path != null) {
|
if (SelectedPlugin.Path != null) {
|
||||||
if (ChangePathFieldEvent != null)
|
if (ChangePathFieldEvent != null)
|
||||||
ChangePathFieldEvent (SelectedPlugin.Path, null, FieldState.Disabled);
|
ChangePathFieldEvent (SelectedPlugin.Path, "", FieldState.Disabled);
|
||||||
|
|
||||||
} else if (SelectedPlugin.PathExample != null) {
|
} else if (SelectedPlugin.PathExample != null) {
|
||||||
if (ChangePathFieldEvent != null)
|
if (ChangePathFieldEvent != null)
|
||||||
ChangePathFieldEvent (PreviousFolder, SelectedPlugin.PathExample, FieldState.Enabled);
|
ChangePathFieldEvent ("", SelectedPlugin.PathExample, FieldState.Enabled);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (ChangePathFieldEvent != null)
|
if (ChangePathFieldEvent != null)
|
||||||
ChangePathFieldEvent (PreviousFolder, SelectedPlugin.PathExample, FieldState.Enabled);
|
ChangePathFieldEvent ("", "", FieldState.Enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: previous server/folder doesn't work yet
|
// TODO: previous server/folder doesn't work yet
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<sparkleshare>
|
|
||||||
<plugin>
|
|
||||||
<info>
|
|
||||||
<_name>Red Hat UX Team Hub</_name>
|
|
||||||
<_description>Internal server for the UX team</_description>
|
|
||||||
<icon>redhat.png</icon>
|
|
||||||
<backend>Git</backend>
|
|
||||||
</info>
|
|
||||||
<address>
|
|
||||||
<value>ssh://git@design.bos.lab.redhat.com/</value>
|
|
||||||
<example></example>
|
|
||||||
</address>
|
|
||||||
<path>
|
|
||||||
<value></value>
|
|
||||||
<_example>/project</_example>
|
|
||||||
</path>
|
|
||||||
</plugin>
|
|
||||||
</sparkleshare>
|
|
||||||
|
|
Loading…
Reference in a new issue