Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Source/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -3606,6 +3606,11 @@ - (NSToolbarItem *)baselineToolbarItemWithIdentifier:(NSToolbarItemIdentifier)id
item.paletteLabel = label ?: @"";
#if defined(GNUSTEP)
item.label = @"";
// Folded into » the item is a menu item titled from its label, which is empty, so it needs
// its own: Undo and Redo overflow first and showed as blank rows.
NSMenuItem *menuForm = [[NSMenuItem alloc] initWithTitle:item.paletteLabel action:selector keyEquivalent:@""];
menuForm.target = self;
item.menuFormRepresentation = menuForm;
#else
item.label = item.paletteLabel;
#endif
Expand Down
18 changes: 18 additions & 0 deletions Tests/TitleBarToolbarProbe_test.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,24 @@ - (void)testSaveAndCopyKeepTheirNamesInTheOverflowMenu {
XCTAssertEqual(menuItem.target, (id)_appDelegate, @"%@ goes to the app delegate", identifier);
}
}

- (void)testIconItemsKeepTheirNamesInTheOverflowMenu {
XCTSkipIf(_shouldSkip, @"No window server");
// Icon-only items have empty labels too, and Undo and Redo are the first to go into ».
NSToolbar *toolbar = _appDelegate.window.toolbar;
id<NSToolbarDelegate> delegate = (id<NSToolbarDelegate>)_appDelegate;
NSDictionary<NSString *, NSString *> *expected = @{@"undo": @"Undo", @"redo": @"Redo"};
NSDictionary<NSString *, NSString *> *actions = @{@"undo": @"undo:", @"redo": @"redo:"};
for (NSString *name in expected) {
NSString *identifier = [@"com.screenshottool.toolbar." stringByAppendingString:name];
NSToolbarItem *item = [delegate toolbar:toolbar itemForItemIdentifier:identifier willBeInsertedIntoToolbar:YES];
NSMenuItem *menuItem = item.menuFormRepresentation;
XCTAssertNotNil(menuItem, @"%@ has a menu form", identifier);
XCTAssertEqualObjects(menuItem.title, expected[name], @"%@ is named in »", identifier);
XCTAssertEqualObjects(NSStringFromSelector(menuItem.action), actions[name], @"%@ runs its command from »", identifier);
XCTAssertEqual(menuItem.target, (id)_appDelegate, @"%@ goes to the app delegate", identifier);
}
}
#endif

#pragma mark - Slim toolbar (#53)
Expand Down
Loading