mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
6a8f495318
In 10.6 Apple removed the private QL API that existed in 10.5 and added a new public API. However they did not port the new API back to 10.5 so we have to do some work to get it working in both.
This patch has GitX choose the correct version at run time.
- The delegate code is based on Apple's QuickLookDownloader example project
- added three of the public API methods to CWQuickLook.h to avoid warnings about unknown method calls
- In ApplicationController try to load the public API first then load the private one if it fails
- Created PBQLTextView, a subclass of NSTextView to allow the space key event to toggle the preview panel
- PBGitHistoryView.xib:
- set the text view's class to PBQLTextView
- connected the history controller to the controller outlet
- bound the quick look button's enabled binding to File's Owner.selectedCommitDetailsIndex
- added "Quick Look" to the quick look button's tooltip
- The commit list table view toggles the panel if the tree view is active
- changed name of the toggle IBAction method which caused MainMenu.xib and PBGitHistoryView.xib to update
97 lines
2.7 KiB
Objective-C
97 lines
2.7 KiB
Objective-C
//
|
|
// PBQLOutlineView.m
|
|
// GitX
|
|
//
|
|
// Created by Pieter de Bie on 6/17/08.
|
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
|
//
|
|
|
|
#import "PBQLOutlineView.h"
|
|
|
|
|
|
@implementation PBQLOutlineView
|
|
|
|
- initWithCoder: (NSCoder *) coder
|
|
{
|
|
id a = [super initWithCoder:coder];
|
|
[a setDataSource: a];
|
|
[a registerForDraggedTypes: [NSArray arrayWithObject:NSFilesPromisePboardType]];
|
|
return a;
|
|
}
|
|
|
|
/* Needed to drag outside application */
|
|
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL) local
|
|
{
|
|
return NSDragOperationCopy;
|
|
}
|
|
|
|
- (void) keyDown: (NSEvent *) event
|
|
{
|
|
if ([[event characters] isEqualToString:@" "]) {
|
|
[controller toggleQLPreviewPanel:self];
|
|
return;
|
|
}
|
|
|
|
[super keyDown:event];
|
|
}
|
|
|
|
- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *) pb
|
|
{
|
|
NSMutableArray* fileNames = [NSMutableArray array];
|
|
for (id tree in items)
|
|
[fileNames addObject: [[[tree representedObject] path] pathExtension]];
|
|
|
|
[pb declareTypes:[NSArray arrayWithObject:NSFilesPromisePboardType] owner:self];
|
|
[pb setPropertyList:fileNames forType:NSFilesPromisePboardType];
|
|
|
|
return YES;
|
|
}
|
|
|
|
- (NSArray *)outlineView:(NSOutlineView *)outlineView namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination forDraggedItems:(NSArray *)items
|
|
{
|
|
NSMutableArray* fileNames = [NSMutableArray array];
|
|
for (id obj in items) {
|
|
PBGitTree* tree = [obj representedObject];
|
|
[fileNames addObject: [tree path]];
|
|
[tree saveToFolder:[dropDestination path]];
|
|
}
|
|
return fileNames;
|
|
}
|
|
|
|
- (NSMenu *)menuForEvent:(NSEvent *)theEvent
|
|
{
|
|
if ([theEvent type] == NSRightMouseDown)
|
|
{
|
|
// get the current selections for the outline view.
|
|
NSIndexSet *selectedRowIndexes = [self selectedRowIndexes];
|
|
|
|
// select the row that was clicked before showing the menu for the event
|
|
NSPoint mousePoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
|
int row = [self rowAtPoint:mousePoint];
|
|
|
|
// figure out if the row that was just clicked on is currently selected
|
|
if ([selectedRowIndexes containsIndex:row] == NO) {
|
|
NSIndexSet *index = [NSIndexSet indexSetWithIndex:row];
|
|
[self selectRowIndexes:index byExtendingSelection:NO];
|
|
}
|
|
}
|
|
|
|
return [controller contextMenuForTreeView];
|
|
}
|
|
|
|
/* Implemented to satisfy datasourcee protocol */
|
|
- (BOOL) outlineView: (NSOutlineView *)ov
|
|
isItemExpandable: (id)item { return NO; }
|
|
|
|
- (NSInteger) outlineView: (NSOutlineView *)ov
|
|
numberOfChildrenOfItem:(id)item { return 0; }
|
|
|
|
- (id) outlineView: (NSOutlineView *)ov
|
|
child:(NSInteger)index
|
|
ofItem:(id)item { return nil; }
|
|
|
|
- (id) outlineView: (NSOutlineView *)ov
|
|
objectValueForTableColumn:(NSTableColumn*)col
|
|
byItem:(id)item { return nil; }
|
|
@end
|