summaryrefslogtreecommitdiff
path: root/src/nsmenu.m
diff options
context:
space:
mode:
authorMasahiro Nakamura <tsuucat@icloud.com>2021-08-22 10:13:58 +0900
committerAlan Third <alan@idiocy.org>2021-08-22 20:58:26 +0100
commit48d49694539beae5270ca49eae2d5419938a906e (patch)
tree90b261f51314d84d841be53614fc81cdd1cdc794 /src/nsmenu.m
parentf405756811741b805c2833aa941d23bfd0f36919 (diff)
downloademacs-48d49694539beae5270ca49eae2d5419938a906e.tar.gz
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.
Diffstat (limited to 'src/nsmenu.m')
-rw-r--r--src/nsmenu.m7
1 files changed, 7 insertions, 0 deletions
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:)];