Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is really just a skeleton for things to come.
There are two parts: 1) Dialog plug-in for TextMate, this registers a “TextMate dialog server” connection to which it is possible to send a path to a nib file and optional arguments. This nib is then loaded in the TextMate program space, so it will appear with the proper window layer etc. 2) tm_dialog is the shell tool to signal the Dialog plug-in The idea is that TM commands can then just create a nib for their UI and use tm_dialog to have the nib shown, and get back the “result” from this nib, w/o having to do compile things etc. A suite of standard dialogs is planned which could replace the need for CocoaDialog. There is currently one major problem with this approach: Distributed Objects seems to only allow one connection per task, so if you install this plug-in, you will lose ‘mate’ support, as that also works via Distributed Objects. Maybe there is a simple solution for this.
- Loading branch information
0 parents
commit b06f34c
Showing
12 changed files
with
727 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>currentDocument</key> | ||
<string>Dialog.mm</string> | ||
<key>documents</key> | ||
<array> | ||
<dict> | ||
<key>expanded</key> | ||
<true/> | ||
<key>name</key> | ||
<string>Dialog PlugIn</string> | ||
<key>regexFolderFilter</key> | ||
<string>!.*/(\.[^/]*|CVS|include|3rd_party|\{arch\}|build|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string> | ||
<key>sourceDirectory</key> | ||
<string></string> | ||
</dict> | ||
</array> | ||
<key>fileHierarchyDrawerWidth</key> | ||
<integer>200</integer> | ||
<key>metaData</key> | ||
<dict> | ||
<key>Dialog.h</key> | ||
<dict> | ||
<key>caret</key> | ||
<dict> | ||
<key>column</key> | ||
<integer>0</integer> | ||
<key>line</key> | ||
<integer>5</integer> | ||
</dict> | ||
<key>firstVisibleColumn</key> | ||
<integer>0</integer> | ||
<key>firstVisibleLine</key> | ||
<integer>0</integer> | ||
</dict> | ||
<key>Dialog.mm</key> | ||
<dict> | ||
<key>caret</key> | ||
<dict> | ||
<key>column</key> | ||
<integer>0</integer> | ||
<key>line</key> | ||
<integer>53</integer> | ||
</dict> | ||
<key>firstVisibleColumn</key> | ||
<integer>0</integer> | ||
<key>firstVisibleLine</key> | ||
<integer>35</integer> | ||
</dict> | ||
<key>tm_dialog.mm</key> | ||
<dict> | ||
<key>caret</key> | ||
<dict> | ||
<key>column</key> | ||
<integer>0</integer> | ||
<key>line</key> | ||
<integer>3</integer> | ||
</dict> | ||
<key>firstVisibleColumn</key> | ||
<integer>0</integer> | ||
<key>firstVisibleLine</key> | ||
<integer>0</integer> | ||
</dict> | ||
</dict> | ||
<key>openDocuments</key> | ||
<array> | ||
<string>Dialog.mm</string> | ||
<string>Dialog.h</string> | ||
<string>tm_dialog.mm</string> | ||
</array> | ||
<key>showFileHierarchyDrawer</key> | ||
<true/> | ||
<key>windowFrame</key> | ||
<string>{{515, 451}, {766, 578}}</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#import <Cocoa/Cocoa.h> | ||
|
||
@protocol TMPlugInController | ||
- (float)version; | ||
@end | ||
|
||
@protocol TextMateDialogServerProtocol | ||
- (int)textMateDialogServerProtocolVersion; | ||
- (void)showNib:(NSString*)aNib withArguments:(id)someArguments; | ||
@end | ||
|
||
@interface Dialog : NSObject | ||
{ | ||
} | ||
- (id)initWithPlugInController:(id <TMPlugInController>)aController; | ||
- (void)dealloc; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#import "Dialog.h" | ||
|
||
#ifndef enumerate | ||
#define enumerate(container,var) for(NSEnumerator* _enumerator = [container objectEnumerator]; var = [_enumerator nextObject]; ) | ||
#endif | ||
|
||
@interface CatchAllNibLoader : NSObject | ||
{ | ||
} | ||
@end | ||
|
||
@implementation CatchAllNibLoader | ||
- (void)setValue:(id)aValue forKey:(NSString*)aKey | ||
{ | ||
NSLog(@"%s %@ = %@", _cmd, aKey, aValue); | ||
} | ||
@end | ||
|
||
@interface DialogServer : NSObject <TextMateDialogServerProtocol> | ||
{ | ||
} | ||
@end | ||
|
||
@implementation DialogServer | ||
- (int)textMateDialogServerProtocolVersion | ||
{ | ||
return 1; | ||
} | ||
|
||
- (void)showNib:(NSString*)aNibPath withArguments:(id)someArguments | ||
{ | ||
NSFileManager* fm = [NSFileManager defaultManager]; | ||
|
||
if(![aNibPath hasPrefix:@"/"]) // relative URL | ||
aNibPath = [[fm currentDirectoryPath] stringByAppendingPathComponent:aNibPath]; | ||
|
||
if(![aNibPath hasSuffix:@".nib"]) | ||
aNibPath = [aNibPath stringByAppendingPathExtension:@"nib"]; | ||
|
||
if(![fm fileExistsAtPath:aNibPath]) | ||
{ | ||
NSLog(@"%s nib file not found: %@", _cmd, aNibPath); | ||
return; | ||
} | ||
|
||
NSNib* nib = [[NSNib alloc] initWithContentsOfURL:[NSURL fileURLWithPath:aNibPath]]; | ||
if(!nib) | ||
{ | ||
NSLog(@"%s failed loading nib: %@", _cmd, aNibPath); | ||
return; | ||
} | ||
|
||
NSMutableArray* topLevelObjects = nil; | ||
BOOL didInstantiate = [nib instantiateNibWithOwner:[[CatchAllNibLoader new] autorelease] topLevelObjects:&topLevelObjects]; | ||
if(!didInstantiate) | ||
{ | ||
NSLog(@"%s failed to instantiate nib", _cmd); | ||
} | ||
|
||
NSLog(@"%s loaded nib with top levle objects %@", _cmd, topLevelObjects); | ||
enumerate(topLevelObjects, id object) | ||
{ | ||
if([object isKindOfClass:[NSWindow class]]) | ||
[object makeKeyAndOrderFront:self]; | ||
} | ||
} | ||
@end | ||
|
||
@implementation Dialog | ||
- (id)initWithPlugInController:(id <TMPlugInController>)aController | ||
{ | ||
NSApp = [NSApplication sharedApplication]; | ||
if(self = [super init]) | ||
{ | ||
NSConnection* connection = [NSConnection defaultConnection]; | ||
[connection setRootObject:[[DialogServer new] autorelease]]; | ||
if([connection registerName:@"TextMate dialog server"] == NO) | ||
NSLog(@"couldn't setup TextMate dialog server."), NSBeep(); | ||
} | ||
return self; | ||
} | ||
|
||
- (void)dealloc | ||
{ | ||
[super dealloc]; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>currentDocument</key> | ||
<string>Clock.mm</string> | ||
<key>documents</key> | ||
<array> | ||
<dict> | ||
<key>expanded</key> | ||
<true/> | ||
<key>name</key> | ||
<string>Clock</string> | ||
<key>regexFileFilter</key> | ||
<string>!(/\.(?!htaccess)[^/]*|\.(tmproj|o|pyc|db)|/Icon\r)$</string> | ||
<key>regexFolderFilter</key> | ||
<string>!.*/(\.[^/]*|CVS|\{arch\}|build|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string> | ||
<key>sourceDirectory</key> | ||
<string></string> | ||
</dict> | ||
</array> | ||
<key>fileHierarchyDrawerWidth</key> | ||
<integer>200</integer> | ||
<key>metaData</key> | ||
<dict> | ||
<key>Clock.mm</key> | ||
<dict> | ||
<key>caret</key> | ||
<dict> | ||
<key>column</key> | ||
<integer>0</integer> | ||
<key>line</key> | ||
<integer>69</integer> | ||
</dict> | ||
<key>firstVisibleColumn</key> | ||
<integer>0</integer> | ||
<key>firstVisibleLine</key> | ||
<integer>42</integer> | ||
</dict> | ||
</dict> | ||
<key>openDocuments</key> | ||
<array> | ||
<string>Clock.mm</string> | ||
</array> | ||
<key>showFileHierarchyDrawer</key> | ||
<true/> | ||
<key>windowFrame</key> | ||
<string>{{417, 275}, {658, 660}}</string> | ||
</dict> | ||
</plist> |
Oops, something went wrong.