unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#50159: [PATCH] Set label for NSToolbarItem
@ 2021-08-22  2:11 tsuucat via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-08-22 19:59 ` Alan Third
  0 siblings, 1 reply; 2+ messages in thread
From: tsuucat via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-08-22  2:11 UTC (permalink / raw)
  To: 50159

[-- Attachment #1: Type: text/plain, Size: 251 bytes --]

Emacs version: 28.0.50
window system: ns

I found when toolbar narrowed and ≫ is clicked there is no text
(no-label.png). This is because ToolbarItem has no label.


I made a patch to set label for NSToolbarItem.

Thanks.

--
tsuucat


[-- Attachment #2: no-label.png --]
[-- Type: image/png, Size: 42926 bytes --]

[-- Attachment #3: Type: text/plain, Size: 2 bytes --]




[-- Attachment #4: 0001-Set-label-for-NSToolbarItem.patch --]
[-- Type: application/octet-stream, Size: 3085 bytes --]

From 85360e9c1cfa05f00afe7a7645b28cd7ec519cc3 Mon Sep 17 00:00:00 2001
From: Masahiro Nakamura <tsuucat@icloud.com>
Date: Sun, 22 Aug 2021 10:13:58 +0900
Subject: [PATCH] Set label for NSToolbarItem

* src/nsmenu.m (update_frame_tool_bar): Get label text and pass it to ...
([EmacsToolbar addDisplayItemWithImage:idx::tag:labelText:helpText:enabled:]):
... this that set label for NSToolbarItem.
* src/nsterm.h
([EmacsToolbar addDisplayItemWithImage:idx::tag:labelText:helpText:enabled:]):
Add labelText argument.
---
 src/nsmenu.m | 7 +++++++
 src/nsterm.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/src/nsmenu.m b/src/nsmenu.m
index bb0dd2634d..2cceab70b7 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -1033,6 +1033,8 @@ - (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item
       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 @@ - (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item
         {
           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 @@ - (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item
       [toolbar addDisplayItemWithImage: img->pixmap
                                    idx: k++
                                    tag: i
+                             labelText: labelText
                               helpText: helpText
                                enabled: enabled_p];
 #undef TOOLPROP
@@ -1188,6 +1193,7 @@ - (BOOL) changed
 - (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 @@ - (void) addDisplayItemWithImage: (EmacsImage *)img
       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 404c714005..6d4ea77121 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -548,6 +548,7 @@ #define NSTRACE_UNSILENCE()
 - (void) addDisplayItemWithImage: (EmacsImage *)img
                              idx: (int)idx
                              tag: (int)tag
+                       labelText: (const char *)label
                         helpText: (const char *)help
                          enabled: (BOOL)enabled;
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#50159: [PATCH] Set label for NSToolbarItem
  2021-08-22  2:11 bug#50159: [PATCH] Set label for NSToolbarItem tsuucat via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-08-22 19:59 ` Alan Third
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Third @ 2021-08-22 19:59 UTC (permalink / raw)
  To: tsuucat; +Cc: 50159-done

On Sun, Aug 22, 2021 at 11:11:58AM +0900, tsuucat via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote:
> Emacs version: 28.0.50
> window system: ns
> 
> I found when toolbar narrowed and ≫ is clicked there is no text
> (no-label.png). This is because ToolbarItem has no label.
> 
> 
> I made a patch to set label for NSToolbarItem.

This looks good. I've pushed it to the master branch.

Thanks!

-- 
Alan Third





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-22 19:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-22  2:11 bug#50159: [PATCH] Set label for NSToolbarItem tsuucat via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-08-22 19:59 ` Alan Third

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).