add a protocol for the info view controllers, and as a result eliminate some excessive code
This commit is contained in:
parent
83e43a81b5
commit
efce4e9759
|
@ -135,6 +135,7 @@
|
|||
A245030E0D6A1FBC00B49D00 /* DownArrowGroupTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = A245030D0D6A1FBC00B49D00 /* DownArrowGroupTemplate.png */; };
|
||||
A24621410C769D0900088E81 /* trevent.h in Headers */ = {isa = PBXBuildFile; fileRef = A24621350C769CF400088E81 /* trevent.h */; };
|
||||
A24621420C769D0900088E81 /* trevent.c in Sources */ = {isa = PBXBuildFile; fileRef = A24621360C769CF400088E81 /* trevent.c */; };
|
||||
A247A443114C701800547DFC /* InfoViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = A247A442114C701800547DFC /* InfoViewController.h */; };
|
||||
A24B65600D3F30870079EA4D /* QuitBadge.png in Resources */ = {isa = PBXBuildFile; fileRef = A24B655F0D3F30870079EA4D /* QuitBadge.png */; };
|
||||
A24F19080A3A790800C9C145 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A24F19070A3A790800C9C145 /* Sparkle.framework */; };
|
||||
A24F19210A3A796800C9C145 /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = A24F19070A3A790800C9C145 /* Sparkle.framework */; };
|
||||
|
@ -578,6 +579,7 @@
|
|||
A245030D0D6A1FBC00B49D00 /* DownArrowGroupTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = DownArrowGroupTemplate.png; path = macosx/Images/DownArrowGroupTemplate.png; sourceTree = "<group>"; };
|
||||
A24621350C769CF400088E81 /* trevent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = trevent.h; path = libtransmission/trevent.h; sourceTree = "<group>"; };
|
||||
A24621360C769CF400088E81 /* trevent.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = trevent.c; path = libtransmission/trevent.c; sourceTree = "<group>"; };
|
||||
A247A442114C701800547DFC /* InfoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InfoViewController.h; path = macosx/InfoViewController.h; sourceTree = "<group>"; };
|
||||
A24B655F0D3F30870079EA4D /* QuitBadge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = QuitBadge.png; path = macosx/Images/QuitBadge.png; sourceTree = "<group>"; };
|
||||
A24F19070A3A790800C9C145 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = macosx/Sparkle.framework; sourceTree = "<group>"; };
|
||||
A250EE800E2ED87B00A688E6 /* web */ = {isa = PBXFileReference; lastKnownFileType = folder; path = web; sourceTree = "<group>"; };
|
||||
|
@ -1425,6 +1427,7 @@
|
|||
E1B6FBF80C0D719B0015FE4D /* Info Window */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A247A442114C701800547DFC /* InfoViewController.h */,
|
||||
A209EAC41142CF28002B02D1 /* InfoGeneralViewController.h */,
|
||||
A209EAC51142CF28002B02D1 /* InfoGeneralViewController.m */,
|
||||
A209EAC21142CF28002B02D1 /* InfoActivityViewController.h */,
|
||||
|
@ -1545,6 +1548,7 @@
|
|||
4D8017EB10BBC073008A4AF2 /* torrent-magnet.h in Headers */,
|
||||
4D80185A10BBC0B0008A4AF2 /* magnet.h in Headers */,
|
||||
A209EE5D1144B51E002B02D1 /* history.h in Headers */,
|
||||
A247A443114C701800547DFC /* InfoViewController.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -23,11 +23,12 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "InfoViewController.h"
|
||||
|
||||
@class PiecesView;
|
||||
@class Torrent;
|
||||
|
||||
@interface InfoActivityViewController : NSViewController
|
||||
@interface InfoActivityViewController : NSViewController <InfoViewController>
|
||||
{
|
||||
NSArray * fTorrents;
|
||||
|
||||
|
|
|
@ -23,10 +23,11 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "InfoViewController.h"
|
||||
|
||||
@class FileOutlineController;
|
||||
|
||||
@interface InfoFileViewController : NSViewController
|
||||
@interface InfoFileViewController : NSViewController <InfoViewController>
|
||||
{
|
||||
NSArray * fTorrents;
|
||||
|
||||
|
|
|
@ -23,8 +23,9 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "InfoViewController.h"
|
||||
|
||||
@interface InfoGeneralViewController : NSViewController
|
||||
@interface InfoGeneralViewController : NSViewController <InfoViewController>
|
||||
{
|
||||
NSArray * fTorrents;
|
||||
|
||||
|
|
|
@ -23,8 +23,9 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "InfoViewController.h"
|
||||
|
||||
@interface InfoOptionsViewController : NSViewController
|
||||
@interface InfoOptionsViewController : NSViewController <InfoViewController>
|
||||
{
|
||||
NSArray * fTorrents;
|
||||
|
||||
|
|
|
@ -23,8 +23,9 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "InfoViewController.h"
|
||||
|
||||
@interface InfoPeersViewController : NSViewController
|
||||
@interface InfoPeersViewController : NSViewController <InfoViewController>
|
||||
{
|
||||
NSArray * fTorrents;
|
||||
|
||||
|
|
|
@ -23,12 +23,13 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "InfoViewController.h"
|
||||
|
||||
@class Torrent;
|
||||
@class TrackerTableView;
|
||||
@class TrackerCell;
|
||||
|
||||
@interface InfoTrackersViewController : NSViewController
|
||||
@interface InfoTrackersViewController : NSViewController <InfoViewController>
|
||||
{
|
||||
NSArray * fTorrents;
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/******************************************************************************
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2010 Transmission authors and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*****************************************************************************/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
|
||||
@protocol InfoViewController
|
||||
|
||||
- (void) setInfoForTorrents: (NSArray *) torrents;
|
||||
- (void) updateInfo;
|
||||
|
||||
@end
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@protocol InfoViewController;
|
||||
@class InfoGeneralViewController;
|
||||
@class InfoActivityViewController;
|
||||
@class InfoTrackersViewController;
|
||||
|
@ -35,15 +36,16 @@
|
|||
{
|
||||
NSArray * fTorrents;
|
||||
|
||||
NSViewController <InfoViewController> * fViewController;
|
||||
NSInteger fCurrentTabTag;
|
||||
IBOutlet NSMatrix * fTabMatrix;
|
||||
|
||||
InfoGeneralViewController * fGeneralViewController;
|
||||
InfoActivityViewController * fActivityViewController;
|
||||
InfoTrackersViewController * fTrackersViewController;
|
||||
InfoPeersViewController * fPeersViewController;
|
||||
InfoFileViewController * fFileViewController;
|
||||
InfoOptionsViewController * fOptionsViewController;
|
||||
|
||||
NSInteger fCurrentTabTag;
|
||||
IBOutlet NSMatrix * fTabMatrix;
|
||||
|
||||
IBOutlet NSImageView * fImageView;
|
||||
IBOutlet NSTextField * fNameField, * fBasicInfoField;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#import "InfoWindowController.h"
|
||||
#import "InfoViewController.h"
|
||||
#import "InfoGeneralViewController.h"
|
||||
#import "InfoActivityViewController.h"
|
||||
#import "InfoTrackersViewController.h"
|
||||
|
@ -60,8 +61,6 @@ typedef enum
|
|||
- (void) resetInfo;
|
||||
- (void) resetInfoForTorrent: (NSNotification *) notification;
|
||||
|
||||
- (NSView *) tabViewForTag: (NSInteger) tag;
|
||||
|
||||
@end
|
||||
|
||||
@implementation InfoWindowController
|
||||
|
@ -157,7 +156,7 @@ typedef enum
|
|||
break;
|
||||
}
|
||||
if (resizeSaveKey)
|
||||
[[NSUserDefaults standardUserDefaults] setFloat: [[self tabViewForTag: fCurrentTabTag] frame].size.height forKey: resizeSaveKey];
|
||||
[[NSUserDefaults standardUserDefaults] setFloat: [[fViewController view] frame].size.height forKey: resizeSaveKey];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
|
||||
|
@ -177,32 +176,6 @@ typedef enum
|
|||
[self resetInfo];
|
||||
}
|
||||
|
||||
#warning simplify?
|
||||
- (void) updateInfoStats
|
||||
{
|
||||
switch ([fTabMatrix selectedTag])
|
||||
{
|
||||
case TAB_GENERAL_TAG:
|
||||
[fGeneralViewController updateInfo];
|
||||
break;
|
||||
case TAB_ACTIVITY_TAG:
|
||||
[fActivityViewController updateInfo];
|
||||
break;
|
||||
case TAB_TRACKERS_TAG:
|
||||
[fTrackersViewController updateInfo];
|
||||
break;
|
||||
case TAB_PEERS_TAG:
|
||||
[fPeersViewController updateInfo];
|
||||
break;
|
||||
case TAB_FILE_TAG:
|
||||
[fFileViewController updateInfo];
|
||||
break;
|
||||
case TAB_OPTIONS_TAG:
|
||||
[fOptionsViewController updateInfo];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSRect) windowWillUseStandardFrame: (NSWindow *) window defaultFrame: (NSRect) defaultFrame
|
||||
{
|
||||
NSRect windowRect = [window frame];
|
||||
|
@ -263,7 +236,7 @@ typedef enum
|
|||
break;
|
||||
}
|
||||
|
||||
NSView * oldView = [self tabViewForTag: oldTabTag];
|
||||
NSView * oldView = [fViewController view];
|
||||
oldHeight = [oldView frame].size.height;
|
||||
if (oldResizeSaveKey)
|
||||
[[NSUserDefaults standardUserDefaults] setFloat: oldHeight forKey: oldResizeSaveKey];
|
||||
|
@ -286,6 +259,7 @@ typedef enum
|
|||
[fGeneralViewController setInfoForTorrents: fTorrents];
|
||||
}
|
||||
|
||||
fViewController = fGeneralViewController;
|
||||
identifier = TAB_INFO_IDENT;
|
||||
title = NSLocalizedString(@"General Info", "Inspector -> title");
|
||||
break;
|
||||
|
@ -296,6 +270,7 @@ typedef enum
|
|||
[fActivityViewController setInfoForTorrents: fTorrents];
|
||||
}
|
||||
|
||||
fViewController = fActivityViewController;
|
||||
identifier = TAB_ACTIVITY_IDENT;
|
||||
title = NSLocalizedString(@"Activity", "Inspector -> title");
|
||||
break;
|
||||
|
@ -306,6 +281,7 @@ typedef enum
|
|||
[fTrackersViewController setInfoForTorrents: fTorrents];
|
||||
}
|
||||
|
||||
fViewController = fTrackersViewController;
|
||||
identifier = TAB_TRACKER_IDENT;
|
||||
title = NSLocalizedString(@"Trackers", "Inspector -> title");
|
||||
resizeSaveKey = @"InspectorContentHeightTracker";
|
||||
|
@ -317,6 +293,7 @@ typedef enum
|
|||
[fPeersViewController setInfoForTorrents: fTorrents];
|
||||
}
|
||||
|
||||
fViewController = fPeersViewController;
|
||||
identifier = TAB_PEERS_IDENT;
|
||||
title = NSLocalizedString(@"Peers", "Inspector -> title");
|
||||
resizeSaveKey = @"InspectorContentHeightPeers";
|
||||
|
@ -328,6 +305,7 @@ typedef enum
|
|||
[fFileViewController setInfoForTorrents: fTorrents];
|
||||
}
|
||||
|
||||
fViewController = fFileViewController;
|
||||
identifier = TAB_FILES_IDENT;
|
||||
title = NSLocalizedString(@"Files", "Inspector -> title");
|
||||
resizeSaveKey = @"InspectorContentHeightFiles";
|
||||
|
@ -339,6 +317,7 @@ typedef enum
|
|||
[fOptionsViewController setInfoForTorrents: fTorrents];
|
||||
}
|
||||
|
||||
fViewController = fOptionsViewController;
|
||||
identifier = TAB_OPTIONS_IDENT;
|
||||
title = NSLocalizedString(@"Options", "Inspector -> title");
|
||||
break;
|
||||
|
@ -356,9 +335,9 @@ typedef enum
|
|||
//selected tab item
|
||||
[(InfoTabButtonCell *)[fTabMatrix selectedCell] setSelectedTab: YES];
|
||||
|
||||
NSView * view = [self tabViewForTag: fCurrentTabTag];
|
||||
NSView * view = [fViewController view];
|
||||
|
||||
[self updateInfoStats];
|
||||
[fViewController updateInfo];
|
||||
|
||||
NSRect windowRect = [window frame], viewRect = [view frame];
|
||||
|
||||
|
@ -420,6 +399,11 @@ typedef enum
|
|||
[self setTab: nil];
|
||||
}
|
||||
|
||||
- (void) updateInfoStats
|
||||
{
|
||||
[fViewController updateInfo];
|
||||
}
|
||||
|
||||
- (void) updateOptions
|
||||
{
|
||||
[fOptionsViewController updateOptions];
|
||||
|
@ -567,7 +551,7 @@ typedef enum
|
|||
[fFileViewController setInfoForTorrents: fTorrents];
|
||||
[fOptionsViewController setInfoForTorrents: fTorrents];
|
||||
|
||||
[self updateInfoStats];
|
||||
[fViewController updateInfo];
|
||||
}
|
||||
|
||||
- (void) resetInfoForTorrent: (NSNotification *) notification
|
||||
|
@ -576,27 +560,4 @@ typedef enum
|
|||
[self resetInfo];
|
||||
}
|
||||
|
||||
#warning should we use the view controllers directly
|
||||
- (NSView *) tabViewForTag: (NSInteger) tag
|
||||
{
|
||||
switch (tag)
|
||||
{
|
||||
case TAB_GENERAL_TAG:
|
||||
return [fGeneralViewController view];
|
||||
case TAB_ACTIVITY_TAG:
|
||||
return [fActivityViewController view];
|
||||
case TAB_TRACKERS_TAG:
|
||||
return [fTrackersViewController view];
|
||||
case TAB_PEERS_TAG:
|
||||
return [fPeersViewController view];
|
||||
case TAB_FILE_TAG:
|
||||
return [fFileViewController view];
|
||||
case TAB_OPTIONS_TAG:
|
||||
return [fOptionsViewController view];
|
||||
default:
|
||||
NSAssert1(NO, @"Unknown tab view for tag: %d", tag);
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue