summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXInit.c
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/tkMacOSXInit.c')
-rw-r--r--macosx/tkMacOSXInit.c53
1 files changed, 32 insertions, 21 deletions
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index 6ba726d..e861089 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
@@ -63,13 +61,17 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt
@implementation TKApplication(TKInit)
#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:);
@@ -81,13 +83,17 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt
CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, &keyboardChanged, kTISNotifySelectedKeyboardInputSourceChanged, NULL, CFNotificationSuspensionBehaviorCoalesce);
#endif
}
-- (void)_setupEventLoop {
- /*Remove private API calls here.*/
+- (void) _setupEventLoop
+{
+
+ /*Remove private API flags here.*/
[self finishLaunching];
[self setWindowsNeedUpdate:YES];
}
-- (void)_setup:(Tcl_Interp *)interp {
+
+- (void) _setup: (Tcl_Interp *) interp
+{
_eventInterp = interp;
_defaultMainMenu = nil;
[self _setupMenus];
@@ -99,8 +105,11 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt
[self _setupWindowNotifications];
[self _setupApplicationNotifications];
}
-- (NSString *)tkFrameworkImagePath:(NSString*)image {
+
+- (NSString *) tkFrameworkImagePath: (NSString *) image
+{
NSString *path = nil;
+
if (tkLibPath[0] != '\0') {
path = [[NSBundle bundleWithPath:[[NSString stringWithUTF8String:
tkLibPath] stringByAppendingString:@"/../.."]]
@@ -109,8 +118,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]) {
@@ -217,7 +228,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;
}
@@ -226,7 +237,7 @@ TkpInit(
Tcl_Panic("Mac OS X 10.%d or later required !",
(MAC_OS_X_VERSION_MIN_REQUIRED/10)-100);
}
-
+
#ifdef TK_FRAMEWORK
/*
@@ -348,11 +359,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);
}
}
@@ -365,11 +376,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);
}
@@ -406,7 +417,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 {