Add app.dock.setMenu API

This commit is contained in:
Cheng Zhao 2014-11-16 23:04:31 +08:00
parent ba4f502b1e
commit 0e94977d42
8 changed files with 52 additions and 13 deletions

View file

@ -4,7 +4,16 @@
#import <Cocoa/Cocoa.h>
#import "atom/browser/ui/cocoa/atom_menu_controller.h"
@interface AtomApplicationDelegate : NSObject<NSApplicationDelegate> {
@private
base::scoped_nsobject<AtomMenuController> menu_controller_;
}
- (id)init;
// Sets the menu that will be returned in "applicationDockMenu:".
- (void)setApplicationDockMenu:(ui::MenuModel*)model;
@end

View file

@ -10,6 +10,16 @@
@implementation AtomApplicationDelegate
- (id)init {
self = [super init];
menu_controller_.reset([[AtomMenuController alloc] init]);
return self;
}
- (void)setApplicationDockMenu:(ui::MenuModel*)model {
[menu_controller_ populateWithModel:model];
}
- (void)applicationWillFinishLaunching:(NSNotification*)notify {
atom::Browser::Get()->WillFinishLaunching();
}
@ -18,6 +28,10 @@
atom::Browser::Get()->DidFinishLaunching();
}
- (NSMenu*)applicationDockMenu:(NSApplication*)sender {
return [menu_controller_ menu];
}
- (BOOL)application:(NSApplication*)sender
openFile:(NSString*)filename {
std::string filename_str(base::SysNSStringToUTF8(filename));