Changeset 4466

Show
Ignore:
Timestamp:
02/01/07 11:32:55 (2 years ago)
Author:
morris
Message:

Cancel sheets when hiding windows

Update for WiredAdditions?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WiredClient/trunk/WCChat.m

    r4439 r4466  
    15391539 
    15401540- (void)topicSheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { 
    1541         if(returnCode == NSRunStoppedResponse) { 
     1541        if(returnCode == NSAlertDefaultReturn) { 
    15421542                [[self connection] sendCommand:WCTopicCommand 
    15431543                                                  withArgument:[NSSWF:@"%u", [self chatID]] 
  • WiredClient/trunk/WCConnectionController.h

    r4455 r4466  
    4242- (id)initWithWindowNibName:(NSString *)windowNibName name:(NSString *)name connection:(WCServerConnection *)connection; 
    4343 
    44 - (NSDictionary *)windowTemplate; 
    45 - (BOOL)isHidden
     44- (void)windowTemplateShouldLoad:(NSMutableDictionary *)windowTemplate; 
     45- (void)windowTemplateShouldSave:(NSMutableDictionary *)windowTemplate
    4646 
    4747- (void)setName:(NSString *)name; 
     
    5151- (void)setReleasedWhenClosed:(BOOL)value; 
    5252- (BOOL)isReleasedWhenClosed; 
     53- (NSDictionary *)windowTemplate; 
     54- (BOOL)isHidden; 
    5355 
    5456- (BOOL)beginConfirmDisconnectSheetModalForWindow:(NSWindow *)window modalDelegate:(id)delegate didEndSelector:(SEL)selector contextInfo:(void *)contextInfo; 
    55  
    56 - (void)windowTemplateShouldLoad:(NSMutableDictionary *)windowTemplate; 
    57 - (void)windowTemplateShouldSave:(NSMutableDictionary *)windowTemplate; 
    5857 
    5958- (IBAction)disconnect:(id)sender; 
  • WiredClient/trunk/WCConnectionController.m

    r4457 r4466  
    8484} 
    8585 
     86 
     87 
     88#pragma mark - 
     89 
     90- (void)_WC_applicationWillTerminate:(NSNotification *)notification { 
     91        [self _saveWindowTemplate]; 
     92} 
     93 
     94 
     95 
     96- (void)_WC_windowWillClose:(NSNotification *)notification { 
     97        if([self isReleasedWhenClosed]) { 
     98                [self _saveWindowTemplate]; 
     99                 
     100                [self autorelease]; 
     101        } 
     102} 
     103 
     104 
     105 
     106- (void)_serverConnectionShouldLoadWindowTemplate:(NSNotification *)notification { 
     107        [self _loadWindowTemplate]; 
     108} 
     109 
     110 
     111 
     112- (void)_serverConnectionShouldSaveWindowTemplate:(NSNotification *)notification { 
     113        [self _saveWindowTemplate]; 
     114} 
     115 
     116 
     117 
     118- (void)_connectionWillTerminate:(NSNotification *)notification { 
     119        [self _saveWindowTemplate]; 
     120} 
     121 
     122 
     123 
     124- (void)_connectionDidTerminate:(NSNotification *)notification { 
     125        [_connection removeObserver:self]; 
     126        _connection = NULL; 
     127} 
     128 
     129 
     130 
     131- (void)_serverConnectionShouldHide:(NSNotification *)notification { 
     132        NSWindow        *sheet; 
     133                 
     134        _wasVisible = [[self window] isVisible]; 
     135        _hidden = YES; 
     136         
     137        if(_wasVisible) { 
     138                sheet = [[self window] attachedSheet]; 
     139                 
     140                if(sheet) 
     141                        [NSApp endSheet:sheet returnCode:NSAlertAlternateReturn]; 
     142                 
     143                [[self window] orderOut:self]; 
     144        } 
     145} 
     146 
     147 
     148 
     149- (void)_serverConnectionShouldUnhide:(NSNotification *)notification { 
     150        if(_wasVisible) 
     151                [[self window] orderFront:self]; 
     152                 
     153        _hidden = NO; 
     154} 
     155 
     156 
     157 
     158 
     159- (void)_disconnectSheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { 
     160        if(returnCode == NSAlertDefaultReturn) 
     161                [[self connection] disconnect]; 
     162} 
     163 
    86164@end 
    87165 
     
    107185 
    108186        [_connection addObserver:self 
     187                                        selector:@selector(_serverConnectionShouldLoadWindowTemplate:) 
     188                                                name:WCServerConnectionShouldLoadWindowTemplate]; 
     189 
     190        [_connection addObserver:self 
     191                                        selector:@selector(_serverConnectionShouldSaveWindowTemplate:) 
     192                                                name:WCServerConnectionShouldSaveWindowTemplate]; 
     193 
     194        [_connection addObserver:self 
    109195                                        selector:@selector(_connectionWillTerminate:) 
    110196                                                name:WCConnectionWillTerminate]; 
     
    122208                                                name:WCServerConnectionShouldUnhide]; 
    123209 
    124         [_connection addObserver:self 
    125                                         selector:@selector(_serverConnectionShouldLoadWindowTemplate:) 
    126                                                 name:WCServerConnectionShouldLoadWindowTemplate]; 
    127  
    128         [_connection addObserver:self 
    129                                         selector:@selector(_serverConnectionShouldSaveWindowTemplate:) 
    130                                                 name:WCServerConnectionShouldSaveWindowTemplate]; 
    131          
    132210        if([self respondsToSelector:@selector(connectionDidConnect:)]) { 
    133211                [_connection addObserver:self 
     
    183261                                                        name:WCServerConnectionPrivilegesDidChange]; 
    184262        } 
    185          
     263 
    186264        return self; 
    187265} 
     
    199277 
    200278        [super dealloc]; 
    201 } 
    202  
    203  
    204  
    205 #pragma mark - 
    206  
    207 - (void)_WC_applicationWillTerminate:(NSNotification *)notification { 
    208         [self _saveWindowTemplate]; 
    209 } 
    210  
    211  
    212  
    213 - (void)_WC_windowWillClose:(NSNotification *)notification { 
    214         if([self isReleasedWhenClosed]) { 
    215                 [self _saveWindowTemplate]; 
    216                  
    217                 [self autorelease]; 
    218         } 
    219 } 
    220  
    221  
    222  
    223 - (void)_connectionWillTerminate:(NSNotification *)notification { 
    224         [self _saveWindowTemplate]; 
    225 } 
    226  
    227  
    228  
    229 - (void)_connectionDidTerminate:(NSNotification *)notification { 
    230         [_connection removeObserver:self]; 
    231         _connection = NULL; 
    232 } 
    233  
    234  
    235  
    236 - (void)_serverConnectionShouldHide:(NSNotification *)notification { 
    237         _wasVisible = [[self window] isVisible]; 
    238         _hidden = YES; 
    239  
    240         [[self window] orderOut:self]; 
    241 } 
    242  
    243  
    244  
    245 - (void)_serverConnectionShouldUnhide:(NSNotification *)notification { 
    246         if(_wasVisible) 
    247                 [[self window] orderFront:self]; 
    248  
    249         _hidden = NO; 
    250 } 
    251  
    252  
    253  
    254 - (void)_serverConnectionShouldLoadWindowTemplate:(NSNotification *)notification { 
    255         [self _loadWindowTemplate]; 
    256 } 
    257  
    258  
    259  
    260 - (void)_serverConnectionShouldSaveWindowTemplate:(NSNotification *)notification { 
    261         [self _saveWindowTemplate]; 
    262279} 
    263280 
     
    276293 
    277294 
     295- (void)windowTemplateShouldLoad:(NSMutableDictionary *)windowTemplate { 
     296} 
     297 
     298 
     299 
     300- (void)windowTemplateShouldSave:(NSMutableDictionary *)windowTemplate { 
     301} 
     302 
     303 
     304 
     305#pragma mark - 
     306 
     307- (void)setName:(NSString *)name { 
     308        [name retain]; 
     309        [_name release]; 
     310 
     311        _name = name; 
     312} 
     313 
     314 
     315 
     316- (NSString *)name { 
     317        return _name; 
     318} 
     319 
     320 
     321 
     322- (void)setConnection:(WCServerConnection *)connection { 
     323        [connection retain]; 
     324        [_connection release]; 
     325 
     326        _connection = connection; 
     327} 
     328 
     329 
     330 
     331- (WCServerConnection *)connection { 
     332        return _connection; 
     333} 
     334 
     335 
     336 
     337- (void)setReleasedWhenClosed:(BOOL)value { 
     338        _releasedWhenClosed = value; 
     339} 
     340 
     341 
     342 
     343- (BOOL)isReleasedWhenClosed { 
     344        return _releasedWhenClosed; 
     345} 
     346 
     347 
     348 
    278349- (NSDictionary *)windowTemplate { 
    279350        if(!_windowTemplate) 
     
    287358- (BOOL)isHidden { 
    288359        return _hidden; 
    289 } 
    290  
    291  
    292  
    293 #pragma mark - 
    294  
    295 - (void)setName:(NSString *)name { 
    296         [name retain]; 
    297         [_name release]; 
    298  
    299         _name = name; 
    300 } 
    301  
    302  
    303  
    304 - (NSString *)name { 
    305         return _name; 
    306 } 
    307  
    308  
    309  
    310 - (void)setConnection:(WCServerConnection *)connection { 
    311         [connection retain]; 
    312         [_connection release]; 
    313  
    314         _connection = connection; 
    315 } 
    316  
    317  
    318  
    319 - (WCServerConnection *)connection { 
    320         return _connection; 
    321 } 
    322  
    323  
    324  
    325 - (void)setReleasedWhenClosed:(BOOL)value { 
    326         _releasedWhenClosed = value; 
    327 } 
    328  
    329  
    330  
    331 - (BOOL)isReleasedWhenClosed { 
    332         return _releasedWhenClosed; 
    333360} 
    334361 
     
    360387#pragma mark - 
    361388 
    362 - (void)windowTemplateShouldLoad:(NSMutableDictionary *)windowTemplate { 
    363 } 
    364  
    365  
    366  
    367 - (void)windowTemplateShouldSave:(NSMutableDictionary *)windowTemplate { 
    368 } 
    369  
    370  
    371  
    372 - (void)disconnectSheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { 
    373         if(returnCode == NSAlertDefaultReturn) 
    374                 [[self connection] disconnect]; 
    375 } 
    376  
    377  
    378  
    379 #pragma mark - 
    380  
    381389- (BOOL)validateMenuItem:(NSMenuItem *)item { 
    382390        SEL                     selector; 
     
    405413                if([self beginConfirmDisconnectSheetModalForWindow:[[[self connection] chat] window] 
    406414                                                                                         modalDelegate:self 
    407                                                                                         didEndSelector:@selector(disconnectSheetDidEnd:returnCode:contextInfo:) 
     415                                                                                        didEndSelector:@selector(_disconnectSheetDidEnd:returnCode:contextInfo:) 
    408416                                                                                           contextInfo:NULL]) { 
    409417                        [[self connection] disconnect]; 
  • WiredClient/trunk/WCFiles.m

    r4439 r4466  
    875875        [_createFolderPanel close]; 
    876876 
    877         if(returnCode == NSRunStoppedResponse) { 
     877        if(returnCode == NSAlertDefaultReturn) { 
    878878                path = [[[self _currentPath] path] stringByAppendingPathComponent:[_createFolderTextField stringValue]]; 
    879879                 
  • WiredClient/trunk/WCMessages.m

    r4439 r4466  
    837837 
    838838- (void)broadcastSheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { 
    839         if(returnCode == NSRunStoppedResponse
     839        if(returnCode == NSAlertDefaultReturn
    840840                [[self connection] sendCommand:WCBroadcastCommand withArgument:[_broadcastTextView string]]; 
    841841 
     
    870870        WCConversation  *conversation; 
    871871         
    872         if(returnCode == NSRunStoppedResponse) { 
     872        if(returnCode == NSAlertDefaultReturn) { 
    873873                message = [WCMessage messageToUser:user string:[[[_replyTextView string] copy] autorelease]]; 
    874874                [_allMessages addObject:message]; 
  • WiredClient/trunk/WCNews.m

    r4439 r4466  
    351351 
    352352- (void)postSheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { 
    353         if(returnCode == NSRunStoppedResponse
     353        if(returnCode == NSAlertDefaultReturn
    354354                [[self connection] sendCommand:WCPostCommand withArgument:[_postTextView string]]; 
    355355 
  • WiredClient/trunk/WCPublicChat.m

    r4457 r4466  
    576576        WCUser          *user = (WCUser *) contextInfo; 
    577577 
    578         if(returnCode == NSRunStoppedResponse) { 
     578        if(returnCode == NSAlertDefaultReturn) { 
    579579                [[self connection] sendCommand:WCBanCommand 
    580580                                                  withArgument:[NSSWF:@"%u", [user userID]] 
     
    603603        WCUser          *user = (WCUser *) contextInfo; 
    604604 
    605         if(returnCode == NSRunStoppedResponse) { 
     605        if(returnCode == NSAlertDefaultReturn) { 
    606606                [[self connection] sendCommand:WCKickCommand 
    607607                                                  withArgument:[NSSWF:@"%u", [user userID]]