Move UI events to controllers

This commit is contained in:
Hylke Bons 2011-07-04 04:07:07 +01:00
parent 1d8867ce44
commit c3db3a3b4e
5 changed files with 47 additions and 63 deletions

View file

@ -2,19 +2,15 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>TicketVersion</key>
<integer>1</integer>
<key>AllNotifications</key>
<array>
<string>Start</string>
<string>Stop</string>
<string>Info</string>
</array>
<key>DefaultNotifications</key>
<array>
<string>Start</string>
<string>Stop</string>
<string>Info</string>
</array>
<key>TicketVersion</key>
<integer>1</integer>
<key>AllNotifications</key>
<array>
<string>Event</string>
</array>
<key>DefaultNotifications</key>
<array>
<string>Event</string>
</array>
</dict>
</plist>

View file

@ -31,7 +31,7 @@ namespace SparkleShare {
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 {
if (!GrowlApplicationBridge.IsGrowlRunning ()) {
NSApplication.SharedApplication.RequestUserAttention (
@ -40,14 +40,22 @@ namespace SparkleShare {
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)) {
NSData image_data = NSData.FromFile (image_path);
GrowlApplicationBridge.Notify (title, subtext,
"Start", image_data, 0, false, null);
"Event", image_data, 0, false, null);
} else {
GrowlApplicationBridge.Notify (title, subtext,
"Start", null, 0, false, null);
"Event", null, 0, false, null);
}
});
};

View file

@ -28,14 +28,15 @@ namespace SparkleShare {
public SparkleBubblesController ()
{
SparkleShare.Controller.ConflictNotificationRaised += delegate {
if (ShowBubbleEvent != null)
if (ShowBubbleEvent != null && SparkleShare.Controller.NotificationsEnabled)
ShowBubbleEvent ("Ouch! Mid-air collision!",
"Don't worry, SparkleShare made a copy of each conflicting file.", null);
};
SparkleShare.Controller.NotificationRaised += delegate (string user_name, string user_email,
string message, string folder_path) {
if (ShowBubbleEvent != null)
if (ShowBubbleEvent != null && SparkleShare.Controller.NotificationsEnabled)
ShowBubbleEvent (user_name, message,
SparkleShare.Controller.GetAvatar (user_email, 36));
};

View file

@ -91,8 +91,8 @@
<Compile Include="SparkleEventLog.cs" />
<Compile Include="SparkleBadger.cs" />
<Compile Include="SparkleEventLogController.cs" />
<Compile Include="SparkleBubbleController.cs" />
<Compile Include="SparkleBubbles.cs" />
<Compile Include="SparkleBubblesController.cs" />
</ItemGroup>
<ItemGroup>
<Page Include="MainMenu.xib" />

View file

@ -29,25 +29,12 @@ using MonoMac.Growl;
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 static SparkleStatusIcon StatusIcon;
public static SparkleEventLog EventLog;
public static SparkleIntro Intro;
public static SparkleBubbles Bubbles;
public static SparkleAbout About;
public static NSFont Font;
@ -69,7 +56,6 @@ namespace SparkleShare {
// Use translations
Catalog.Init ("sparkleshare",
Path.Combine (NSBundle.MainBundle.ResourcePath, "Translations"));
using (NSAutoreleasePool pool = new NSAutoreleasePool ()) {
@ -79,45 +65,24 @@ namespace SparkleShare {
NSApplication.SharedApplication.ApplicationIconImage
= NSImage.ImageNamed ("sparkleshare.icns");
SetFolderIcon ();
if (!SparkleShare.Controller.BackendIsPresent) {
this.alert = new SparkleAlert ();
this.alert.RunModal ();
return;
}
SetFolderIcon ();
Font = NSFontManager.SharedFontManager.FontWithFamily
("Lucida Grande", NSFontTraitMask.Condensed, 0, 13);
StatusIcon = new SparkleStatusIcon ();
}
Bubbles = new SparkleBubbles ();
SparkleShare.Controller.NotificationRaised += delegate (string user_name, string user_email,
string message, string repository_path) {
InvokeOnMainThread (delegate {
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 ();
if (SparkleShare.Controller.FirstRun) {
Intro = new SparkleIntro ();
Intro.ShowAccountForm ();
}
}
}
@ -147,4 +112,18 @@ namespace SparkleShare {
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 ();
}
}
}