diff options
Diffstat (limited to 'macosx/tkMacOSXInit.c')
-rw-r--r-- | macosx/tkMacOSXInit.c | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index 8e353b4..33a60f2 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -14,8 +14,6 @@ #include "tkMacOSXPrivate.h" -#include "tclInt.h" /* for Tcl_GetStartupScript() & Tcl_SetStartupScript() */ - #include <sys/stat.h> #include <sys/utsname.h> #include <dlfcn.h> @@ -32,7 +30,7 @@ static char scriptPath[PATH_MAX + 1] = ""; long tkMacOSXMacOSXVersion = 0; -#pragma mark TKApplication(TKInit) +#pragma mark TKApplication(TKInit) #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 #define NSTextInputContextKeyboardSelectionDidChangeNotification @"NSTextInputContextKeyboardSelectionDidChangeNotification" @@ -42,7 +40,7 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt #endif @interface TKApplication(TKKeyboard) -- (void)keyboardChanged:(NSNotification *)notification; +- (void) keyboardChanged: (NSNotification *) notification; @end #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 @@ -51,11 +49,11 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt #define TKApplication_NSApplicationDelegate #endif @interface TKApplication(TKWindowEvent) TKApplication_NSApplicationDelegate -- (void)_setupWindowNotifications; +- (void) _setupWindowNotifications; @end @interface TKApplication(TKMenus) -- (void)_setupMenus; +- (void) _setupMenus; @end @implementation TKApplication @@ -70,16 +68,18 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt _mainPool = [NSAutoreleasePool new]; } } - #ifdef TK_MAC_DEBUG_NOTIFICATIONS -- (void)_postedNotification:(NSNotification *)notification { +- (void) _postedNotification: (NSNotification *) notification +{ TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); } #endif -- (void)_setupApplicationNotifications { +- (void) _setupApplicationNotifications +{ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; -#define observe(n, s) [nc addObserver:self selector:@selector(s) name:(n) object:nil] +#define observe(n, s) \ + [nc addObserver:self selector:@selector(s) name:(n) object:nil] observe(NSApplicationDidBecomeActiveNotification, applicationActivate:); observe(NSApplicationDidResignActiveNotification, applicationDeactivate:); observe(NSApplicationDidUnhideNotification, applicationShowHide:); @@ -92,14 +92,16 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt #endif } -- (void)_setupEventLoop { +- (void) _setupEventLoop +{ NSAutoreleasePool *pool = [NSAutoreleasePool new]; [self finishLaunching]; [self setWindowsNeedUpdate:YES]; [pool drain]; } -- (void)_setup:(Tcl_Interp *)interp { +- (void) _setup: (Tcl_Interp *) interp +{ _eventInterp = interp; _mainPool = [NSAutoreleasePool new]; [NSApp setPoolProtected:NO]; @@ -114,7 +116,8 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt [self _setupApplicationNotifications]; } -- (NSString *)tkFrameworkImagePath:(NSString*)image { +- (NSString *) tkFrameworkImagePath: (NSString *) image +{ NSString *path = nil; NSAutoreleasePool *pool = [NSAutoreleasePool new]; if (tkLibPath[0] != '\0') { @@ -125,8 +128,10 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt if (!path) { const char *tk_library = Tcl_GetVar2(_eventInterp, "tk_library", NULL, TCL_GLOBAL_ONLY); + if (tk_library) { NSFileManager *fm = [NSFileManager defaultManager]; + path = [[NSString stringWithUTF8String:tk_library] stringByAppendingFormat:@"/%@", image]; if (![fm isReadableFileAtPath:path]) { @@ -237,7 +242,7 @@ TkpInit( if (!uname(&name)) { tkMacOSXMacOSXVersion = (strtod(name.release, NULL) + 96) * 10; } - /*Check for new versioning scheme on Yosemite (10.10) and later.*/ + /*Check for new versioning scheme on Yosemite (10.10) and later.*/ if (MAC_OS_X_VERSION_MIN_REQUIRED > 100000) { tkMacOSXMacOSXVersion = MAC_OS_X_VERSION_MIN_REQUIRED/100; } @@ -246,7 +251,7 @@ TkpInit( Tcl_Panic("Mac OS X 10.%d or later required !", (MAC_OS_X_VERSION_MIN_REQUIRED/10)-100); } - + #ifdef TK_FRAMEWORK /* @@ -339,7 +344,7 @@ TkpInit( TkMacOSXInitCGDrawing(interp, TRUE, 0); [pool drain]; } - + /* * FIXME: Close stdin & stdout for remote debugging otherwise we will * fight with gdb for stdin & stdout @@ -370,11 +375,11 @@ TkpInit( */ if (Tcl_GetStartupScript(NULL) == NULL) { - const char *intvar = Tcl_GetVar(interp, - "tcl_interactive", TCL_GLOBAL_ONLY); + const char *intvar = Tcl_GetVar2(interp, + "tcl_interactive", NULL, TCL_GLOBAL_ONLY); if (intvar == NULL) { - Tcl_SetVar(interp, "tcl_interactive", "1", + Tcl_SetVar2(interp, "tcl_interactive", NULL, "1", TCL_GLOBAL_ONLY); } } @@ -387,11 +392,11 @@ TkpInit( Tk_MacOSXSetupTkNotifier(); if (tkLibPath[0] != '\0') { - Tcl_SetVar(interp, "tk_library", tkLibPath, TCL_GLOBAL_ONLY); + Tcl_SetVar2(interp, "tk_library", NULL, tkLibPath, TCL_GLOBAL_ONLY); } if (scriptPath[0] != '\0') { - Tcl_SetVar(interp, "auto_path", scriptPath, + Tcl_SetVar2(interp, "auto_path", NULL, scriptPath, TCL_GLOBAL_ONLY|TCL_LIST_ELEMENT|TCL_APPEND_VALUE); } @@ -428,7 +433,7 @@ TkpGetAppName( { const char *p, *name; - name = Tcl_GetVar(interp, "argv0", TCL_GLOBAL_ONLY); + name = Tcl_GetVar2(interp, "argv0", NULL, TCL_GLOBAL_ONLY); if ((name == NULL) || (*name == 0)) { name = "tk"; } else { |