From 69d23e9e0880bad6fd2712e7fa4cd6a318eb6885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Berg?= Date: Mon, 5 Apr 2010 15:52:01 +0200 Subject: [PATCH] Move Remote segmented controls from Sidebar to Repository window's top gradient bar. Now, I know conceptually the Remotes segmented control was down there because it is related to the repository and the current branch, but I really grew tired having to travel all the way down the monitor real estate just to click a button. And you can't just fast travel down, you need be quite specific with the click. --- English.lproj/RepositoryWindow.xib | 25 ++-- PBGitHistoryController.h | 16 +++ PBGitHistoryController.m | 65 ++++++++++ PBGitSidebarController.h | 3 +- PBGitSidebarController.m | 6 +- PBGitSidebarView.xib | 192 ++++++++++------------------- 6 files changed, 163 insertions(+), 144 deletions(-) diff --git a/English.lproj/RepositoryWindow.xib b/English.lproj/RepositoryWindow.xib index a1aca53..969e6dc 100644 --- a/English.lproj/RepositoryWindow.xib +++ b/English.lproj/RepositoryWindow.xib @@ -12,7 +12,7 @@ YES - + YES @@ -816,6 +816,13 @@ YES + + NSObject + + IBProjectSource + BMScript.h + + PBGitWindowController NSWindowController @@ -1231,13 +1238,6 @@ ImageKit.framework/Headers/IKImageBrowserView.h - - NSObject - - IBFrameworkSource - ImageKit.framework/Headers/IKSaveOptions.h - - NSObject @@ -1280,13 +1280,6 @@ QuartzFilters.framework/Headers/QuartzFilterManager.h - - NSObject - - IBFrameworkSource - QuickLookUI.framework/Headers/QLPreviewPanel.h - - NSObject @@ -1500,7 +1493,7 @@ com.apple.InterfaceBuilder.CocoaPlugin.macosx - + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 diff --git a/PBGitHistoryController.h b/PBGitHistoryController.h index da846d3..c886a2c 100644 --- a/PBGitHistoryController.h +++ b/PBGitHistoryController.h @@ -17,6 +17,8 @@ @class PBGitGradientBarView; @class PBRefController; @class QLPreviewPanel; +@class PBCommitList; +@class PBSourceViewItem; @interface PBGitHistoryController : PBViewController { IBOutlet PBRefController *refController; @@ -40,12 +42,19 @@ IBOutlet NSButton *selectedBranchFilterItem; IBOutlet id webView; + + // moved from PBGitSidebarController + IBOutlet NSSegmentedControl * remoteControls; + int selectedCommitDetailsIndex; BOOL forceSelectionUpdate; PBGitTree *gitTree; PBGitCommit *webCommit; PBGitCommit *selectedCommit; + + PBSourceViewItem * sidebarRemotes; + NSOutlineView * sidebarSourceView; } @property (assign) int selectedCommitDetailsIndex; @@ -53,6 +62,8 @@ @property (retain) PBGitTree* gitTree; @property (readonly) NSArrayController *commitController; @property (readonly) PBRefController *refController; +@property (assign) NSOutlineView * sidebarSourceView; +@property (assign) PBSourceViewItem * sidebarRemotes; - (IBAction) setDetailedView:(id)sender; - (IBAction) setTreeView:(id)sender; @@ -64,6 +75,11 @@ - (IBAction) openSelectedFile:(id)sender; - (void) updateQuicklookForce: (BOOL) force; + +// Moved over Sidebar methods +- (IBAction) fetchPullPushAction:(id)sender; +- (void) updateRemoteControls:(PBGitRef *)forRef; + // Context menu methods - (NSMenu *)contextMenuForTreeView; - (NSArray *)menuItemsForPaths:(NSArray *)paths; diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index 1aeebcc..337ecd1 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -21,6 +21,9 @@ #import "PBDiffWindowController.h" #import "PBGitDefaults.h" #import "PBGitRevList.h" +#import "PBCommitList.h" +#import "PBSourceViewItem.h" +#import "PBRefController.h" #define QLPreviewPanel NSClassFromString(@"QLPreviewPanel") #define kHistorySelectedDetailIndexKey @"PBHistorySelectedDetailIndex" @@ -38,6 +41,7 @@ @implementation PBGitHistoryController @synthesize selectedCommitDetailsIndex, webCommit, gitTree, commitController, refController; +@synthesize sidebarSourceView, sidebarRemotes; #pragma mark NSToolbarItemValidation Methods @@ -623,6 +627,67 @@ } } +#pragma mark Remote controls + +// !!! Andre Berg 20100330: moved these over from the PBGitSidebarController +// since I grew tired of having to go all the way down with the mouse just +// to do some basic actions I need to frequently (YMMV) =) + +enum { + kAddRemoteSegment = 0, + kFetchSegment, + kPullSegment, + kPushSegment +}; + +- (void) updateRemoteControls:(PBGitRef *)forRef +{ + BOOL hasRemote = NO; + + PBGitRef *ref = forRef; + if ([ref isRemote] || ([ref isBranch] && [[repository remoteRefForBranch:ref error:NULL] remoteName])) + hasRemote = YES; + + [remoteControls setEnabled:hasRemote forSegment:kFetchSegment]; + [remoteControls setEnabled:hasRemote forSegment:kPullSegment]; + [remoteControls setEnabled:hasRemote forSegment:kPushSegment]; +} + +- (IBAction) fetchPullPushAction:(id)sender +{ + NSInteger selectedSegment = [sender selectedSegment]; + + if (selectedSegment == kAddRemoteSegment) { + [PBAddRemoteSheet beginAddRemoteSheetForRepository:repository]; + return; + } + NSOutlineView * sourceView = sidebarSourceView; + NSInteger index = [sourceView selectedRow]; + PBSourceViewItem *item = [sourceView itemAtRow:index]; + PBGitRef *ref = [[item revSpecifier] ref]; + + if (!ref && (item.parent == sidebarRemotes)) + ref = [PBGitRef refFromString:[kGitXRemoteRefPrefix stringByAppendingString:[item title]]]; + + if (![ref isRemote] && ![ref isBranch]) + return; + + PBGitRef *remoteRef = [repository remoteRefForBranch:ref error:NULL]; + if (!remoteRef) + return; + + if (selectedSegment == kFetchSegment) + [repository beginFetchFromRemoteForRef:ref]; + else if (selectedSegment == kPullSegment) + [repository beginPullFromRemote:remoteRef forRef:ref]; + else if (selectedSegment == kPushSegment) { + if ([ref isRemote]) + [refController showConfirmPushRefSheet:nil remote:remoteRef]; + else if ([ref isBranch]) + [refController showConfirmPushRefSheet:ref remote:remoteRef]; + } +} + #pragma mark - #pragma mark Quick Look Public API support diff --git a/PBGitSidebarController.h b/PBGitSidebarController.h index ba4dd2f..6bb5104 100644 --- a/PBGitSidebarController.h +++ b/PBGitSidebarController.h @@ -18,7 +18,6 @@ IBOutlet NSOutlineView *sourceView; IBOutlet NSView *sourceListControlsView; IBOutlet NSPopUpButton *actionButton; - IBOutlet NSSegmentedControl *remoteControls; NSMutableArray *items; @@ -40,4 +39,6 @@ @property(readonly) NSMutableArray *items; @property(readonly) NSView *sourceListControlsView; +@property(readonly) PBSourceViewItem * remotes; +@property(readonly) NSOutlineView * sourceView; @end diff --git a/PBGitSidebarController.m b/PBGitSidebarController.m index ad2e872..a36d63c 100644 --- a/PBGitSidebarController.m +++ b/PBGitSidebarController.m @@ -23,12 +23,12 @@ - (PBSourceViewItem *) itemForRev:(PBGitRevSpecifier *)rev; - (void) removeRevSpec:(PBGitRevSpecifier *)rev; - (void) updateActionMenu; -- (void) updateRemoteControls; + @end @implementation PBGitSidebarController @synthesize items; -@synthesize sourceListControlsView; +@synthesize sourceListControlsView, sourceView, remotes; - (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGitWindowController *)controller { @@ -193,7 +193,7 @@ } [self updateActionMenu]; - [self updateRemoteControls]; + [historyViewController updateRemoteControls:[[self selectedItem] ref]]; } #pragma mark NSOutlineView delegate methods diff --git a/PBGitSidebarView.xib b/PBGitSidebarView.xib index cdf65f9..453589f 100644 --- a/PBGitSidebarView.xib +++ b/PBGitSidebarView.xib @@ -3,16 +3,15 @@ 1050 10C540 - 759 + 740 1038.25 458.00 com.apple.InterfaceBuilder.CocoaPlugin - 759 + 740 YES - @@ -82,7 +81,7 @@ 3 - MC4zMzMzMzI5OQA + MC4zMzMzMzI5ODU2AA 6 @@ -110,7 +109,7 @@ controlBackgroundColor 3 - MC42NjY2NjY2NjY3AA + MC42NjY2NjY2ODY1AA @@ -173,7 +172,7 @@ _doScroller: - 0.99698790000000004 + 0.99698787927627563 @@ -183,7 +182,7 @@ 1 _doScroller: - 0.57142859999999995 + 0.57142859697341919 {153, 354} @@ -201,74 +200,10 @@ NSView - + 268 YES - - - 268 - {{52, 2}, {141, 25}} - - YES - - 67239424 - 0 - - LucidaGrande - 13 - 16 - - - - YES - - 33 - - NSImage - AddRemote - - - Add remote - 0 - - - 33 - - NSImage - FetchTemplate - - - Fetch from default remote - 1 - 0 - - - 33 - - NSImage - PullTemplate - - Pull from default remote - 2 - 0 - - - 33 - - NSImage - PushTemplate - - Push to default remote - 3 - 0 - - - 1 - 2 - 2 - - 268 @@ -354,7 +289,6 @@ {200, 31} - NSView @@ -409,22 +343,6 @@ 46 - - - remoteControls - - - - 49 - - - - fetchPullPushAction: - - - - 50 - delegate @@ -521,7 +439,6 @@ YES - Source List Controls View @@ -570,20 +487,6 @@ - - 47 - - - YES - - - - - - 48 - - - @@ -606,9 +509,6 @@ 42.IBPluginDependency 43.IBPluginDependency 44.IBPluginDependency - 47.IBPluginDependency - 48.IBPluginDependency - 48.IBSegmentedControlInspectorSelectedSegmentMetadataKey 8.IBEditorWindowLastContentRect 8.IBPluginDependency 9.IBPluginDependency @@ -623,7 +523,7 @@ com.apple.InterfaceBuilder.CocoaPlugin {{482, 590}, {153, 354}} com.apple.InterfaceBuilder.CocoaPlugin - {{626, 507}, {200, 31}} + {{695, 521}, {200, 31}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -631,9 +531,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - {{105, 545}, {153, 354}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -660,6 +557,13 @@ YES + + NSObject + + IBProjectSource + BMScript.h + + NSOutlineView @@ -717,6 +621,10 @@ PBViewController NSViewController + + refresh: + id + IBProjectSource PBViewController.h @@ -1084,6 +992,55 @@ Foundation.framework/Headers/NSURLDownload.h + + NSObject + + IBFrameworkSource + ImageKit.framework/Headers/IKImageBrowserView.h + + + + NSObject + + IBFrameworkSource + ImageKit.framework/Headers/ImageKitDeprecated.h + + + + NSObject + + IBFrameworkSource + PDFKit.framework/Headers/PDFDocument.h + + + + NSObject + + IBFrameworkSource + PDFKit.framework/Headers/PDFView.h + + + + NSObject + + IBFrameworkSource + QuartzComposer.framework/Headers/QCCompositionParameterView.h + + + + NSObject + + IBFrameworkSource + QuartzComposer.framework/Headers/QCCompositionPickerView.h + + + + NSObject + + IBFrameworkSource + QuartzFilters.framework/Headers/QuartzFilterManager.h + + NSObject @@ -1220,14 +1177,6 @@ AppKit.framework/Headers/NSScroller.h - - NSSegmentedCell - NSActionCell - - IBFrameworkSource - AppKit.framework/Headers/NSSegmentedCell.h - - NSSegmentedControl NSControl @@ -1317,7 +1266,6 @@ 0 - IBCocoaFramework com.apple.InterfaceBuilder.CocoaPlugin.macosx @@ -1333,9 +1281,5 @@ YES GitX.xcodeproj 3 - - NSActionTemplate - {15, 15} -