summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXHLEvents.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2019-06-15 20:20:29 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2019-06-15 20:20:29 (GMT)
commitc2438211ba9f4dc38923537ccd1d1ad107647c8a (patch)
tree2145b945539f7c43d56ab352642c283c8a7c02b2 /macosx/tkMacOSXHLEvents.c
parentbc7034e2a3d599b3976b75741334d0598f2eb127 (diff)
parent4e0f2e932c49f1910a446374f803f1a7cdf82020 (diff)
downloadtk-c2438211ba9f4dc38923537ccd1d1ad107647c8a.zip
tk-c2438211ba9f4dc38923537ccd1d1ad107647c8a.tar.gz
tk-c2438211ba9f4dc38923537ccd1d1ad107647c8a.tar.bz2
merge core-8-6-branch: mac services improvements
Diffstat (limited to 'macosx/tkMacOSXHLEvents.c')
-rw-r--r--macosx/tkMacOSXHLEvents.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c
index 8f04e45..fa52613 100644
--- a/macosx/tkMacOSXHLEvents.c
+++ b/macosx/tkMacOSXHLEvents.c
@@ -105,8 +105,21 @@ static void RunSimpleTclCommand(Tcl_Interp *interp,
- (void) handlePrintDocumentsEvent: (NSAppleEventDescriptor *)event
withReplyEvent: (NSAppleEventDescriptor *)replyEvent
{
- tkMacOSXProcessFiles(event, replyEvent, _eventInterp,
- "::tk::mac::PrintDocument");
+ NSString* file = [[event paramDescriptorForKeyword:keyDirectObject]
+ stringValue];
+ const char *printFile = [file UTF8String];
+ Tcl_DString print;
+
+ Tcl_DStringInit(&print);
+ if (Tcl_FindCommand(_eventInterp, "::tk::mac::PrintDocument", NULL, 0)) {
+ Tcl_DStringAppend(&print, "::tk::mac::PrintDocument", -1);
+ }
+ Tcl_DStringAppendElement(&print, printFile);
+ int tclErr = Tcl_EvalEx(_eventInterp, Tcl_DStringValue(&print),
+ Tcl_DStringLength(&print), TCL_EVAL_GLOBAL);
+ if (tclErr != TCL_OK) {
+ Tcl_BackgroundException(_eventInterp, tclErr);
+ }
}
- (void) handleDoScriptEvent: (NSAppleEventDescriptor *)event
@@ -239,6 +252,27 @@ static void RunSimpleTclCommand(Tcl_Interp *interp,
Tcl_Release(_eventInterp);
return;
}
+
+- (void)handleURLEvent:(NSAppleEventDescriptor*)event
+ withReplyEvent:(NSAppleEventDescriptor*)replyEvent
+{
+ NSString* url = [[event paramDescriptorForKeyword:keyDirectObject]
+ stringValue];
+ const char *cURL = [url UTF8String];
+ Tcl_DString launch;
+
+ Tcl_DStringInit(&launch);
+ if (Tcl_FindCommand(_eventInterp, "::tk::mac::LaunchURL", NULL, 0)) {
+ Tcl_DStringAppend(&launch, "::tk::mac::LaunchURL", -1);
+ }
+ Tcl_DStringAppendElement(&launch, cURL);
+ int tclErr = Tcl_EvalEx(_eventInterp, Tcl_DStringValue(&launch),
+ Tcl_DStringLength(&launch), TCL_EVAL_GLOBAL);
+ if (tclErr != TCL_OK) {
+ Tcl_BackgroundException(_eventInterp, tclErr);
+ }
+}
+
@end
#pragma mark -
@@ -423,12 +457,17 @@ TkMacOSXInitAppleEvents(
forEventClass:kCoreEventClass andEventID:kAEOpenDocuments];
[aeManager setEventHandler:NSApp
- andSelector:@selector(handleOpenDocumentsEvent:withReplyEvent:)
+ andSelector:@selector(handlePrintDocumentsEvent:withReplyEvent:)
forEventClass:kCoreEventClass andEventID:kAEPrintDocuments];
[aeManager setEventHandler:NSApp
andSelector:@selector(handleDoScriptEvent:withReplyEvent:)
forEventClass:kAEMiscStandards andEventID:kAEDoScript];
+
+ [aeManager setEventHandler:NSApp
+ andSelector:@selector(handleURLEvent:withReplyEvent:)
+ forEventClass:kInternetEventClass andEventID:kAEGetURL];
+
}
}