Skip to content

Commit

Permalink
Added SUWindowController to reduce duplication of running-in-bundle s…
Browse files Browse the repository at this point in the history
…pecial-case code.
  • Loading branch information
andym committed Feb 14, 2008
1 parent 9eb1cb4 commit 1462087
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 35 deletions.
4 changes: 3 additions & 1 deletion SUAutomaticUpdateAlert.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
#ifndef SUAUTOMATICUPDATEALERT_H
#define SUAUTOMATICUPDATEALERT_H

#import "SUWindowController.h"

@class SUAppcastItem;
@interface SUAutomaticUpdateAlert : NSWindowController {
@interface SUAutomaticUpdateAlert : SUWindowController {
SUAppcastItem *updateItem;
NSBundle *hostBundle;
}
Expand Down
14 changes: 2 additions & 12 deletions SUAutomaticUpdateAlert.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,8 @@ - (id)initWithAppcastItem:(SUAppcastItem *)item hostBundle:(NSBundle *)hb;
{
updateItem = [item retain];
hostBundle = [hb retain];

NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"SUAutomaticUpdateAlert" ofType:@"nib"];
if (path == nil) // Slight hack to resolve issues with running Sparkle in debug configurations.
{
NSString *frameworkPath = [[hostBundle sharedFrameworksPath] stringByAppendingPathComponent:@"Sparkle.framework"];
NSBundle *framework = [NSBundle bundleWithPath:frameworkPath];
path = [framework pathForResource:@"SUAutomaticUpdateAlert" ofType:@"nib"];
}

self = [super initWithWindowNibPath:path owner:self];
[self setShouldCascadeWindows:NO];

[super initWithHostBundle:hb windowNibName:@"SUAutomaticUpdateAlert"];
[self setShouldCascadeWindows:NO];
return self;
}

Expand Down
3 changes: 2 additions & 1 deletion SUStatusController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#ifndef SUSTATUSCONTROLLER_H
#define SUSTATUSCONTROLLER_H

#import "SUWindowController.h"

@interface SUStatusController : NSWindowController {
@interface SUStatusController : SUWindowController {
double progressValue, maxProgressValue;
NSString *title, *statusText, *buttonTitle;
IBOutlet NSButton *actionButton;
Expand Down
9 changes: 1 addition & 8 deletions SUStatusController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ @implementation SUStatusController
- (id)initWithHostBundle:(NSBundle *)hb
{
hostBundle = [hb retain];
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"SUStatus" ofType:@"nib"];
if (path == nil) // Slight hack to resolve issues with running Sparkle in debug configurations.
{
NSString *frameworkPath = [[hostBundle sharedFrameworksPath] stringByAppendingPathComponent:@"Sparkle.framework"];
NSBundle *framework = [NSBundle bundleWithPath:frameworkPath];
path = [framework pathForResource:@"SUStatus" ofType:@"nib"];
}
self = [super initWithWindowNibPath:path owner:self];
[super initWithHostBundle:hb windowNibName:@"SUStatus"];
[self setShouldCascadeWindows:NO];
return self;
}
Expand Down
4 changes: 3 additions & 1 deletion SUUpdateAlert.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#ifndef SUUPDATEALERT_H
#define SUUPDATEALERT_H

#import "SUWindowController.h"

typedef enum
{
SUInstallUpdateChoice,
Expand All @@ -17,7 +19,7 @@ typedef enum
} SUUpdateAlertChoice;

@class WebView, SUAppcastItem;
@interface SUUpdateAlert : NSWindowController {
@interface SUUpdateAlert : SUWindowController {
SUAppcastItem *updateItem;
NSBundle *hostBundle;
id delegate;
Expand Down
11 changes: 1 addition & 10 deletions SUUpdateAlert.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,7 @@ - (id)initWithAppcastItem:(SUAppcastItem *)item hostBundle:(NSBundle *)hb
{
hostBundle = [hb retain];
updateItem = [item retain];

NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"SUUpdateAlert" ofType:@"nib"];
if (path == nil) // Slight hack to resolve issues with running Sparkle in debug configurations.
{
NSString *frameworkPath = [[hostBundle sharedFrameworksPath] stringByAppendingPathComponent:@"Sparkle.framework"];
NSBundle *framework = [NSBundle bundleWithPath:frameworkPath];
path = [framework pathForResource:@"SUUpdateAlert" ofType:@"nib"];
}

self = [super initWithWindowNibPath:path owner:self];
[super initWithHostBundle:hb windowNibName:@"SUUpdateAlert"];
[self setShouldCascadeWindows:NO];
return self;
}
Expand Down
3 changes: 2 additions & 1 deletion Sparkle.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
// there are name-space collisions) so we can list all of them to start with:

#import "NSBundle+SUAdditions.h"
#import "NSFileManager+Aliases.h"
#import "NSFileManager+Authentication.h"
#import "NSFileManager+Verification.h"
#import "NSFileManager+Aliases.h"
#import "NSString+extras.h"
#import "NSWorkspace_RBAdditions.h"

Expand All @@ -48,5 +48,6 @@
#import "SUUpdater.h"
#import "SUUserDefaults.h"
#import "SUVersionComparisonProtocol.h"
#import "SUWindowController.h"

#endif
8 changes: 8 additions & 0 deletions Sparkle.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
611779590D1111C900749C97 /* NSWorkspace_RBAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 611779570D1111C400749C97 /* NSWorkspace_RBAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
6117795A0D1111C900749C97 /* NSWorkspace_RBAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 611779560D1111C400749C97 /* NSWorkspace_RBAdditions.m */; };
61177A1F0D1112E900749C97 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6117796E0D1112E000749C97 /* IOKit.framework */; };
61180BCA0D64138900B4E0D1 /* SUWindowController.h in Headers */ = {isa = PBXBuildFile; fileRef = 61180BC80D64138900B4E0D1 /* SUWindowController.h */; settings = {ATTRIBUTES = (Public, ); }; };
61180BCB0D64138900B4E0D1 /* SUWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 61180BC90D64138900B4E0D1 /* SUWindowController.m */; };
6120721209CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.h in Headers */ = {isa = PBXBuildFile; fileRef = 6120721009CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.h */; settings = {ATTRIBUTES = (Public, ); }; };
6120721309CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = 6120721109CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.m */; };
61299A2F09CA2DAB00B7442F /* NSFileManager+Verification.h in Headers */ = {isa = PBXBuildFile; fileRef = 61299A2D09CA2DAB00B7442F /* NSFileManager+Verification.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -122,6 +124,8 @@
611779560D1111C400749C97 /* NSWorkspace_RBAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSWorkspace_RBAdditions.m; sourceTree = "<group>"; };
611779570D1111C400749C97 /* NSWorkspace_RBAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSWorkspace_RBAdditions.h; sourceTree = "<group>"; };
6117796E0D1112E000749C97 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = "<absolute>"; };
61180BC80D64138900B4E0D1 /* SUWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUWindowController.h; sourceTree = "<group>"; };
61180BC90D64138900B4E0D1 /* SUWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUWindowController.m; sourceTree = "<group>"; };
6120721009CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUAutomaticUpdateAlert.h; sourceTree = "<group>"; };
6120721109CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUAutomaticUpdateAlert.m; sourceTree = "<group>"; };
6129984309C9E2DA00B7442F /* NSFileManager+Authentication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSFileManager+Authentication.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -412,6 +416,8 @@
6196CFE409C71ADE000DC222 /* SUStatusController.m */,
612DCBAD0D488BC60015DBEA /* SUUpdatePermissionPrompt.h */,
612DCBAE0D488BC60015DBEA /* SUUpdatePermissionPrompt.m */,
61180BC80D64138900B4E0D1 /* SUWindowController.h */,
61180BC90D64138900B4E0D1 /* SUWindowController.m */,
);
name = "User Interface";
sourceTree = "<group>";
Expand Down Expand Up @@ -485,6 +491,7 @@
6160E7E10D3B4A8800E9CD71 /* NTSynchronousTask.h in Headers */,
612DCBAF0D488BC60015DBEA /* SUUpdatePermissionPrompt.h in Headers */,
6171D9070D57B81800BFE886 /* NSFileManager+Aliases.h in Headers */,
61180BCA0D64138900B4E0D1 /* SUWindowController.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -683,6 +690,7 @@
61A2279D0D1CEE7600430CCD /* SUSystemProfiler.m in Sources */,
612DCBB00D488BC60015DBEA /* SUUpdatePermissionPrompt.m in Sources */,
6171D9080D57B81800BFE886 /* NSFileManager+Aliases.m in Sources */,
61180BCB0D64138900B4E0D1 /* SUWindowController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion en.lproj/SUPermissionPrompt.nib/info.nib

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified en.lproj/SUPermissionPrompt.nib/keyedobjects.nib
Binary file not shown.

0 comments on commit 1462087

Please sign in to comment.