Permalink
Browse files

[build] Add Cocoa solution and status icon in Cocoa

  • Loading branch information...
hbons committed Nov 14, 2010
1 parent 600948d commit 2e404b74f43cac75b4ea9c06fabcdfc529b90560
View
@@ -1,7 +1,9 @@
*~
+.DS_Store
*.exe
*.exe.mdb
*.userprefs
+*.app
*.pidb
*.gmo
po/POTFILES
@@ -0,0 +1,125 @@
+using System;
+using System.Drawing;
+using MonoMac.Foundation;
+using MonoMac.AppKit;
+using MonoMac.ObjCRuntime;
+
+namespace SparkleShare
+{
+ public partial class AppDelegate : NSApplicationDelegate
+ {
+ MainWindowController mainWindowController;
+
+ public AppDelegate ()
+ {
+ }
+
+ public override void FinishedLaunching (NSObject notification)
+ {
+ mainWindowController = new MainWindowController ();
+ mainWindowController.Window.MakeKeyAndOrderFront (this);
+
+ // SparkleStatusIcon = new SparkleStatusIcon ();
+
+
+ var statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem (32);
+
+ statusItem.Enabled = true;
+
+ statusItem.Image = NSImage.ImageNamed ("sparkleshare-idle.png");
+ statusItem.AlternateImage = NSImage.ImageNamed ("sparkleshare-idle-focus.png");
+ statusItem.Image.Size = new SizeF (16, 16);
+ statusItem.AlternateImage.Size = new SizeF (16, 16);
+
+ NSMenu menu = new NSMenu() {};
+ menu.AddItem (new NSMenuItem () { Title="Up to date (102 MB)", Enabled = true });
+ menu.AddItem (NSMenuItem.SeparatorItem);
+
+ var item = new NSMenuItem () {
+ Title="SparkleShare", Enabled = true,
+ Action = new Selector ("ddd")
+ };
+
+ item.Activated += delegate {
+ Console.WriteLine ("DDDD");
+ };
+
+ item.Image = NSImage.ImageNamed ("NSFolder");
+ item.Image.Size = new SizeF (16, 16);
+
+ menu.AddItem (item);
+
+ var tmp = new NSMenuItem () {
+ Title="gnome-design", Enabled = true,
+ Action = new Selector ("ddd")
+ };
+
+ tmp.Activated += delegate {
+ Console.WriteLine ("DDDD");
+ };
+
+ tmp.Image = NSImage.ImageNamed ("NSFolder");
+ tmp.Image.Size = new SizeF (16, 16);
+
+ menu.AddItem (tmp);
+ menu.AddItem (NSMenuItem.SeparatorItem);
+
+ Console.WriteLine (item.Action.Name);
+
+ NSMenuItem sync_menu_item = new NSMenuItem () {
+ Title = "Sync Remote Folder..."
+ };
+
+ sync_menu_item.Activated += delegate {
+ Console.WriteLine ("DDDD");
+ };
+
+ menu.AddItem (sync_menu_item);
+ menu.AddItem (NSMenuItem.SeparatorItem);
+
+ NSMenuItem notifications_menu_item = new NSMenuItem () {
+ Title = "Show Notifications",
+ State = NSCellStateValue.On
+ };
+
+ notifications_menu_item.Activated += delegate {
+ statusItem.Image = NSImage.ImageNamed ("NSComputer");
+ if (notifications_menu_item.State == NSCellStateValue.On)
+ notifications_menu_item.State = NSCellStateValue.Off;
+ else
+ notifications_menu_item.State = NSCellStateValue.On;
+ };
+
+ menu.AddItem (notifications_menu_item);
+ menu.AddItem (NSMenuItem.SeparatorItem);
+
+ NSMenuItem about_menu_item = new NSMenuItem () {
+ Title = "About"
+ };
+
+ about_menu_item.Activated += delegate {
+ Console.WriteLine ("DDDD");
+ statusItem.Title = "bla";
+ };
+
+ menu.AddItem (about_menu_item);
+ menu.AddItem (NSMenuItem.SeparatorItem);
+
+ NSMenuItem quit_menu_item = new NSMenuItem () {
+ Title = "Quit"
+ };
+ quit_menu_item.Activated += delegate {
+ Console.WriteLine ("DDDD");
+ Environment.Exit (0);
+ };
+
+ menu.AddItem (quit_menu_item);
+
+
+
+ statusItem.Menu = menu;
+ statusItem.HighlightMode = true;
+ }
+ }
+}
+
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.SparkleShare</string>
+ <key>CFBundleName</key>
+ <string>SparkleShare</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>10.6</string>
+ <key>NSMainNibFile</key>
+ <string>MainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
@@ -0,0 +1,18 @@
+using System;
+using System.Drawing;
+using MonoMac.Foundation;
+using MonoMac.AppKit;
+using MonoMac.ObjCRuntime;
+
+namespace SparkleShare
+{
+ class MainClass
+ {
+ static void Main (string[] args)
+ {
+ NSApplication.Init ();
+ NSApplication.Main (args);
+ }
+ }
+}
+
Oops, something went wrong.

0 comments on commit 2e404b7

Please sign in to comment.