File: tkUnixInit.c

package info (click to toggle)
nam 1.15~RC3-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 29,100 kB
  • ctags: 2,694
  • sloc: cpp: 17,375; tcl: 10,655; sh: 2,990; ansic: 1,250; makefile: 132; perl: 66
file content (89 lines) | stat: -rw-r--r-- 1,504 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifdef WIN32
#include <windows.h>
#endif

#include <tcl.h>
#include <tk.h>
#include <string.h>

int
#if (TK_MAJOR_VERSION < 8)
TkPlatformInit(Tcl_Interp *interp)
#else
TkpInit(Tcl_Interp *interp)
#endif
{
#ifndef WIN32
	{
		extern void TkCreateXEventSource(void);
		TkCreateXEventSource();
	}
#endif
        return (TCL_OK);
}

#if (TK_MAJOR_VERSION == 8)
void
TkpGetAppName(Tcl_Interp* interp, Tcl_DString* namePtr)
{
  const char *name;
  char *p;
#ifdef WIN32
    int argc;
    char** argv;
#endif

    name = Tcl_GetVar(interp, "argv0", TCL_GLOBAL_ONLY);
#ifdef WIN32
    if (name != NULL) {
	Tcl_SplitPath(name, &argc, &argv);
	if (argc > 0) {
	    name = argv[argc-1];
	    p = strrchr(name, '.');
	    if (p != NULL) {
		*p = '\0';
	    }
	} else {
	    name = NULL;
	}
    }
#endif

    if ((name == NULL) || (*name == 0)) {
	name = "tk";
    }
#ifndef WIN32
    else {
	p = strrchr(name, '/');
	if (p != NULL) {
	    name = p+1;
	}
    }
#endif

    Tcl_DStringAppend(namePtr, name, -1);

#ifdef WIN32
    if (argv != NULL) {
	ckfree((char *)argv);
    }
#endif    
    
}
void
TkpDisplayWarning(char* msg, char* title)
{
#ifdef WIN32
    MessageBox(NULL, msg, title, MB_OK | MB_ICONEXCLAMATION | MB_SYSTEMMODAL
	    | MB_SETFOREGROUND | MB_TOPMOST);
#else
    Tcl_Channel errChannel = Tcl_GetStdChannel(TCL_STDERR);
    if (errChannel) {
	Tcl_Write(errChannel, title, -1);
	Tcl_Write(errChannel, ": ", 2);
	Tcl_Write(errChannel, msg, -1);
	Tcl_Write(errChannel, "\n", 1);
    }
#endif
}
#endif