From a4e3a7370b1647afb5fa60c930b44e1036192e06 Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Sat, 21 Jun 2008 18:14:36 +0200 Subject: [PATCH] Search for toolbar icons in 'runtimepath' --- src/MacVim/MMVimController.m | 11 ++++++++--- src/MacVim/gui_macvim.m | 17 ++++++++++++----- src/gui.c | 3 ++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/MacVim/MMVimController.m b/src/MacVim/MMVimController.m index 9cc3a31415..374998e58d 100644 --- a/src/MacVim/MMVimController.m +++ b/src/MacVim/MMVimController.m @@ -1131,7 +1131,8 @@ static int MMReceiveQueueCap = 100; } - (void)addToolbarItemToDictionaryWithLabel:(NSString *)title - toolTip:(NSString *)tip icon:(NSString *)icon + toolTip:(NSString *)tip + icon:(NSString *)icon { // If the item corresponds to a separator then do nothing, since it is // already defined by Cocoa. @@ -1147,6 +1148,8 @@ static int MMReceiveQueueCap = 100; [item setAutovalidates:NO]; NSImage *img = [NSImage imageNamed:icon]; + if (!img) + img = [[[NSImage alloc] initByReferencingFile:icon] autorelease]; if (!img) { NSLog(@"WARNING: Could not find image with name '%@' to use as toolbar" " image for identifier '%@';" @@ -1163,8 +1166,10 @@ static int MMReceiveQueueCap = 100; [item release]; } -- (void)addToolbarItemWithLabel:(NSString *)label tip:(NSString - *)tip icon:(NSString *)icon atIndex:(int)idx +- (void)addToolbarItemWithLabel:(NSString *)label + tip:(NSString *)tip + icon:(NSString *)icon + atIndex:(int)idx { if (!toolbar) return; diff --git a/src/MacVim/gui_macvim.m b/src/MacVim/gui_macvim.m index e59080e321..e18268f28b 100644 --- a/src/MacVim/gui_macvim.m +++ b/src/MacVim/gui_macvim.m @@ -691,11 +691,6 @@ gui_mch_add_menu(vimmenu_T *menu, int idx) void gui_mch_add_menu_item(vimmenu_T *menu, int idx) { - // NOTE! If 'iconfile' is not set but 'iconidx' is, use the name of the - // menu item. (Should correspond to a stock item.) - char_u *icon = menu->iconfile ? menu->iconfile : - menu->iconidx >= 0 ? menu->dname : - NULL; char_u *tip = menu->strings[MENU_INDEX_TIP] ? menu->strings[MENU_INDEX_TIP] : menu->actext; NSArray *desc = descriptor_for_menu(menu); @@ -703,6 +698,18 @@ gui_mch_add_menu_item(vimmenu_T *menu, int idx) ? [NSString stringWithFormat:@"%C", specialKeyToNSKey(menu->mac_key)] : [NSString string]; int modifierMask = vimModMaskToEventModifierFlags(menu->mac_mods); + char_u *icon = NULL; + + if (menu_is_toolbar(menu->parent->name)) { + char_u fname[MAXPATHL]; + + // TODO: Ensure menu->iconfile exists (if != NULL) + icon = menu->iconfile; + if (!icon && gui_find_bitmap(menu->name, fname, "bmp") == OK) + icon = fname; + if (!icon && menu->iconidx >= 0) + icon = menu->dname; + } [[MMBackend sharedInstance] queueMessage:AddMenuItemMsgID properties: [NSDictionary dictionaryWithObjectsAndKeys: diff --git a/src/gui.c b/src/gui.c index 1065f1ff70..3a65f8224b 100644 --- a/src/gui.c +++ b/src/gui.c @@ -4836,7 +4836,8 @@ ex_gui(eap) } #if ((defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32) \ - || defined(FEAT_GUI_PHOTON)) && defined(FEAT_TOOLBAR)) || defined(PROTO) + || defined(FEAT_GUI_PHOTON)) && defined(FEAT_TOOLBAR) \ + || defined(FEAT_GUI_MACVIM)) || defined(PROTO) /* * This is shared between Athena, Motif and GTK. */