mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-29 18:02:03 +00:00
UI overhaul, first attempt at 10.6 compatibility.
This commit is contained in:
1 parent
791a1eb130
commit
97f7eaf499
12 files changed
+583
-2522
No files matched your search
@@ -25,11 +25,10 @@
|
||||
{
|
||||
IBOutlet NSMenu *statusMenu;
|
||||
IBOutlet NSMenuItem *menuItemOpenXCode;
|
||||
IBOutlet NSMenuItem *menuItemStart;
|
||||
IBOutlet NSMenuItem *menuItemStop;
|
||||
IBOutlet NSMenuItem *menuItemProjectName;
|
||||
IBOutlet NSMenuItem *menuItemStartStop;
|
||||
IBOutlet NSPanel *errorsPanel;
|
||||
IBOutlet NSTableView *errorsTable;
|
||||
IBOutlet NSPanel *aboutWindow;
|
||||
IBOutlet NSWindow *helpWindow;
|
||||
IBOutlet NSTextView *helpTextView;
|
||||
IBOutlet NSTextField *labelVersion;
|
||||
@@ -46,12 +45,15 @@
|
||||
- (void)registerDefaults;
|
||||
- (void)updateErrorTable;
|
||||
- (void)growlWithTitle:(NSString *)aTitle message:(NSString *)aMessage;
|
||||
- (void)openCenteredWindow:(NSWindow *)aWindow;
|
||||
|
||||
- (IBAction)chooseFolder:(id)aSender;
|
||||
- (IBAction)openErrors:(id)sender;
|
||||
- (IBAction)clearErrors:(id)sender;
|
||||
- (IBAction)openXCode:(id)aSender;
|
||||
- (IBAction)stopListener:(id)aSender;
|
||||
- (IBAction)openHelp:(id)aSender;
|
||||
- (IBAction)openAbout:(id)aSender;
|
||||
|
||||
- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(int)aRow;
|
||||
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row;
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
|
||||
#import "AppController.h"
|
||||
#include "defines.h"
|
||||
#include "macros.h"
|
||||
|
||||
|
||||
@implementation AppController
|
||||
@@ -30,6 +32,12 @@
|
||||
*/
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
#if ACTIVATE_DATE_BASED_MODE
|
||||
DLog(@"using 10.6 mode listening (dirty)");
|
||||
#else
|
||||
DLog(@"using 10.7+ mode listening (clean)");
|
||||
#endif
|
||||
|
||||
if (!growlDelegateRef)
|
||||
growlDelegateRef = [[[PRHEmptyGrowlDelegate alloc] init] autorelease];
|
||||
|
||||
@@ -68,6 +76,8 @@
|
||||
[[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];
|
||||
}
|
||||
|
||||
@@ -126,9 +136,7 @@
|
||||
*/
|
||||
- (void)XCodeCappPopulateProject:(NSNotification *)aNotification
|
||||
{
|
||||
[self growlWithTitle:[[[[aNotification userInfo] objectForKey:@"URL"] path] lastPathComponent]
|
||||
message:@"Your project has been loaded successfully!"];
|
||||
|
||||
[self growlWithTitle:@"Project loaded" message:[[[aNotification userInfo] objectForKey:@"URL"] path]];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -138,7 +146,10 @@
|
||||
- (void)XCodeCappListeningDidStart:(NSNotification *)aNotification
|
||||
{
|
||||
[_statusItem setImage:_iconActive];
|
||||
[menuItemProjectName setTitle:[NSString stringWithFormat:@"Current project: %@", [_xcc currentProjectName]]];
|
||||
[menuItemStartStop setTitle:[NSString stringWithFormat:@"Stop Listening to “%@”", [_xcc currentProjectName]]];
|
||||
[menuItemStartStop setAction:@selector(stopListener:)];
|
||||
|
||||
[self growlWithTitle:@"Listening to project" message:[[_xcc currentProjectURL] path]];
|
||||
}
|
||||
|
||||
|
||||
@@ -172,11 +183,13 @@
|
||||
*/
|
||||
- (IBAction)chooseFolder:(id)aSender
|
||||
{
|
||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
||||
|
||||
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
|
||||
|
||||
[openPanel setCanChooseDirectories:YES];
|
||||
[openPanel setCanCreateDirectories:YES];
|
||||
[openPanel setPrompt:@"Choose Cappuccino project"];
|
||||
[openPanel setTitle:@"Choose Cappuccino Project"];
|
||||
[openPanel setCanChooseFiles:NO];
|
||||
|
||||
if ([openPanel runModal] != NSFileHandlingPanelOKButton)
|
||||
@@ -194,7 +207,8 @@
|
||||
[_xcc clear];
|
||||
|
||||
[_statusItem setImage:_iconInactive];
|
||||
[menuItemProjectName setTitle:@"No project selected"];
|
||||
[menuItemStartStop setTitle:@"Listen to Project…"];
|
||||
[menuItemStartStop setAction:@selector(chooseFolder:)];
|
||||
|
||||
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"LastOpenedPath"];
|
||||
}
|
||||
@@ -208,7 +222,7 @@
|
||||
if (![_xcc currentProjectURL])
|
||||
return;
|
||||
|
||||
NSLog(@"Open Xcode project at URL : '%@'", [[_xcc XCodeSupportProject] path]);
|
||||
DLog(@"Opening Xcode project at URL: '%@'", [[_xcc XCodeSupportProject] path]);
|
||||
system([[NSString stringWithFormat:@"open \"%@\"", [[_xcc XCodeSupportProject] path]] UTF8String]);
|
||||
}
|
||||
|
||||
@@ -219,9 +233,19 @@
|
||||
- (void)updateErrorTable
|
||||
{
|
||||
[errorsTable reloadData];
|
||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
||||
[errorsPanel orderFront:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
Open the errors window
|
||||
@param aSender the sender of the action
|
||||
*/
|
||||
- (IBAction)openErrors:(id)aSender
|
||||
{
|
||||
[self openCenteredWindow:errorsPanel];
|
||||
}
|
||||
|
||||
/*!
|
||||
Clear all errors in errors table
|
||||
@param aSender the sender of the action
|
||||
@@ -240,8 +264,27 @@
|
||||
{
|
||||
[helpTextView readRTFDFromFile:[[NSBundle mainBundle] pathForResource:@"help" ofType:@"rtfd"]];
|
||||
|
||||
[helpWindow center];
|
||||
[helpWindow makeKeyAndOrderFront:aSender];
|
||||
[self openCenteredWindow:helpWindow];
|
||||
}
|
||||
|
||||
/*!
|
||||
Open the about window
|
||||
@param aSender the sender of the action
|
||||
*/
|
||||
- (IBAction)openAbout:(id)aSender
|
||||
{
|
||||
[self openCenteredWindow:aboutWindow];
|
||||
}
|
||||
|
||||
/*!
|
||||
Open a centered window.
|
||||
*/
|
||||
- (void)openCenteredWindow:(NSWindow *)aWindow
|
||||
{
|
||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
||||
|
||||
[aWindow center];
|
||||
[aWindow makeKeyAndOrderFront:nil];
|
||||
}
|
||||
|
||||
|
||||
@@ -250,9 +293,7 @@
|
||||
|
||||
- (BOOL)validateMenuItem:(NSMenuItem *)aMenuItem
|
||||
{
|
||||
if (aMenuItem == menuItemStart)
|
||||
return ![_xcc currentProjectURL];
|
||||
if ((aMenuItem == menuItemStop) || (aMenuItem == menuItemOpenXCode))
|
||||
if (aMenuItem == menuItemOpenXCode)
|
||||
return !![_xcc currentProjectURL];
|
||||
|
||||
return YES;
|
||||
|
||||
+241
-2443
File diff suppressed because it is too large.
Load diff
Binary file not shown.
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is a part of program xcodecapp-cocoa
|
||||
* Copyright (C) 2011 Antoine Mercadal (primalmotion@archipelproject.org)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#import "FSEventCallback.h"
|
||||
|
||||
/*!
|
||||
This is the FSEvent callback
|
||||
*/
|
||||
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];
|
||||
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
|
||||
// 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
|
||||
{
|
||||
NSLog(@"this file has been modified or created");
|
||||
[xcc handleFileModification:path notify:YES];
|
||||
}
|
||||
#else
|
||||
NSArray *subpaths = [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:NULL];
|
||||
for(NSString *currentPath in subpaths)
|
||||
[xcc handleFileModification:currentPath notify:YES];
|
||||
#endif
|
||||
|
||||
[xcc updateLastEventId:eventIds[i]];
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@
|
||||
#define xcodecapp_cocoa_FSEventCallback_h
|
||||
|
||||
#import "TNXCodeCapp.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "defines.h"
|
||||
|
||||
void fsevents_callback(ConstFSEventStreamRef, void*, size_t, void*, const FSEventStreamEventFlags*, const FSEventStreamEventId*);
|
||||
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
|
||||
#import "FSEventCallback.h"
|
||||
|
||||
#if (ACTIVATE_DATE_BASED_MODE == 0)
|
||||
|
||||
/*!
|
||||
This is the FSEvent callback
|
||||
This is the FSEvent callback for 10.7
|
||||
*/
|
||||
void fsevents_callback(ConstFSEventStreamRef streamRef,
|
||||
void *userData,
|
||||
@@ -31,15 +33,9 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
|
||||
TNXCodeCapp *xcc = (TNXCodeCapp *)userData;
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < numEvents; i++)
|
||||
for (i = 0; i < numEvents; i++)
|
||||
{
|
||||
NSString *path = [(NSArray *)eventPaths objectAtIndex:i];
|
||||
|
||||
// /!\ IMPORTANT /!\
|
||||
//
|
||||
// This is a test. Maybe these values where present as
|
||||
// private API in 10.6, and maybe not
|
||||
// If not, we will drop support for 10.6
|
||||
|
||||
// kFSEventStreamEventFlagItemIsFile = 0x00010000
|
||||
if (!(eventFlags[i] & 0x00010000)
|
||||
@@ -49,14 +45,59 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
|
||||
|
||||
// kFSEventStreamEventFlagItemRemoved = 0x00000200
|
||||
if (eventFlags[i] & 0x00000200)
|
||||
{
|
||||
[xcc handleFileRemoval:path];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"this file has been modified or created");
|
||||
[xcc handleFileModification:path 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,6 +19,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "PRHEmptyGrowlDelegate.h"
|
||||
#import "FSEventCallback.h"
|
||||
#import "defines.h"
|
||||
|
||||
extern NSString * const XCCDidPopulateProjectNotification;
|
||||
extern NSString * const XCCConversionStartNotification;
|
||||
@@ -31,7 +32,7 @@ extern NSString * const XCCListeningStartNotification;
|
||||
FSEventStreamRef stream;
|
||||
NSFileManager *fm;
|
||||
NSMutableArray *errorList;
|
||||
NSMutableArray *ignoredFilePaths;
|
||||
NSMutableSet *ignoredFilePaths;
|
||||
NSNumber *lastEventId;
|
||||
NSString *currentProjectName;
|
||||
NSString *parserPath;
|
||||
@@ -45,6 +46,11 @@ extern NSString * const XCCListeningStartNotification;
|
||||
NSURL *XCodeSupportProjectSources;
|
||||
PRHEmptyGrowlDelegate *growlDelegateRef;
|
||||
NSObject *delegate;
|
||||
NSDate *appStartedTimestamp;
|
||||
|
||||
#if (ACTIVATE_DATE_BASED_MODE == 1)
|
||||
NSMutableDictionary *pathModificationDates;
|
||||
#endif
|
||||
}
|
||||
|
||||
@property (retain) NSObject* delegate;
|
||||
@@ -69,5 +75,15 @@ extern NSString * const XCCListeningStartNotification;
|
||||
- (void)clear;
|
||||
- (void)start;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#if (ACTIVATE_DATE_BASED_MODE == 1)
|
||||
@interface TNXCodeCapp (SnowLeopard)
|
||||
|
||||
- (void)updateLastModificationDateForPath:(NSString *)path;
|
||||
- (NSDate*)lastModificationDateForPath:(NSString *)path;
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#import "TNXCodeCapp.h"
|
||||
#include "macros.h"
|
||||
|
||||
NSString * const XCCDidPopulateProjectNotification = @"XCCDidPopulateProjectNotification";
|
||||
NSString * const XCCConversionStartNotification = @"XCCConversionStartNotification";
|
||||
@@ -43,9 +44,10 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
|
||||
{
|
||||
errorList = [NSMutableArray arrayWithCapacity:10];
|
||||
fm = [NSFileManager defaultManager];
|
||||
ignoredFilePaths = [NSMutableArray new];
|
||||
ignoredFilePaths = [NSMutableSet new];
|
||||
parserPath = [[NSBundle mainBundle] pathForResource:@"parser" ofType:@"j"];
|
||||
lastEventId = [[NSUserDefaults standardUserDefaults] objectForKey:@"lastEventId"];
|
||||
appStartedTimestamp = [NSDate date];
|
||||
|
||||
if([fm fileExistsAtPath:[@"~/.bash_profile" stringByExpandingTildeInPath]])
|
||||
profilePath = [@"source ~/.bash_profile" stringByExpandingTildeInPath];
|
||||
@@ -57,11 +59,11 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
|
||||
profilePath = [@"source ~/.zshrc" stringByExpandingTildeInPath];
|
||||
else
|
||||
{
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:@"Cannot find any valid profile file"
|
||||
defaultButton:@"Ok"
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:@"Cannot find any valid profile file."
|
||||
defaultButton:@"OK"
|
||||
alternateButton:nil
|
||||
otherButton:nil
|
||||
informativeTextWithFormat:@"We have checked for ~/.bash_profile, ~/.profile, ~/.bashrc and ~/.zshrc without luck.\n\nYou need to have on of this file to tell XCodeCapp-cocoa where is located nib2cib. Now we gonna try to without sourcing one this file and it may fail.\n\nIf you notice any error or weird behaviour, please look at Mac OS' Console.app for log message and open a ticket."];
|
||||
informativeTextWithFormat:@"Neither ~/.bash_profile, ~/.profile, ~/.bashrc nor ~/.zshrc can be found.\n\nWithout this XcodeCapp-cocoa cannot locate nib2cib.\n\nIf you notice any errors or strange behaviour, please look at the system log for messages and open a ticket."];
|
||||
[alert runModal];
|
||||
profilePath = @"";
|
||||
}
|
||||
@@ -73,13 +75,11 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
|
||||
- (void)start
|
||||
{
|
||||
NSString *lastOpenedPath = [[NSUserDefaults standardUserDefaults] objectForKey:@"LastOpenedPath"];
|
||||
|
||||
if (lastOpenedPath)
|
||||
{
|
||||
if ([fm fileExistsAtPath:lastOpenedPath])
|
||||
{
|
||||
NSString *message = [NSString stringWithFormat:@"Resuming project %@", [lastOpenedPath lastPathComponent], nil];
|
||||
|
||||
[delegate performSelector:@selector(growlWithTitle:message:) withObject:@"Resume project" withObject:message];
|
||||
{
|
||||
[self listenProjectAtPath:[NSString stringWithFormat:@"%@/", lastOpenedPath]];
|
||||
}
|
||||
else
|
||||
@@ -101,9 +101,11 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
|
||||
NSTimeInterval latency = 2.0;
|
||||
|
||||
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 );
|
||||
|
||||
|
||||
FSEventStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
|
||||
FSEventStreamStart(stream);
|
||||
}
|
||||
@@ -187,19 +189,17 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
|
||||
if ([self isPathMatchingIgnoredPaths:fullPath] || ![fm fileExistsAtPath:fullPath])
|
||||
return;
|
||||
|
||||
NSLog(@"Starting to parse file modification %@", fullPath);
|
||||
DLog(@"Parsing modified file: %@", fullPath);
|
||||
|
||||
NSArray *arguments = nil;
|
||||
NSString *successTitle = nil;
|
||||
NSString *successMsg = nil;
|
||||
NSString *response = nil;
|
||||
NSString *errorTitle = nil;
|
||||
NSString *errorMsg = nil;
|
||||
NSNumber *status = [NSNumber numberWithInt:0];
|
||||
NSString *splitedPath = [NSString stringWithFormat:@"%@/%@", [[fullPath pathComponents] objectAtIndex:[[fullPath pathComponents] count] - 2], [fullPath lastPathComponent]];
|
||||
NSString *splitPath = [fullPath substringFromIndex:[[currentProjectURL path] length] + 1];
|
||||
NSString *shadowPath = [[self shadowURLForSourceURL:[NSURL URLWithString:[fullPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]] path];
|
||||
|
||||
NSLog(@"Shadow path is: %@", shadowPath);
|
||||
|
||||
DLog(@"Shadow path: %@", shadowPath);
|
||||
|
||||
if ([self isXIBFile:fullPath] || [self isObjJFile:fullPath] || [self isXCCIgnoreFile:fullPath])
|
||||
{
|
||||
@@ -207,56 +207,52 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
|
||||
|
||||
if ([self isXIBFile:fullPath])
|
||||
{
|
||||
NSLog(@"File is XIB file");
|
||||
arguments = [NSArray arrayWithObjects: @"-c", [NSString stringWithFormat:@"(%@; nib2cib '%@';) 2>&1", profilePath, fullPath],@"",nil];
|
||||
successMsg = @"The XIB file has been converted";
|
||||
successTitle = @"XIB converted";
|
||||
successMsg = splitPath;
|
||||
}
|
||||
else if ([self isObjJFile:fullPath])
|
||||
{
|
||||
NSLog(@"File is J file");
|
||||
arguments = [NSArray arrayWithObjects: @"-c", [NSString stringWithFormat:@"(%@; objj '%@' '%@' '%@';) 2>&1", profilePath, parserPath, fullPath, shadowPath],@"",nil];
|
||||
successMsg = @"The Objective-J file has been converted";
|
||||
successTitle = @"Objective-J source parsed";
|
||||
successMsg = splitPath;
|
||||
}
|
||||
else if ([self isXCCIgnoreFile:fullPath])
|
||||
{
|
||||
NSLog(@"File is .xcodecapp-ignore");
|
||||
[self computeIgnoredPaths];
|
||||
successTitle = @".xcodecapp-ignore parsed";
|
||||
successMsg = @"Ignored files list updated";
|
||||
arguments = nil;
|
||||
}
|
||||
|
||||
//Run the task and get the response if needed
|
||||
// Run the task and get the response if needed
|
||||
if (arguments)
|
||||
{
|
||||
NSLog(@"Running task...");
|
||||
DLog(@"Running task...");
|
||||
NSArray *statusInfo = [self runTask:arguments];
|
||||
|
||||
status = [statusInfo objectAtIndex:0];
|
||||
response = [statusInfo objectAtIndex:1];
|
||||
|
||||
NSLog(@"Task result is : %@", status);
|
||||
NSLog(@"Task response is : %@", response);
|
||||
DLog(@"Task result/response: %@/%@", status, response);
|
||||
}
|
||||
|
||||
|
||||
if ([status intValue] == 0 && shouldNotify)
|
||||
{
|
||||
[delegate performSelector:@selector(growlWithTitle:message:) withObject:splitedPath withObject:successMsg];
|
||||
[delegate performSelector:@selector(growlWithTitle:message:) withObject:successTitle withObject:successMsg];
|
||||
}
|
||||
else if (![status intValue] == 0)
|
||||
{
|
||||
if (response)
|
||||
[errorList addObject:response];
|
||||
|
||||
errorTitle = [NSString stringWithFormat:@"ERROR: %@", splitedPath];
|
||||
errorMsg = [NSString stringWithFormat:@"Error was: %@.\n\n You may want to check in error list.", response];
|
||||
[delegate performSelector:@selector(growlWithTitle:message:) withObject:errorTitle withObject:errorMsg];
|
||||
[delegate performSelector:@selector(growlWithTitle:message:) withObject:@"Error processing file" withObject:splitPath];
|
||||
}
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:XCCConversionStopNotification object:self];
|
||||
DLog(@"Processed: %@", fullPath);
|
||||
}
|
||||
|
||||
NSLog(@"Computing done for file %@", fullPath);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -275,7 +271,7 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
|
||||
{
|
||||
NSString *shadowPath = [[self shadowURLForSourceURL:[NSURL URLWithString:[fullPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]] path];
|
||||
[fm removeItemAtPath:shadowPath error:nil];
|
||||
NSLog(@"Removing shadow file %@", shadowPath);
|
||||
DLog(@"Removing shadow file: %@", shadowPath);
|
||||
}
|
||||
else if ([self isXCCIgnoreFile:fullPath])
|
||||
{
|
||||
@@ -339,10 +335,10 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
|
||||
NSLog(@"Xcode support folder created at: %@", [XCodeSupportProject path]);
|
||||
[fm createDirectoryAtPath:[XCodeSupportProject path] withIntermediateDirectories:YES attributes:nil error:nil];
|
||||
|
||||
NSLog(@"Copying project.pbxproj from %@ to %@", XCodeTemplatePBXPath, [XCodeSupportProject path]);
|
||||
DLog(@"Copying project.pbxproj from %@ to %@", XCodeTemplatePBXPath, [XCodeSupportProject path]);
|
||||
[fm copyItemAtPath:XCodeTemplatePBXPath toPath:XCodeSupportPBXPath error:nil];
|
||||
|
||||
NSLog(@"Reading the content of the project.pbxproj");
|
||||
DLog(@"Reading the content of the project.pbxproj");
|
||||
NSMutableString *PBXContent = [NSMutableString stringWithContentsOfFile:XCodeSupportPBXPath encoding:NSUTF8StringEncoding error:nil];
|
||||
[PBXContent replaceOccurrencesOfString:@"${CappuccinoProjectName}"
|
||||
withString:currentProjectName
|
||||
@@ -354,12 +350,11 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
|
||||
range:NSMakeRange(0, [PBXContent length])];
|
||||
|
||||
[PBXContent writeToFile:XCodeSupportPBXPath atomically:YES encoding:NSUTF8StringEncoding error:nil];
|
||||
NSLog(@"PBX file adapted to the project");
|
||||
DLog(@"PBX file adapted to the project");
|
||||
|
||||
NSLog(@"Creating source folder");
|
||||
DLog(@"Creating source folder");
|
||||
[fm createDirectoryAtPath:[XCodeSupportProjectSources path] withIntermediateDirectories:YES attributes:nil error:nil];
|
||||
|
||||
|
||||
[NSThread detachNewThreadSelector:@selector(populateXCodeProject:)toTarget:self withObject:nil];
|
||||
return NO;
|
||||
}
|
||||
@@ -374,10 +369,11 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
|
||||
*/
|
||||
- (void)populateXCodeProject:(id)arguments
|
||||
{
|
||||
[delegate performSelector:@selector(growlWithTitle:message:) withObject:[[currentProjectURL path] lastPathComponent] withObject:@"Loading of project..."];
|
||||
[delegate performSelector:@selector(growlWithTitle:message:) withObject:@"Loading project" withObject:[currentProjectURL path]];
|
||||
|
||||
[self handleFileModification:[NSString stringWithFormat:@"%@", [currentProjectURL path]] notify:NO];
|
||||
NSArray *subdirs = [fm subpathsAtPath:[currentProjectURL path]];
|
||||
|
||||
for (NSString *p in subdirs)
|
||||
[self handleFileModification:[NSString stringWithFormat:@"%@/%@", [currentProjectURL path], p] notify:NO];
|
||||
|
||||
@@ -396,12 +392,12 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
|
||||
[NSException raise:NSInvalidArgumentException format:@"shadowURLForSourceURL: aSource URL must not be null"];
|
||||
|
||||
NSMutableString *flattenedPath = [NSMutableString stringWithString:[aSourceURL path]];
|
||||
NSLog(@"Flattened path is : %@", flattenedPath);
|
||||
[flattenedPath replaceOccurrencesOfString:@"/"
|
||||
withString:@"_"
|
||||
options:NSCaseInsensitiveSearch
|
||||
range:NSMakeRange(0, [[aSourceURL path] length])];
|
||||
|
||||
DLog(@"Flattened path: %@", flattenedPath);
|
||||
NSString *basename = [NSString stringWithFormat:@"%@.h", [[flattenedPath stringByDeletingPathExtension] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
|
||||
|
||||
return [NSURL URLWithString:basename relativeToURL:XCodeSupportProjectSources];
|
||||
@@ -414,15 +410,18 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
|
||||
- (void)computeIgnoredPaths
|
||||
{
|
||||
NSString *ignorePath = [NSString stringWithFormat:@"%@/.xcodecapp-ignore", [currentProjectURL path]];
|
||||
[ignoredFilePaths removeAllObjects];
|
||||
|
||||
if ([fm fileExistsAtPath:ignorePath])
|
||||
{
|
||||
NSString *ignoreFileContent = [NSString stringWithContentsOfFile:ignorePath encoding:NSUTF8StringEncoding error:nil];
|
||||
ignoredFilePaths = [NSMutableArray arrayWithArray:[ignoreFileContent componentsSeparatedByString:@"\n"]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[ignoredFilePaths removeAllObjects];
|
||||
NSArray *ignoredPatterns = [ignoreFileContent componentsSeparatedByString:@"\n"];
|
||||
|
||||
for (NSString *pattern in ignoredPatterns)
|
||||
{
|
||||
if ([pattern length])
|
||||
[ignoredFilePaths addObject:pattern];
|
||||
}
|
||||
}
|
||||
|
||||
[ignoredFilePaths addObject:@"*.git*"];
|
||||
@@ -432,7 +431,7 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
|
||||
[ignoredFilePaths addObject:@"*.xCodeSupport*"];
|
||||
[ignoredFilePaths addObject:@"*Build*"];
|
||||
|
||||
NSLog(@"ignored file paths are: %@", ignoredFilePaths);
|
||||
NSLog(@"Ignoring file paths: %@", ignoredFilePaths);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -506,3 +505,52 @@ 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
|
||||
{
|
||||
if (!pathModificationDates)
|
||||
{
|
||||
pathModificationDates = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"pathModificationDates"] mutableCopy];
|
||||
if (!pathModificationDates)
|
||||
pathModificationDates = [NSMutableDictionary new];
|
||||
}
|
||||
|
||||
[pathModificationDates setObject:[NSDate date] forKey:path];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:pathModificationDates forKey:@"pathModificationDates"];
|
||||
}
|
||||
|
||||
- (NSDate*)lastModificationDateForPath:(NSString *)path
|
||||
{
|
||||
if (!pathModificationDates)
|
||||
{
|
||||
pathModificationDates = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"pathModificationDates"] mutableCopy];
|
||||
if (!pathModificationDates)
|
||||
pathModificationDates = [NSMutableDictionary new];
|
||||
}
|
||||
|
||||
if([pathModificationDates valueForKey:path] != nil)
|
||||
return [pathModificationDates valueForKey:path];
|
||||
else
|
||||
return appStartedTimestamp;
|
||||
}
|
||||
@end
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// 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
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// macros.h
|
||||
// xcodecapp-cocoa
|
||||
//
|
||||
// Created by Aparajita Fishman on 11/3/11.
|
||||
// Copyright (c) 2011 Victory-Heart Productions. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef xcodecapp_cocoa_macros_h
|
||||
#define xcodecapp_cocoa_macros_h
|
||||
|
||||
#if DEBUG
|
||||
# define DLog(fmt, ...) NSLog((fmt), ##__VA_ARGS__);
|
||||
#else
|
||||
# define DLog(...)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -3,7 +3,7 @@
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 45;
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
@@ -27,6 +27,8 @@
|
||||
02998CF71369C339006C73DB /* Growl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02998CF61369C339006C73DB /* Growl.framework */; };
|
||||
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 */
|
||||
@@ -72,6 +74,8 @@
|
||||
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>"; };
|
||||
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 */
|
||||
@@ -145,8 +149,10 @@
|
||||
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E19F99601463B99500569A7E /* defines.h */,
|
||||
027D9989136969DD00D3DB13 /* xcodecapp-cocoa.pch */,
|
||||
29B97316FDCFA39411CA2CEA /* main.m */,
|
||||
E12AA95F14637828006F55D6 /* macros.h */,
|
||||
);
|
||||
name = "Other Sources";
|
||||
sourceTree = "<group>";
|
||||
@@ -207,8 +213,11 @@
|
||||
/* Begin PBXProject section */
|
||||
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0420;
|
||||
};
|
||||
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "xcodecapp-cocoa" */;
|
||||
compatibilityVersion = "Xcode 3.1";
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 1;
|
||||
knownRegions = (
|
||||
@@ -254,6 +263,8 @@
|
||||
651DAE1F13B0CAB900ECA3F0 /* PRHEmptyGrowlDelegate.m in Sources */,
|
||||
027FE49D1462D74C00B1AB92 /* TNXCodeCapp.m in Sources */,
|
||||
027FE4BD1462F7EB00B1AB92 /* FSEventCallback.m in Sources */,
|
||||
E12AA96014637828006F55D6 /* macros.h in Sources */,
|
||||
E19F99611463B99500569A7E /* defines.h in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -289,7 +300,6 @@
|
||||
"\"$(SRCROOT)\"",
|
||||
);
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = YES;
|
||||
GCC_ENABLE_OBJC_GC = required;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
@@ -328,10 +338,12 @@
|
||||
FRAMEWORK_SEARCH_PATHS = "";
|
||||
GCC_ENABLE_OBJC_GC = required;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
|
||||
GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = "";
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.5;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PREBINDING = NO;
|
||||
SDKROOT = macosx10.6;
|
||||
};
|
||||
name = Debug;
|
||||
@@ -343,9 +355,11 @@
|
||||
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
|
||||
FRAMEWORK_SEARCH_PATHS = "";
|
||||
GCC_ENABLE_OBJC_GC = required;
|
||||
GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = "";
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
PREBINDING = NO;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.5;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx10.6;
|
||||
};
|
||||
name = Release;
|
||||
|
||||
Reference in new issue
Block a user