More work on [osx]
This commit is contained in:
parent
570f8fc56f
commit
116d5c5be2
|
@ -1,60 +0,0 @@
|
||||||
// SparkleShare, an instant update workflow to Git.
|
|
||||||
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Timers;
|
|
||||||
using MonoMac.Foundation;
|
|
||||||
using MonoMac.AppKit;
|
|
||||||
using MonoMac.ObjCRuntime;
|
|
||||||
using MonoMac.WebKit;
|
|
||||||
|
|
||||||
namespace SparkleShare {
|
|
||||||
|
|
||||||
public partial class AppDelegate : NSApplicationDelegate {
|
|
||||||
// Workaround to be able to work with SparkleUI as the main class
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public class SparkleUI : AppDelegate
|
|
||||||
{
|
|
||||||
|
|
||||||
public SparkleStatusIcon StatusIcon;
|
|
||||||
|
|
||||||
|
|
||||||
public SparkleUI ()
|
|
||||||
{
|
|
||||||
|
|
||||||
NSApplication.Init ();
|
|
||||||
//NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
|
||||||
//NSApplication.SharedApplication.applicationIconImage = NSImage.ImageNamed ("sparkleshare.icns");
|
|
||||||
|
|
||||||
//StatusIcon = new SparkleStatusIcon ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void Run ()
|
|
||||||
{
|
|
||||||
|
|
||||||
NSApplication.Main (new string [0]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using MonoMac.Foundation;
|
|
||||||
using MonoMac.AppKit;
|
|
||||||
|
|
||||||
namespace SparkleShare
|
|
||||||
{
|
|
||||||
public partial class MainWindow : MonoMac.AppKit.NSWindow
|
|
||||||
{
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
// Called when created from unmanaged code
|
|
||||||
public MainWindow (IntPtr handle) : base(handle)
|
|
||||||
{
|
|
||||||
Initialize ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called when created directly from a XIB file
|
|
||||||
[Export("initWithCoder:")]
|
|
||||||
public MainWindow (NSCoder coder) : base(coder)
|
|
||||||
{
|
|
||||||
Initialize ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shared initialization code
|
|
||||||
void Initialize ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
// <autogenerated>
|
|
||||||
// This code was generated by a tool.
|
|
||||||
// Mono Runtime Version: 2.0.50727.1433
|
|
||||||
//
|
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
|
||||||
// the code is regenerated.
|
|
||||||
// </autogenerated>
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace SparkleShare {
|
|
||||||
|
|
||||||
|
|
||||||
// Should subclass MonoMac.AppKit.NSWindow
|
|
||||||
[MonoMac.Foundation.Register("MainWindow")]
|
|
||||||
public partial class MainWindow {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Should subclass MonoMac.AppKit.NSWindowController
|
|
||||||
[MonoMac.Foundation.Register("MainWindowController")]
|
|
||||||
public partial class MainWindowController {
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using MonoMac.Foundation;
|
|
||||||
using MonoMac.AppKit;
|
|
||||||
|
|
||||||
namespace SparkleShare
|
|
||||||
{
|
|
||||||
public partial class MainWindowController : MonoMac.AppKit.NSWindowController
|
|
||||||
{
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
// Called when created from unmanaged code
|
|
||||||
public MainWindowController (IntPtr handle) : base(handle)
|
|
||||||
{
|
|
||||||
Initialize ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called when created directly from a XIB file
|
|
||||||
[Export("initWithCoder:")]
|
|
||||||
public MainWindowController (NSCoder coder) : base(coder)
|
|
||||||
{
|
|
||||||
Initialize ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Call to load from the XIB/NIB file
|
|
||||||
public MainWindowController () : base("MainWindow")
|
|
||||||
{
|
|
||||||
Initialize ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shared initialization code
|
|
||||||
void Initialize ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//strongly typed window accessor
|
|
||||||
public new MainWindow Window {
|
|
||||||
get { return (MainWindow)base.Window; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace SparkleShare {
|
||||||
};
|
};
|
||||||
|
|
||||||
OpenFolderButton.Activated += delegate {
|
OpenFolderButton.Activated += delegate {
|
||||||
// SparkleShare.Controller.OpenSparkleShareFolder (LocalPath);
|
SparkleShare.Controller.OpenSparkleShareFolder (LocalPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
ContentView.AddSubview (OpenFolderButton);
|
ContentView.AddSubview (OpenFolderButton);
|
||||||
|
@ -73,7 +73,7 @@ namespace SparkleShare {
|
||||||
};
|
};
|
||||||
|
|
||||||
CloseButton.Activated += delegate {
|
CloseButton.Activated += delegate {
|
||||||
Close ();
|
PerformClose (this);
|
||||||
};
|
};
|
||||||
|
|
||||||
ContentView.AddSubview (CloseButton);
|
ContentView.AddSubview (CloseButton);
|
||||||
|
@ -88,11 +88,13 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
new public void Close ()
|
public override void PerformClose (NSObject sender)
|
||||||
{
|
{
|
||||||
|
|
||||||
InvokeOnMainThread (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
base.Close ();
|
Console.WriteLine ("!!!!!!!!!!");
|
||||||
|
SparkleUI.OpenLogs.Remove ((SparkleLog) this);
|
||||||
|
base.PerformClose (this);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
using SparkleLib;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -66,7 +67,12 @@ namespace SparkleShare {
|
||||||
public override void OpenSparkleShareFolder (string subfolder)
|
public override void OpenSparkleShareFolder (string subfolder)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
string folder = Path.Combine (SparklePaths.SparklePath, subfolder);
|
||||||
|
|
||||||
|
Process process = new Process ();
|
||||||
|
process.StartInfo.Arguments = folder.Replace (" ", "\\ "); // Escape space-characters
|
||||||
|
process.StartInfo.FileName = "open";
|
||||||
|
process.Start ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,6 @@
|
||||||
<Reference Include="Mono.Posix" />
|
<Reference Include="Mono.Posix" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Main.cs" />
|
|
||||||
<Compile Include="MainMenu.xib.designer.cs">
|
<Compile Include="MainMenu.xib.designer.cs">
|
||||||
<DependentUpon>MainMenu.xib</DependentUpon>
|
<DependentUpon>MainMenu.xib</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -61,6 +60,8 @@
|
||||||
<Link>SparkleController.cs</Link>
|
<Link>SparkleController.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="SparkleMacController.cs" />
|
<Compile Include="SparkleMacController.cs" />
|
||||||
|
<Compile Include="SparkleUI.cs" />
|
||||||
|
<Compile Include="SparkleWindow.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Page Include="MainMenu.xib" />
|
<Page Include="MainMenu.xib" />
|
||||||
|
@ -80,6 +81,9 @@
|
||||||
<Content Include="Pixmaps\idle3.png" />
|
<Content Include="Pixmaps\idle3.png" />
|
||||||
<Content Include="Pixmaps\sparkleshare-idle.png" />
|
<Content Include="Pixmaps\sparkleshare-idle.png" />
|
||||||
<Content Include="Pixmaps\sparkleshare-idle-focus.png" />
|
<Content Include="Pixmaps\sparkleshare-idle-focus.png" />
|
||||||
|
<Content Include="..\..\..\data\side-splash.png">
|
||||||
|
<Link>Pixmaps\side-splash.png</Link>
|
||||||
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\..\SparkleLib\SparkleLib.csproj">
|
<ProjectReference Include="..\..\..\SparkleLib\SparkleLib.csproj">
|
||||||
|
|
|
@ -58,45 +58,45 @@ namespace SparkleShare {
|
||||||
StatusItem.HighlightMode = true;
|
StatusItem.HighlightMode = true;
|
||||||
|
|
||||||
|
|
||||||
SetAnimationState ();
|
SetNormalState ();
|
||||||
CreateMenu ();
|
CreateMenu ();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* SparkleShare.Controller.FolderSizeChanged += delegate {
|
SparkleShare.Controller.FolderSizeChanged += delegate {
|
||||||
Application.Invoke (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
UpdateMenu ();
|
UpdateMenu ();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
SparkleShare.Controller.FolderListChanged += delegate {
|
SparkleShare.Controller.FolderListChanged += delegate {
|
||||||
Application.Invoke (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
SetNormalState ();
|
SetNormalState ();
|
||||||
CreateMenu ();
|
CreateMenu ();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
SparkleShare.Controller.OnIdle += delegate {
|
SparkleShare.Controller.OnIdle += delegate {
|
||||||
Application.Invoke (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
SetNormalState ();
|
SetNormalState ();
|
||||||
UpdateMenu ();
|
UpdateMenu ();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
SparkleShare.Controller.OnSyncing += delegate {
|
SparkleShare.Controller.OnSyncing += delegate {
|
||||||
Application.Invoke (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
SetAnimationState ();
|
SetAnimationState ();
|
||||||
UpdateMenu ();
|
UpdateMenu ();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
SparkleShare.Controller.OnError += delegate {
|
SparkleShare.Controller.OnError += delegate {
|
||||||
Application.Invoke (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
SetNormalState (true);
|
SetNormalState (true);
|
||||||
UpdateMenu ();
|
UpdateMenu ();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,10 +119,10 @@ namespace SparkleShare {
|
||||||
|
|
||||||
InvokeOnMainThread (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
|
|
||||||
StatusItem.AlternateImage = NSImage.ImageNamed ("idle" + FrameNumber + ".png");
|
StatusItem.AlternateImage = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/idle" + FrameNumber + ".png");
|
||||||
StatusItem.AlternateImage.Size = new SizeF (16, 16);
|
StatusItem.AlternateImage.Size = new SizeF (16, 16);
|
||||||
|
|
||||||
StatusItem.Image = NSImage.ImageNamed ("idle" + FrameNumber + ".png");
|
StatusItem.Image = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/idle" + FrameNumber + ".png");
|
||||||
StatusItem.Image.Size = new SizeF (16, 16);
|
StatusItem.Image.Size = new SizeF (16, 16);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -154,49 +154,49 @@ namespace SparkleShare {
|
||||||
};
|
};
|
||||||
|
|
||||||
FolderMenuItem.Activated += delegate {
|
FolderMenuItem.Activated += delegate {
|
||||||
// SparkleShare.Controller.OpenSparkleShareFolder ();
|
SparkleShare.Controller.OpenSparkleShareFolder ();
|
||||||
};
|
};
|
||||||
|
|
||||||
FolderMenuItem.Image = NSImage.ImageNamed ("sparkleshare.icns");
|
//FolderMenuItem.Image = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/sparkleshare.icns");
|
||||||
|
FolderMenuItem.Image = NSImage.ImageNamed ("NSFolder");
|
||||||
FolderMenuItem.Image.Size = new SizeF (16, 16);
|
FolderMenuItem.Image.Size = new SizeF (16, 16);
|
||||||
|
|
||||||
Menu.AddItem (FolderMenuItem);
|
Menu.AddItem (FolderMenuItem);
|
||||||
|
|
||||||
|
|
||||||
FolderMenuItems = new NSMenuItem [2] {
|
if (SparkleShare.Controller.Folders.Count > 0) {
|
||||||
new NSMenuItem () { Title = "gnome-design" },
|
|
||||||
new NSMenuItem () { Title = "tango-icons" }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
FolderMenuItems = new NSMenuItem [SparkleShare.Controller.Folders.Count];
|
||||||
|
Tasks = new EventHandler [SparkleShare.Controller.Folders.Count];
|
||||||
|
|
||||||
// if (SparkleShare.Controller.Folders.Count > 0) {
|
int i = 0;
|
||||||
|
|
||||||
|
foreach (string path in SparkleShare.Controller.Folders) {
|
||||||
// foreach (string path in SparkleShare.Controller.Folders) {
|
|
||||||
|
|
||||||
foreach (NSMenuItem item in FolderMenuItems) {
|
|
||||||
|
|
||||||
// if (repo.HasUnsyncedChanges)
|
// if (repo.HasUnsyncedChanges)
|
||||||
// folder_action.IconName = "dialog-error";
|
// folder_action.IconName = "dialog-error";
|
||||||
|
|
||||||
|
NSMenuItem item = new NSMenuItem ();
|
||||||
|
|
||||||
|
item.Title = System.IO.Path.GetFileName (path);
|
||||||
item.Image = NSImage.ImageNamed ("NSFolder");
|
item.Image = NSImage.ImageNamed ("NSFolder");
|
||||||
item.Image.Size = new SizeF (16, 16);
|
item.Image.Size = new SizeF (16, 16);
|
||||||
|
|
||||||
item.Activated += delegate {
|
Tasks [i] = OpenEventLogDelegate(item.Title);
|
||||||
|
|
||||||
|
FolderMenuItems [i] = item;
|
||||||
|
FolderMenuItems [i].Activated += Tasks [i];
|
||||||
|
Menu.AddItem (FolderMenuItems [i]);
|
||||||
|
|
||||||
|
i++;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
item.Activated += OpenEventLogDelegate (item.Title);
|
} else {
|
||||||
|
|
||||||
Menu.AddItem (item);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
// } else {
|
|
||||||
|
|
||||||
// TODO: No Remote Folders Yet
|
// TODO: No Remote Folders Yet
|
||||||
|
|
||||||
// }
|
}
|
||||||
|
|
||||||
Menu.AddItem (NSMenuItem.SeparatorItem);
|
Menu.AddItem (NSMenuItem.SeparatorItem);
|
||||||
|
|
||||||
|
@ -205,11 +205,11 @@ namespace SparkleShare {
|
||||||
Title = "Add Remote Folder..."
|
Title = "Add Remote Folder..."
|
||||||
};
|
};
|
||||||
|
|
||||||
// if (SparkleShare.Controller.FirstRun)
|
if (SparkleShare.Controller.FirstRun)
|
||||||
// SyncMenuItem.Enabled = false;
|
SyncMenuItem.Enabled = false;
|
||||||
|
|
||||||
SyncMenuItem.Activated += delegate {
|
SyncMenuItem.Activated += delegate {
|
||||||
// TODO
|
SparkleWindow w = new SparkleWindow ();
|
||||||
};
|
};
|
||||||
|
|
||||||
Menu.AddItem (SyncMenuItem);
|
Menu.AddItem (SyncMenuItem);
|
||||||
|
@ -219,16 +219,21 @@ namespace SparkleShare {
|
||||||
|
|
||||||
|
|
||||||
NotificationsMenuItem = new NSMenuItem () {
|
NotificationsMenuItem = new NSMenuItem () {
|
||||||
Title = "Show Notifications",
|
Title = "Show Notifications"
|
||||||
State = NSCellStateValue.On
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// if (SparkleShare.Controller.NotificationsEnabled)
|
if (SparkleShare.Controller.NotificationsEnabled)
|
||||||
// NotificationsMenuItem.State = NSCellStateValue.On;
|
NotificationsMenuItem.State = NSCellStateValue.On;
|
||||||
// else
|
|
||||||
// NotificationsMenuItem.State = NSCellStateValue.On;
|
|
||||||
NotificationsMenuItem.Activated += delegate {
|
NotificationsMenuItem.Activated += delegate {
|
||||||
// SparkleShare.Controller.ToggleNotifications ();
|
|
||||||
|
SparkleShare.Controller.ToggleNotifications ();
|
||||||
|
|
||||||
|
if (SparkleShare.Controller.NotificationsEnabled)
|
||||||
|
NotificationsMenuItem.State = NSCellStateValue.On;
|
||||||
|
else
|
||||||
|
NotificationsMenuItem.State = NSCellStateValue.Off;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Menu.AddItem (NotificationsMenuItem);
|
Menu.AddItem (NotificationsMenuItem);
|
||||||
|
@ -248,33 +253,30 @@ namespace SparkleShare {
|
||||||
Menu.AddItem (AboutMenuItem);
|
Menu.AddItem (AboutMenuItem);
|
||||||
|
|
||||||
StatusItem.Menu = Menu;
|
StatusItem.Menu = Menu;
|
||||||
|
StatusItem.Menu.Update ();
|
||||||
|
Console.WriteLine ("MENU UPDATED");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public delegate void Task();
|
||||||
|
EventHandler [] Tasks;
|
||||||
|
|
||||||
// A method reference that makes sure that opening the
|
// A method reference that makes sure that opening the
|
||||||
// event log for each repository works correctly
|
// event log for each repository works correctly
|
||||||
private EventHandler OpenEventLogDelegate (string path)
|
private EventHandler OpenEventLogDelegate (string path)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
return delegate {
|
return delegate {
|
||||||
|
|
||||||
SparkleLog log = null; //SparkleUI.OpenLogs.Find (delegate (SparkleLog l) { return l.LocalPath.Equals (path); });
|
SparkleLog log = SparkleUI.OpenLogs.Find (delegate (SparkleLog l) { return l.LocalPath.Equals (path); });
|
||||||
|
|
||||||
// Check whether the log is already open, create a new one if
|
// Check whether the log is already open, create a new one if
|
||||||
// that's not the case or present it to the user if it is
|
// that's not the case or present it to the user if it is
|
||||||
if (log == null) {
|
if (log == null) {
|
||||||
|
|
||||||
log = new SparkleLog (path);
|
SparkleUI.OpenLogs.Add (new SparkleLog (path));
|
||||||
|
|
||||||
/*log.Hidden += delegate {
|
|
||||||
|
|
||||||
SparkleUI.OpenLogs.Remove (log);
|
|
||||||
log.Destroy ();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
SparkleUI.OpenLogs.Add (log);*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,15 +308,15 @@ namespace SparkleShare {
|
||||||
|
|
||||||
Animation.Stop ();
|
Animation.Stop ();
|
||||||
|
|
||||||
if (false /* SparkleShare.Controller.Folders.Count == 0 */) {
|
if (SparkleShare.Controller.Folders.Count == 0) {
|
||||||
|
|
||||||
StateText = _("Welcome to SparkleShare!");
|
StateText = _("Welcome to SparkleShare!");
|
||||||
InvokeOnMainThread (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
|
|
||||||
StatusItem.Image = NSImage.ImageNamed ("idle.png");
|
StatusItem.Image = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/idle.png");
|
||||||
StatusItem.Image.Size = new SizeF (16, 16);
|
StatusItem.Image.Size = new SizeF (16, 16);
|
||||||
|
|
||||||
StatusItem.AlternateImage = NSImage.ImageNamed ("idle-active.png");
|
StatusItem.AlternateImage = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/idle-active.png");
|
||||||
StatusItem.AlternateImage.Size = new SizeF (16, 16);
|
StatusItem.AlternateImage.Size = new SizeF (16, 16);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -330,13 +332,13 @@ namespace SparkleShare {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
StateText = _("Up to date") + " ("/* + SparkleShare.Controller.FolderSize + ")" */;
|
StateText = _("Up to date") + " (" + SparkleShare.Controller.FolderSize + ")";
|
||||||
InvokeOnMainThread (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
|
|
||||||
StatusItem.Image = NSImage.ImageNamed ("idle.png");
|
StatusItem.Image = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/idle.png");
|
||||||
StatusItem.Image.Size = new SizeF (16, 16);
|
StatusItem.Image.Size = new SizeF (16, 16);
|
||||||
|
|
||||||
StatusItem.AlternateImage = NSImage.ImageNamed ("idle-active.png");
|
StatusItem.AlternateImage = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/idle-active.png");
|
||||||
StatusItem.AlternateImage.Size = new SizeF (16, 16);
|
StatusItem.AlternateImage.Size = new SizeF (16, 16);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,155 +14,50 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
using Gtk;
|
|
||||||
using Mono.Unix;
|
|
||||||
using Mono.Unix.Native;
|
|
||||||
using SparkleLib;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.Timers;
|
||||||
using System.Runtime.InteropServices;
|
using MonoMac.Foundation;
|
||||||
using System.Text;
|
using MonoMac.AppKit;
|
||||||
using System.Threading;
|
using MonoMac.ObjCRuntime;
|
||||||
|
using MonoMac.WebKit;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
public class SparkleUI {
|
public partial class AppDelegate : NSApplicationDelegate {
|
||||||
|
// Workaround to be able to work with SparkleUI as the main class
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class SparkleUI : AppDelegate
|
||||||
|
{
|
||||||
|
|
||||||
public static SparkleStatusIcon StatusIcon;
|
public static SparkleStatusIcon StatusIcon;
|
||||||
public static List <SparkleLog> OpenLogs;
|
public static List <SparkleLog> OpenLogs;
|
||||||
|
|
||||||
|
|
||||||
// Short alias for the translations
|
|
||||||
public static string _(string s)
|
|
||||||
{
|
|
||||||
return Catalog.GetString (s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public SparkleUI ()
|
public SparkleUI ()
|
||||||
{
|
{
|
||||||
|
|
||||||
// Initialize the application
|
NSApplication.Init ();
|
||||||
Application.Init ();
|
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
||||||
|
//NSApplication.SharedApplication.applicationIconImage = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/sparkeshare.icns");
|
||||||
|
|
||||||
// Create the statusicon
|
OpenLogs = new List <SparkleLog> ();
|
||||||
StatusIcon = new SparkleStatusIcon ();
|
StatusIcon = new SparkleStatusIcon ();
|
||||||
|
|
||||||
// Keep track of which event logs are open
|
|
||||||
SparkleUI.OpenLogs = new List <SparkleLog> ();
|
|
||||||
|
|
||||||
SparkleShare.Controller.OnFirstRun += delegate {
|
|
||||||
Application.Invoke (delegate {
|
|
||||||
|
|
||||||
SparkleIntro intro = new SparkleIntro ();
|
|
||||||
intro.ShowAll ();
|
|
||||||
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
SparkleShare.Controller.OnInvitation += delegate (string invitation_file_path) {
|
|
||||||
Application.Invoke (delegate {
|
|
||||||
|
|
||||||
SparkleInvitation invitation = new SparkleInvitation (invitation_file_path);
|
|
||||||
invitation.Present ();
|
|
||||||
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Show a bubble when there are new changes
|
|
||||||
SparkleShare.Controller.NotificationRaised += delegate (SparkleCommit commit, string repository_path) {
|
|
||||||
|
|
||||||
string file_name = "";
|
|
||||||
string message = null;
|
|
||||||
|
|
||||||
if (commit.Added.Count > 0) {
|
|
||||||
|
|
||||||
foreach (string added in commit.Added) {
|
|
||||||
file_name = added;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
message = String.Format (_("added ‘{0}’"), file_name);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (commit.Edited.Count > 0) {
|
|
||||||
|
|
||||||
foreach (string modified in commit.Edited) {
|
|
||||||
file_name = modified;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
message = String.Format (_("edited ‘{0}’"), file_name);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (commit.Deleted.Count > 0) {
|
|
||||||
|
|
||||||
foreach (string removed in commit.Deleted) {
|
|
||||||
file_name = removed;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
message = String.Format (_("deleted ‘{0}’"), file_name);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int changes_count = (commit.Added.Count +
|
|
||||||
commit.Edited.Count +
|
|
||||||
commit.Deleted.Count);
|
|
||||||
|
|
||||||
if (changes_count > 1)
|
|
||||||
message += " + " + (changes_count - 1);
|
|
||||||
|
|
||||||
|
|
||||||
Application.Invoke (delegate {
|
|
||||||
|
|
||||||
SparkleBubble bubble = new SparkleBubble (commit.UserName, message);
|
|
||||||
|
|
||||||
string avatar_file_path = SparkleUIHelpers.GetAvatar (commit.UserEmail, 32);
|
|
||||||
|
|
||||||
if (avatar_file_path != null)
|
|
||||||
bubble.Icon = new Gdk.Pixbuf (avatar_file_path);
|
|
||||||
else
|
|
||||||
bubble.Icon = SparkleUIHelpers.GetIcon ("avatar-default", 32);
|
|
||||||
|
|
||||||
// bubble.AddAction ("", "Show Events", delegate {
|
|
||||||
|
|
||||||
// SparkleLog log = new SparkleLog (repository_path);
|
|
||||||
// log.ShowAll ();
|
|
||||||
|
|
||||||
// });
|
|
||||||
|
|
||||||
// bubble.Show ();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
// Show a bubble when there was a conflict
|
|
||||||
SparkleShare.Controller.ConflictNotificationRaised += delegate {
|
|
||||||
Application.Invoke (delegate {
|
|
||||||
|
|
||||||
string title = _("Ouch! Mid-air collision!");
|
|
||||||
string subtext = _("Don't worry, SparkleShare made a copy of each conflicting file.");
|
|
||||||
|
|
||||||
SparkleBubble bubble = new SparkleBubble(title, subtext);
|
|
||||||
// bubble.Show ();
|
|
||||||
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Runs the application
|
|
||||||
public void Run ()
|
public void Run ()
|
||||||
{
|
{
|
||||||
|
|
||||||
Application.Run ();
|
NSApplication.Main (new string [0]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
73
SparkleShare/Mac/SparkleShare/SparkleWindow.cs
Normal file
73
SparkleShare/Mac/SparkleShare/SparkleWindow.cs
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
// SparkleShare, an instant update workflow to Git.
|
||||||
|
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using MonoMac.Foundation;
|
||||||
|
using MonoMac.AppKit;
|
||||||
|
using MonoMac.ObjCRuntime;
|
||||||
|
using MonoMac.WebKit;
|
||||||
|
|
||||||
|
namespace SparkleShare {
|
||||||
|
|
||||||
|
public class SparkleWindow : NSWindow {
|
||||||
|
|
||||||
|
public readonly string LocalPath;
|
||||||
|
|
||||||
|
private WebView WebView;
|
||||||
|
private NSButton CloseButton;
|
||||||
|
private NSButton OpenFolderButton;
|
||||||
|
|
||||||
|
private NSImage SideSplash;
|
||||||
|
|
||||||
|
public SparkleWindow () : base ()
|
||||||
|
{
|
||||||
|
|
||||||
|
SetFrame (new RectangleF (0, 0, 640, 480), true);
|
||||||
|
|
||||||
|
Center ();
|
||||||
|
|
||||||
|
StyleMask = (NSWindowStyle.Closable |
|
||||||
|
NSWindowStyle.Miniaturizable |
|
||||||
|
NSWindowStyle.Titled);
|
||||||
|
|
||||||
|
MaxSize = new SizeF (640, 480);
|
||||||
|
MinSize = new SizeF (640, 480);
|
||||||
|
HasShadow = true;
|
||||||
|
BackingType = NSBackingStore.Buffered;
|
||||||
|
|
||||||
|
SideSplash = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/side-splash.png");
|
||||||
|
SideSplash.Size = new SizeF (150, 480);
|
||||||
|
|
||||||
|
|
||||||
|
NSText tv = new NSText (new RectangleF (200, 200, 200, 200)) {
|
||||||
|
Value = "TEST"
|
||||||
|
};
|
||||||
|
|
||||||
|
ContentView.AddSubview (new NSImageView (new RectangleF (0, 0, 150, 480)) { Image = SideSplash});
|
||||||
|
ContentView.AddSubview (new NSTextField (new RectangleF (200, 100, 128, 31)) { BezelStyle = NSTextFieldBezelStyle.Rounded});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
||||||
|
MakeKeyAndOrderFront (this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue