diff options
Diffstat (limited to 'Slimber/Cocoa')
-rw-r--r-- | Slimber/Cocoa/CocoaController.mm | 14 | ||||
-rw-r--r-- | Slimber/Cocoa/CocoaMenulet.h | 34 | ||||
-rw-r--r-- | Slimber/Cocoa/CocoaMenulet.mm | 86 | ||||
-rw-r--r-- | Slimber/Cocoa/main.mm | 8 |
4 files changed, 71 insertions, 71 deletions
diff --git a/Slimber/Cocoa/CocoaController.mm b/Slimber/Cocoa/CocoaController.mm index 1d2ef5c..7d17948 100644 --- a/Slimber/Cocoa/CocoaController.mm +++ b/Slimber/Cocoa/CocoaController.mm @@ -11,19 +11,19 @@ #include <Slimber/MainController.h> @implementation CocoaController { - CocoaMenulet* menulet; - MainController* main; + CocoaMenulet* menulet; + MainController* main; } - (void) dealloc { - delete main; - delete menulet; - [super dealloc]; + delete main; + delete menulet; + [super dealloc]; } - (void) awakeFromNib { - menulet = new CocoaMenulet(); - main = new MainController(menulet, eventLoop); + menulet = new CocoaMenulet(); + main = new MainController(menulet, eventLoop); } @end diff --git a/Slimber/Cocoa/CocoaMenulet.h b/Slimber/Cocoa/CocoaMenulet.h index c31f15c..0dc06f5 100644 --- a/Slimber/Cocoa/CocoaMenulet.h +++ b/Slimber/Cocoa/CocoaMenulet.h @@ -13,21 +13,21 @@ #include <SwifTools/Cocoa/CocoaAction.h> class CocoaMenulet : public Menulet { - public: - CocoaMenulet(); - virtual ~CocoaMenulet(); - - private: - virtual void clear(); - virtual void addItem(const std::string& name, const std::string& icon); - virtual void addSeparator(); - void setIcon(const std::string& icon); - virtual void addAboutItem(); - virtual void addRestartItem(); - virtual void addExitItem(); - - private: - NSStatusItem* statusItem; - NSMenu* menu; - CocoaAction* restartAction; + public: + CocoaMenulet(); + virtual ~CocoaMenulet(); + + private: + virtual void clear(); + virtual void addItem(const std::string& name, const std::string& icon); + virtual void addSeparator(); + void setIcon(const std::string& icon); + virtual void addAboutItem(); + virtual void addRestartItem(); + virtual void addExitItem(); + + private: + NSStatusItem* statusItem; + NSMenu* menu; + CocoaAction* restartAction; }; diff --git a/Slimber/Cocoa/CocoaMenulet.mm b/Slimber/Cocoa/CocoaMenulet.mm index f62da80..98042d7 100644 --- a/Slimber/Cocoa/CocoaMenulet.mm +++ b/Slimber/Cocoa/CocoaMenulet.mm @@ -11,72 +11,72 @@ #include <SwifTools/Cocoa/CocoaUtil.h> CocoaMenulet::CocoaMenulet() { - restartAction = [[CocoaAction alloc] initWithFunction: - new boost::function<void()>(boost::ref(onRestartClicked))]; - menu = [[NSMenu alloc] init]; + restartAction = [[CocoaAction alloc] initWithFunction: + new boost::function<void()>(boost::ref(onRestartClicked))]; + menu = [[NSMenu alloc] init]; - statusItem = [[[NSStatusBar systemStatusBar] - statusItemWithLength: NSVariableStatusItemLength] retain]; - [statusItem setHighlightMode: YES]; - [statusItem setEnabled: YES]; - [statusItem setToolTip: @"Slimber"]; - [statusItem setMenu: menu]; + statusItem = [[[NSStatusBar systemStatusBar] + statusItemWithLength: NSVariableStatusItemLength] retain]; + [statusItem setHighlightMode: YES]; + [statusItem setEnabled: YES]; + [statusItem setToolTip: @"Slimber"]; + [statusItem setMenu: menu]; } CocoaMenulet::~CocoaMenulet() { - [statusItem release]; - [menu release]; - [restartAction release]; + [statusItem release]; + [menu release]; + [restartAction release]; } void CocoaMenulet::setIcon(const std::string& icon) { - NSString* path = [[NSBundle mainBundle] pathForResource: std2NSString(icon) ofType:@"png"]; - NSImage* image = [[NSImage alloc] initWithContentsOfFile: path]; - [statusItem setImage: image]; - [image release]; + NSString* path = [[NSBundle mainBundle] pathForResource: std2NSString(icon) ofType:@"png"]; + NSImage* image = [[NSImage alloc] initWithContentsOfFile: path]; + [statusItem setImage: image]; + [image release]; } void CocoaMenulet::clear() { - while ([menu numberOfItems] > 0) { - [menu removeItemAtIndex: 0]; - } + while ([menu numberOfItems] > 0) { + [menu removeItemAtIndex: 0]; + } } void CocoaMenulet::addItem(const std::string& name, const std::string& icon) { - NSMenuItem* item = [[NSMenuItem alloc] initWithTitle: std2NSString(name) - action: NULL keyEquivalent: @""]; - if (!icon.empty()) { - NSString* path = [[NSBundle mainBundle] pathForResource: std2NSString(icon) ofType:@"png"]; - NSImage* image = [[NSImage alloc] initWithContentsOfFile: path]; - [item setImage: image]; - [image release]; - } - [menu addItem: item]; - [item release]; + NSMenuItem* item = [[NSMenuItem alloc] initWithTitle: std2NSString(name) + action: NULL keyEquivalent: @""]; + if (!icon.empty()) { + NSString* path = [[NSBundle mainBundle] pathForResource: std2NSString(icon) ofType:@"png"]; + NSImage* image = [[NSImage alloc] initWithContentsOfFile: path]; + [item setImage: image]; + [image release]; + } + [menu addItem: item]; + [item release]; } void CocoaMenulet::addAboutItem() { - NSMenuItem* item = [[NSMenuItem alloc] initWithTitle: @"About Slimber" action: @selector(orderFrontStandardAboutPanel:) keyEquivalent: @""]; - [item setTarget: [NSApplication sharedApplication]]; - [menu addItem: item]; - [item release]; + NSMenuItem* item = [[NSMenuItem alloc] initWithTitle: @"About Slimber" action: @selector(orderFrontStandardAboutPanel:) keyEquivalent: @""]; + [item setTarget: [NSApplication sharedApplication]]; + [menu addItem: item]; + [item release]; } void CocoaMenulet::addRestartItem() { - NSMenuItem* item = [[NSMenuItem alloc] initWithTitle: - @"Restart" action: @selector(doAction:) keyEquivalent: @""]; - [item setTarget: restartAction]; - [menu addItem: item]; - [item release]; + NSMenuItem* item = [[NSMenuItem alloc] initWithTitle: + @"Restart" action: @selector(doAction:) keyEquivalent: @""]; + [item setTarget: restartAction]; + [menu addItem: item]; + [item release]; } void CocoaMenulet::addExitItem() { - NSMenuItem* item = [[NSMenuItem alloc] initWithTitle: @"Exit" action: @selector(terminate:) keyEquivalent: @""]; - [item setTarget: [NSApplication sharedApplication]]; - [menu addItem: item]; - [item release]; + NSMenuItem* item = [[NSMenuItem alloc] initWithTitle: @"Exit" action: @selector(terminate:) keyEquivalent: @""]; + [item setTarget: [NSApplication sharedApplication]]; + [menu addItem: item]; + [item release]; } void CocoaMenulet::addSeparator() { - [menu addItem: [NSMenuItem separatorItem]]; + [menu addItem: [NSMenuItem separatorItem]]; } diff --git a/Slimber/Cocoa/main.mm b/Slimber/Cocoa/main.mm index 41678f1..c5495af 100644 --- a/Slimber/Cocoa/main.mm +++ b/Slimber/Cocoa/main.mm @@ -13,8 +13,8 @@ Swift::CocoaEventLoop* eventLoop; int main(int argc, char *argv[]) { - eventLoop = new Swift::CocoaEventLoop(); - int result = NSApplicationMain(argc, const_cast<const char **>(argv)); - delete eventLoop; - return result; + eventLoop = new Swift::CocoaEventLoop(); + int result = NSApplicationMain(argc, const_cast<const char **>(argv)); + delete eventLoop; + return result; } |