Changeset 10368


Ignore:
Timestamp:
Mar 14, 2010, 1:42:49 AM (12 years ago)
Author:
livings124
Message:

add a protocol for the info view controllers, and as a result eliminate some excessive code

Location:
trunk
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Transmission.xcodeproj/project.pbxproj

    r10333 r10368  
    136136                A24621410C769D0900088E81 /* trevent.h in Headers */ = {isa = PBXBuildFile; fileRef = A24621350C769CF400088E81 /* trevent.h */; };
    137137                A24621420C769D0900088E81 /* trevent.c in Sources */ = {isa = PBXBuildFile; fileRef = A24621360C769CF400088E81 /* trevent.c */; };
     138                A247A443114C701800547DFC /* InfoViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = A247A442114C701800547DFC /* InfoViewController.h */; };
    138139                A24B65600D3F30870079EA4D /* QuitBadge.png in Resources */ = {isa = PBXBuildFile; fileRef = A24B655F0D3F30870079EA4D /* QuitBadge.png */; };
    139140                A24F19080A3A790800C9C145 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A24F19070A3A790800C9C145 /* Sparkle.framework */; };
     
    579580                A24621350C769CF400088E81 /* trevent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = trevent.h; path = libtransmission/trevent.h; sourceTree = "<group>"; };
    580581                A24621360C769CF400088E81 /* trevent.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = trevent.c; path = libtransmission/trevent.c; sourceTree = "<group>"; };
     582                A247A442114C701800547DFC /* InfoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InfoViewController.h; path = macosx/InfoViewController.h; sourceTree = "<group>"; };
    581583                A24B655F0D3F30870079EA4D /* QuitBadge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = QuitBadge.png; path = macosx/Images/QuitBadge.png; sourceTree = "<group>"; };
    582584                A24F19070A3A790800C9C145 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = macosx/Sparkle.framework; sourceTree = "<group>"; };
     
    14261428                        isa = PBXGroup;
    14271429                        children = (
     1430                                A247A442114C701800547DFC /* InfoViewController.h */,
    14281431                                A209EAC41142CF28002B02D1 /* InfoGeneralViewController.h */,
    14291432                                A209EAC51142CF28002B02D1 /* InfoGeneralViewController.m */,
     
    15461549                                4D80185A10BBC0B0008A4AF2 /* magnet.h in Headers */,
    15471550                                A209EE5D1144B51E002B02D1 /* history.h in Headers */,
     1551                                A247A443114C701800547DFC /* InfoViewController.h in Headers */,
    15481552                        );
    15491553                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/macosx/InfoActivityViewController.h

    r10335 r10368  
    2424
    2525#import <Cocoa/Cocoa.h>
     26#import "InfoViewController.h"
    2627
    2728@class PiecesView;
    2829@class Torrent;
    2930
    30 @interface InfoActivityViewController : NSViewController
     31@interface InfoActivityViewController : NSViewController <InfoViewController>
    3132{
    3233    NSArray * fTorrents;
  • trunk/macosx/InfoFileViewController.h

    r10335 r10368  
    2424
    2525#import <Cocoa/Cocoa.h>
     26#import "InfoViewController.h"
    2627
    2728@class FileOutlineController;
    2829
    29 @interface InfoFileViewController : NSViewController
     30@interface InfoFileViewController : NSViewController <InfoViewController>
    3031{
    3132    NSArray * fTorrents;
  • trunk/macosx/InfoGeneralViewController.h

    r10335 r10368  
    2424
    2525#import <Cocoa/Cocoa.h>
     26#import "InfoViewController.h"
    2627
    27 @interface InfoGeneralViewController : NSViewController
     28@interface InfoGeneralViewController : NSViewController <InfoViewController>
    2829{
    2930    NSArray * fTorrents;
  • trunk/macosx/InfoOptionsViewController.h

    r10335 r10368  
    2424
    2525#import <Cocoa/Cocoa.h>
     26#import "InfoViewController.h"
    2627
    27 @interface InfoOptionsViewController : NSViewController
     28@interface InfoOptionsViewController : NSViewController <InfoViewController>
    2829{
    2930    NSArray * fTorrents;
  • trunk/macosx/InfoPeersViewController.h

    r10335 r10368  
    2424
    2525#import <Cocoa/Cocoa.h>
     26#import "InfoViewController.h"
    2627
    27 @interface InfoPeersViewController : NSViewController
     28@interface InfoPeersViewController : NSViewController <InfoViewController>
    2829{
    2930    NSArray * fTorrents;
  • trunk/macosx/InfoTrackersViewController.h

    r10335 r10368  
    2424
    2525#import <Cocoa/Cocoa.h>
     26#import "InfoViewController.h"
    2627
    2728@class Torrent;
     
    2930@class TrackerCell;
    3031
    31 @interface InfoTrackersViewController : NSViewController
     32@interface InfoTrackersViewController : NSViewController <InfoViewController>
    3233{
    3334    NSArray * fTorrents;
  • trunk/macosx/InfoWindowController.h

    r10309 r10368  
    2525#import <Cocoa/Cocoa.h>
    2626
     27@protocol InfoViewController;
    2728@class InfoGeneralViewController;
    2829@class InfoActivityViewController;
     
    3637    NSArray * fTorrents;
    3738   
     39    NSViewController <InfoViewController> * fViewController;
     40    NSInteger fCurrentTabTag;
     41    IBOutlet NSMatrix * fTabMatrix;
     42   
    3843    InfoGeneralViewController * fGeneralViewController;
    3944    InfoActivityViewController * fActivityViewController;
     
    4247    InfoFileViewController * fFileViewController;
    4348    InfoOptionsViewController * fOptionsViewController;
    44    
    45     NSInteger fCurrentTabTag;
    46     IBOutlet NSMatrix * fTabMatrix;
    4749
    4850    IBOutlet NSImageView * fImageView;
  • trunk/macosx/InfoWindowController.m

    r10335 r10368  
    2424
    2525#import "InfoWindowController.h"
     26#import "InfoViewController.h"
    2627#import "InfoGeneralViewController.h"
    2728#import "InfoActivityViewController.h"
     
    6061- (void) resetInfo;
    6162- (void) resetInfoForTorrent: (NSNotification *) notification;
    62 
    63 - (NSView *) tabViewForTag: (NSInteger) tag;
    6463
    6564@end
     
    158157    }
    159158    if (resizeSaveKey)
    160         [[NSUserDefaults standardUserDefaults] setFloat: [[self tabViewForTag: fCurrentTabTag] frame].size.height forKey: resizeSaveKey];
     159        [[NSUserDefaults standardUserDefaults] setFloat: [[fViewController view] frame].size.height forKey: resizeSaveKey];
    161160   
    162161    [[NSNotificationCenter defaultCenter] removeObserver: self];
     
    176175   
    177176    [self resetInfo];
    178 }
    179 
    180 #warning simplify?
    181 - (void) updateInfoStats
    182 {
    183     switch ([fTabMatrix selectedTag])
    184     {
    185         case TAB_GENERAL_TAG:
    186             [fGeneralViewController updateInfo];
    187             break;
    188         case TAB_ACTIVITY_TAG:
    189             [fActivityViewController updateInfo];
    190             break;
    191         case TAB_TRACKERS_TAG:
    192             [fTrackersViewController updateInfo];
    193             break;
    194         case TAB_PEERS_TAG:
    195             [fPeersViewController updateInfo];
    196             break;
    197         case TAB_FILE_TAG:
    198             [fFileViewController updateInfo];
    199             break;
    200         case TAB_OPTIONS_TAG:
    201             [fOptionsViewController updateInfo];
    202             break;
    203     }
    204177}
    205178
     
    264237        }
    265238       
    266         NSView * oldView = [self tabViewForTag: oldTabTag];
     239        NSView * oldView = [fViewController view];
    267240        oldHeight = [oldView frame].size.height;
    268241        if (oldResizeSaveKey)
     
    287260            }
    288261           
     262            fViewController = fGeneralViewController;
    289263            identifier = TAB_INFO_IDENT;
    290264            title = NSLocalizedString(@"General Info", "Inspector -> title");
     
    297271            }
    298272           
     273            fViewController = fActivityViewController;
    299274            identifier = TAB_ACTIVITY_IDENT;
    300275            title = NSLocalizedString(@"Activity", "Inspector -> title");
     
    307282            }
    308283           
     284            fViewController = fTrackersViewController;
    309285            identifier = TAB_TRACKER_IDENT;
    310286            title = NSLocalizedString(@"Trackers", "Inspector -> title");
     
    318294            }
    319295           
     296            fViewController = fPeersViewController;
    320297            identifier = TAB_PEERS_IDENT;
    321298            title = NSLocalizedString(@"Peers", "Inspector -> title");
     
    329306            }
    330307           
     308            fViewController = fFileViewController;
    331309            identifier = TAB_FILES_IDENT;
    332310            title = NSLocalizedString(@"Files", "Inspector -> title");
     
    340318            }
    341319           
     320            fViewController = fOptionsViewController;
    342321            identifier = TAB_OPTIONS_IDENT;
    343322            title = NSLocalizedString(@"Options", "Inspector -> title");
     
    357336    [(InfoTabButtonCell *)[fTabMatrix selectedCell] setSelectedTab: YES];
    358337   
    359     NSView * view = [self tabViewForTag: fCurrentTabTag];
    360    
    361     [self updateInfoStats];
     338    NSView * view = [fViewController view];
     339   
     340    [fViewController updateInfo];
    362341   
    363342    NSRect windowRect = [window frame], viewRect = [view frame];
     
    419398    [fTabMatrix selectCellWithTag: tag];
    420399    [self setTab: nil];
     400}
     401
     402- (void) updateInfoStats
     403{
     404    [fViewController updateInfo];
    421405}
    422406
     
    568552    [fOptionsViewController setInfoForTorrents: fTorrents];
    569553   
    570     [self updateInfoStats];
     554    [fViewController updateInfo];
    571555}
    572556
     
    577561}
    578562
    579 #warning should we use the view controllers directly
    580 - (NSView *) tabViewForTag: (NSInteger) tag
    581 {
    582     switch (tag)
    583     {
    584         case TAB_GENERAL_TAG:
    585             return [fGeneralViewController view];
    586         case TAB_ACTIVITY_TAG:
    587             return [fActivityViewController view];
    588         case TAB_TRACKERS_TAG:
    589             return [fTrackersViewController view];
    590         case TAB_PEERS_TAG:
    591             return [fPeersViewController view];
    592         case TAB_FILE_TAG:
    593             return [fFileViewController view];
    594         case TAB_OPTIONS_TAG:
    595             return [fOptionsViewController view];
    596         default:
    597             NSAssert1(NO, @"Unknown tab view for tag: %d", tag);
    598             return nil;
    599     }
    600 }
    601 
    602563@end
Note: See TracChangeset for help on using the changeset viewer.