group toolbar buttons consistently work in both text and icon modes

This commit is contained in:
Mitchell Livingston 2007-12-07 03:41:46 +00:00
parent c7e6bd9a15
commit 46a509a127
2 changed files with 18 additions and 6 deletions

View File

@ -41,6 +41,7 @@
- (void) validate
{
NSSegmentedControl * control = (NSSegmentedControl *)[self view];
NSLog(@"%d %d", [(NSSegmentedCell *)[control cell] tagForSegment: 0], [(NSSegmentedCell *)[control cell] tagForSegment: 1]);
int i;
for (i = 0; i < [control segmentCount]; i++)

View File

@ -2729,10 +2729,6 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
[segmentedControl setSegmentCount: 2];
[(NSSegmentedCell *)[segmentedControl cell] setTrackingMode: NSSegmentSwitchTrackingMomentary];
NSSize groupSize = NSMakeSize(72.0, 25.0);
[groupItem setMinSize: groupSize];
[groupItem setMaxSize: groupSize];
[groupItem setLabel: NSLocalizedString(@"Apply All", "All toolbar item -> label")];
[groupItem setPaletteLabel: NSLocalizedString(@"Pause / Resume All", "All toolbar item -> palette label")];
[groupItem setTarget: self];
@ -2740,18 +2736,27 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
[groupItem setIdentifiers: [NSArray arrayWithObjects: TOOLBAR_PAUSE_ALL, TOOLBAR_RESUME_ALL, nil]];
[(NSSegmentedCell *)[segmentedControl cell] setTag: TOOLBAR_PAUSE_TAG forSegment: TOOLBAR_PAUSE_TAG];
[segmentedControl setImage: [NSImage imageNamed: @"PauseAll.png"] forSegment: TOOLBAR_PAUSE_TAG];
[(NSSegmentedCell *)[segmentedControl cell] setToolTip: NSLocalizedString(@"Pause all transfers",
"All toolbar item -> tooltip") forSegment: TOOLBAR_PAUSE_TAG];
[(NSSegmentedCell *)[segmentedControl cell] setTag: TOOLBAR_RESUME_TAG forSegment: TOOLBAR_RESUME_TAG];
[segmentedControl setImage: [NSImage imageNamed: @"ResumeAll.png"] forSegment: TOOLBAR_RESUME_TAG];
[(NSSegmentedCell *)[segmentedControl cell] setToolTip: NSLocalizedString(@"Resume all transfers",
"All toolbar item -> tooltip") forSegment: TOOLBAR_RESUME_TAG];
NSLog(@"%d %d", [(NSSegmentedCell *)[segmentedControl cell] tagForSegment: TOOLBAR_PAUSE_TAG],
[(NSSegmentedCell *)[segmentedControl cell] tagForSegment: TOOLBAR_RESUME_TAG]);
[groupItem createMenu: [NSArray arrayWithObjects: NSLocalizedString(@"Pause All", "All toolbar item -> label"),
NSLocalizedString(@"Resume All", "All toolbar item -> label"), nil]];
NSSize groupSize = NSMakeSize(72.0, 25.0);
[groupItem setMinSize: groupSize];
[groupItem setMaxSize: groupSize];
[segmentedControl release];
return [groupItem autorelease];
}
else if ([ident isEqualToString: TOOLBAR_PAUSE_RESUME_SELECTED])
@ -2775,10 +2780,12 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
[groupItem setIdentifiers: [NSArray arrayWithObjects: TOOLBAR_PAUSE_SELECTED, TOOLBAR_RESUME_SELECTED, nil]];
[(NSSegmentedCell *)[segmentedControl cell] setTag: TOOLBAR_PAUSE_TAG forSegment: TOOLBAR_PAUSE_TAG];
[segmentedControl setImage: [NSImage imageNamed: @"PauseSelected.png"] forSegment: TOOLBAR_PAUSE_TAG];
[(NSSegmentedCell *)[segmentedControl cell] setToolTip: NSLocalizedString(@"Pause selected transfers",
"Selected toolbar item -> tooltip") forSegment: TOOLBAR_PAUSE_TAG];
[(NSSegmentedCell *)[segmentedControl cell] setTag: TOOLBAR_RESUME_TAG forSegment: TOOLBAR_RESUME_TAG];
[segmentedControl setImage: [NSImage imageNamed: @"ResumeSelected.png"] forSegment: TOOLBAR_RESUME_TAG];
[(NSSegmentedCell *)[segmentedControl cell] setToolTip: NSLocalizedString(@"Resume selected transfers",
"Selected toolbar item -> tooltip") forSegment: TOOLBAR_RESUME_TAG];
@ -2809,7 +2816,9 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
- (void) allToolbarClicked: (id) sender
{
switch ([sender tag])
int tagValue = [sender isKindOfClass: [NSSegmentedControl class]]
? [(NSSegmentedCell *)[sender cell] tagForSegment: [sender selectedSegment]] : [sender tag];
switch (tagValue)
{
case TOOLBAR_PAUSE_TAG:
[self stopAllTorrents: sender];
@ -2822,7 +2831,9 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
- (void) selectedToolbarClicked: (id) sender
{
switch ([sender tag])
int tagValue = [sender isKindOfClass: [NSSegmentedControl class]]
? [(NSSegmentedCell *)[sender cell] tagForSegment: [sender selectedSegment]] : [sender tag];
switch (tagValue)
{
case TOOLBAR_PAUSE_TAG:
[self stopSelectedTorrents: sender];