mirror of
https://github.com/transmission/transmission
synced 2025-03-12 23:23:54 +00:00
fix the toolbar customization sheet
This commit is contained in:
parent
59857deded
commit
65507f5df9
3 changed files with 35 additions and 42 deletions
|
@ -26,12 +26,11 @@
|
|||
|
||||
@interface ButtonGroupToolbarItem : NSToolbarItem
|
||||
{
|
||||
NSArray * fLabels, * fIdentifiers;
|
||||
|
||||
BOOL fMenuCreated;
|
||||
NSArray * fIdentifiers;
|
||||
}
|
||||
|
||||
- (void) setLabels: (NSArray *) labels;
|
||||
- (void) setIdentifiers: (NSArray *) identifiers;
|
||||
|
||||
- (void) createMenu: (NSArray *) labels;
|
||||
|
||||
@end
|
||||
|
|
|
@ -32,12 +32,6 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) setLabels: (NSArray *) labels
|
||||
{
|
||||
[fLabels release];
|
||||
fLabels = [labels retain];
|
||||
}
|
||||
|
||||
- (void) setIdentifiers: (NSArray *) identifiers
|
||||
{
|
||||
[fIdentifiers release];
|
||||
|
@ -54,36 +48,34 @@
|
|||
[[[NSToolbarItem alloc] initWithItemIdentifier: [fIdentifiers objectAtIndex: i]] autorelease]] forSegment: i];
|
||||
}
|
||||
|
||||
- (void) createMenu: (NSArray *) labels
|
||||
{
|
||||
NSMenuItem * menuItem = [[NSMenuItem alloc] initWithTitle: [self label] action: NULL keyEquivalent: @""];
|
||||
NSMenu * menu = [[NSMenu alloc] initWithTitle: [self label]];
|
||||
[menuItem setSubmenu: menu];
|
||||
|
||||
[menu setAutoenablesItems: NO];
|
||||
|
||||
NSMenuItem * addItem;
|
||||
int i;
|
||||
for (i = 0; i < [(NSSegmentedControl *)[self view] segmentCount]; i++)
|
||||
{
|
||||
addItem = [[NSMenuItem alloc] initWithTitle: [labels objectAtIndex: i] action: [self action] keyEquivalent: @""];
|
||||
[addItem setTarget: [self target]];
|
||||
[addItem setTag: i];
|
||||
|
||||
[menu addItem: addItem];
|
||||
[addItem release];
|
||||
}
|
||||
|
||||
[menu release];
|
||||
[self setMenuFormRepresentation: menuItem];
|
||||
[menuItem release];
|
||||
}
|
||||
|
||||
- (NSMenuItem *) menuFormRepresentation
|
||||
{
|
||||
NSMenuItem * menuItem;
|
||||
if (!fMenuCreated)
|
||||
{
|
||||
fMenuCreated = YES;
|
||||
|
||||
menuItem = [[[NSMenuItem alloc] initWithTitle: [self label] action: NULL keyEquivalent: @""] autorelease];
|
||||
NSMenu * menu = [[NSMenu alloc] initWithTitle: [self label]];
|
||||
[menuItem setSubmenu: menu];
|
||||
|
||||
[menu setAutoenablesItems: NO];
|
||||
|
||||
NSMenuItem * addItem;
|
||||
int i;
|
||||
for (i = 0; i < [(NSSegmentedControl *)[self view] segmentCount]; i++)
|
||||
{
|
||||
addItem = [[NSMenuItem alloc] initWithTitle: [fLabels objectAtIndex: i] action: [self action] keyEquivalent: @""];
|
||||
[addItem setTarget: [self target]];
|
||||
[addItem setTag: i];
|
||||
|
||||
[menu addItem: addItem];
|
||||
[addItem release];
|
||||
}
|
||||
|
||||
[menu release];
|
||||
[self setMenuFormRepresentation: menuItem];
|
||||
}
|
||||
else
|
||||
menuItem = [super menuFormRepresentation];
|
||||
NSMenuItem * menuItem = [super menuFormRepresentation];
|
||||
|
||||
int i;
|
||||
for (i = 0; i < [(NSSegmentedControl *)[self view] segmentCount]; i++)
|
||||
|
|
|
@ -2718,8 +2718,6 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
[groupItem setAction: @selector(allToolbarClicked:)];
|
||||
|
||||
[groupItem setIdentifiers: [NSArray arrayWithObjects: TOOLBAR_PAUSE_ALL, TOOLBAR_RESUME_ALL, nil]];
|
||||
[groupItem setLabels: [NSArray arrayWithObjects: NSLocalizedString(@"Pause All", "All toolbar item -> label"),
|
||||
NSLocalizedString(@"Resume All", "All toolbar item -> label"), nil]];
|
||||
|
||||
[segmentedControl setImage: [NSImage imageNamed: @"PauseAll.png"] forSegment: TOOLBAR_PAUSE_TAG];
|
||||
[(NSSegmentedCell *)[segmentedControl cell] setToolTip: NSLocalizedString(@"Pause all transfers",
|
||||
|
@ -2729,6 +2727,9 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
[(NSSegmentedCell *)[segmentedControl cell] setToolTip: NSLocalizedString(@"Resume all transfers",
|
||||
"All toolbar item -> tooltip") forSegment: TOOLBAR_RESUME_TAG];
|
||||
|
||||
[groupItem createMenu: [NSArray arrayWithObjects: NSLocalizedString(@"Pause All", "All toolbar item -> label"),
|
||||
NSLocalizedString(@"Resume All", "All toolbar item -> label"), nil]];
|
||||
|
||||
[segmentedControl release];
|
||||
return groupItem;
|
||||
}
|
||||
|
@ -2753,8 +2754,6 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
[groupItem setAction: @selector(selectedToolbarClicked:)];
|
||||
|
||||
[groupItem setIdentifiers: [NSArray arrayWithObjects: TOOLBAR_PAUSE_SELECTED, TOOLBAR_RESUME_SELECTED, nil]];
|
||||
[groupItem setLabels: [NSArray arrayWithObjects: NSLocalizedString(@"Pause Selected", "Selected toolbar item -> label"),
|
||||
NSLocalizedString(@"Resume Selected", "Selected toolbar item -> label"), nil]];
|
||||
|
||||
[segmentedControl setImage: [NSImage imageNamed: @"PauseSelected.png"] forSegment: TOOLBAR_PAUSE_TAG];
|
||||
[(NSSegmentedCell *)[segmentedControl cell] setToolTip: NSLocalizedString(@"Pause selected transfers",
|
||||
|
@ -2764,6 +2763,9 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
[(NSSegmentedCell *)[segmentedControl cell] setToolTip: NSLocalizedString(@"Resume selected transfers",
|
||||
"Selected toolbar item -> tooltip") forSegment: TOOLBAR_RESUME_TAG];
|
||||
|
||||
[groupItem createMenu: [NSArray arrayWithObjects: NSLocalizedString(@"Pause Selected", "Selected toolbar item -> label"),
|
||||
NSLocalizedString(@"Resume Selected", "Selected toolbar item -> label"), nil]];
|
||||
|
||||
[segmentedControl release];
|
||||
return groupItem;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue