diff options
| author | Masahiro Nakamura | 2021-08-22 10:13:58 +0900 |
|---|---|---|
| committer | Alan Third | 2021-08-22 20:58:26 +0100 |
| commit | 48d49694539beae5270ca49eae2d5419938a906e (patch) | |
| tree | 90b261f51314d84d841be53614fc81cdd1cdc794 /src | |
| parent | f405756811741b805c2833aa941d23bfd0f36919 (diff) | |
| download | emacs-48d49694539beae5270ca49eae2d5419938a906e.tar.gz emacs-48d49694539beae5270ca49eae2d5419938a906e.zip | |
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')
| -rw-r--r-- | src/nsmenu.m | 7 | ||||
| -rw-r--r-- | src/nsterm.h | 1 |
2 files changed, 8 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) | |||
| 1033 | ptrdiff_t img_id; | 1033 | ptrdiff_t img_id; |
| 1034 | struct image *img; | 1034 | struct image *img; |
| 1035 | Lisp_Object image; | 1035 | Lisp_Object image; |
| 1036 | Lisp_Object labelObj; | ||
| 1037 | const char *labelText; | ||
| 1036 | Lisp_Object helpObj; | 1038 | Lisp_Object helpObj; |
| 1037 | const char *helpText; | 1039 | const char *helpText; |
| 1038 | 1040 | ||
| @@ -1059,6 +1061,8 @@ update_frame_tool_bar (struct frame *f) | |||
| 1059 | { | 1061 | { |
| 1060 | idx = -1; | 1062 | idx = -1; |
| 1061 | } | 1063 | } |
| 1064 | labelObj = TOOLPROP (TOOL_BAR_ITEM_LABEL); | ||
| 1065 | labelText = NILP (labelObj) ? "" : SSDATA (labelObj); | ||
| 1062 | helpObj = TOOLPROP (TOOL_BAR_ITEM_HELP); | 1066 | helpObj = TOOLPROP (TOOL_BAR_ITEM_HELP); |
| 1063 | if (NILP (helpObj)) | 1067 | if (NILP (helpObj)) |
| 1064 | helpObj = TOOLPROP (TOOL_BAR_ITEM_CAPTION); | 1068 | helpObj = TOOLPROP (TOOL_BAR_ITEM_CAPTION); |
| @@ -1084,6 +1088,7 @@ update_frame_tool_bar (struct frame *f) | |||
| 1084 | [toolbar addDisplayItemWithImage: img->pixmap | 1088 | [toolbar addDisplayItemWithImage: img->pixmap |
| 1085 | idx: k++ | 1089 | idx: k++ |
| 1086 | tag: i | 1090 | tag: i |
| 1091 | labelText: labelText | ||
| 1087 | helpText: helpText | 1092 | helpText: helpText |
| 1088 | enabled: enabled_p]; | 1093 | enabled: enabled_p]; |
| 1089 | #undef TOOLPROP | 1094 | #undef TOOLPROP |
| @@ -1188,6 +1193,7 @@ update_frame_tool_bar (struct frame *f) | |||
| 1188 | - (void) addDisplayItemWithImage: (EmacsImage *)img | 1193 | - (void) addDisplayItemWithImage: (EmacsImage *)img |
| 1189 | idx: (int)idx | 1194 | idx: (int)idx |
| 1190 | tag: (int)tag | 1195 | tag: (int)tag |
| 1196 | labelText: (const char *)label | ||
| 1191 | helpText: (const char *)help | 1197 | helpText: (const char *)help |
| 1192 | enabled: (BOOL)enabled | 1198 | enabled: (BOOL)enabled |
| 1193 | { | 1199 | { |
| @@ -1205,6 +1211,7 @@ update_frame_tool_bar (struct frame *f) | |||
| 1205 | item = [[[NSToolbarItem alloc] initWithItemIdentifier: identifier] | 1211 | item = [[[NSToolbarItem alloc] initWithItemIdentifier: identifier] |
| 1206 | autorelease]; | 1212 | autorelease]; |
| 1207 | [item setImage: img]; | 1213 | [item setImage: img]; |
| 1214 | [item setLabel: [NSString stringWithUTF8String: label]]; | ||
| 1208 | [item setToolTip: [NSString stringWithUTF8String: help]]; | 1215 | [item setToolTip: [NSString stringWithUTF8String: help]]; |
| 1209 | [item setTarget: emacsView]; | 1216 | [item setTarget: emacsView]; |
| 1210 | [item setAction: @selector (toolbarClicked:)]; | 1217 | [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; | |||
| 548 | - (void) addDisplayItemWithImage: (EmacsImage *)img | 548 | - (void) addDisplayItemWithImage: (EmacsImage *)img |
| 549 | idx: (int)idx | 549 | idx: (int)idx |
| 550 | tag: (int)tag | 550 | tag: (int)tag |
| 551 | labelText: (const char *)label | ||
| 551 | helpText: (const char *)help | 552 | helpText: (const char *)help |
| 552 | enabled: (BOOL)enabled; | 553 | enabled: (BOOL)enabled; |
| 553 | 554 | ||