From: Masahiro Nakamura Date: Sun, 22 Aug 2021 01:13:58 +0000 (+0900) Subject: Set label for NSToolbarItem (bug#50159) X-Git-Tag: emacs-28.0.90~1355 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=48d49694539beae5270ca49eae2d5419938a906e;p=emacs.git Set label for NSToolbarItem (bug#50159) * src/nsmenu.m (update_frame_tool_bar): Get label text and pass it to ... ([EmacsToolbar addDisplayItemWithImage:idx:tag:labelText:helpText:enabled:]): ... this that sets label for NSToolbarItem. * src/nsterm.h ([EmacsToolbar addDisplayItemWithImage:idx:tag:labelText:helpText:enabled:]): Add labelText argument. --- diff --git a/src/nsmenu.m b/src/nsmenu.m index fe4f8258322..3493e4e131d 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -1033,6 +1033,8 @@ update_frame_tool_bar (struct frame *f) ptrdiff_t img_id; struct image *img; Lisp_Object image; + Lisp_Object labelObj; + const char *labelText; Lisp_Object helpObj; const char *helpText; @@ -1059,6 +1061,8 @@ update_frame_tool_bar (struct frame *f) { idx = -1; } + labelObj = TOOLPROP (TOOL_BAR_ITEM_LABEL); + labelText = NILP (labelObj) ? "" : SSDATA (labelObj); helpObj = TOOLPROP (TOOL_BAR_ITEM_HELP); if (NILP (helpObj)) helpObj = TOOLPROP (TOOL_BAR_ITEM_CAPTION); @@ -1084,6 +1088,7 @@ update_frame_tool_bar (struct frame *f) [toolbar addDisplayItemWithImage: img->pixmap idx: k++ tag: i + labelText: labelText helpText: helpText enabled: enabled_p]; #undef TOOLPROP @@ -1188,6 +1193,7 @@ update_frame_tool_bar (struct frame *f) - (void) addDisplayItemWithImage: (EmacsImage *)img idx: (int)idx tag: (int)tag + labelText: (const char *)label helpText: (const char *)help enabled: (BOOL)enabled { @@ -1205,6 +1211,7 @@ update_frame_tool_bar (struct frame *f) item = [[[NSToolbarItem alloc] initWithItemIdentifier: identifier] autorelease]; [item setImage: img]; + [item setLabel: [NSString stringWithUTF8String: label]]; [item setToolTip: [NSString stringWithUTF8String: help]]; [item setTarget: emacsView]; [item setAction: @selector (toolbarClicked:)]; diff --git a/src/nsterm.h b/src/nsterm.h index 404c7140056..6d4ea771212 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -548,6 +548,7 @@ typedef id instancetype; - (void) addDisplayItemWithImage: (EmacsImage *)img idx: (int)idx tag: (int)tag + labelText: (const char *)label helpText: (const char *)help enabled: (BOOL)enabled;