~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to tcl/browsehelpexe.c

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* an executable to launch browsehelp.tcl 
 
2
 * by Matthieu PHILIPPE 01/01/2003
 
3
 */
 
4
#include <string.h>
 
5
#include <stdio.h>
 
6
#include <tcl.h>
 
7
#include <tk.h>
 
8
char *getenv();
 
9
void flushTKEvents();
 
10
 
 
11
Tk_Window TKmainWindow=NULL;
 
12
Display *XTKdisplay;
 
13
int XTKsocket;
 
14
char TkScriptpath[1000];
 
15
 
 
16
int main(int argc, char *argv[]) 
 
17
{
 
18
  Tcl_Interp *interp;
 
19
  if (argc!=4)
 
20
    {
 
21
      printf("browsehelpexe: 3 arguments are needed !\n");
 
22
      return(1);
 
23
    }
 
24
  if (getenv("SCI")==(char *)NULL)
 
25
    {
 
26
      printf("The SCI environment variable is not set.\nTK initialisation failed !\n");
 
27
      return(1);
 
28
    }
 
29
  strcpy(TkScriptpath, getenv("SCI"));
 
30
  strcat(TkScriptpath, "/tcl/browsehelp.tcl");
 
31
 
 
32
#ifdef TCL_MAJOR_VERSION
 
33
#ifdef TCL_MINOR_VERSION
 
34
#if TCL_MAJOR_VERSION >= 8
 
35
#if TCL_MINOR_VERSION > 0  
 
36
  Tcl_FindExecutable(NULL);
 
37
#endif
 
38
#endif
 
39
#endif
 
40
#endif 
 
41
 
 
42
  interp = Tcl_CreateInterp();
 
43
  /* TK_AppInit*/
 
44
  if (Tcl_Init(interp) == TCL_ERROR) 
 
45
    {
 
46
      return TCL_ERROR;
 
47
    }
 
48
  if (Tk_Init(interp) == TCL_ERROR) 
 
49
    {
 
50
      /*return TCL_ERROR;*/
 
51
    }
 
52
  if (TKmainWindow == NULL)
 
53
    {
 
54
      TKmainWindow = Tk_MainWindow(interp);
 
55
      XTKdisplay = Tk_Display(TKmainWindow);
 
56
      XTKsocket = ConnectionNumber(XTKdisplay);
 
57
      Tk_GeometryRequest(TKmainWindow,200,200);
 
58
      Tcl_SetVar(interp, "manpath", argv[1],TCL_GLOBAL_ONLY);
 
59
      Tcl_SetVar(interp, "Home", argv[2],TCL_GLOBAL_ONLY);
 
60
      Tcl_SetVar(interp, "lang", argv[3],TCL_GLOBAL_ONLY);
 
61
      Tcl_SetVar(interp, "SciPath",getenv("SCI") ,TCL_GLOBAL_ONLY);
 
62
      Tcl_EvalFile(interp, TkScriptpath);
 
63
      Tcl_Eval(interp, "wm withdraw .");
 
64
      /*Tcl_Eval(interp, "catch {destroy $sciw}");*/
 
65
      Tcl_Eval(interp, "wm protocol $sciw WM_DELETE_WINDOW exit;");
 
66
      Tcl_Eval(interp, "proc quitapp {widget} {exit;}");
 
67
      flushTKEvents();
 
68
    }
 
69
  Tk_MainLoop();
 
70
  return(0);
 
71
}
 
72
 
 
73
void flushTKEvents()
 
74
{
 
75
  while (Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT)==1) {}
 
76
}