summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/tk_mac.n3
-rw-r--r--macosx/tkMacOSXHLEvents.c3
-rw-r--r--macosx/tkMacOSXInit.c4
-rw-r--r--macosx/tkMacOSXLaunch.c49
-rw-r--r--unix/Makefile.in3
5 files changed, 35 insertions, 27 deletions
diff --git a/doc/tk_mac.n b/doc/tk_mac.n
index 2a35b95..2b67d34 100644
--- a/doc/tk_mac.n
+++ b/doc/tk_mac.n
@@ -23,7 +23,6 @@ tk::mac \- Access Mac-Specific Functionality on OS X from Tk
\fB::tk::mac::OnShow\fR
\fB::tk::mac::ShowHelp\fR
\fB::tk::mac::PerformService\fR
-
\fB::tk::mac::LaunchURL \fIURL...\fR
\fB::tk::mac::LaunchFile \fIfile...\fR
\fB::tk::mac::GetAppPath\fR
@@ -37,6 +36,7 @@ tk::mac \- Access Mac-Specific Functionality on OS X from Tk
\fB::tk::mac::antialiasedtext \fInumber\fR
\fB::tk::mac::useThemedToplevel \fIboolean\fR
+
\fB::tk::mac::iconBitmap \fIname width height \-kind value\fR
.fi
.BE
@@ -194,6 +194,7 @@ that file format.
\fB::tk::mac::GetAppPath\fR
.
Returns the current applications's file path.
+.TP
\fB::tk::mac::GetDefaultApp \fIURL...\fR
.
Returns the current default application for a URL format.
diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c
index 47788d5..9383d96 100644
--- a/macosx/tkMacOSXHLEvents.c
+++ b/macosx/tkMacOSXHLEvents.c
@@ -252,12 +252,13 @@ static int ReallyKillMe(Tcl_Event *eventPtr, int flags);
{
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, url);
+ Tcl_DStringAppendElement(&launch, cURL);
int tclErr = Tcl_EvalEx(_eventInterp, Tcl_DStringValue(&launch),
Tcl_DStringLength(&launch), TCL_EVAL_GLOBAL);
if (tclErr!= TCL_OK) {
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index 295f886..5b99371 100644
--- a/macosx/tkMacOSXInit.c
+++ b/macosx/tkMacOSXInit.c
@@ -374,7 +374,8 @@ TkpInit(
TCL_GLOBAL_ONLY|TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
}
- Tk_MacOSXServices_Init();
+ Tk_MacOSXServices_Init(interp);
+ TkMacOSXLaunch_Init(interp);
Tcl_CreateObjCommand(interp, "::tk::mac::standardAboutPanel",
TkMacOSXStandardAboutPanelObjCmd, NULL, NULL);
@@ -382,6 +383,7 @@ TkpInit(
TkMacOSXRegisterServiceWidgetObjCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap",
TkMacOSXIconBitmapObjCmd, NULL, NULL);
+
/*
* Workaround for 3efbe4a397; console not accepting keyboard input on 10.14
diff --git a/macosx/tkMacOSXLaunch.c b/macosx/tkMacOSXLaunch.c
index 5004bf2..4252d14 100644
--- a/macosx/tkMacOSXLaunch.c
+++ b/macosx/tkMacOSXLaunch.c
@@ -17,9 +17,16 @@
#include <ApplicationServices/ApplicationServices.h>
#define panic Tcl_Panic
+/*Forward declarations of functions.*/
+int TkMacOSXLaunchURL(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]);
+int TkMacOSXLaunchFile(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]);
+int TkMacOSXGetAppPath(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]);
+int TkMacOSXGetDefaultApp(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]);
+int TkMacOSXSetDefaultApp(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]);
+
/*Tcl function to launch URL with default app.*/
-int LaunchURL(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) {
+int TkMacOSXLaunchURL(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) {
if(objc != 2) {
Tcl_WrongNumArgs(ip, 1, objv, "url");
@@ -43,7 +50,7 @@ int LaunchURL(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) {
}
/*Tcl function to launch file with default app.*/
-int LaunchFile(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) {
+int TkMacOSXLaunchFile(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) {
if(objc != 2) {
Tcl_WrongNumArgs(ip, 1, objv, "file");
@@ -67,7 +74,7 @@ int LaunchFile(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) {
/*Tcl function to get path to app bundle.*/
-int GetAppPath(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) {
+int TkMacOSXGetAppPath(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) {
CFURLRef mainBundleURL = CFBundleCopyBundleURL(CFBundleGetMainBundle());
@@ -89,8 +96,8 @@ int GetAppPath(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) {
}
-/*Tcl function to launch file with default app.*/
-int GetDefaultApp(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) {
+/*Tcl function to get default app for URL.*/
+int TkMacOSXGetDefaultApp(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) {
if(objc != 2) {
Tcl_WrongNumArgs(ip, 1, objv, "url");
@@ -103,11 +110,13 @@ int GetDefaultApp(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]
CFStringRef defaultApp;
defaultApp = LSCopyDefaultHandlerForURLScheme(url);
-
+ CFStringRef appURL;
OSStatus result;
- CFURLRef appURL = NULL;
result = LSFindApplicationForInfo(kLSUnknownCreator, defaultApp, NULL, NULL, &appURL);
+CFURLRef httpURL = CFURLCreateWithString(kCFAllocatorDefault, CFSTR("feed://"), NULL);
+NSLog(@"%@", LSCopyDefaultApplicationURLForURL(httpURL, kLSRolesAll, nil));
+
/* Convert the URL reference into a string reference. */
CFStringRef appPath = CFURLCopyFileSystemPath(appURL, kCFURLPOSIXPathStyle);
@@ -128,7 +137,7 @@ int GetDefaultApp(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]
}
/*Tcl function to set default app for URL.*/
-int SetDefaultApp(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) {
+int TkMacOSXSetDefaultApp(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) {
if(objc != 3) {
Tcl_WrongNumArgs(ip, 1, objv, "url path");
@@ -143,7 +152,7 @@ int SetDefaultApp(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]
CFStringRef apppath = CFStringCreateWithCString(NULL, Tcl_GetString(objv[2]), kCFStringEncodingUTF8);
- /* Convert filepath to URL, create bundle object, get bundle ID. */
+ /* Convert filepath to URL, create bundle object, get bundle ID. */
appURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, apppath, kCFURLPOSIXPathStyle, false);
bundle = CFBundleCreate(NULL, appURL);
@@ -158,28 +167,20 @@ int SetDefaultApp(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]
CFRelease(apppath);
CFRelease(bundleID);
- return TCL_OK;
+ return TCL_OK;
}
/*Initalize the package in the tcl interpreter, create Tcl commands. */
-int TkMacOSXLauncher_Init (Tcl_Interp *interp) {
-
-
- if (Tcl_InitStubs(interp, "8.5", 0) == NULL) {
- return TCL_ERROR;
- }
- if (Tk_InitStubs(interp, "8.5", 0) == NULL) {
- return TCL_ERROR;
- }
+int TkMacOSXLaunch_Init (Tcl_Interp *interp) {
- Tcl_CreateObjCommand(interp, "::tk::mac::LaunchURL", LaunchURL,(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
- Tcl_CreateObjCommand(interp, "::tk::mac::LaunchFile", LaunchFile,(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
- Tcl_CreateObjCommand(interp, "::tk::mac::GetAppPath", GetAppPath,(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
- Tcl_CreateObjCommand(interp, "::tk::mac::GetDefaultApp", GetDefaultApp,(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
- Tcl_CreateObjCommand(interp, "::tk::mac::SetDefaultApp",SetDefaultApp,(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+ Tcl_CreateObjCommand(interp, "::tk::mac::LaunchURL", TkMacOSXLaunchURL,(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+ Tcl_CreateObjCommand(interp, "::tk::mac::LaunchFile", TkMacOSXLaunchFile,(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+ Tcl_CreateObjCommand(interp, "::tk::mac::GetAppPath", TkMacOSXGetAppPath,(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+ Tcl_CreateObjCommand(interp, "::tk::mac::GetDefaultApp",TkMacOSXGetDefaultApp,(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+ Tcl_CreateObjCommand(interp, "::tk::mac::SetDefaultApp",TkMacOSXSetDefaultApp,(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
return TCL_OK;
diff --git a/unix/Makefile.in b/unix/Makefile.in
index c5ba8f7..47cc229 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -1290,6 +1290,9 @@ tkMacOSXKeyboard.o: $(MAC_OSX_DIR)/tkMacOSXKeyboard.c
tkMacOSXKeyEvent.o: $(MAC_OSX_DIR)/tkMacOSXKeyEvent.c
$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXKeyEvent.c
+
+tkMacOSXLaunch.o: $(MAC_OSX_DIR)/tkMacOSXLaunch.c
+ $(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXLaunch.c
tkMacOSXMenu.o: $(MAC_OSX_DIR)/tkMacOSXMenu.c
$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXMenu.c