mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-28 09:22:03 +00:00
Fixed support for 10.6
This commit is contained in:
1 parent
38eb3e489e
commit
eb8a566ae8
11 files changed
+230
-179
No files matched your search
@@ -33,7 +33,7 @@
|
||||
IBOutlet NSTextView *helpTextView;
|
||||
IBOutlet NSTextField *labelVersion;
|
||||
|
||||
TNXCodeCapp *_xcc;
|
||||
TNXCodeCapp *xcc;
|
||||
NSImage *_iconActive;
|
||||
NSImage *_iconInactive;
|
||||
NSImage *_iconWorking;
|
||||
@@ -41,6 +41,11 @@
|
||||
PRHEmptyGrowlDelegate *growlDelegateRef;
|
||||
}
|
||||
|
||||
@property BOOL supportsFileModeListening;
|
||||
@property (assign) TNXCodeCapp *xcc;
|
||||
|
||||
+ (AppController *)sharedAppController;
|
||||
|
||||
- (BOOL)validateMenuItem:(NSMenuItem*)menuItem;
|
||||
- (void)registerDefaults;
|
||||
- (void)updateErrorTable;
|
||||
|
||||
@@ -17,13 +17,25 @@
|
||||
*/
|
||||
|
||||
|
||||
#import <AppKit/NSApplication.h>
|
||||
|
||||
#import "AppController.h"
|
||||
#include "defines.h"
|
||||
#include "macros.h"
|
||||
|
||||
|
||||
AppController *SharedAppControllerInstance = nil;
|
||||
|
||||
|
||||
@implementation AppController
|
||||
|
||||
@synthesize supportsFileModeListening;
|
||||
@synthesize xcc;
|
||||
|
||||
+ (AppController *)sharedAppController
|
||||
{
|
||||
return SharedAppControllerInstance;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Initialization
|
||||
|
||||
@@ -32,12 +44,8 @@
|
||||
*/
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
#if ACTIVATE_DATE_BASED_MODE
|
||||
DLog(@"using 10.6 mode listening (dirty)");
|
||||
#else
|
||||
DLog(@"using 10.7+ mode listening (clean)");
|
||||
#endif
|
||||
|
||||
SharedAppControllerInstance = self;
|
||||
|
||||
if (!growlDelegateRef)
|
||||
growlDelegateRef = [[[PRHEmptyGrowlDelegate alloc] init] autorelease];
|
||||
|
||||
@@ -68,17 +76,17 @@
|
||||
[self openHelp:self];
|
||||
}
|
||||
|
||||
_xcc = [[TNXCodeCapp alloc] init];
|
||||
[_xcc setDelegate:self];
|
||||
xcc = [[TNXCodeCapp alloc] init];
|
||||
[xcc setDelegate:self];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(XCodeCappConversionDidStart:) name:XCCConversionStartNotification object:_xcc];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(XCodeCappConversionDidStop:) name:XCCConversionStopNotification object:_xcc];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(XCodeCappPopulateProject:) name:XCCDidPopulateProjectNotification object:_xcc];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(XCodeCappListeningDidStart:) name:XCCListeningStartNotification object:_xcc];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(XCodeCappConversionDidStart:) name:XCCConversionStartNotification object:xcc];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(XCodeCappConversionDidStop:) name:XCCConversionStopNotification object:xcc];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(XCodeCappPopulateProject:) name:XCCDidPopulateProjectNotification object:xcc];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(XCodeCappListeningDidStart:) name:XCCListeningStartNotification object:xcc];
|
||||
|
||||
[helpTextView setTextContainerInset:NSSizeFromCGSize(CGSizeMake(10.0, 10.0))];
|
||||
|
||||
[_xcc start];
|
||||
[xcc start];
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +115,7 @@
|
||||
*/
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)app
|
||||
{
|
||||
[_xcc clear];
|
||||
[xcc clear];
|
||||
|
||||
return NSTerminateNow;
|
||||
}
|
||||
@@ -146,10 +154,10 @@
|
||||
- (void)XCodeCappListeningDidStart:(NSNotification *)aNotification
|
||||
{
|
||||
[_statusItem setImage:_iconActive];
|
||||
[menuItemStartStop setTitle:[NSString stringWithFormat:@"Stop Listening to “%@”", [_xcc currentProjectName]]];
|
||||
[menuItemStartStop setTitle:[NSString stringWithFormat:@"Stop Listening to “%@”", [xcc currentProjectName]]];
|
||||
[menuItemStartStop setAction:@selector(stopListener:)];
|
||||
|
||||
[self growlWithTitle:@"Listening to project" message:[[_xcc currentProjectURL] path]];
|
||||
[self growlWithTitle:@"Listening to project" message:[[xcc currentProjectURL] path]];
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +203,7 @@
|
||||
if ([openPanel runModal] != NSFileHandlingPanelOKButton)
|
||||
return;
|
||||
|
||||
[_xcc listenProjectAtPath:[NSString stringWithFormat:@"%@/", [[[openPanel URLs] objectAtIndex:0] path]]];
|
||||
[xcc listenProjectAtPath:[NSString stringWithFormat:@"%@/", [[[openPanel URLs] objectAtIndex:0] path]]];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -204,7 +212,7 @@
|
||||
*/
|
||||
- (IBAction)stopListener:(id)aSender
|
||||
{
|
||||
[_xcc clear];
|
||||
[xcc clear];
|
||||
|
||||
[_statusItem setImage:_iconInactive];
|
||||
[menuItemStartStop setTitle:@"Listen to Project…"];
|
||||
@@ -219,11 +227,11 @@
|
||||
*/
|
||||
- (IBAction)openXCode:(id)aSender
|
||||
{
|
||||
if (![_xcc currentProjectURL])
|
||||
if (![xcc currentProjectURL])
|
||||
return;
|
||||
|
||||
DLog(@"Opening Xcode project at URL: '%@'", [[_xcc XCodeSupportProject] path]);
|
||||
system([[NSString stringWithFormat:@"open \"%@\"", [[_xcc XCodeSupportProject] path]] UTF8String]);
|
||||
DLog(@"Opening Xcode project at URL: '%@'", [[xcc XCodeSupportProject] path]);
|
||||
system([[NSString stringWithFormat:@"open \"%@\"", [[xcc XCodeSupportProject] path]] UTF8String]);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -252,7 +260,7 @@
|
||||
*/
|
||||
- (IBAction)clearErrors:(id)sender
|
||||
{
|
||||
[[_xcc errorList] removeAllObjects];
|
||||
[[xcc errorList] removeAllObjects];
|
||||
[errorsTable reloadData];
|
||||
}
|
||||
|
||||
@@ -294,25 +302,25 @@
|
||||
- (BOOL)validateMenuItem:(NSMenuItem *)aMenuItem
|
||||
{
|
||||
if (aMenuItem == menuItemOpenXCode)
|
||||
return !![_xcc currentProjectURL];
|
||||
return !![xcc currentProjectURL];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
|
||||
{
|
||||
return [[_xcc errorList] count];
|
||||
return [[xcc errorList] count];
|
||||
}
|
||||
|
||||
- (id)tableView:(NSTableView*)aTableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
|
||||
{
|
||||
return [[_xcc errorList] objectAtIndex:row];
|
||||
return [[xcc errorList] objectAtIndex:row];
|
||||
}
|
||||
|
||||
- (void)tableViewColumnDidResize:(NSNotification *)tableView
|
||||
{
|
||||
[errorsTable noteHeightOfRowsWithIndexesChanged:
|
||||
[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [[_xcc errorList] count])]];
|
||||
[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [[xcc errorList] count])]];
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(int)aRow
|
||||
@@ -322,7 +330,7 @@
|
||||
float width = [tabCol width];
|
||||
NSRect r = NSMakeRect(0,0,width,1000.0);
|
||||
NSCell *cell = [tabCol dataCellForRow:aRow];
|
||||
NSString *content = [[_xcc errorList] objectAtIndex:aRow];
|
||||
NSString *content = [[xcc errorList] objectAtIndex:aRow];
|
||||
[cell setObjectValue:content];
|
||||
float height = [cell cellSizeForBounds:r].height;
|
||||
|
||||
|
||||
+105
-26
@@ -2,13 +2,13 @@
|
||||
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">1050</int>
|
||||
<string key="IBDocument.SystemVersion">11C74</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">1938</string>
|
||||
<string key="IBDocument.AppKitVersion">1138.23</string>
|
||||
<string key="IBDocument.HIToolboxVersion">567.00</string>
|
||||
<string key="IBDocument.SystemVersion">10K549</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">1923</string>
|
||||
<string key="IBDocument.AppKitVersion">1038.36</string>
|
||||
<string key="IBDocument.HIToolboxVersion">461.00</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="NS.object.0">1938</string>
|
||||
<string key="NS.object.0">1923</string>
|
||||
</object>
|
||||
<array key="IBDocument.IntegratedClassDependencies">
|
||||
<string>NSScroller</string>
|
||||
@@ -54,7 +54,6 @@
|
||||
<string key="NSWindowTitle">About</string>
|
||||
<string key="NSWindowClass">NSPanel</string>
|
||||
<nil key="NSViewClass"/>
|
||||
<nil key="NSUserInterfaceItemIdentifier"/>
|
||||
<object class="NSView" key="NSWindowView" id="524832152">
|
||||
<nil key="NSNextResponder"/>
|
||||
<int key="NSvFlags">256</int>
|
||||
@@ -113,9 +112,8 @@ bgphcGFyYWppdGFAYXBhcmFqaXRhLmNvbQ</string>
|
||||
<string key="NSFrameSize">{375, 153}</string>
|
||||
<reference key="NSNextKeyView" ref="135374801"/>
|
||||
</object>
|
||||
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
|
||||
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
|
||||
<bool key="NSWindowIsRestorable">YES</bool>
|
||||
<string key="NSScreenRect">{{0, 0}, {1600, 1178}}</string>
|
||||
<string key="NSMaxSize">{1e+13, 1e+13}</string>
|
||||
</object>
|
||||
<object class="NSMenu" id="293792969">
|
||||
<string key="NSTitle"/>
|
||||
@@ -204,7 +202,6 @@ bgphcGFyYWppdGFAYXBhcmFqaXRhLmNvbQ</string>
|
||||
<string key="NSWindowTitle">Errors and Warnings</string>
|
||||
<string key="NSWindowClass">NSPanel</string>
|
||||
<nil key="NSViewClass"/>
|
||||
<nil key="NSUserInterfaceItemIdentifier"/>
|
||||
<object class="NSView" key="NSWindowView" id="166068453">
|
||||
<nil key="NSNextResponder"/>
|
||||
<int key="NSvFlags">256</int>
|
||||
@@ -299,7 +296,6 @@ bgphcGFyYWppdGFAYXBhcmFqaXRhLmNvbQ</string>
|
||||
<int key="NSDraggingSourceMaskForNonLocal">0</int>
|
||||
<bool key="NSAllowsTypeSelect">YES</bool>
|
||||
<int key="NSTableViewDraggingDestinationStyle">0</int>
|
||||
<int key="NSTableViewGroupRowStyle">1</int>
|
||||
</object>
|
||||
</array>
|
||||
<string key="NSFrame">{{1, 1}, {512, 249}}</string>
|
||||
@@ -334,7 +330,7 @@ bgphcGFyYWppdGFAYXBhcmFqaXRhLmNvbQ</string>
|
||||
<string key="NSFrame">{{-1, 35}, {514, 251}}</string>
|
||||
<reference key="NSSuperview" ref="166068453"/>
|
||||
<reference key="NSNextKeyView" ref="493529786"/>
|
||||
<int key="NSsFlags">133682</int>
|
||||
<int key="NSsFlags">562</int>
|
||||
<reference key="NSVScroller" ref="185808728"/>
|
||||
<reference key="NSHScroller" ref="169310253"/>
|
||||
<reference key="NSContentView" ref="493529786"/>
|
||||
@@ -389,9 +385,8 @@ bgphcGFyYWppdGFAYXBhcmFqaXRhLmNvbQ</string>
|
||||
<string key="NSFrameSize">{512, 285}</string>
|
||||
<reference key="NSNextKeyView" ref="351336909"/>
|
||||
</object>
|
||||
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
|
||||
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
|
||||
<bool key="NSWindowIsRestorable">YES</bool>
|
||||
<string key="NSScreenRect">{{0, 0}, {1600, 1178}}</string>
|
||||
<string key="NSMaxSize">{1e+13, 1e+13}</string>
|
||||
</object>
|
||||
<object class="NSWindowTemplate" id="180699084">
|
||||
<int key="NSWindowStyleMask">15</int>
|
||||
@@ -401,7 +396,6 @@ bgphcGFyYWppdGFAYXBhcmFqaXRhLmNvbQ</string>
|
||||
<string key="NSWindowTitle">Help</string>
|
||||
<string key="NSWindowClass">NSWindow</string>
|
||||
<nil key="NSViewClass"/>
|
||||
<nil key="NSUserInterfaceItemIdentifier"/>
|
||||
<object class="NSView" key="NSWindowView" id="516282358">
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">256</int>
|
||||
@@ -417,7 +411,7 @@ bgphcGFyYWppdGFAYXBhcmFqaXRhLmNvbQ</string>
|
||||
<object class="NSTextView" id="690414145">
|
||||
<reference key="NSNextResponder" ref="599960028"/>
|
||||
<int key="NSvFlags">2322</int>
|
||||
<string key="NSFrameSize">{716, 14}</string>
|
||||
<string key="NSFrameSize">{701, 14}</string>
|
||||
<reference key="NSSuperview" ref="599960028"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="56491000"/>
|
||||
@@ -436,7 +430,7 @@ bgphcGFyYWppdGFAYXBhcmFqaXRhLmNvbQ</string>
|
||||
<nil key="NSDelegate"/>
|
||||
</object>
|
||||
<reference key="NSTextView" ref="690414145"/>
|
||||
<double key="NSWidth">716</double>
|
||||
<double key="NSWidth">701</double>
|
||||
<int key="NSTCFlags">1</int>
|
||||
</object>
|
||||
<object class="NSTextViewSharedData" key="NSSharedData">
|
||||
@@ -471,16 +465,14 @@ bgphcGFyYWppdGFAYXBhcmFqaXRhLmNvbQ</string>
|
||||
<integer value="1" key="NSUnderline"/>
|
||||
</dictionary>
|
||||
<nil key="NSDefaultParagraphStyle"/>
|
||||
<nil key="NSTextFinder"/>
|
||||
<int key="NSPreferredTextFinderStyle">1</int>
|
||||
</object>
|
||||
<int key="NSTVFlags">6</int>
|
||||
<string key="NSMaxSize">{716, 10000000}</string>
|
||||
<string key="NSMaxSize">{716, 1e+07}</string>
|
||||
<string key="NSMinize">{238, 0}</string>
|
||||
<nil key="NSDelegate"/>
|
||||
</object>
|
||||
</array>
|
||||
<string key="NSFrame">{{1, 1}, {716, 571}}</string>
|
||||
<string key="NSFrame">{{1, 1}, {701, 571}}</string>
|
||||
<reference key="NSSuperview" ref="1007710927"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="690414145"/>
|
||||
@@ -542,7 +534,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
|
||||
<reference key="NSSuperview" ref="516282358"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="568058546"/>
|
||||
<int key="NSsFlags">133138</int>
|
||||
<int key="NSsFlags">18</int>
|
||||
<reference key="NSVScroller" ref="56491000"/>
|
||||
<reference key="NSHScroller" ref="568058546"/>
|
||||
<reference key="NSContentView" ref="599960028"/>
|
||||
@@ -553,9 +545,8 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="1007710927"/>
|
||||
</object>
|
||||
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
|
||||
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
|
||||
<bool key="NSWindowIsRestorable">YES</bool>
|
||||
<string key="NSScreenRect">{{0, 0}, {1600, 1178}}</string>
|
||||
<string key="NSMaxSize">{1e+13, 1e+13}</string>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
@@ -1041,6 +1032,94 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">AppController</string>
|
||||
<string key="superclassName">NSObject</string>
|
||||
<dictionary class="NSMutableDictionary" key="actions">
|
||||
<string key="chooseFolder:">id</string>
|
||||
<string key="clearErrors:">id</string>
|
||||
<string key="openAbout:">id</string>
|
||||
<string key="openErrors:">id</string>
|
||||
<string key="openHelp:">id</string>
|
||||
<string key="openXCode:">id</string>
|
||||
<string key="stopListener:">id</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="actionInfosByName">
|
||||
<object class="IBActionInfo" key="chooseFolder:">
|
||||
<string key="name">chooseFolder:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo" key="clearErrors:">
|
||||
<string key="name">clearErrors:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo" key="openAbout:">
|
||||
<string key="name">openAbout:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo" key="openErrors:">
|
||||
<string key="name">openErrors:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo" key="openHelp:">
|
||||
<string key="name">openHelp:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo" key="openXCode:">
|
||||
<string key="name">openXCode:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo" key="stopListener:">
|
||||
<string key="name">stopListener:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="outlets">
|
||||
<string key="aboutWindow">NSPanel</string>
|
||||
<string key="errorsPanel">NSPanel</string>
|
||||
<string key="errorsTable">NSTableView</string>
|
||||
<string key="helpTextView">NSTextView</string>
|
||||
<string key="helpWindow">NSWindow</string>
|
||||
<string key="labelVersion">NSTextField</string>
|
||||
<string key="menuItemOpenXCode">NSMenuItem</string>
|
||||
<string key="menuItemStartStop">NSMenuItem</string>
|
||||
<string key="statusMenu">NSMenu</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
|
||||
<object class="IBToOneOutletInfo" key="aboutWindow">
|
||||
<string key="name">aboutWindow</string>
|
||||
<string key="candidateClassName">NSPanel</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="errorsPanel">
|
||||
<string key="name">errorsPanel</string>
|
||||
<string key="candidateClassName">NSPanel</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="errorsTable">
|
||||
<string key="name">errorsTable</string>
|
||||
<string key="candidateClassName">NSTableView</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="helpTextView">
|
||||
<string key="name">helpTextView</string>
|
||||
<string key="candidateClassName">NSTextView</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="helpWindow">
|
||||
<string key="name">helpWindow</string>
|
||||
<string key="candidateClassName">NSWindow</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="labelVersion">
|
||||
<string key="name">labelVersion</string>
|
||||
<string key="candidateClassName">NSTextField</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="menuItemOpenXCode">
|
||||
<string key="name">menuItemOpenXCode</string>
|
||||
<string key="candidateClassName">NSMenuItem</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="menuItemStartStop">
|
||||
<string key="name">menuItemStartStop</string>
|
||||
<string key="candidateClassName">NSMenuItem</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="statusMenu">
|
||||
<string key="name">statusMenu</string>
|
||||
<string key="candidateClassName">NSMenu</string>
|
||||
</object>
|
||||
</dictionary>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/AppController.h</string>
|
||||
|
||||
Binary file not shown.
@@ -21,7 +21,6 @@
|
||||
|
||||
#import "TNXCodeCapp.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "defines.h"
|
||||
|
||||
void fsevents_callback(ConstFSEventStreamRef, void*, size_t, void*, const FSEventStreamEventFlags*, const FSEventStreamEventId*);
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#import "AppController.h"
|
||||
#import "FSEventCallback.h"
|
||||
|
||||
#if (ACTIVATE_DATE_BASED_MODE == 0)
|
||||
|
||||
/*!
|
||||
This is the FSEvent callback for 10.7
|
||||
@@ -29,75 +29,53 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
|
||||
void *eventPaths,
|
||||
const FSEventStreamEventFlags eventFlags[],
|
||||
const FSEventStreamEventId eventIds[])
|
||||
{
|
||||
{
|
||||
TNXCodeCapp *xcc = (TNXCodeCapp *)userData;
|
||||
BOOL useFileBasedListening = [xcc supportsFileBasedListening];
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < numEvents; i++)
|
||||
{
|
||||
NSString *path = [(NSArray *)eventPaths objectAtIndex:i];
|
||||
|
||||
// kFSEventStreamEventFlagItemIsFile = 0x00010000
|
||||
if (!(eventFlags[i] & 0x00010000)
|
||||
|| [xcc isPathMatchingIgnoredPaths:path]
|
||||
|| (![xcc isXIBFile:path] && ![xcc isObjJFile:path] && ![xcc isXCCIgnoreFile:path]))
|
||||
continue;
|
||||
|
||||
// kFSEventStreamEventFlagItemRemoved = 0x00000200
|
||||
if (eventFlags[i] & 0x00000200)
|
||||
[xcc handleFileRemoval:path];
|
||||
if (useFileBasedListening)
|
||||
{
|
||||
// kFSEventStreamEventFlagItemIsFile = 0x00010000
|
||||
if (!(eventFlags[i] & 0x00010000)
|
||||
|| [xcc isPathMatchingIgnoredPaths:path]
|
||||
|| (![xcc isXIBFile:path] && ![xcc isObjJFile:path] && ![xcc isXCCIgnoreFile:path]))
|
||||
continue;
|
||||
|
||||
// kFSEventStreamEventFlagItemRemoved = 0x00000200
|
||||
if (eventFlags[i] & 0x00000200)
|
||||
[xcc handleFileRemoval:path];
|
||||
else
|
||||
[xcc handleFileModification:path notify:YES];
|
||||
}
|
||||
else
|
||||
[xcc handleFileModification:path notify:YES];
|
||||
{
|
||||
NSArray *subpaths = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:NULL];
|
||||
|
||||
for (NSString *subpath in subpaths)
|
||||
{
|
||||
NSString *fullPath = [NSString stringWithFormat:@"%@%@", path, subpath];
|
||||
|
||||
if ([xcc isPathMatchingIgnoredPaths:fullPath]
|
||||
|| (![xcc isXIBFile:fullPath] && ![xcc isObjJFile:fullPath] && ![xcc isXCCIgnoreFile:fullPath]))
|
||||
continue;
|
||||
|
||||
NSDate *lastModifiedDate = [xcc lastModificationDateForPath:subpath];
|
||||
NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:fullPath error:nil];
|
||||
NSDate *fileModDate = [fileAttributes objectForKey:NSFileModificationDate];
|
||||
|
||||
if ([fileModDate compare:lastModifiedDate] == NSOrderedDescending)
|
||||
{
|
||||
[xcc updateLastModificationDate:fileModDate forPath:subpath];
|
||||
[xcc handleFileModification:fullPath notify:YES];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[xcc updateLastEventId:eventIds[i]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
/*!
|
||||
This is the FSEvent callback for 10.6
|
||||
*/
|
||||
void fsevents_callback(ConstFSEventStreamRef streamRef,
|
||||
void *userData,
|
||||
size_t numEvents,
|
||||
void *eventPaths,
|
||||
const FSEventStreamEventFlags eventFlags[],
|
||||
const FSEventStreamEventId eventIds[])
|
||||
{
|
||||
TNXCodeCapp *xcc = (TNXCodeCapp *)userData;
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < numEvents; i++)
|
||||
{
|
||||
NSString *path = [(NSArray *)eventPaths objectAtIndex:i];
|
||||
|
||||
// TEST on 10.7
|
||||
// BOOL isDir;
|
||||
// [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir];
|
||||
// if (!isDir)
|
||||
// continue;
|
||||
// END TEST
|
||||
|
||||
NSArray *subpaths = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:NULL];
|
||||
|
||||
for(NSString *currentPath in subpaths)
|
||||
{
|
||||
[xcc updateLastModificationDateForPath:currentPath];
|
||||
|
||||
currentPath = [NSString stringWithFormat:@"%@/%@", path, currentPath];
|
||||
|
||||
NSDate *lastModifiedDate = [xcc lastModificationDateForPath:currentPath];
|
||||
NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:currentPath error:nil];
|
||||
NSDate *fileModDate = [fileAttributes objectForKey:NSFileModificationDate];
|
||||
|
||||
if([fileModDate compare:lastModifiedDate] == NSOrderedDescending)
|
||||
[xcc handleFileModification:currentPath notify:YES];
|
||||
|
||||
[xcc updateLastEventId:eventIds[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -19,7 +19,6 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "PRHEmptyGrowlDelegate.h"
|
||||
#import "FSEventCallback.h"
|
||||
#import "defines.h"
|
||||
|
||||
extern NSString * const XCCDidPopulateProjectNotification;
|
||||
extern NSString * const XCCConversionStartNotification;
|
||||
@@ -47,10 +46,8 @@ extern NSString * const XCCListeningStartNotification;
|
||||
PRHEmptyGrowlDelegate *growlDelegateRef;
|
||||
NSObject *delegate;
|
||||
NSDate *appStartedTimestamp;
|
||||
|
||||
#if (ACTIVATE_DATE_BASED_MODE == 1)
|
||||
NSMutableDictionary *pathModificationDates;
|
||||
#endif
|
||||
BOOL supportsFileBasedListening;
|
||||
}
|
||||
|
||||
@property (retain) NSObject* delegate;
|
||||
@@ -58,6 +55,7 @@ extern NSString * const XCCListeningStartNotification;
|
||||
@property (retain) NSURL* XCodeSupportProject;
|
||||
@property (retain) NSURL* currentProjectURL;
|
||||
@property (retain) NSString* currentProjectName;
|
||||
@property BOOL supportsFileBasedListening;
|
||||
|
||||
- (BOOL)isObjJFile:(NSString*)path;
|
||||
- (void)computeIgnoredPaths;
|
||||
@@ -77,13 +75,10 @@ extern NSString * const XCCListeningStartNotification;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#if (ACTIVATE_DATE_BASED_MODE == 1)
|
||||
@interface TNXCodeCapp (SnowLeopard)
|
||||
|
||||
- (void)updateLastModificationDateForPath:(NSString *)path;
|
||||
- (void)updateLastModificationDate:(NSDate *)date forPath:(NSString *)path;
|
||||
- (NSDate*)lastModificationDateForPath:(NSString *)path;
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
||||
@@ -32,6 +32,7 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
|
||||
@synthesize XCodeSupportProject;
|
||||
@synthesize currentProjectURL;
|
||||
@synthesize currentProjectName;
|
||||
@synthesize supportsFileBasedListening;
|
||||
|
||||
/*!
|
||||
Initialize the AppController
|
||||
@@ -49,6 +50,18 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
|
||||
lastEventId = [[NSUserDefaults standardUserDefaults] objectForKey:@"lastEventId"];
|
||||
appStartedTimestamp = [NSDate date];
|
||||
|
||||
SInt32 versionMajor = 0;
|
||||
SInt32 versionMinor = 0;
|
||||
Gestalt(gestaltSystemVersionMajor, &versionMajor);
|
||||
Gestalt(gestaltSystemVersionMinor, &versionMinor);
|
||||
|
||||
supportsFileBasedListening = versionMajor >= 10 && versionMinor >= 7;
|
||||
|
||||
if (supportsFileBasedListening)
|
||||
DLog(@"using 10.7+ mode listening (clean)");
|
||||
else
|
||||
DLog(@"using 10.6 mode listening (dirty)");
|
||||
|
||||
if([fm fileExistsAtPath:[@"~/.bash_profile" stringByExpandingTildeInPath]])
|
||||
profilePath = [@"source ~/.bash_profile" stringByExpandingTildeInPath];
|
||||
else if([fm fileExistsAtPath:[@"~/.profile" stringByExpandingTildeInPath]])
|
||||
@@ -99,13 +112,25 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
|
||||
void *appPointer = (void *)self;
|
||||
FSEventStreamContext context = {0, appPointer, NULL, NULL, NULL};
|
||||
NSTimeInterval latency = 2.0;
|
||||
FSEventStreamCreateFlags flags = 0;
|
||||
|
||||
if (stream != NULL)
|
||||
free(stream);
|
||||
|
||||
if (supportsFileBasedListening)
|
||||
{
|
||||
DLog(@"Initializing the FSEventStream at file level (clean)");
|
||||
flags = kFSEventStreamCreateFlagUseCFTypes | kFSEventStreamCreateFlagNoDefer | 0x00000010;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Initializing the FSEventStream at folder level (dirty)");
|
||||
flags = kFSEventStreamCreateFlagUseCFTypes;
|
||||
}
|
||||
|
||||
free(stream);
|
||||
|
||||
DLog(@"Initializing the FSEventStream at file level (clean)");
|
||||
stream = FSEventStreamCreate(NULL, &fsevents_callback, &context, (CFArrayRef) pathsToWatch,
|
||||
[lastEventId unsignedLongLongValue], (CFAbsoluteTime) latency, kFSEventStreamCreateFlagUseCFTypes | kFSEventStreamCreateFlagNoDefer | 0x00000010 );
|
||||
|
||||
[lastEventId unsignedLongLongValue], (CFAbsoluteTime) latency, flags);
|
||||
|
||||
FSEventStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
|
||||
FSEventStreamStart(stream);
|
||||
}
|
||||
@@ -214,13 +239,13 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
|
||||
else if ([self isObjJFile:fullPath])
|
||||
{
|
||||
arguments = [NSArray arrayWithObjects: @"-c", [NSString stringWithFormat:@"(%@; objj '%@' '%@' '%@';) 2>&1", profilePath, parserPath, fullPath, shadowPath],@"",nil];
|
||||
successTitle = @"Objective-J source parsed";
|
||||
successTitle = @"Objective-J source processed";
|
||||
successMsg = splitPath;
|
||||
}
|
||||
else if ([self isXCCIgnoreFile:fullPath])
|
||||
{
|
||||
[self computeIgnoredPaths];
|
||||
successTitle = @".xcodecapp-ignore parsed";
|
||||
successTitle = @".xcodecapp-ignore processed";
|
||||
successMsg = @"Ignored files list updated";
|
||||
arguments = nil;
|
||||
}
|
||||
@@ -507,50 +532,36 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
|
||||
@end
|
||||
|
||||
|
||||
#if (ACTIVATE_DATE_BASED_MODE == 1)
|
||||
@implementation TNXCodeCapp (SnowLeopard)
|
||||
|
||||
- (void)initializeEventStreamWithPath:(NSString*)aPath
|
||||
{
|
||||
NSArray *pathsToWatch = [NSArray arrayWithObject:aPath];
|
||||
void *appPointer = (void *)self;
|
||||
FSEventStreamContext context = {0, appPointer, NULL, NULL, NULL};
|
||||
NSTimeInterval latency = 2.0;
|
||||
free(stream);
|
||||
NSLog(@"Initializing the FSEventStream at folder level (dirty)");
|
||||
stream = FSEventStreamCreate(NULL, &fsevents_callback, &context, (CFArrayRef) pathsToWatch,
|
||||
[lastEventId unsignedLongLongValue], (CFAbsoluteTime) latency, kFSEventStreamCreateFlagUseCFTypes);
|
||||
|
||||
FSEventStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
|
||||
FSEventStreamStart(stream);
|
||||
}
|
||||
|
||||
- (void)updateLastModificationDateForPath:(NSString *)path
|
||||
- (void)updateLastModificationDate:(NSDate *)date forPath:(NSString *)path
|
||||
{
|
||||
if (!pathModificationDates)
|
||||
{
|
||||
pathModificationDates = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"pathModificationDates"] mutableCopy];
|
||||
|
||||
if (!pathModificationDates)
|
||||
pathModificationDates = [NSMutableDictionary new];
|
||||
}
|
||||
|
||||
[pathModificationDates setObject:[NSDate date] forKey:path];
|
||||
[pathModificationDates setObject:[date retain] forKey:path];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:pathModificationDates forKey:@"pathModificationDates"];
|
||||
}
|
||||
|
||||
- (NSDate*)lastModificationDateForPath:(NSString *)path
|
||||
- (NSDate *)lastModificationDateForPath:(NSString *)path
|
||||
{
|
||||
if (!pathModificationDates)
|
||||
{
|
||||
pathModificationDates = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"pathModificationDates"] mutableCopy];
|
||||
|
||||
if (!pathModificationDates)
|
||||
pathModificationDates = [NSMutableDictionary new];
|
||||
}
|
||||
|
||||
if([pathModificationDates valueForKey:path] != nil)
|
||||
if ([pathModificationDates valueForKey:path] != nil)
|
||||
return [pathModificationDates valueForKey:path];
|
||||
else
|
||||
return appStartedTimestamp;
|
||||
}
|
||||
|
||||
@end
|
||||
#endif
|
||||
@@ -1,18 +0,0 @@
|
||||
//
|
||||
// defines.h
|
||||
// xcodecapp-cocoa
|
||||
//
|
||||
// Created by Antoine Mercadal on 04/11/11.
|
||||
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef xcodecapp_cocoa_defines_h
|
||||
#define xcodecapp_cocoa_defines_h
|
||||
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_6)
|
||||
#define ACTIVATE_DATE_BASED_MODE 0
|
||||
#else
|
||||
#define ACTIVATE_DATE_BASED_MODE 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -10,7 +10,7 @@
|
||||
#define xcodecapp_cocoa_macros_h
|
||||
|
||||
#if DEBUG
|
||||
# define DLog(fmt, ...) NSLog((fmt), ##__VA_ARGS__);
|
||||
# define DLog(fmt, ...) NSLog((fmt), ##__VA_ARGS__)
|
||||
#else
|
||||
# define DLog(...)
|
||||
#endif
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
02998CF91369C38A006C73DB /* Growl.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 02998CF61369C339006C73DB /* Growl.framework */; };
|
||||
651DAE1F13B0CAB900ECA3F0 /* PRHEmptyGrowlDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 651DAE1D13B0CAB900ECA3F0 /* PRHEmptyGrowlDelegate.m */; };
|
||||
E12AA96014637828006F55D6 /* macros.h in Sources */ = {isa = PBXBuildFile; fileRef = E12AA95F14637828006F55D6 /* macros.h */; };
|
||||
E19F99611463B99500569A7E /* defines.h in Sources */ = {isa = PBXBuildFile; fileRef = E19F99601463B99500569A7E /* defines.h */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
@@ -61,7 +60,6 @@
|
||||
027FE4BC1462F7EB00B1AB92 /* FSEventCallback.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FSEventCallback.m; sourceTree = "<group>"; };
|
||||
02998CEA1369BF7D006C73DB /* Growl Registration Ticket.growlRegDict */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "Growl Registration Ticket.growlRegDict"; sourceTree = "<group>"; };
|
||||
02998CF61369C339006C73DB /* Growl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Growl.framework; sourceTree = "<group>"; };
|
||||
02D00BD514635F9B0071080E /* defines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = defines.h; sourceTree = "<group>"; };
|
||||
089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
|
||||
13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
|
||||
@@ -74,9 +72,8 @@
|
||||
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
8E01A8DD0DE51A7C0008BB35 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = "<absolute>"; };
|
||||
8E01A91D0DE9EED20008BB35 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = "<group>"; };
|
||||
8E01A91E0DE9EED20008BB35 /* AppController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppController.m; sourceTree = "<group>"; };
|
||||
8E01A91E0DE9EED20008BB35 /* AppController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = AppController.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
|
||||
E12AA95F14637828006F55D6 /* macros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.objj.h; path = macros.h; sourceTree = "<group>"; };
|
||||
E19F99601463B99500569A7E /* defines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.objj.h; path = defines.h; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -104,7 +101,6 @@
|
||||
027FE49C1462D74C00B1AB92 /* TNXCodeCapp.m */,
|
||||
027FE4BB1462F7D600B1AB92 /* FSEventCallback.h */,
|
||||
027FE4BC1462F7EB00B1AB92 /* FSEventCallback.m */,
|
||||
02D00BD514635F9B0071080E /* defines.h */,
|
||||
);
|
||||
name = Classes;
|
||||
sourceTree = "<group>";
|
||||
@@ -151,7 +147,6 @@
|
||||
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E19F99601463B99500569A7E /* defines.h */,
|
||||
027D9989136969DD00D3DB13 /* xcodecapp-cocoa.pch */,
|
||||
29B97316FDCFA39411CA2CEA /* main.m */,
|
||||
E12AA95F14637828006F55D6 /* macros.h */,
|
||||
@@ -266,7 +261,6 @@
|
||||
027FE49D1462D74C00B1AB92 /* TNXCodeCapp.m in Sources */,
|
||||
027FE4BD1462F7EB00B1AB92 /* FSEventCallback.m in Sources */,
|
||||
E12AA96014637828006F55D6 /* macros.h in Sources */,
|
||||
E19F99611463B99500569A7E /* defines.h in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user