Move UI events to controllers
This commit is contained in:
parent
ca8ad5dc96
commit
9f63b5e565
|
@ -6,15 +6,11 @@
|
||||||
<integer>1</integer>
|
<integer>1</integer>
|
||||||
<key>AllNotifications</key>
|
<key>AllNotifications</key>
|
||||||
<array>
|
<array>
|
||||||
<string>Start</string>
|
<string>Event</string>
|
||||||
<string>Stop</string>
|
|
||||||
<string>Info</string>
|
|
||||||
</array>
|
</array>
|
||||||
<key>DefaultNotifications</key>
|
<key>DefaultNotifications</key>
|
||||||
<array>
|
<array>
|
||||||
<string>Start</string>
|
<string>Event</string>
|
||||||
<string>Stop</string>
|
|
||||||
<string>Info</string>
|
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
@ -70,7 +57,6 @@ namespace SparkleShare {
|
||||||
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 ()) {
|
||||||
|
|
||||||
// Needed for Growl
|
// Needed for Growl
|
||||||
|
@ -79,47 +65,26 @@ 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,
|
|
||||||
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) {
|
if (SparkleShare.Controller.FirstRun) {
|
||||||
Intro = new SparkleIntro ();
|
Intro = new SparkleIntro ();
|
||||||
Intro.ShowAccountForm ();
|
Intro.ShowAccountForm ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SetFolderIcon ()
|
public void SetFolderIcon ()
|
||||||
|
@ -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