Skip to content

Commit 0f09401

Browse files
cljpieter
authored andcommitted
Add a preferences window
This adds a preference window with default preferences to change the sparkle options and to set a custom path to a git binary.
1 parent 85fa5a1 commit 0f09401

13 files changed

+39258
-7
lines changed

ApplicationController.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
@class PBCLIProxy;
1313

14-
@interface ApplicationController : NSObject
14+
@interface ApplicationController : NSObject
1515
{
1616
IBOutlet NSWindow *window;
1717
IBOutlet id firstResponder;
@@ -27,6 +27,8 @@
2727
- (NSManagedObjectModel *)managedObjectModel;
2828
- (NSManagedObjectContext *)managedObjectContext;
2929

30+
- (IBAction)openPreferencesWindow:(id)sender;
31+
3032
- (IBAction)installCliTool:(id)sender;
3133

3234
- (IBAction)saveAction:sender;

ApplicationController.m

+11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#import "PBCLIProxy.h"
1414
#import "PBServicesController.h"
1515
#import "PBGitXProtocol.h"
16+
#import "PBPrefsWindowController.h"
17+
#import "PBNSURLPathUserDefaultsTransfomer.h"
1618

1719
@implementation ApplicationController
1820
@synthesize cliProxy;
@@ -30,6 +32,10 @@ - (ApplicationController*)init
3032
self.cliProxy = [PBCLIProxy new];
3133
}
3234

35+
/* Value Transformers */
36+
NSValueTransformer *transformer = [[PBNSURLPathUserDefaultsTransfomer alloc] init];
37+
[NSValueTransformer setValueTransformer:transformer forName:@"PBNSURLPathUserDefaultsTransfomer"];
38+
3339
return self;
3440
}
3541

@@ -78,6 +84,11 @@ - (void) windowWillClose: sender
7884
[firstResponder terminate: sender];
7985
}
8086

87+
- (IBAction)openPreferencesWindow:(id)sender
88+
{
89+
[[PBPrefsWindowController sharedPrefsWindowController] showWindow:nil];
90+
}
91+
8192
- (IBAction)installCliTool:(id)sender;
8293
{
8394
BOOL success = NO;

DBPrefsWindowController.h

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
//
2+
// DBPrefsWindowController.h
3+
//
4+
// Created by Dave Batton
5+
// http://www.Mere-Mortal-Software.com/blog/
6+
//
7+
// Documentation for this class is available here:
8+
// http://www.mere-mortal-software.com/blog/details.php?d=2007-03-11
9+
//
10+
// Copyright 2007. Some rights reserved.
11+
// This work is licensed under a Creative Commons license:
12+
// http://creativecommons.org/licenses/by/3.0/
13+
//
14+
// 11 March 2007 : Initial 1.0 release
15+
// 15 March 2007 : Version 1.1
16+
// Resizing is now handled along with the cross-fade by
17+
// the NSViewAnimation routine.
18+
// Cut the fade time in half to speed up the window resize.
19+
// -setupToolbar is now called each time the window opens so
20+
// you can configure it differently each time if you want.
21+
// Holding down the shift key will now slow down the animation.
22+
// This can be disabled by using the new -setShiftSlowsAnimation:
23+
// method.
24+
// 23 March 2007 : Version 1.1.1
25+
// The initial first responder now gets set when the view is
26+
// swapped so that the user can tab to the objects displayed
27+
// in the window.
28+
// Also added a work-around to Cocoa's insistance on drawing
29+
// a focus ring around the first toolbar icon when going from
30+
// a view with a focusable item to a view without a focusable item.
31+
//
32+
// 31 May 2007 : Version 1.1.2
33+
// The window's title bar and toolbar heights are now calculated at
34+
// runtime, rather than being hard-coded.
35+
// Fixed a redraw problem and a window placement problem associated
36+
// with large preference windows.
37+
// Added some code to supress compiler warnings from unused parameters.
38+
// Fixed a couple of objects that weren't being properly released.
39+
//
40+
41+
42+
#import <Cocoa/Cocoa.h>
43+
44+
45+
@interface DBPrefsWindowController : NSWindowController {
46+
NSMutableArray *toolbarIdentifiers;
47+
NSMutableDictionary *toolbarViews;
48+
NSMutableDictionary *toolbarItems;
49+
50+
BOOL _crossFade;
51+
BOOL _shiftSlowsAnimation;
52+
53+
NSView *contentSubview;
54+
NSViewAnimation *viewAnimation;
55+
}
56+
57+
58+
+ (DBPrefsWindowController *)sharedPrefsWindowController;
59+
+ (NSString *)nibName;
60+
61+
- (void)setupToolbar;
62+
- (void)addView:(NSView *)view label:(NSString *)label;
63+
- (void)addView:(NSView *)view label:(NSString *)label image:(NSImage *)image;
64+
65+
- (BOOL)crossFade;
66+
- (void)setCrossFade:(BOOL)fade;
67+
- (BOOL)shiftSlowsAnimation;
68+
- (void)setShiftSlowsAnimation:(BOOL)slows;
69+
70+
- (void)displayViewForIdentifier:(NSString *)identifier animate:(BOOL)animate;
71+
- (void)crossFadeView:(NSView *)oldView withView:(NSView *)newView;
72+
- (NSRect)frameForView:(NSView *)view;
73+
74+
75+
@end

0 commit comments

Comments
 (0)