From 8579cbea202b7f81f0f89ea380112c2945e532e9 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Fri, 8 Mar 2019 03:44:09 +0000 Subject: Remove tkMacOSXLaunch.c from TIP; adds too many extraneous commands. Re-focus on URL and print events, and Services --- doc/tk_mac.n | 23 +---------------------- macosx/tkMacOSXInit.c | 40 +++++++++++++++++++++++++++++++++++++++- macosx/tkMacOSXPrivate.h | 2 ++ unix/Makefile.in | 5 ----- 4 files changed, 42 insertions(+), 28 deletions(-) diff --git a/doc/tk_mac.n b/doc/tk_mac.n index 3762afc..9f241fa 100644 --- a/doc/tk_mac.n +++ b/doc/tk_mac.n @@ -24,10 +24,7 @@ tk::mac \- Access Mac-Specific Functionality on OS X from Tk \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 -\fB::tk::mac::GetDefaultApp \fIURL...\fR -\fB::tk::mac::SetDefaultApp \fIURL \fIfile...\fR \fB::tk::mac::standardAboutPanel\fR @@ -185,29 +182,11 @@ application wants to handle a URL itself, such as displaying data from an RSS feed, rather than launching a default application to handle the URL, although it can defined as such. .TP -\fB::tk::mac::LaunchFile \fIfile...\fR -. -If defined, launches a file with the system's default application for -that file format. -.TP \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. -Note that the URL must be in the format -.QW url:// -or it will return an error. -.TP -\fB::tk::mac::SetDefaultApp \fIURL \fIpath-to-app...\fR -. -Sets a specific application as the system default handler for a -specific URL format. Note that the URL must be in the format -.QW url:// -or it will return an error. -.TP + .SH "ADDITIONAL DIALOGS" .PP diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index 5b99371..e559bfc 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -375,7 +375,6 @@ TkpInit( } Tk_MacOSXServices_Init(interp); - TkMacOSXLaunch_Init(interp); Tcl_CreateObjCommand(interp, "::tk::mac::standardAboutPanel", TkMacOSXStandardAboutPanelObjCmd, NULL, NULL); @@ -383,6 +382,7 @@ TkpInit( TkMacOSXRegisterServiceWidgetObjCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap", TkMacOSXIconBitmapObjCmd, NULL, NULL); + Tcl_CreateObjCommand(interp, "::tk::mac::GetAppPath", TkMacOSXGetAppPath,(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); /* @@ -585,6 +585,44 @@ TkMacOSXGetStringObjFromCFString( } return obj; } + +/* + *---------------------------------------------------------------------- + * + * TkMacOSXGetAppPath -- + * + * Retrieves the path to the current installed Wish application. + * + * Results: + * Returns the application name path. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int TkMacOSXGetAppPath(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) { + + CFURLRef mainBundleURL = CFBundleCopyBundleURL(CFBundleGetMainBundle()); + + + /* Convert the URL reference into a string reference. */ + CFStringRef appPath = CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle); + + /* Get the system encoding method. */ + CFStringEncoding encodingMethod = CFStringGetSystemEncoding(); + + /* Convert the string reference into a C string. */ + char *path = CFStringGetCStringPtr(appPath, encodingMethod); + + Tcl_SetResult(ip, path, NULL); + + CFRelease(mainBundleURL); + CFRelease(appPath); + return TCL_OK; + +} /* * Local Variables: diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 8a512fe..1f8ff45 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -423,6 +423,8 @@ VISIBILITY_HIDDEN #endif /* _TKMACPRIV */ +int TkMacOSXGetAppPath(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]); + /* * Local Variables: * mode: objc diff --git a/unix/Makefile.in b/unix/Makefile.in index 47cc229..8b86e00 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -396,7 +396,6 @@ AQUA_OBJS = tkMacOSXBitmap.o tkMacOSXButton.o tkMacOSXClipboard.o \ tkMacOSXDialog.o tkMacOSXDraw.o tkMacOSXEmbed.o tkMacOSXEntry.o \ tkMacOSXEvent.o tkMacOSXFont.o tkMacOSXHLEvents.o tkMacOSXImage.o \ tkMacOSXInit.o tkMacOSXKeyboard.o tkMacOSXKeyEvent.o \ - tkMacOSXLaunch.o \ tkMacOSXMenu.o \ tkMacOSXMenubutton.o tkMacOSXMenus.o tkMacOSXMouseEvent.o \ tkMacOSXNotify.o tkMacOSXRegion.o tkMacOSXScrlbr.o tkMacOSXSend.o \ @@ -524,7 +523,6 @@ AQUA_SRCS = \ $(MAC_OSX_DIR)/tkMacOSXImage.c \ $(MAC_OSX_DIR)/tkMacOSXInit.c $(MAC_OSX_DIR)/tkMacOSXKeyboard.c \ $(MAC_OSX_DIR)/tkMacOSXKeyEvent.c \ - $(MAC_OSX_DIR)/tkMacOSXLaunch.c \ $(MAC_OSX_DIR)/tkMacOSXMenu.c \ $(MAC_OSX_DIR)/tkMacOSXMenubutton.c $(MAC_OSX_DIR)/tkMacOSXMenus.c \ $(MAC_OSX_DIR)/tkMacOSXMouseEvent.c $(MAC_OSX_DIR)/tkMacOSXNotify.c \ @@ -1290,9 +1288,6 @@ 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 -- cgit v0.12