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.
This commit is contained in:
Christian Jacobsen
2008-10-02 17:46:30 +02:00
committed by Pieter de Bie
parent 85fa5a1d8f
commit 0f09401aa6
13 changed files with 39258 additions and 7 deletions
+3 -1
View File
@@ -11,7 +11,7 @@
@class PBCLIProxy;
@interface ApplicationController : NSObject
@interface ApplicationController : NSObject
{
IBOutlet NSWindow *window;
IBOutlet id firstResponder;
@@ -27,6 +27,8 @@
- (NSManagedObjectModel *)managedObjectModel;
- (NSManagedObjectContext *)managedObjectContext;
- (IBAction)openPreferencesWindow:(id)sender;
- (IBAction)installCliTool:(id)sender;
- (IBAction)saveAction:sender;
+11
View File
@@ -13,6 +13,8 @@
#import "PBCLIProxy.h"
#import "PBServicesController.h"
#import "PBGitXProtocol.h"
#import "PBPrefsWindowController.h"
#import "PBNSURLPathUserDefaultsTransfomer.h"
@implementation ApplicationController
@synthesize cliProxy;
@@ -30,6 +32,10 @@
self.cliProxy = [PBCLIProxy new];
}
/* Value Transformers */
NSValueTransformer *transformer = [[PBNSURLPathUserDefaultsTransfomer alloc] init];
[NSValueTransformer setValueTransformer:transformer forName:@"PBNSURLPathUserDefaultsTransfomer"];
return self;
}
@@ -78,6 +84,11 @@
[firstResponder terminate: sender];
}
- (IBAction)openPreferencesWindow:(id)sender
{
[[PBPrefsWindowController sharedPrefsWindowController] showWindow:nil];
}
- (IBAction)installCliTool:(id)sender;
{
BOOL success = NO;
+75
View File
@@ -0,0 +1,75 @@
//
// DBPrefsWindowController.h
//
// Created by Dave Batton
// http://www.Mere-Mortal-Software.com/blog/
//
// Documentation for this class is available here:
// http://www.mere-mortal-software.com/blog/details.php?d=2007-03-11
//
// Copyright 2007. Some rights reserved.
// This work is licensed under a Creative Commons license:
// http://creativecommons.org/licenses/by/3.0/
//
// 11 March 2007 : Initial 1.0 release
// 15 March 2007 : Version 1.1
// Resizing is now handled along with the cross-fade by
// the NSViewAnimation routine.
// Cut the fade time in half to speed up the window resize.
// -setupToolbar is now called each time the window opens so
// you can configure it differently each time if you want.
// Holding down the shift key will now slow down the animation.
// This can be disabled by using the new -setShiftSlowsAnimation:
// method.
// 23 March 2007 : Version 1.1.1
// The initial first responder now gets set when the view is
// swapped so that the user can tab to the objects displayed
// in the window.
// Also added a work-around to Cocoa's insistance on drawing
// a focus ring around the first toolbar icon when going from
// a view with a focusable item to a view without a focusable item.
//
// 31 May 2007 : Version 1.1.2
// The window's title bar and toolbar heights are now calculated at
// runtime, rather than being hard-coded.
// Fixed a redraw problem and a window placement problem associated
// with large preference windows.
// Added some code to supress compiler warnings from unused parameters.
// Fixed a couple of objects that weren't being properly released.
//
#import <Cocoa/Cocoa.h>
@interface DBPrefsWindowController : NSWindowController {
NSMutableArray *toolbarIdentifiers;
NSMutableDictionary *toolbarViews;
NSMutableDictionary *toolbarItems;
BOOL _crossFade;
BOOL _shiftSlowsAnimation;
NSView *contentSubview;
NSViewAnimation *viewAnimation;
}
+ (DBPrefsWindowController *)sharedPrefsWindowController;
+ (NSString *)nibName;
- (void)setupToolbar;
- (void)addView:(NSView *)view label:(NSString *)label;
- (void)addView:(NSView *)view label:(NSString *)label image:(NSImage *)image;
- (BOOL)crossFade;
- (void)setCrossFade:(BOOL)fade;
- (BOOL)shiftSlowsAnimation;
- (void)setShiftSlowsAnimation:(BOOL)slows;
- (void)displayViewForIdentifier:(NSString *)identifier animate:(BOOL)animate;
- (void)crossFadeView:(NSView *)oldView withView:(NSView *)newView;
- (NSRect)frameForView:(NSView *)view;
@end
+409
View File
@@ -0,0 +1,409 @@
//
// DBPrefsWindowController.m
//
#import "DBPrefsWindowController.h"
static DBPrefsWindowController *_sharedPrefsWindowController = nil;
@implementation DBPrefsWindowController
#pragma mark -
#pragma mark Class Methods
+ (DBPrefsWindowController *)sharedPrefsWindowController
{
if (!_sharedPrefsWindowController) {
_sharedPrefsWindowController = [[self alloc] initWithWindowNibName:[self nibName]];
}
return _sharedPrefsWindowController;
}
+ (NSString *)nibName
// Subclasses can override this to use a nib with a different name.
{
return @"Preferences";
}
#pragma mark -
#pragma mark Setup & Teardown
- (id)initWithWindow:(NSWindow *)window
// -initWithWindow: is the designated initializer for NSWindowController.
{
self = [super initWithWindow:nil];
if (self != nil) {
// Set up an array and some dictionaries to keep track
// of the views we'll be displaying.
toolbarIdentifiers = [[NSMutableArray alloc] init];
toolbarViews = [[NSMutableDictionary alloc] init];
toolbarItems = [[NSMutableDictionary alloc] init];
// Set up an NSViewAnimation to animate the transitions.
viewAnimation = [[NSViewAnimation alloc] init];
[viewAnimation setAnimationBlockingMode:NSAnimationNonblocking];
[viewAnimation setAnimationCurve:NSAnimationEaseInOut];
[viewAnimation setDelegate:self];
[self setCrossFade:YES];
[self setShiftSlowsAnimation:YES];
}
return self;
(void)window; // To prevent compiler warnings.
}
- (void)windowDidLoad
{
// Create a new window to display the preference views.
// If the developer attached a window to this controller
// in Interface Builder, it gets replaced with this one.
NSWindow *window = [[[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,1000,1000)
styleMask:(NSTitledWindowMask |
NSClosableWindowMask |
NSMiniaturizableWindowMask)
backing:NSBackingStoreBuffered
defer:YES] autorelease];
[self setWindow:window];
contentSubview = [[[NSView alloc] initWithFrame:[[[self window] contentView] frame]] autorelease];
[contentSubview setAutoresizingMask:(NSViewMinYMargin | NSViewWidthSizable)];
[[[self window] contentView] addSubview:contentSubview];
[[self window] setShowsToolbarButton:NO];
}
- (void) dealloc {
[toolbarIdentifiers release];
[toolbarViews release];
[toolbarItems release];
[viewAnimation release];
[super dealloc];
}
#pragma mark -
#pragma mark Configuration
- (void)setupToolbar
{
// Subclasses must override this method to add items to the
// toolbar by calling -addView:label: or -addView:label:image:.
}
- (void)addView:(NSView *)view label:(NSString *)label
{
[self addView:view
label:label
image:[NSImage imageNamed:label]];
}
- (void)addView:(NSView *)view label:(NSString *)label image:(NSImage *)image
{
NSAssert (view != nil,
@"Attempted to add a nil view when calling -addView:label:image:.");
NSString *identifier = [[label copy] autorelease];
[toolbarIdentifiers addObject:identifier];
[toolbarViews setObject:view forKey:identifier];
NSToolbarItem *item = [[[NSToolbarItem alloc] initWithItemIdentifier:identifier] autorelease];
[item setLabel:label];
[item setImage:image];
[item setTarget:self];
[item setAction:@selector(toggleActivePreferenceView:)];
[toolbarItems setObject:item forKey:identifier];
}
#pragma mark -
#pragma mark Accessor Methods
- (BOOL)crossFade
{
return _crossFade;
}
- (void)setCrossFade:(BOOL)fade
{
_crossFade = fade;
}
- (BOOL)shiftSlowsAnimation
{
return _shiftSlowsAnimation;
}
- (void)setShiftSlowsAnimation:(BOOL)slows
{
_shiftSlowsAnimation = slows;
}
#pragma mark -
#pragma mark Overriding Methods
- (IBAction)showWindow:(id)sender
{
// This forces the resources in the nib to load.
(void)[self window];
// Clear the last setup and get a fresh one.
[toolbarIdentifiers removeAllObjects];
[toolbarViews removeAllObjects];
[toolbarItems removeAllObjects];
[self setupToolbar];
NSAssert (([toolbarIdentifiers count] > 0),
@"No items were added to the toolbar in -setupToolbar.");
if ([[self window] toolbar] == nil) {
NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier:@"DBPreferencesToolbar"];
[toolbar setAllowsUserCustomization:NO];
[toolbar setAutosavesConfiguration:NO];
[toolbar setSizeMode:NSToolbarSizeModeDefault];
[toolbar setDisplayMode:NSToolbarDisplayModeIconAndLabel];
[toolbar setDelegate:self];
[[self window] setToolbar:toolbar];
[toolbar release];
}
NSString *firstIdentifier = [toolbarIdentifiers objectAtIndex:0];
[[[self window] toolbar] setSelectedItemIdentifier:firstIdentifier];
[self displayViewForIdentifier:firstIdentifier animate:NO];
[[self window] center];
[super showWindow:sender];
}
#pragma mark -
#pragma mark Toolbar
- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar
{
return toolbarIdentifiers;
(void)toolbar;
}
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar
{
return toolbarIdentifiers;
(void)toolbar;
}
- (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar
{
return toolbarIdentifiers;
(void)toolbar;
}
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)identifier willBeInsertedIntoToolbar:(BOOL)willBeInserted
{
return [toolbarItems objectForKey:identifier];
(void)toolbar;
(void)willBeInserted;
}
- (void)toggleActivePreferenceView:(NSToolbarItem *)toolbarItem
{
[self displayViewForIdentifier:[toolbarItem itemIdentifier] animate:YES];
}
- (void)displayViewForIdentifier:(NSString *)identifier animate:(BOOL)animate
{
// Find the view we want to display.
NSView *newView = [toolbarViews objectForKey:identifier];
// See if there are any visible views.
NSView *oldView = nil;
if ([[contentSubview subviews] count] > 0) {
// Get a list of all of the views in the window. Usually at this
// point there is just one visible view. But if the last fade
// hasn't finished, we need to get rid of it now before we move on.
NSEnumerator *subviewsEnum = [[contentSubview subviews] reverseObjectEnumerator];
// The first one (last one added) is our visible view.
oldView = [subviewsEnum nextObject];
// Remove any others.
NSView *reallyOldView = nil;
while ((reallyOldView = [subviewsEnum nextObject]) != nil) {
[reallyOldView removeFromSuperviewWithoutNeedingDisplay];
}
}
if (![newView isEqualTo:oldView]) {
NSRect frame = [newView bounds];
frame.origin.y = NSHeight([contentSubview frame]) - NSHeight([newView bounds]);
[newView setFrame:frame];
[contentSubview addSubview:newView];
[[self window] setInitialFirstResponder:newView];
if (animate && [self crossFade])
[self crossFadeView:oldView withView:newView];
else {
[oldView removeFromSuperviewWithoutNeedingDisplay];
[newView setHidden:NO];
[[self window] setFrame:[self frameForView:newView] display:YES animate:animate];
}
[[self window] setTitle:[[toolbarItems objectForKey:identifier] label]];
}
}
#pragma mark -
#pragma mark Cross-Fading Methods
- (void)crossFadeView:(NSView *)oldView withView:(NSView *)newView
{
[viewAnimation stopAnimation];
if ([self shiftSlowsAnimation] && [[[self window] currentEvent] modifierFlags] & NSShiftKeyMask)
[viewAnimation setDuration:1.25];
else
[viewAnimation setDuration:0.25];
NSDictionary *fadeOutDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
oldView, NSViewAnimationTargetKey,
NSViewAnimationFadeOutEffect, NSViewAnimationEffectKey,
nil];
NSDictionary *fadeInDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
newView, NSViewAnimationTargetKey,
NSViewAnimationFadeInEffect, NSViewAnimationEffectKey,
nil];
NSDictionary *resizeDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
[self window], NSViewAnimationTargetKey,
[NSValue valueWithRect:[[self window] frame]], NSViewAnimationStartFrameKey,
[NSValue valueWithRect:[self frameForView:newView]], NSViewAnimationEndFrameKey,
nil];
NSArray *animationArray = [NSArray arrayWithObjects:
fadeOutDictionary,
fadeInDictionary,
resizeDictionary,
nil];
[viewAnimation setViewAnimations:animationArray];
[viewAnimation startAnimation];
}
- (void)animationDidEnd:(NSAnimation *)animation
{
NSView *subview;
// Get a list of all of the views in the window. Hopefully
// at this point there are two. One is visible and one is hidden.
NSEnumerator *subviewsEnum = [[contentSubview subviews] reverseObjectEnumerator];
// This is our visible view. Just get past it.
subview = [subviewsEnum nextObject];
// Remove everything else. There should be just one, but
// if the user does a lot of fast clicking, we might have
// more than one to remove.
while ((subview = [subviewsEnum nextObject]) != nil) {
[subview removeFromSuperviewWithoutNeedingDisplay];
}
// This is a work-around that prevents the first
// toolbar icon from becoming highlighted.
[[self window] makeFirstResponder:nil];
(void)animation;
}
- (NSRect)frameForView:(NSView *)view
// Calculate the window size for the new view.
{
NSRect windowFrame = [[self window] frame];
NSRect contentRect = [[self window] contentRectForFrameRect:windowFrame];
float windowTitleAndToolbarHeight = NSHeight(windowFrame) - NSHeight(contentRect);
windowFrame.size.height = NSHeight([view frame]) + windowTitleAndToolbarHeight;
windowFrame.size.width = NSWidth([view frame]);
windowFrame.origin.y = NSMaxY([[self window] frame]) - NSHeight(windowFrame);
return windowFrame;
}
@end
+16 -6
View File
@@ -8,7 +8,7 @@
<string key="IBDocument.HIToolboxVersion">352.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="106"/>
<integer value="57"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1193,6 +1193,14 @@
</object>
<int key="connectionID">932</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">openPreferencesWindow:</string>
<reference key="source" ref="859235683"/>
<reference key="destination" ref="704355783"/>
</object>
<int key="connectionID">933</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -2036,7 +2044,7 @@
<integer value="1" id="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{789, 817}, {138, 23}}</string>
<string>{{789, 713}, {138, 23}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -2154,7 +2162,7 @@
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{521, 840}, {329, 20}}</string>
<string>{{521, 736}, {329, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{297, 739}, {329, 20}}</string>
@@ -2170,7 +2178,7 @@
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{279, 643}, {262, 223}}</string>
<string>{{533, 513}, {262, 223}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{309, 536}, {262, 203}}</string>
@@ -2192,7 +2200,7 @@
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{373, 680}, {199, 203}}</string>
<string>{{582, 533}, {199, 203}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{358, 536}, {199, 203}}</string>
@@ -2235,7 +2243,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">932</int>
<int key="maxID">933</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -2248,6 +2256,7 @@
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>installCliTool:</string>
<string>openPreferencesWindow:</string>
<string>saveAction:</string>
<string>showHelp:</string>
</object>
@@ -2256,6 +2265,7 @@
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
File diff suppressed because it is too large Load Diff
+44
View File
@@ -10,6 +10,11 @@
056438B70ED0C40B00985397 /* DetailViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 056438B60ED0C40B00985397 /* DetailViewTemplate.png */; };
3BC07F4C0ED5A5C5009A7768 /* HistoryViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 3BC07F4A0ED5A5C5009A7768 /* HistoryViewTemplate.png */; };
3BC07F4D0ED5A5C5009A7768 /* CommitViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 3BC07F4B0ED5A5C5009A7768 /* CommitViewTemplate.png */; };
47DBDB580E94EDE700671A1E /* DBPrefsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 47DBDB570E94EDE700671A1E /* DBPrefsWindowController.m */; };
47DBDB670E94EE8B00671A1E /* PBPrefsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 47DBDB660E94EE8B00671A1E /* PBPrefsWindowController.m */; };
47DBDB6A0E94EF6500671A1E /* Preferences.xib in Resources */ = {isa = PBXBuildFile; fileRef = 47DBDB680E94EF6500671A1E /* Preferences.xib */; };
47DBDBB10E94F6CA00671A1E /* Updates.png in Resources */ = {isa = PBXBuildFile; fileRef = 47DBDBB00E94F6CA00671A1E /* Updates.png */; };
47DBDBCA0E95016F00671A1E /* PBNSURLPathUserDefaultsTransfomer.m in Sources */ = {isa = PBXBuildFile; fileRef = 47DBDBC90E95016F00671A1E /* PBNSURLPathUserDefaultsTransfomer.m */; };
770B37ED0679A11B001EADE2 /* GitTest_DataModel.xcdatamodel in Sources */ = {isa = PBXBuildFile; fileRef = 770B37EC0679A11B001EADE2 /* GitTest_DataModel.xcdatamodel */; };
77C8280E06725ACE000B614F /* ApplicationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77C8280C06725ACE000B614F /* ApplicationController.m */; };
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
@@ -132,6 +137,14 @@
32CA4F630368D1EE00C91783 /* GitX_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GitX_Prefix.pch; sourceTree = "<group>"; };
3BC07F4A0ED5A5C5009A7768 /* HistoryViewTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = HistoryViewTemplate.png; path = Images/HistoryViewTemplate.png; sourceTree = "<group>"; };
3BC07F4B0ED5A5C5009A7768 /* CommitViewTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = CommitViewTemplate.png; path = Images/CommitViewTemplate.png; sourceTree = "<group>"; };
47DBDB560E94EDE700671A1E /* DBPrefsWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBPrefsWindowController.h; sourceTree = "<group>"; };
47DBDB570E94EDE700671A1E /* DBPrefsWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DBPrefsWindowController.m; sourceTree = "<group>"; };
47DBDB650E94EE8B00671A1E /* PBPrefsWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBPrefsWindowController.h; sourceTree = "<group>"; };
47DBDB660E94EE8B00671A1E /* PBPrefsWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBPrefsWindowController.m; sourceTree = "<group>"; };
47DBDB690E94EF6500671A1E /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/Preferences.xib; sourceTree = "<group>"; };
47DBDBB00E94F6CA00671A1E /* Updates.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Updates.png; path = Images/Preferences/Updates.png; sourceTree = "<group>"; };
47DBDBC80E95016F00671A1E /* PBNSURLPathUserDefaultsTransfomer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBNSURLPathUserDefaultsTransfomer.h; sourceTree = "<group>"; };
47DBDBC90E95016F00671A1E /* PBNSURLPathUserDefaultsTransfomer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBNSURLPathUserDefaultsTransfomer.m; sourceTree = "<group>"; };
770B37EC0679A11B001EADE2 /* GitTest_DataModel.xcdatamodel */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = wrapper.xcdatamodel; path = GitTest_DataModel.xcdatamodel; sourceTree = "<group>"; };
77C82804067257F0000B614F /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
77C8280B06725ACE000B614F /* ApplicationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplicationController.h; sourceTree = "<group>"; };
@@ -362,6 +375,7 @@
isa = PBXGroup;
children = (
F50A41130EBB872D00208746 /* Widgets */,
47DBDB920E94F47200671A1E /* Preference Icons */,
D26DC6440E782C9000C777B2 /* gitx.icns */,
8D1107310486CEB800E47090 /* Info.plist */,
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
@@ -370,6 +384,7 @@
F5E424100EA3E4D60046E362 /* PBDiffWindow.xib */,
F52BCE020E84208300AA3741 /* PBGitHistoryView.xib */,
F59116E50E843BB50072CCB1 /* PBGitCommitView.xib */,
47DBDB680E94EF6500671A1E /* Preferences.xib */,
);
name = Resources;
sourceTree = "<group>";
@@ -384,6 +399,14 @@
name = Frameworks;
sourceTree = "<group>";
};
47DBDB920E94F47200671A1E /* Preference Icons */ = {
isa = PBXGroup;
children = (
47DBDBB00E94F6CA00671A1E /* Updates.png */,
);
name = "Preference Icons";
sourceTree = "<group>";
};
7756732906782D8800D1FEB8 /* Models */ = {
isa = PBXGroup;
children = (
@@ -446,6 +469,10 @@
F5EF8C8D0E9D4A5D0050906B /* PBWebController.m */,
F5FE6C010EB13BC900F30D12 /* PBServicesController.h */,
F5FE6C020EB13BC900F30D12 /* PBServicesController.m */,
47DBDB560E94EDE700671A1E /* DBPrefsWindowController.h */,
47DBDB570E94EDE700671A1E /* DBPrefsWindowController.m */,
47DBDB650E94EE8B00671A1E /* PBPrefsWindowController.h */,
47DBDB660E94EE8B00671A1E /* PBPrefsWindowController.m */,
);
name = Controllers;
sourceTree = "<group>";
@@ -453,6 +480,10 @@
F57CC43E0E05E472000472E2 /* Aux */ = {
isa = PBXGroup;
children = (
47DBDBC80E95016F00671A1E /* PBNSURLPathUserDefaultsTransfomer.h */,
47DBDBC90E95016F00671A1E /* PBNSURLPathUserDefaultsTransfomer.m */,
F5AD56770E79B78100EDAAFE /* PBCommitList.h */,
F5AD56780E79B78100EDAAFE /* PBCommitList.m */,
F56524B90E02D22D00F03B52 /* NSFileHandleExt.m */,
F56524BA0E02D22D00F03B52 /* NSFileHandleExt.h */,
F57CC38F0E05DDF2000472E2 /* PBEasyPipe.h */,
@@ -673,6 +704,8 @@
F56ADDDA0ED19F9E002AC78F /* AddLabelTemplate.png in Resources */,
3BC07F4C0ED5A5C5009A7768 /* HistoryViewTemplate.png in Resources */,
3BC07F4D0ED5A5C5009A7768 /* CommitViewTemplate.png in Resources */,
47DBDB6A0E94EF6500671A1E /* Preferences.xib in Resources */,
47DBDBB10E94F6CA00671A1E /* Updates.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -766,6 +799,9 @@
F574A2850EAE2EAC003F2CB1 /* PBRefController.m in Sources */,
F5FC43FE0EBD08EE00191D80 /* PBRefMenuItem.m in Sources */,
F523CEB60ED3399200DDD714 /* PBGitIndexController.m in Sources */,
47DBDB580E94EDE700671A1E /* DBPrefsWindowController.m in Sources */,
47DBDB670E94EE8B00671A1E /* PBPrefsWindowController.m in Sources */,
47DBDBCA0E95016F00671A1E /* PBNSURLPathUserDefaultsTransfomer.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -821,6 +857,14 @@
name = InfoPlist.strings;
sourceTree = "<group>";
};
47DBDB680E94EF6500671A1E /* Preferences.xib */ = {
isa = PBXVariantGroup;
children = (
47DBDB690E94EF6500671A1E /* English */,
);
name = Preferences.xib;
sourceTree = "<group>";
};
911111E00E58BD5A00BF76B4 /* RepositoryWindow.xib */ = {
isa = PBXVariantGroup;
children = (
Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

+6
View File
@@ -49,6 +49,12 @@ static NSString* gitPath = nil;
+ (void) initialize
{
// Check what we might have in user defaults
// NOTE: Currently this should NOT have a registered default, or the searching bits below won't work
gitPath = [[NSUserDefaults standardUserDefaults] stringForKey:@"gitExecutable"];
if (gitPath.length > 0)
return;
// Try to find the path of the Git binary
char* path = getenv("GIT_PATH");
if (path && [self acceptBinary:[NSString stringWithCString:path]])
+16
View File
@@ -0,0 +1,16 @@
//
// PBNSURLPathUserDefaultsTransfomer.h
// GitX
//
// Created by Christian Jacobsen on 28/09/2008.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface PBNSURLPathUserDefaultsTransfomer : NSValueTransformer {
}
@end
+46
View File
@@ -0,0 +1,46 @@
//
// PBNSURLPathUserDefaultsTransfomer.m
// GitX
//
// Created by Christian Jacobsen on 28/09/2008.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "PBNSURLPathUserDefaultsTransfomer.h"
/*
This ValueTransformer is used to store NSURLs in the user defaults system
as strings, without a host part. It is assumed that the path is an absolute
path in the local filesystem.
*/
@implementation PBNSURLPathUserDefaultsTransfomer
+ (Class)transformedValueClass {
return [NSURL class];
}
+ (BOOL)allowsReverseTransformation {
return YES;
}
- (id)transformedValue:(id)value {
if(value == nil)
{
return nil;
}
return [NSURL URLWithString:value
relativeToURL:[NSURL URLWithString:@"file://localhost/"]];
}
- (id)reverseTransformedValue:(id)value {
if(value == nil)
{
return nil;
}
return [value path];
}
@end
+29
View File
@@ -0,0 +1,29 @@
//
// PBPrefsWindowController.h
// GitX
//
// Created by Christian Jacobsen on 02/10/2008.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "DBPrefsWindowController.h"
@interface PBPrefsWindowController : DBPrefsWindowController {
/* Outlets for Preference Views */
IBOutlet NSView *generalPrefsView;
IBOutlet NSView *updatesPrefsView;
/* Variables for the Updates View */
IBOutlet NSPathControl *gitPathController;
IBOutlet NSImageView *badGitPathIcon;
IBOutlet NSView *gitPathOpenAccessory;
NSOpenPanel *gitPathOpenPanel;
}
- (IBAction) checkGitValidity: sender;
- (void)pathCell:(NSPathCell *)pathCell willDisplayOpenPanel:(NSOpenPanel *)openPanel;
- (IBAction) showHideAllFiles: sender;
@end
+55
View File
@@ -0,0 +1,55 @@
//
// PBPrefsWindowController.m
// GitX
//
// Created by Christian Jacobsen on 02/10/2008.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "PBPrefsWindowController.h"
#import "PBGitRepository.h"
@implementation PBPrefsWindowController
# pragma mark DBPrefsWindowController overrides
- (void)setupToolbar
{
// GENERAL
[self addView:generalPrefsView label:@"General" image:[NSImage imageNamed:@"gitx"]];
// UPDATES
[self addView:updatesPrefsView label:@"Updates"];
}
#pragma mark -
#pragma mark Delegate methods
- (IBAction) checkGitValidity: sender
{
// FIXME: This does not work reliably, probably due to: http://www.cocoabuilder.com/archive/message/cocoa/2008/9/10/217850
//[badGitPathIcon setHidden:[PBGitRepository validateGit:[[NSValueTransformer valueTransformerForName:@"PBNSURLPathUserDefaultsTransfomer"] reverseTransformedValue:[gitPathController URL]]]];
}
- (void)pathCell:(NSPathCell *)pathCell willDisplayOpenPanel:(NSOpenPanel *)openPanel
{
[openPanel setCanChooseDirectories:NO];
[openPanel setCanChooseFiles:YES];
[openPanel setAllowsMultipleSelection:NO];
[openPanel setTreatsFilePackagesAsDirectories:YES];
[openPanel setAccessoryView:gitPathOpenAccessory];
//[[openPanel _navView] setShowsHiddenFiles:YES];
gitPathOpenPanel = openPanel;
}
#pragma mark -
#pragma mark Git Path open panel actions
- (IBAction) showHideAllFiles: sender
{
/* FIXME: This uses undocumented OpenPanel features to show hidden files! */
NSNumber *showHidden = [NSNumber numberWithBool:[sender state] == NSOnState];
[[gitPathOpenPanel valueForKey:@"_navView"] setValue:showHidden forKey:@"showsHiddenFiles"];
}
@end