summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXInit.c
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/tkMacOSXInit.c')
-rw-r--r--macosx/tkMacOSXInit.c47
1 files changed, 29 insertions, 18 deletions
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index 2bf1962..1f70149 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>
@@ -43,7 +41,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
@@ -52,15 +50,15 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt
#define TKApplication_NSApplicationDelegate
#endif
@interface TKApplication(TKWindowEvent) TKApplication_NSApplicationDelegate
-- (void)_setupWindowNotifications;
+- (void) _setupWindowNotifications;
@end
@interface TKApplication(TKScrlbr)
-- (void)_setupScrollBarNotifications;
+- (void) _setupScrollBarNotifications;
@end
@interface TKApplication(TKMenus)
-- (void)_setupMenus;
+- (void) _setupMenus;
@end
@implementation TKApplication
@@ -68,13 +66,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:);
@@ -86,7 +88,9 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt
CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, &keyboardChanged, kTISNotifySelectedKeyboardInputSourceChanged, NULL, CFNotificationSuspensionBehaviorCoalesce);
#endif
}
-- (void)_setupEventLoop {
+
+- (void) _setupEventLoop
+{
_running = 1;
if (!_appFlags._hasBeenRun) {
_appFlags._hasBeenRun = YES;
@@ -94,7 +98,9 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt
}
[self setWindowsNeedUpdate:YES];
}
-- (void)_setup:(Tcl_Interp *)interp {
+
+- (void) _setup: (Tcl_Interp *) interp
+{
_eventInterp = interp;
_defaultMainMenu = nil;
[self _setupMenus];
@@ -107,8 +113,11 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt
[self _setupScrollBarNotifications];
[self _setupApplicationNotifications];
}
-- (NSString *)tkFrameworkImagePath:(NSString*)image {
+
+- (NSString *) tkFrameworkImagePath: (NSString *) image
+{
NSString *path = nil;
+
if (tkLibPath[0] != '\0') {
path = [[NSBundle bundleWithPath:[[NSString stringWithUTF8String:
tkLibPath] stringByAppendingString:@"/../.."]]
@@ -117,8 +126,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]) {
@@ -352,11 +363,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);
}
}
@@ -369,11 +380,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);
}
@@ -410,7 +421,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 {