]> khamidou — GitHub mirrors - electron.git/commitdiff
[Mac] Clean up the menu controller. v0.3.3
authorCheng Zhao <zcbenz@gmail.com>
Wed, 14 Aug 2013 15:03:02 +0000 (23:03 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 14 Aug 2013 15:03:02 +0000 (23:03 +0800)
browser/api/atom_api_menu_mac.mm
browser/ui/atom_menu_controller_mac.h
browser/ui/atom_menu_controller_mac.mm

index 2ae9f05e9a97d8f049d46f07ca5deb40efc17565..acf4849435ef4de6f4b2af11d4dc10a3e643b305 100644 (file)
@@ -24,8 +24,7 @@ MenuMac::~MenuMac() {
 
 void MenuMac::Popup(NativeWindow* native_window) {
   scoped_nsobject<AtomMenuController> menu_controller(
-      [[AtomMenuController alloc] initWithModel:model_.get()
-                         useWithPopUpButtonCell:NO]);
+      [[AtomMenuController alloc] initWithModel:model_.get()]);
 
   NSWindow* window = native_window->GetNativeWindow();
   content::WebContents* web_contents = native_window->GetWebContents();
@@ -82,8 +81,7 @@ v8::Handle<v8::Value> Menu::SetApplicationMenu(const v8::Arguments &args) {
     return node::ThrowError("Menu is destroyed");
 
   scoped_nsobject<AtomMenuController> menu_controller(
-      [[AtomMenuController alloc] initWithModel:menu->model_.get()
-                         useWithPopUpButtonCell:NO]);
+      [[AtomMenuController alloc] initWithModel:menu->model_.get()]);
   [NSApp setMainMenu:[menu_controller menu]];
 
   // Ensure the menu_controller_ is destroyed after main menu is set.
index 0455de17eb81c6612b1d26e7ae9fed4509bc1a41..74c2240efac115ec530e6d11b89c29392961d2a9 100644 (file)
@@ -25,14 +25,10 @@ class MenuModel;
  @protected
   ui::MenuModel* model_;  // weak
   scoped_nsobject<NSMenu> menu_;
-  BOOL useWithPopUpButtonCell_;  // If YES, 0th item is blank
   BOOL isMenuOpen_;
 }
 
 @property(nonatomic, assign) ui::MenuModel* model;
-// Note that changing this will have no effect if you use
-// |-initWithModel:useWithPopUpButtonCell:| or after the first call to |-menu|.
-@property(nonatomic) BOOL useWithPopUpButtonCell;
 
 // NIB-based initializer. This does not create a menu. Clients can set the
 // properties of the object and the menu will be created upon the first call to
@@ -40,12 +36,8 @@ class MenuModel;
 - (id)init;
 
 // Builds a NSMenu from the pre-built model (must not be nil). Changes made
-// to the contents of the model after calling this will not be noticed. If
-// the menu will be displayed by a NSPopUpButtonCell, it needs to be of a
-// slightly different form (0th item is empty). Note this attribute of the menu
-// cannot be changed after it has been created.
-- (id)initWithModel:(ui::MenuModel*)model
-    useWithPopUpButtonCell:(BOOL)useWithCell;
+// to the contents of the model after calling this will not be noticed.
+- (id)initWithModel:(ui::MenuModel*)model;
 
 // Programmatically close the constructed menu.
 - (void)cancel;
@@ -75,10 +67,6 @@ class MenuModel;
               atIndex:(NSInteger)index
             fromModel:(ui::MenuModel*)model;
 - (NSMenu*)menuFromModel:(ui::MenuModel*)model;
-// Returns the maximum width for the menu item. Returns -1 to indicate
-// that there's no maximum width.
-- (int)maxWidthForMenuModel:(ui::MenuModel*)model
-                 modelIndex:(int)modelIndex;
 @end
 
 #endif  // ATOM_BROWSER_UI_ATOM_MENU_CONTROLLER_MAC_H_
index ae352a5967b32311c2858bec8643565aa80e848b..ea4a0d9358cef06891504b1d4b7938ffd3d2a919 100644 (file)
@@ -68,18 +68,15 @@ int EventFlagsFromNSEvent(NSEvent* event) {
 @implementation AtomMenuController
 
 @synthesize model = model_;
-@synthesize useWithPopUpButtonCell = useWithPopUpButtonCell_;
 
 - (id)init {
   self = [super init];
   return self;
 }
 
-- (id)initWithModel:(ui::MenuModel*)model
-    useWithPopUpButtonCell:(BOOL)useWithCell {
+- (id)initWithModel:(ui::MenuModel*)model {
   if ((self = [super init])) {
     model_ = model;
-    useWithPopUpButtonCell_ = useWithCell;
     [self menu];
   }
   return self;
@@ -120,11 +117,6 @@ int EventFlagsFromNSEvent(NSEvent* event) {
   return menu;
 }
 
-- (int)maxWidthForMenuModel:(ui::MenuModel*)model
-                 modelIndex:(int)modelIndex {
-  return -1;
-}
-
 // Adds a separator item at the given index. As the separator doesn't need
 // anything from the model, this method doesn't need the model index as the
 // other method below does.
@@ -241,15 +233,6 @@ int EventFlagsFromNSEvent(NSEvent* event) {
   if (!menu_ && model_) {
     menu_.reset([[self menuFromModel:model_] retain]);
     [menu_ setDelegate:self];
-    // If this is to be used with a NSPopUpButtonCell, add an item at the 0th
-    // position that's empty. Doing it after the menu has been constructed won't
-    // complicate creation logic, and since the tags are model indexes, they
-    // are unaffected by the extra item.
-    if (useWithPopUpButtonCell_) {
-      scoped_nsobject<NSMenuItem> blankItem(
-          [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]);
-      [menu_ insertItem:blankItem atIndex:0];
-    }
   }
   return menu_.get();
 }