| 1 |
/* $Id: tixAppInit.c,v 1.1.2.1 2001/11/15 05:18:16 idiscovery Exp $ */ |
| 2 |
/* |
| 3 |
* tixAppInit.c -- |
| 4 |
* |
| 5 |
* Provides a default version of the Tcl_AppInit procedure for |
| 6 |
* use in wish and similar Tk-based applications. |
| 7 |
* |
| 8 |
* Copyright (c) 1995 Ioi K Lam |
| 9 |
* Copyright (c) 1993 The Regents of the University of California. |
| 10 |
* Copyright (c) 1994 Sun Microsystems, Inc. |
| 11 |
* |
| 12 |
* See the file "license.terms" for information on usage and redistribution |
| 13 |
* of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 14 |
*/ |
| 15 |
|
| 16 |
#ifndef lint |
| 17 |
static char sccsid[] = "@(#) tkAppInit.c 1.15 95/06/28 13:14:28"; |
| 18 |
#endif /* not lint */ |
| 19 |
|
| 20 |
#include "tk.h" |
| 21 |
#include "itcl.h" |
| 22 |
#include "itk.h" |
| 23 |
#include <tix.h> |
| 24 |
|
| 25 |
/* |
| 26 |
* The following variable is a special hack that is needed in order for |
| 27 |
* Sun shared libraries to be used for Tcl. |
| 28 |
*/ |
| 29 |
|
| 30 |
extern int matherr(); |
| 31 |
int *tclDummyMathPtr = (int *) matherr; |
| 32 |
|
| 33 |
/* |
| 34 |
*---------------------------------------------------------------------- |
| 35 |
* |
| 36 |
* main -- |
| 37 |
* |
| 38 |
* This is the main program for the application. |
| 39 |
* |
| 40 |
* Results: |
| 41 |
* None: Tk_Main never returns here, so this procedure never |
| 42 |
* returns either. |
| 43 |
* |
| 44 |
* Side effects: |
| 45 |
* Whatever the application does. |
| 46 |
* |
| 47 |
*---------------------------------------------------------------------- |
| 48 |
*/ |
| 49 |
|
| 50 |
int |
| 51 |
main(argc, argv) |
| 52 |
int argc; /* Number of command-line arguments. */ |
| 53 |
char **argv; /* Values of command-line arguments. */ |
| 54 |
{ |
| 55 |
Tk_Main(argc, argv, Tcl_AppInit); |
| 56 |
return 0; /* Needed only to prevent compiler warning. */ |
| 57 |
} |
| 58 |
|
| 59 |
/* |
| 60 |
*---------------------------------------------------------------------- |
| 61 |
* |
| 62 |
* Tcl_AppInit -- |
| 63 |
* |
| 64 |
* This procedure performs application-specific initialization. |
| 65 |
* Most applications, especially those that incorporate additional |
| 66 |
* packages, will have their own version of this procedure. |
| 67 |
* |
| 68 |
* Results: |
| 69 |
* Returns a standard Tcl completion code, and leaves an error |
| 70 |
* message in interp->result if an error occurs. |
| 71 |
* |
| 72 |
* Side effects: |
| 73 |
* Depends on the startup script. |
| 74 |
* |
| 75 |
*---------------------------------------------------------------------- |
| 76 |
*/ |
| 77 |
|
| 78 |
int |
| 79 |
Tcl_AppInit(interp) |
| 80 |
Tcl_Interp *interp; /* Interpreter for application. */ |
| 81 |
{ |
| 82 |
if (Tcl_Init(interp) == TCL_ERROR) { |
| 83 |
return TCL_ERROR; |
| 84 |
} |
| 85 |
if (Tk_Init(interp) == TCL_ERROR) { |
| 86 |
return TCL_ERROR; |
| 87 |
} |
| 88 |
Tcl_StaticPackage(interp, "Tk", Tk_Init, (Tcl_PackageInitProc *) NULL); |
| 89 |
|
| 90 |
/* |
| 91 |
* Call the init procedures for included packages. Each call should |
| 92 |
* look like this: |
| 93 |
* |
| 94 |
* if (Mod_Init(interp) == TCL_ERROR) { |
| 95 |
* return TCL_ERROR; |
| 96 |
* } |
| 97 |
* |
| 98 |
* where "Mod" is the name of the module. |
| 99 |
*/ |
| 100 |
if (Itcl_Init(interp) == TCL_ERROR) { |
| 101 |
return TCL_ERROR; |
| 102 |
} |
| 103 |
if (Itk_Init(interp) == TCL_ERROR) { |
| 104 |
return TCL_ERROR; |
| 105 |
} |
| 106 |
Tcl_StaticPackage(interp, "Itcl", Itcl_Init, Itcl_SafeInit); |
| 107 |
Tcl_StaticPackage(interp, "Itk", Itk_Init, (Tcl_PackageInitProc *) NULL); |
| 108 |
|
| 109 |
/* |
| 110 |
* This is itclsh, so import all [incr Tcl] commands by |
| 111 |
* default into the global namespace. Fix up the autoloader |
| 112 |
* to do the same. |
| 113 |
*/ |
| 114 |
if (Tcl_Import(interp, Tcl_GetGlobalNamespace(interp), |
| 115 |
"::itcl::*", /* allowOverwrite */ 1) != TCL_OK) { |
| 116 |
return TCL_ERROR; |
| 117 |
} |
| 118 |
|
| 119 |
if (Tcl_Eval(interp, "auto_mkindex_parser::slavehook { _%@namespace import -force ::itcl::* }") != TCL_OK) { |
| 120 |
return TCL_ERROR; |
| 121 |
} |
| 122 |
|
| 123 |
/* |
| 124 |
* Call Tcl_CreateCommand for application-specific commands, if |
| 125 |
* they weren't already created by the init procedures called above. |
| 126 |
*/ |
| 127 |
if (Tix_Init(interp) == TCL_ERROR) { |
| 128 |
return TCL_ERROR; |
| 129 |
} |
| 130 |
Tcl_StaticPackage(interp, "Tix", Tix_Init, (Tcl_PackageInitProc *) NULL); |
| 131 |
|
| 132 |
/* |
| 133 |
Tix_SetRcFileName(interp, "~/.tixwishrc"); |
| 134 |
In the past, the interactive initialization file was inconsistent, |
| 135 |
and on Windows, $env(HOME) is undefined or most users don't even |
| 136 |
know where there HOME is (Profiles\User\Application Data\)! |
| 137 |
So a site wide initialization file tixwishrc.tcl is now used, |
| 138 |
which must be in the same directory as the executable. To restore |
| 139 |
the past behaviour, simply add the following line to that file: |
| 140 |
if {[file isfile [set file ~/.tixwishrc]]} {source $file} |
| 141 |
*/ |
| 142 |
|
| 143 |
return TCL_OK; |
| 144 |
} |