diff -r ce342364fad5 -r c284c15509a8 ui/cocoa/menu.m --- a/ui/cocoa/menu.m Wed Jul 13 16:40:59 2016 +0200 +++ b/ui/cocoa/menu.m Sat Sep 17 19:32:44 2016 +0200 @@ -118,10 +118,7 @@ @end -//static NSMenu *currentMenu = NULL; - -static UcxList *current; - +static NSMenu *currentMenu = NULL; static int currentItemIndex = 0; static UiMenuDelegate *delegate; @@ -144,34 +141,8 @@ [menu setAutoenablesItems:NO]; [[NSApp mainMenu] setSubmenu:menu forItem:menuItem]; - //currentMenu = menu; + currentMenu = menu; currentItemIndex = 0; - - current = ucx_list_prepend(NULL, menu); -} - -void ui_submenu(char *title) { - NSString *str = [[NSString alloc] initWithUTF8String:title]; - NSMenu *currentMenu = current->data; - - NSMenu *menu = [[NSMenu alloc] initWithTitle: str]; - NSMenuItem *menuItem = [currentMenu addItemWithTitle:str - action:nil keyEquivalent:@""]; - [menu setDelegate: delegate]; - [menu setAutoenablesItems:NO]; - - [currentMenu setSubmenu:menu forItem:menuItem]; - //currentMenu = menu; - currentItemIndex = 0; - - current = ucx_list_prepend(current, menu); -} - -void ui_submenu_end() { - if(ucx_list_size(current) < 2) { - return; - } - current = ucx_list_remove(current, current); } void ui_menuitem(char *label, ui_callback f, void *data) { @@ -198,7 +169,6 @@ } va_end(ap); - NSMenu *currentMenu = current->data; [currentMenu addItem:item]; currentItemIndex++; @@ -222,7 +192,6 @@ } va_end(ap); - NSMenu *currentMenu = current->data; [currentMenu addItem:item]; currentItemIndex++; @@ -232,7 +201,6 @@ EventWrapper *event = [[EventWrapper alloc]initWithData:data callback:f]; NSString *str = [[NSString alloc] initWithUTF8String:label]; - NSMenu *currentMenu = current->data; NSMenuItem *item = [currentMenu addItemWithTitle:str action:@selector(handleStateEvent:) keyEquivalent:@""]; [item setTarget:event]; @@ -245,7 +213,6 @@ EventWrapper *event = [[EventWrapper alloc]initWithData:NULL callback:NULL]; NSString *str = [[NSString alloc] initWithUTF8String:label]; - NSMenu *currentMenu = current->data; NSMenuItem *item = [currentMenu addItemWithTitle:str action:@selector(handleStateEvent:) keyEquivalent:@""]; [item setTarget:event]; @@ -255,13 +222,11 @@ } void ui_menuseparator() { - NSMenu *currentMenu = current->data; [currentMenu addItem: [NSMenuItem separatorItem]]; currentItemIndex++; } void ui_menuitem_list (UiList *items, ui_callback f, void *data) { - NSMenu *currentMenu = current->data; [delegate addList:items menu:currentMenu index:currentItemIndex callback:f data:data]; }