summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXInit.c
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/tkMacOSXInit.c')
-rw-r--r--macosx/tkMacOSXInit.c52
1 files changed, 31 insertions, 21 deletions
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index cb97f47..997d306 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
@@ -73,13 +71,17 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt
}
}
#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:);
@@ -91,13 +93,17 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt
CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, &keyboardChanged, kTISNotifySelectedKeyboardInputSourceChanged, NULL, CFNotificationSuspensionBehaviorCoalesce);
#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 = nil;
[NSApp setPoolProtected:NO];
@@ -113,7 +119,9 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt
[self _setupApplicationNotifications];
[pool drain];
}
-- (NSString *)tkFrameworkImagePath:(NSString*)image {
+
+- (NSString *) tkFrameworkImagePath: (NSString *) image
+{
NSString *path = nil;
NSAutoreleasePool *pool = [NSAutoreleasePool new];
if (tkLibPath[0] != '\0') {
@@ -124,8 +132,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]) {
@@ -236,7 +246,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;
}
@@ -245,7 +255,7 @@ TkpInit(
Tcl_Panic("Mac OS X 10.%d or later required !",
(MAC_OS_X_VERSION_MIN_REQUIRED/10)-100);
}
-
+
#ifdef TK_FRAMEWORK
/*
@@ -338,7 +348,7 @@ TkpInit(
TkMacOSXInitCGDrawing(interp, TRUE, 0);
[pool drain];
}
-
+
/*
* FIXME: Close stdin & stdout for remote debugging otherwise we will
* fight with gdb for stdin & stdout
@@ -369,11 +379,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);
}
}
@@ -386,11 +396,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);
}
@@ -427,7 +437,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 {