remove references and dead code to the group window being its own window; other rearrangements of code

This commit is contained in:
Mitchell Livingston
2008-11-29 20:29:54 +00:00
parent 16e6aadec3
commit d6fce3abcb
10 changed files with 69 additions and 136 deletions

View File

@@ -63,6 +63,5 @@
- (void) updateStatusField: (NSNotification *) notification;
- (void) updateGroupMenu: (NSNotification *) notification;
- (void) showGroupsWindow: (id) sender;
@end

View File

@@ -236,12 +236,6 @@
}
}
- (void) showGroupsWindow: (id) sender
{
[fGroupPopUp selectItemWithTag: fGroupValue];
[fController showGroups: sender];
}
@end
@implementation AddWindowController (Private)
@@ -288,14 +282,8 @@
- (void) setGroupsMenu
{
NSMenu * menu = [fGroupPopUp menu];
for (NSInteger i = [menu numberOfItems]-1 - 2; i >= 0; i--)
[menu removeItemAtIndex: i];
NSMenu * groupMenu = [[GroupsController groups] groupMenuWithTarget: self action: @selector(changeGroupValue:) isSmall: NO];
[menu appendItemsFromMenu: groupMenu atIndexes: [NSIndexSet indexSetWithIndexesInRange:
NSMakeRange(0, [groupMenu numberOfItems])] atBottom: NO];
[fGroupPopUp setMenu: groupMenu];
}
- (void) changeGroupValue: (id) sender

View File

@@ -209,7 +209,6 @@ typedef enum
- (void) setStatusLabel: (id) sender;
- (void) showGroups: (id) sender;
- (void) setGroup: (id) sender; //used by delegate-generated menu items
- (void) setGroupFilter: (id) sender;
- (void) updateGroupsFilterButton;

View File

@@ -2218,11 +2218,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
[self updateUI];
}
- (void) showGroups: (id) sender
{
[[GroupsWindowController groupsWindow] showWindow: self];
}
- (void) menuNeedsUpdate: (NSMenu *) menu
{
if (menu == fGroupsSetMenu || menu == fGroupsSetContextMenu)

View File

@@ -45,7 +45,7 @@
- (void) setColor: (NSColor *) color forIndex: (NSInteger) index;
- (void) addNewGroup;
- (void) removeGroupWithRowIndexes: (NSIndexSet *) rowIndexes;
- (void) removeGroupWithRowIndex: (NSInteger) row;
- (NSIndexSet *) moveGroupsAtRowIndexes: (NSIndexSet *) indexes toRow: (NSInteger) newRow oldSelected: (NSIndexSet *) selectedIndexes;

View File

@@ -193,18 +193,15 @@ GroupsController * fGroupsInstance = nil;
[self saveGroups];
}
- (void) removeGroupWithRowIndexes: (NSIndexSet *) rowIndexes
- (void) removeGroupWithRowIndex: (NSInteger) row
{
NSMutableIndexSet * indexes = [NSMutableIndexSet indexSet];
for (NSInteger index = [rowIndexes firstIndex]; index != NSNotFound; index = [rowIndexes indexGreaterThanIndex: index])
[indexes addIndex: [[[fGroups objectAtIndex: index] objectForKey: @"Index"] intValue]];
[fGroups removeObjectsAtIndexes: rowIndexes];
NSInteger index = [[[fGroups objectAtIndex: row] objectForKey: @"Index"] intValue];
[fGroups removeObjectAtIndex: index];
[[NSNotificationCenter defaultCenter] postNotificationName: @"GroupValueRemoved" object: self userInfo:
[NSDictionary dictionaryWithObject: indexes forKey: @"Indexes"]];
[NSDictionary dictionaryWithObject: [NSNumber numberWithInt: index] forKey: @"Index"]];
if ([indexes containsIndex: [[NSUserDefaults standardUserDefaults] integerForKey: @"FilterGroup"]])
if (index == [[NSUserDefaults standardUserDefaults] integerForKey: @"FilterGroup"])
[[NSUserDefaults standardUserDefaults] setInteger: -2 forKey: @"FilterGroup"];
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateGroups" object: self];

View File

@@ -33,11 +33,9 @@
IBOutlet NSTableView * fTableView;
IBOutlet NSSegmentedControl * fAddRemoveControl;
int fCurrentColorIndex;
NSInteger fCurrentColorIndex;
}
+ (GroupsWindowController *) groupsWindow;
- (void) addRemoveGroup: (id) sender;
@end

View File

@@ -39,17 +39,8 @@
@implementation GroupsWindowController
GroupsWindowController * fGroupsWindowInstance = nil;
+ (GroupsWindowController *) groupsWindow
{
if (!fGroupsWindowInstance)
fGroupsWindowInstance = [[GroupsWindowController alloc] initWithWindowNibName: @"GroupsWindow"];
return fGroupsWindowInstance;
}
- (void) awakeFromNib
{
[[self window] setTitle: NSLocalizedString(@"Groups", "Groups -> window title")];
[[[fTableView tableColumnWithIdentifier: @"Button"] dataCell] setTitle: NSLocalizedString(@"Color", "Groups -> color button")];
[fTableView registerForDraggedTypes: [NSArray arrayWithObject: GROUP_TABLE_VIEW_DATA_TYPE]];
@@ -68,14 +59,6 @@ GroupsWindowController * fGroupsWindowInstance = nil;
[self updateSelectedColor];
}
- (void) windowWillClose: (id) sender
{
[[NSColorPanel sharedColorPanel] close];
[fGroupsWindowInstance release];
fGroupsWindowInstance = nil;
}
- (NSInteger) numberOfRowsInTableView: (NSTableView *) tableview
{
return [[GroupsController groups] numberOfGroups];
@@ -93,13 +76,6 @@ GroupsWindowController * fGroupsWindowInstance = nil;
return [groupsController nameForIndex: groupsIndex];
}
- (void) tableView: (NSTableView *) tableView setObjectValue: (id) object forTableColumn: (NSTableColumn *) tableColumn
row: (NSInteger) row
{
[[GroupsController groups] setName: object forIndex: [[GroupsController groups] indexForRow: row]];
[self updateSelectedColor];
}
- (void) tableViewSelectionDidChange: (NSNotification *) notification
{
[self updateSelectedColor];
@@ -110,7 +86,7 @@ GroupsWindowController * fGroupsWindowInstance = nil;
[fAddRemoveControl setEnabled: [fTableView numberOfSelectedRows] > 0 forSegment: REMOVE_TAG];
if ([fTableView numberOfSelectedRows] == 1)
{
int index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
NSInteger index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
[fSelectedColorView setColor: [[GroupsController groups] colorForIndex: index]];
[fSelectedColorView setEnabled: YES];
[fSelectedColorNameField setStringValue: [[GroupsController groups] nameForIndex: index]];
@@ -129,7 +105,7 @@ GroupsWindowController * fGroupsWindowInstance = nil;
{
if (object == fSelectedColorView && [fTableView numberOfSelectedRows] == 1)
{
int index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
NSInteger index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
[[GroupsController groups] setColor: [fSelectedColorView color] forIndex: index];
[fTableView setNeedsDisplay: YES];
}
@@ -139,7 +115,7 @@ GroupsWindowController * fGroupsWindowInstance = nil;
{
if ([notification object] == fSelectedColorNameField)
{
int index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
NSInteger index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
[[GroupsController groups] setName: [fSelectedColorNameField stringValue] forIndex: index];
[fTableView setNeedsDisplay: YES];
}
@@ -184,10 +160,10 @@ GroupsWindowController * fGroupsWindowInstance = nil;
- (void) addRemoveGroup: (id) sender
{
NSIndexSet * indexes;
switch ([[sender cell] tagForSegment: [sender selectedSegment]])
{
NSInteger row;
case ADD_TAG:
[[GroupsController groups] addNewGroup];
@@ -199,13 +175,14 @@ GroupsWindowController * fGroupsWindowInstance = nil;
break;
case REMOVE_TAG:
#warning refactor in color picker (fCurrentColorIndex) code)
//close color picker if corresponding row is removed
indexes = [fTableView selectedRowIndexes];
row = [fTableView selectedRow];
if ([[NSColorPanel sharedColorPanel] isVisible]
&& [indexes containsIndex: [[GroupsController groups] rowValueForIndex: fCurrentColorIndex]])
&& row == [[GroupsController groups] rowValueForIndex: fCurrentColorIndex])
[[NSColorPanel sharedColorPanel] close];
[[GroupsController groups] removeGroupWithRowIndexes: indexes];
[[GroupsController groups] removeGroupWithRowIndex: row];
[fTableView deselectAll: self];
[fTableView reloadData];

View File

@@ -1443,7 +1443,7 @@ void completenessChangeCallback(tr_torrent * torrent, tr_completeness status, vo
- (void) checkGroupValueForRemoval: (NSNotification *) notification
{
if (fGroupValue != -1 && [[[notification userInfo] objectForKey: @"Indexes"] containsIndex: fGroupValue])
if (fGroupValue != -1 && [[[notification userInfo] objectForKey: @"Index"] intValue] == fGroupValue)
fGroupValue = -1;
}

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">9E17</string>
<string key="IBDocument.InterfaceBuilderVersion">670</string>
<string key="IBDocument.AppKitVersion">949.33</string>
<string key="IBDocument.SystemVersion">9F33</string>
<string key="IBDocument.InterfaceBuilderVersion">677</string>
<string key="IBDocument.AppKitVersion">949.34</string>
<string key="IBDocument.HIToolboxVersion">352.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -14,6 +14,15 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomObject" id="1001">
@@ -306,48 +315,15 @@
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">400</int>
<int key="NSPeriodicInterval">75</int>
<object class="NSMenuItem" key="NSMenuItem" id="196915222">
<reference key="NSMenu" ref="594668561"/>
<bool key="NSIsDisabled">YES</bool>
<bool key="NSIsSeparator">YES</bool>
<string key="NSTitle"/>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<int key="NSState">1</int>
<object class="NSCustomResource" key="NSOnImage" id="42644489">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuCheckmark</string>
</object>
<object class="NSCustomResource" key="NSMixedImage" id="971181110">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuMixedState</string>
</object>
<string key="NSAction">_popUpItemAction:</string>
<int key="NSTag">-2</int>
<reference key="NSTarget" ref="693599709"/>
</object>
<nil key="NSMenuItem"/>
<bool key="NSMenuItemRespectAlignment">YES</bool>
<object class="NSMenu" key="NSMenu" id="594668561">
<string key="NSTitle">OtherViews</string>
<object class="NSMutableArray" key="NSMenuItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="196915222"/>
<object class="NSMenuItem" id="674774797">
<reference key="NSMenu" ref="594668561"/>
<string type="base64-UTF8" key="NSTitle">U2hvdyBHcm91cHPigKY</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="42644489"/>
<reference key="NSMixedImage" ref="971181110"/>
<string key="NSAction">_popUpItemAction:</string>
<int key="NSTag">-3</int>
<reference key="NSTarget" ref="693599709"/>
</object>
</object>
</object>
<int key="NSSelectedIndex">1</int>
<int key="NSSelectedIndex">-1</int>
<int key="NSPreferredEdge">1</int>
<bool key="NSUsesItemFromMenu">YES</bool>
<bool key="NSAltersState">YES</bool>
@@ -776,14 +752,6 @@
</object>
<int key="connectionID">61</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">showGroupsWindow:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="674774797"/>
</object>
<int key="connectionID">64</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">verifyLocalData:</string>
@@ -1018,8 +986,6 @@
<reference key="object" ref="594668561"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="196915222"/>
<reference ref="674774797"/>
</object>
<reference key="parent" ref="693599709"/>
</object>
@@ -1137,16 +1103,6 @@
<reference key="object" ref="819741823"/>
<reference key="parent" ref="46983627"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">63</int>
<reference key="object" ref="196915222"/>
<reference key="parent" ref="594668561"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">62</int>
<reference key="object" ref="674774797"/>
<reference key="parent" ref="594668561"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">65</int>
<reference key="object" ref="38073450"/>
@@ -1171,7 +1127,6 @@
<string>-2.IBPluginDependency</string>
<string>-3.IBPluginDependency</string>
<string>1.IBEditorWindowLastContentRect</string>
<string>1.IBPluginDependency</string>
<string>1.IBWindowTemplateEditedContentRect</string>
<string>1.NSWindowTemplate.visibleAtLaunch</string>
<string>1.WindowOrigin</string>
@@ -1186,27 +1141,39 @@
<string>11.ImportedFromIB2</string>
<string>12.IBPluginDependency</string>
<string>12.ImportedFromIB2</string>
<string>13.IBPluginDependency</string>
<string>14.IBPluginDependency</string>
<string>15.IBPluginDependency</string>
<string>16.IBPluginDependency</string>
<string>17.IBPluginDependency</string>
<string>17.ImportedFromIB2</string>
<string>18.IBPluginDependency</string>
<string>19.IBPluginDependency</string>
<string>19.ImportedFromIB2</string>
<string>2.IBPluginDependency</string>
<string>20.IBPluginDependency</string>
<string>21.IBPluginDependency</string>
<string>21.ImportedFromIB2</string>
<string>22.IBPluginDependency</string>
<string>3.IBPluginDependency</string>
<string>3.ImportedFromIB2</string>
<string>33.IBPluginDependency</string>
<string>34.IBPluginDependency</string>
<string>35.IBEditorWindowLastContentRect</string>
<string>35.IBPluginDependency</string>
<string>35.editorWindowContentRectSynchronizationRect</string>
<string>4.IBPluginDependency</string>
<string>4.ImportedFromIB2</string>
<string>40.IBPluginDependency</string>
<string>40.ImportedFromIB2</string>
<string>41.IBPluginDependency</string>
<string>42.IBPluginDependency</string>
<string>42.ImportedFromIB2</string>
<string>43.IBPluginDependency</string>
<string>43.IBShouldRemoveOnLegacySave</string>
<string>44.IBPluginDependency</string>
<string>44.IBShouldRemoveOnLegacySave</string>
<string>45.IBPluginDependency</string>
<string>45.IBShouldRemoveOnLegacySave</string>
<string>46.CustomClassName</string>
<string>46.IBPluginDependency</string>
@@ -1219,19 +1186,20 @@
<string>49.ImportedFromIB2</string>
<string>5.IBPluginDependency</string>
<string>5.ImportedFromIB2</string>
<string>50.IBPluginDependency</string>
<string>50.IBShouldRemoveOnLegacySave</string>
<string>51.IBPluginDependency</string>
<string>51.ImportedFromIB2</string>
<string>52.IBPluginDependency</string>
<string>52.IBShouldRemoveOnLegacySave</string>
<string>53.IBPluginDependency</string>
<string>58.IBPluginDependency</string>
<string>59.IBPluginDependency</string>
<string>62.IBPluginDependency</string>
<string>62.ImportedFromIB2</string>
<string>63.IBPluginDependency</string>
<string>63.ImportedFromIB2</string>
<string>6.IBPluginDependency</string>
<string>65.IBPluginDependency</string>
<string>66.IBPluginDependency</string>
<string>7.IBPluginDependency</string>
<string>8.IBPluginDependency</string>
<string>9.IBPluginDependency</string>
<string>9.ImportedFromIB2</string>
</object>
@@ -1240,9 +1208,8 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{69, 482}, {414, 493}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{69, 482}, {414, 493}}</string>
<string>{{69, 327}, {414, 493}}</string>
<string>{{69, 327}, {414, 493}}</string>
<integer value="1" id="9"/>
<string>{196, 240}</string>
<string>{{186, 418}, {414, 493}}</string>
@@ -1257,16 +1224,24 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{333, 417}, {173, 4}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{465, 481}, {173, 33}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1274,9 +1249,13 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>FileOutlineView</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1289,17 +1268,18 @@
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1460,7 +1440,7 @@
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.LastKnownRelativeProjectPath">../../../Transmission.xcodeproj</string>
<string key="IBDocument.LastKnownRelativeProjectPath">../../Transmission.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>