Move UI events to controllers
This commit is contained in:
parent
ca8ad5dc96
commit
9f63b5e565
|
@ -2,19 +2,15 @@
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>TicketVersion</key>
|
<key>TicketVersion</key>
|
||||||
<integer>1</integer>
|
<integer>1</integer>
|
||||||
<key>AllNotifications</key>
|
<key>AllNotifications</key>
|
||||||
<array>
|
<array>
|
||||||
<string>Start</string>
|
<string>Event</string>
|
||||||
<string>Stop</string>
|
</array>
|
||||||
<string>Info</string>
|
<key>DefaultNotifications</key>
|
||||||
</array>
|
<array>
|
||||||
<key>DefaultNotifications</key>
|
<string>Event</string>
|
||||||
<array>
|
</array>
|
||||||
<string>Start</string>
|
|
||||||
<string>Stop</string>
|
|
||||||
<string>Info</string>
|
|
||||||
</array>
|
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public SparkleBubbles ()
|
public SparkleBubbles ()
|
||||||
{
|
{
|
||||||
this.controller.ShowBubbleEvent += delegate(string title, string subtext, string image_path) {
|
this.controller.ShowBubbleEvent += delegate (string title, string subtext, string image_path) {
|
||||||
InvokeOnMainThread (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
if (!GrowlApplicationBridge.IsGrowlRunning ()) {
|
if (!GrowlApplicationBridge.IsGrowlRunning ()) {
|
||||||
NSApplication.SharedApplication.RequestUserAttention (
|
NSApplication.SharedApplication.RequestUserAttention (
|
||||||
|
@ -40,14 +40,22 @@ namespace SparkleShare {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (NSApplication.SharedApplication.DockTile.BadgeLabel == null) {
|
||||||
|
NSApplication.SharedApplication.DockTile.BadgeLabel = "1";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
int events = int.Parse (NSApplication.SharedApplication.DockTile.BadgeLabel);
|
||||||
|
NSApplication.SharedApplication.DockTile.BadgeLabel = (events + 1).ToString ();
|
||||||
|
}
|
||||||
|
|
||||||
if (image_path != null && File.Exists (image_path)) {
|
if (image_path != null && File.Exists (image_path)) {
|
||||||
NSData image_data = NSData.FromFile (image_path);
|
NSData image_data = NSData.FromFile (image_path);
|
||||||
GrowlApplicationBridge.Notify (title, subtext,
|
GrowlApplicationBridge.Notify (title, subtext,
|
||||||
"Start", image_data, 0, false, null);
|
"Event", image_data, 0, false, null);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
GrowlApplicationBridge.Notify (title, subtext,
|
GrowlApplicationBridge.Notify (title, subtext,
|
||||||
"Start", null, 0, false, null);
|
"Event", null, 0, false, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,14 +28,15 @@ namespace SparkleShare {
|
||||||
public SparkleBubblesController ()
|
public SparkleBubblesController ()
|
||||||
{
|
{
|
||||||
SparkleShare.Controller.ConflictNotificationRaised += delegate {
|
SparkleShare.Controller.ConflictNotificationRaised += delegate {
|
||||||
if (ShowBubbleEvent != null)
|
if (ShowBubbleEvent != null && SparkleShare.Controller.NotificationsEnabled)
|
||||||
ShowBubbleEvent ("Ouch! Mid-air collision!",
|
ShowBubbleEvent ("Ouch! Mid-air collision!",
|
||||||
"Don't worry, SparkleShare made a copy of each conflicting file.", null);
|
"Don't worry, SparkleShare made a copy of each conflicting file.", null);
|
||||||
};
|
};
|
||||||
|
|
||||||
SparkleShare.Controller.NotificationRaised += delegate (string user_name, string user_email,
|
SparkleShare.Controller.NotificationRaised += delegate (string user_name, string user_email,
|
||||||
string message, string folder_path) {
|
string message, string folder_path) {
|
||||||
if (ShowBubbleEvent != null)
|
|
||||||
|
if (ShowBubbleEvent != null && SparkleShare.Controller.NotificationsEnabled)
|
||||||
ShowBubbleEvent (user_name, message,
|
ShowBubbleEvent (user_name, message,
|
||||||
SparkleShare.Controller.GetAvatar (user_email, 36));
|
SparkleShare.Controller.GetAvatar (user_email, 36));
|
||||||
};
|
};
|
|
@ -91,8 +91,8 @@
|
||||||
<Compile Include="SparkleEventLog.cs" />
|
<Compile Include="SparkleEventLog.cs" />
|
||||||
<Compile Include="SparkleBadger.cs" />
|
<Compile Include="SparkleBadger.cs" />
|
||||||
<Compile Include="SparkleEventLogController.cs" />
|
<Compile Include="SparkleEventLogController.cs" />
|
||||||
<Compile Include="SparkleBubbleController.cs" />
|
|
||||||
<Compile Include="SparkleBubbles.cs" />
|
<Compile Include="SparkleBubbles.cs" />
|
||||||
|
<Compile Include="SparkleBubblesController.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Page Include="MainMenu.xib" />
|
<Page Include="MainMenu.xib" />
|
||||||
|
|
|
@ -29,25 +29,12 @@ using MonoMac.Growl;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
public partial class AppDelegate : NSApplicationDelegate {
|
|
||||||
|
|
||||||
public override void WillBecomeActive (NSNotification notification)
|
|
||||||
{
|
|
||||||
NSApplication.SharedApplication.DockTile.BadgeLabel = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void WillTerminate (NSNotification notification)
|
|
||||||
{
|
|
||||||
SparkleShare.Controller.Quit ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public class SparkleUI : AppDelegate {
|
public class SparkleUI : AppDelegate {
|
||||||
|
|
||||||
public static SparkleStatusIcon StatusIcon;
|
public static SparkleStatusIcon StatusIcon;
|
||||||
public static SparkleEventLog EventLog;
|
public static SparkleEventLog EventLog;
|
||||||
public static SparkleIntro Intro;
|
public static SparkleIntro Intro;
|
||||||
|
public static SparkleBubbles Bubbles;
|
||||||
public static SparkleAbout About;
|
public static SparkleAbout About;
|
||||||
public static NSFont Font;
|
public static NSFont Font;
|
||||||
|
|
||||||
|
@ -69,7 +56,6 @@ namespace SparkleShare {
|
||||||
// Use translations
|
// Use translations
|
||||||
Catalog.Init ("sparkleshare",
|
Catalog.Init ("sparkleshare",
|
||||||
Path.Combine (NSBundle.MainBundle.ResourcePath, "Translations"));
|
Path.Combine (NSBundle.MainBundle.ResourcePath, "Translations"));
|
||||||
|
|
||||||
|
|
||||||
using (NSAutoreleasePool pool = new NSAutoreleasePool ()) {
|
using (NSAutoreleasePool pool = new NSAutoreleasePool ()) {
|
||||||
|
|
||||||
|
@ -79,45 +65,24 @@ namespace SparkleShare {
|
||||||
NSApplication.SharedApplication.ApplicationIconImage
|
NSApplication.SharedApplication.ApplicationIconImage
|
||||||
= NSImage.ImageNamed ("sparkleshare.icns");
|
= NSImage.ImageNamed ("sparkleshare.icns");
|
||||||
|
|
||||||
SetFolderIcon ();
|
|
||||||
|
|
||||||
if (!SparkleShare.Controller.BackendIsPresent) {
|
if (!SparkleShare.Controller.BackendIsPresent) {
|
||||||
this.alert = new SparkleAlert ();
|
this.alert = new SparkleAlert ();
|
||||||
this.alert.RunModal ();
|
this.alert.RunModal ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetFolderIcon ();
|
||||||
|
|
||||||
Font = NSFontManager.SharedFontManager.FontWithFamily
|
Font = NSFontManager.SharedFontManager.FontWithFamily
|
||||||
("Lucida Grande", NSFontTraitMask.Condensed, 0, 13);
|
("Lucida Grande", NSFontTraitMask.Condensed, 0, 13);
|
||||||
|
|
||||||
StatusIcon = new SparkleStatusIcon ();
|
StatusIcon = new SparkleStatusIcon ();
|
||||||
}
|
Bubbles = new SparkleBubbles ();
|
||||||
|
|
||||||
SparkleShare.Controller.NotificationRaised += delegate (string user_name, string user_email,
|
if (SparkleShare.Controller.FirstRun) {
|
||||||
string message, string repository_path) {
|
Intro = new SparkleIntro ();
|
||||||
InvokeOnMainThread (delegate {
|
Intro.ShowAccountForm ();
|
||||||
|
}
|
||||||
if (SparkleShare.Controller.NotificationsEnabled) {
|
|
||||||
if (NSApplication.SharedApplication.DockTile.BadgeLabel == null)
|
|
||||||
NSApplication.SharedApplication.DockTile.BadgeLabel = "1";
|
|
||||||
else
|
|
||||||
NSApplication.SharedApplication.DockTile.BadgeLabel =
|
|
||||||
(int.Parse (NSApplication.SharedApplication.DockTile.BadgeLabel) + 1).ToString ();
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (SparkleShare.Controller.FirstRun) {
|
|
||||||
Intro = new SparkleIntro ();
|
|
||||||
Intro.ShowAccountForm ();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,4 +112,18 @@ namespace SparkleShare {
|
||||||
return NSDictionary.FromFile (path);
|
return NSDictionary.FromFile (path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public partial class AppDelegate : NSApplicationDelegate {
|
||||||
|
|
||||||
|
public override void WillBecomeActive (NSNotification notification)
|
||||||
|
{
|
||||||
|
NSApplication.SharedApplication.DockTile.BadgeLabel = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WillTerminate (NSNotification notification)
|
||||||
|
{
|
||||||
|
SparkleShare.Controller.Quit ();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue