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

« back to all changes in this revision

Viewing changes to routines/gtksci/menus.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
/*------------------------------------------------------------------------
 
2
 *    Copyright (C) 2001-2003 Enpc/Jean-Philippe Chancelier
 
3
 *    jpc@cermics.enpc.fr 
 
4
 *    main menu and graphic window menus 
 
5
 *--------------------------------------------------------------*/
 
6
 
 
7
#include <stdio.h>
 
8
#include <stdlib.h>
 
9
#include <signal.h>
 
10
#include <string.h>
 
11
#include <math.h>
 
12
#include <sys/stat.h>
 
13
#include <time.h>
 
14
#include <unistd.h>
 
15
#include "../graphics/Math.h"
 
16
#include "../graphics/bcg.h" 
 
17
#include "../graphics/Graphics.h" 
 
18
#include "../sun/Sun.h" 
 
19
#include "../sun/men_Sutils.h"
 
20
/* #include "../menusX/men_scilab.h"*/
 
21
#include "All-extern.h"
 
22
 
 
23
 
 
24
#define PI0 (integer *) 0
 
25
#define PD0 (double *) 0
 
26
 
 
27
void menu_entry_show(menu_entry *m);  /* only used for debug */ 
 
28
extern void create_scilab_about(void); 
 
29
extern int prtdlg  __PARAMS((integer *flag, char *printer, integer *colored, integer *orientation, char *file, integer *ok));
 
30
extern int sci_get_file_window __PARAMS((char *, char **, char *, int,int, int *,char *));
 
31
 
 
32
extern char GetDriver();
 
33
static void *sci_window_initial_menu() ;
 
34
static void sci_menu_to_item_factory(GtkItemFactory *ifactory,menu_entry *m);
 
35
static void sci_menu_delete(menu_entry **m, char *name) ;
 
36
static int sci_menu_add(menu_entry **m,int winid,char *name,char** entries,int ne, 
 
37
                        int action_type,char *fname);
 
38
static menu_entry * sci_menu_set_status(menu_entry *m,int winid,char *name,
 
39
                                        int subid,int status);
 
40
static int call_predefined_callbacks(char *name, int winid);
 
41
 
 
42
static void sci_factory_add_menu_entry(GtkItemFactory *ifactory,menu_entry *m);
 
43
static void sci_factory_add_last_menu_entry(GtkItemFactory *ifactory,menu_entry *m);
 
44
/*--------------------------------------------------------------
 
45
 * main menu. i.e the menu of the main scilab window 
 
46
 *            this menu is attached to a zterm through a plug widget
 
47
 *--------------------------------------------------------------*/
 
48
 
 
49
static menu_entry *main_menu_entries = NULL;
 
50
static GtkItemFactory  *main_item_factory= NULL;
 
51
 
 
52
/*
 
53
 * used when the menu is plugged 
 
54
 */
 
55
 
 
56
void create_plugged_main_menu() 
 
57
{
 
58
  static GtkWidget *menubar = NULL; 
 
59
  static int first = 0; 
 
60
  static GtkWidget *Plug;
 
61
  static GtkItemFactory *item_factory;
 
62
  GtkAccelGroup *accel_group = NULL ; 
 
63
  char * plug_info = getenv("SCIWIN");
 
64
 
 
65
  if ( plug_info == NULL) return ;
 
66
 
 
67
  main_item_factory= item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", 
 
68
                                                          accel_group);
 
69
  
 
70
  if ( first == 0 ) {
 
71
    Plug = gtk_plug_new(atoi(getenv("SCIWIN")));
 
72
    main_menu_entries = sci_window_initial_menu();
 
73
    if ( main_menu_entries == NULL) return;
 
74
    first = 1;
 
75
  }
 
76
 
 
77
  /* This function generates the menu items from scilab description */
 
78
  /* Attention il faut aussi gerer les menu en set unest XXXXX */
 
79
 
 
80
  sci_menu_to_item_factory(item_factory, main_menu_entries);
 
81
  
 
82
  /* Attach the new accelerator group to the window. */
 
83
  /* gtk_window_add_accel_group (GTK_WINDOW (window), accel_group); */ 
 
84
  
 
85
  /* Finally, return the actual menu bar created by the item factory. */ 
 
86
 
 
87
  if ( menubar != NULL) gtk_widget_destroy(menubar);
 
88
  menubar = gtk_item_factory_get_widget (item_factory, "<main>");
 
89
  gtk_container_add(GTK_CONTAINER(Plug),menubar);
 
90
  if ( accel_group != NULL ) 
 
91
    gtk_window_add_accel_group (GTK_WINDOW (Plug), accel_group);
 
92
  gtk_widget_show_all(Plug);
 
93
 
 
94
}
 
95
 
 
96
 
 
97
 
 
98
/*
 
99
 * used when zterm is plugged 
 
100
 */
 
101
 
 
102
GtkWidget *create_main_menu( GtkWidget  *window)
 
103
{
 
104
  static int first = 0;
 
105
  static GtkWidget *menubar = NULL; 
 
106
  static GtkItemFactory *item_factory;
 
107
  GtkAccelGroup *accel_group = NULL ; 
 
108
  
 
109
  /* Make an accelerator group (shortcut keys) */
 
110
  if ( window != NULL)  accel_group = gtk_accel_group_new ();
 
111
 
 
112
  main_item_factory= item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", 
 
113
                                                          accel_group);
 
114
  if ( first == 0 ) {
 
115
    main_menu_entries = sci_window_initial_menu();
 
116
    if ( main_menu_entries == NULL) return NULL;
 
117
    first = 1;
 
118
  }
 
119
 
 
120
  /* This function generates the menu items from scilab description */
 
121
  /* Attention il faut aussi gerer les menu en set unset XXXXX */
 
122
 
 
123
  sci_menu_to_item_factory(item_factory, main_menu_entries);
 
124
  
 
125
  /* Finally, return the actual menu bar created by the item factory. */ 
 
126
  if ( menubar != NULL) gtk_widget_destroy(menubar);
 
127
  menubar = gtk_item_factory_get_widget (item_factory, "<main>");
 
128
  if ( window != NULL )  gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
 
129
  return menubar;
 
130
 
 
131
}
 
132
 
 
133
 
 
134
 
 
135
/*--------------------------------------------------------------
 
136
 * Graphic window menu in main menu 
 
137
 *--------------------------------------------------------------*/
 
138
 
 
139
static integer lab_count = 0;
 
140
static char gwin_name[100];
 
141
 
 
142
 
 
143
void MenuFixCurrentWin(int ivalue)
 
144
{
 
145
  int w=-1;
 
146
  char *graphic_entries[] = { "Create or Select||$gwselect",
 
147
                              "Raise||$gwraise", 
 
148
                              "Delete||$gwdelete",
 
149
                              "+||$gwplus" ,
 
150
                              "-||$gwminus" } ;
 
151
  if ( ivalue == lab_count ) return ; 
 
152
  if ( main_item_factory == NULL ) return;
 
153
  sprintf( gwin_name, "Graphic Window %d", (int) lab_count );
 
154
  C2F(delbtn)(&w, gwin_name);
 
155
  sprintf( gwin_name, "Graphic Window %d", (int) ivalue );
 
156
  lab_count = ivalue;
 
157
  sci_menu_add(&main_menu_entries,-1,gwin_name,
 
158
               graphic_entries,5,0,"$graphic_window");
 
159
  sci_factory_add_last_menu_entry(main_item_factory,main_menu_entries);
 
160
}
 
161
 
 
162
 
 
163
/*--------------------------------------------------------------
 
164
 * Graphic window menu 
 
165
 *--------------------------------------------------------------*/
 
166
 
 
167
void create_graphic_window_menu(struct BCG *dd)
 
168
{
 
169
  GtkAccelGroup *accel_group=  gtk_accel_group_new ();
 
170
 
 
171
  /* Attach the new accelerator group to the window. */
 
172
  gtk_window_add_accel_group (GTK_WINDOW (dd->window), accel_group);
 
173
 
 
174
  dd->item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", 
 
175
                                           accel_group);
 
176
  
 
177
  /* This function generates the menu items from scilab description */
 
178
  /* Attention il faut aussi gerer les menu en set unest XXXXX */
 
179
  
 
180
  sci_menu_to_item_factory(dd->item_factory,dd->menu_entries);
 
181
  
 
182
  /* Finally, return the actual menu bar created by the item factory. */ 
 
183
 
 
184
  dd->menubar = gtk_item_factory_get_widget (dd->item_factory, "<main>");
 
185
  gtk_box_pack_start (GTK_BOX (dd->vbox),dd->menubar, FALSE, TRUE, 0);
 
186
  gtk_widget_show (dd->menubar);
 
187
  return ;
 
188
}
 
189
 
 
190
/**********************************************************
 
191
 * General routines for dynamic menu item creation and deletion
 
192
 ***********************************************************/
 
193
 
 
194
/*---------------------------------------------------
 
195
 * Delete the button named button_name in the menu of window 
 
196
 * number win_num 
 
197
 *---------------------------------------------------*/
 
198
 
 
199
int C2F(delbtn)(int *win_num,char *button_name)
 
200
{
 
201
  GtkItemFactory  *item_factory;
 
202
  static char btn[64];
 
203
  char *p,*but= button_name;
 
204
  p = btn ; 
 
205
  *(p++) = '/';
 
206
  while ( *but != '\0' ) {
 
207
    if ( *but == '/') break ; 
 
208
    else if ( *but == '_') but++ ; 
 
209
    else { *(p++)= *(but++);}
 
210
  }
 
211
  *p = '\0';
 
212
  if ( *win_num == -1 ) 
 
213
    {
 
214
      item_factory = main_item_factory; 
 
215
      sci_menu_delete(&main_menu_entries,button_name);
 
216
    }
 
217
  else 
 
218
    {
 
219
      BCG *dd = GetWindowXgcNumber(*win_num);
 
220
      if ( dd == NULL || dd->item_factory == NULL) return 0;
 
221
      item_factory = dd->item_factory;
 
222
      sci_menu_delete(&dd->menu_entries,button_name);
 
223
    }
 
224
  gtk_item_factory_delete_item (item_factory,btn);
 
225
  return 0;
 
226
}
 
227
 
 
228
/*----------------------------------------------------------------
 
229
 * Add dynamically buttons and menus in The Scilab Graphic Window
 
230
 * or in the Scilab main window 
 
231
 * Scilab interface for the AddMenu function 
 
232
 * Add a menu in  window  number win_num or in Main window
 
233
 *
 
234
 *  win_num     : graphic window number or -1 for main scilab window
 
235
 *  button_name : label of button
 
236
 *  entries     : labels of submenus if any (in scilab code)
 
237
 *  ptrentries  : table of pointers on each entries
 
238
 *  ne          : number of submenus
 
239
 *  typ         : Action mode
 
240
 *                typ==0 : interpreted (execution of scilab instruction
 
241
 *                typ!=0 : hard coded a routine is called
 
242
 *  fname;      : name of the action function  
 
243
 *----------------------------------------------------------------*/
 
244
 
 
245
int C2F(addmen)(win_num,button_name,entries,ptrentries,ne,typ,fname,ierr)
 
246
     integer *win_num,*entries,*ptrentries,*ne,*ierr,*typ;
 
247
     char *button_name,*fname;
 
248
{
 
249
  char ** menu_entries;
 
250
  *ierr =0;
 
251
  if (*ne!=0) {
 
252
    ScilabMStr2CM(entries,ne,ptrentries,&menu_entries,ierr);
 
253
    if ( *ierr == 1) return(0);
 
254
  }
 
255
  AddMenu(win_num,button_name,menu_entries,ne,typ,fname,ierr);
 
256
  return(0);
 
257
}
 
258
 
 
259
 
 
260
/*---------------------------------------------------
 
261
 * Add a menu in  window  number wun_num or in Main window
 
262
 *  win_num     : graphic window number or -1 for main scilab window
 
263
 *  button_name : label of button
 
264
 *  entries     : labels of submenus if any
 
265
 *  ne          : number of submenus
 
266
 *  typ         : Action mode
 
267
 *                typ==0 : interpreted (execution of scilab instruction
 
268
 *  typ!=0 : hard coded a routine is called
 
269
 *  fname;      : name of the action function  
 
270
 *---------------------------------------------------*/
 
271
 
 
272
void AddMenu(win_num, button_name, entries, ne, typ, fname, ierr)
 
273
     integer *win_num;
 
274
     char *button_name;
 
275
     char **entries;
 
276
     integer *ne;
 
277
     integer *typ;
 
278
     char *fname;
 
279
     integer *ierr;
 
280
 
281
  if ( *win_num == -1 ) 
 
282
    {
 
283
      /* Scilab main menu */ 
 
284
      if ( main_item_factory == NULL ) return;
 
285
      if ( sci_menu_add(&main_menu_entries,*win_num,button_name,entries,*ne,
 
286
                        *typ,fname) == 1 ) 
 
287
        {
 
288
          *ierr=1;
 
289
          return ;
 
290
        }
 
291
      sci_factory_add_last_menu_entry(main_item_factory,main_menu_entries);
 
292
    }
 
293
  else 
 
294
    {
 
295
      BCG *dd = GetWindowXgcNumber(*win_num);
 
296
      if ( dd == NULL || dd->item_factory == NULL ) return;
 
297
      if ( sci_menu_add(&dd->menu_entries,*win_num,button_name,entries,
 
298
                        *ne,*typ,fname) == 1 ) 
 
299
        {
 
300
          *ierr=1;
 
301
          return ;
 
302
        }
 
303
      sci_factory_add_last_menu_entry(dd->item_factory,dd->menu_entries);
 
304
    }
 
305
}
 
306
 
 
307
/*--------------------------------------------------
 
308
 * Activate or deactivate a menu 
 
309
 *---------------------------------------------------*/
 
310
 
 
311
void SetUnsetMenu(win_num, button_name, ne,flag)
 
312
     integer *win_num;
 
313
     char *button_name;
 
314
     integer *ne;
 
315
     int flag;
 
316
 
317
  menu_entry *e,*entries;
 
318
  GtkItemFactory  *item_factory;
 
319
  if ( *win_num == -1 ) 
 
320
    {
 
321
      item_factory = main_item_factory; 
 
322
      entries =main_menu_entries;
 
323
    }
 
324
  else 
 
325
    {
 
326
      BCG *dd = GetWindowXgcNumber(*win_num);
 
327
      if ( dd == NULL || dd->item_factory == NULL) return ;
 
328
      item_factory = dd->item_factory;
 
329
      entries = dd->menu_entries;
 
330
    }
 
331
  
 
332
  e = sci_menu_set_status(entries,*win_num,button_name,*ne,flag);
 
333
  if ( e != NULL) 
 
334
    {
 
335
      GtkWidget *w;
 
336
      char buf[128];
 
337
      if ( *ne == 0)
 
338
        { 
 
339
          /* top menu */ 
 
340
          char *loc = e->name, *pbuf; 
 
341
          strcpy(buf,"<main>/");
 
342
          pbuf = buf + strlen(buf);
 
343
          while ( *loc != '\0' ) 
 
344
            { 
 
345
              if ( *loc != '_' ) { *pbuf = *loc ; pbuf++; loc++;} 
 
346
              else loc++;
 
347
            }
 
348
          *pbuf = '\0';
 
349
        }
 
350
      else 
 
351
        {
 
352
          /* sub_menu */
 
353
          char *loc = e->menu->name, *pbuf; 
 
354
          strcpy(buf,"<main>/");
 
355
          pbuf = buf + strlen(buf);
 
356
          while ( *loc != '\0' ) 
 
357
            { 
 
358
              if ( *loc != '_' ) { *pbuf = *loc ; pbuf++; loc++;} 
 
359
              else loc++;
 
360
            }
 
361
          *pbuf = '/';pbuf++;
 
362
          loc = e->name ; 
 
363
          while ( *loc != '\0' ) 
 
364
            { 
 
365
              if ( *loc != '_' ) { *pbuf = *loc ; pbuf++; loc++;} 
 
366
              else loc++;
 
367
            }
 
368
          *pbuf = '\0';
 
369
        }
 
370
      w = gtk_item_factory_get_widget (item_factory,buf);
 
371
      /* rend le menu non sensitif */
 
372
      if ( w != NULL) 
 
373
        {
 
374
          if ( flag == TRUE ) 
 
375
            gtk_widget_set_sensitive (w, TRUE);
 
376
          else 
 
377
            gtk_widget_set_sensitive (w, FALSE);
 
378
        }
 
379
    }
 
380
}
 
381
 
 
382
/** activate a menu (scilab interface) **/
 
383
 
 
384
int C2F(setmen)(win_num,button_name,entries,ptrentries,ne,ierr)
 
385
     integer *win_num,*entries,*ptrentries,*ne,*ierr;
 
386
     char *button_name;
 
387
{
 
388
  SetUnsetMenu(win_num,button_name,ne,TRUE);
 
389
  return(0);
 
390
}
 
391
 
 
392
int C2F(unsmen)(win_num,button_name,entries,ptrentries,ne,ierr)
 
393
     integer *win_num,*entries,*ptrentries,*ne,*ierr;
 
394
     char *button_name;
 
395
{
 
396
  SetUnsetMenu(win_num,button_name,ne,FALSE);
 
397
  return(0);
 
398
}
 
399
 
 
400
/*--------------------------------------------------------
 
401
 * A Set of functions to make addmenu/delmenu/set-unsetmenu 
 
402
 * work with itemfactory menus of gtk 
 
403
 * It seams that toplevel menu buttons cannot 
 
404
 * be deleted in itemfactory. 
 
405
 * thus we recreate a new menubar when menus are deleted 
 
406
 *--------------------------------------------------------*/
 
407
 
 
408
static void submenu_entry_set_menu(menu_entry *subs,menu_entry *father);
 
409
 
 
410
/* checks that name and name1 are the same taking care of _ */
 
411
 
 
412
static int is_menu_name(char *name,char *name1) 
 
413
{
 
414
  while ( *name != 0) 
 
415
    {
 
416
      if ( *name == '_' ) 
 
417
        {
 
418
          name++;
 
419
          if ( *name1 == '_' )  name1++;
 
420
        }
 
421
      else if ( *name != *name1 ) {
 
422
        return 1;
 
423
      }
 
424
      else {
 
425
        name++; name1++;
 
426
      }
 
427
    }
 
428
  if ( *name1 != 0) return 1;
 
429
  return 0;
 
430
}
 
431
 
 
432
void menu_entry_show(menu_entry *m)
 
433
{
 
434
  if ( m== NULL) return ;
 
435
  fprintf(stdout,"name = %s ",m->name);
 
436
  fprintf(stdout,"status %d nsub=%d win=%d action=%d fname=%s\n",
 
437
          m->status,m->nsub,m->winid,m->action_type,m->fname);
 
438
  if ( m->accel != NULL) 
 
439
    fprintf(stdout,"accel %s \n",m->accel);
 
440
  if ( m->subs != NULL) 
 
441
    {
 
442
      fprintf(stdout,"{\n");
 
443
      menu_entry_show(m->subs);
 
444
      fprintf(stdout,"}\n");
 
445
    }
 
446
  menu_entry_show(m->next);
 
447
}
 
448
 
 
449
menu_entry *new_menu_entry(char *name,char *accel,int status,int nsub,
 
450
                           menu_entry *subs,int winid,
 
451
                           int action_type,char *fname)
 
452
{
 
453
  menu_entry *loc; 
 
454
  if ((loc = MALLOC(sizeof(menu_entry)))== NULL) 
 
455
    return NULL;
 
456
  if ((loc->name = MALLOC((strlen(name)+1)*sizeof(char)))==NULL) 
 
457
    return NULL;
 
458
  strcpy(loc->name,name);
 
459
 
 
460
  if (accel != NULL) 
 
461
    {
 
462
      if ((loc->accel = MALLOC((strlen(accel)+1)*sizeof(accel)))==NULL) 
 
463
        return NULL;
 
464
      strcpy(loc->accel,accel);
 
465
    }
 
466
  else loc->accel = NULL;
 
467
 
 
468
  if (fname != NULL) 
 
469
    {
 
470
      if ((loc->fname = MALLOC((strlen(fname)+1)*sizeof(fname)))==NULL) 
 
471
        return NULL;
 
472
      strcpy(loc->fname,fname);
 
473
    }
 
474
  else loc->fname= NULL;
 
475
 
 
476
  loc->status = status;
 
477
  loc->nsub = nsub;
 
478
  loc->subs = subs;
 
479
  loc->winid = winid;
 
480
  loc->action_type = action_type;
 
481
  loc->menu= NULL;
 
482
  loc->next = NULL;
 
483
  submenu_entry_set_menu(loc->subs,loc);
 
484
  return loc;
 
485
}
 
486
 
 
487
static void submenu_entry_set_menu(menu_entry *subs,menu_entry *father)
 
488
{
 
489
  if ( subs == NULL) return ;
 
490
  subs->menu = father ;
 
491
  submenu_entry_set_menu(subs->next,father);
 
492
}
 
493
 
 
494
void menu_entry_delete(menu_entry *me)
 
495
{
 
496
  if ( me == NULL) return ;
 
497
  /* recursive free  */
 
498
  FREE(me->name); 
 
499
  FREE(me->fname); 
 
500
  FREE(me->accel); 
 
501
  menu_entry_delete(me->subs);
 
502
  menu_entry_delete(me->next);
 
503
  FREE(me);
 
504
}
 
505
 
 
506
void submenu_add(menu_entry *me,menu_entry *more)
 
507
{
 
508
  menu_entry *loc = me->subs;
 
509
  if (loc == NULL) me->subs = more;
 
510
  while ( loc->next != NULL) loc = loc->next ;
 
511
  loc->next = more;
 
512
}
 
513
 
 
514
 
 
515
/****************************************************
 
516
 * Add a menu in a menu_item list
 
517
 *  win_num     : graphic window number or -1 for main scilab window
 
518
 *  name        : label of menu button
 
519
 *                if entries is empty then name can be 
 
520
 *                   "name|accelerator|specific_action"
 
521
 *  entries     : labels of submenus if any. each entry is a string 
 
522
 *                "entry_name" or "entry_name|accelerator|specific_action"
 
523
 * 
 
524
 *  ne          : number of submenus
 
525
 *  action_type : Action mode
 
526
 *                action_type==0 : interpreted (execution of scilab instruction
 
527
 *                action_type!=0 : hard coded a routine is called
 
528
 *  fname;      : name of the action function  
 
529
 ****************************************************/
 
530
 
 
531
 
 
532
static menu_entry *gtksci_new_menu_entry(char *entry_name,int winid,int pos,int action_type,char *fname)
 
533
{
 
534
  menu_entry *menu ; 
 
535
  char *entry=NULL,*accel=NULL,*action=NULL;
 
536
  entry=strdup(entry_name);
 
537
  accel = strchr(entry,'|');
 
538
  if (accel != NULL) 
 
539
    {
 
540
      *accel = '\0'; accel +=1;
 
541
      action =  strchr(accel,'|');
 
542
      if ( action != NULL ) 
 
543
        { 
 
544
          *action = '\0'; action+=1;
 
545
        }
 
546
    }
 
547
  if (action == NULL) action = fname ;
 
548
  menu = new_menu_entry(entry,accel,1,pos+1,NULL,winid,action_type,action);
 
549
  if ( menu == NULL) 
 
550
    {
 
551
      /* XXXXX clean and return */
 
552
      if(entry != NULL) free(entry);
 
553
      return NULL;
 
554
    }
 
555
  return menu;
 
556
}
 
557
 
 
558
 
 
559
 
 
560
static int sci_menu_add(menu_entry **m,int winid,char *name,char** entries,int ne, 
 
561
                        int action_type,char *fname)
 
562
{  
 
563
  int i;
 
564
  char *entry=NULL;
 
565
  /* here we must find the menu_entry associated to win_num */
 
566
  menu_entry *me1=NULL,*me2,*top,*subs=NULL;
 
567
  /* first build the sub_menus */
 
568
  for (i=0 ; i < ne ;i++) 
 
569
    {
 
570
      me2 = gtksci_new_menu_entry(entries[i],winid,i,action_type,fname);
 
571
      if ( me2 == NULL) 
 
572
        {
 
573
          return 1;
 
574
        }
 
575
      if ( i != 0) me1->next = me2;
 
576
      else { subs = me2;}
 
577
      me1=me2;
 
578
    }
 
579
  if ( ne == 0 ) 
 
580
    {
 
581
      top = gtksci_new_menu_entry(name,winid,0,action_type,fname);
 
582
    }
 
583
  else
 
584
    {
 
585
      /* now the menu entry */
 
586
      top = new_menu_entry(name,NULL,1,1,subs,winid,action_type,fname);
 
587
    }
 
588
  if ( top == NULL) 
 
589
    {
 
590
      /* XXXXX clean and return */
 
591
      if(entry != NULL) free(entry);
 
592
      return 1;
 
593
    }
 
594
  if ( *m == NULL) *m = top ;
 
595
  else 
 
596
    { 
 
597
      menu_entry *loc= *m ; 
 
598
      while (loc->next != NULL) loc=loc->next;
 
599
      loc->next = top;
 
600
    }
 
601
  if(entry != NULL) free(entry);
 
602
  return 0;
 
603
}
 
604
 
 
605
/****************************************************
 
606
 *Delete the menu name in menu_entry list 
 
607
 ****************************************************/
 
608
 
 
609
static void sci_menu_delete(menu_entry **m, char *name) 
 
610
 
611
  menu_entry *loc,*nloc;
 
612
  if ( *m == NULL ) return ;
 
613
  /* we want to delete a toplevel menu */
 
614
  loc = *m ;
 
615
  if ( is_menu_name((*m)->name,name) ==0) 
 
616
    {
 
617
      /* we delete the first entry of m */
 
618
      *m = (*m)->next ; 
 
619
      loc->next = NULL;
 
620
      menu_entry_delete(loc);
 
621
      return ;
 
622
    }
 
623
  nloc = loc->next;
 
624
  while ( nloc != NULL) 
 
625
    {
 
626
      if ( is_menu_name(nloc->name,name)==0) 
 
627
        {
 
628
          loc->next = nloc->next ;
 
629
          nloc->next = NULL;
 
630
          menu_entry_delete(nloc);
 
631
          return ;
 
632
        }
 
633
      loc = nloc;
 
634
      nloc= nloc->next ;
 
635
    }
 
636
}
 
637
 
 
638
/****************************************************
 
639
 * Set the status of a menu 
 
640
 ****************************************************/
 
641
 
 
642
 
 
643
static menu_entry * sci_menu_set_status(menu_entry *m,int winid,char *name,
 
644
                                        int subid,int status)
 
645
{  
 
646
  menu_entry *loc = m ;
 
647
  while ( loc != NULL) 
 
648
    {
 
649
      if ( is_menu_name(loc->name,name)==0) 
 
650
        {
 
651
          if ( subid == 0) 
 
652
            {
 
653
              loc->status = status ;
 
654
              return loc;
 
655
            }
 
656
          else 
 
657
            {
 
658
              int count;
 
659
              /* walk to find submenu number subid */
 
660
              loc = loc->subs; 
 
661
              for ( count = 0 ; count < subid -1 ; count++) 
 
662
                loc = (loc == NULL) ? NULL : loc->next ;
 
663
              if ( loc == NULL) return NULL ;
 
664
              loc->status = status;
 
665
              return loc;
 
666
            }
 
667
        }
 
668
      loc = loc->next ;
 
669
    }
 
670
  return NULL;
 
671
}
 
672
 
 
673
/*------------------------------------------------------
 
674
 * menu callback 
 
675
 *------------------------------------------------------*/
 
676
 
 
677
static void sci_menu_default_callback (gpointer  callback_data,
 
678
                                       guint     callback_action,
 
679
                                       GtkWidget  *widget)
 
680
{
 
681
  static char buf[256];
 
682
  menu_entry *m = (menu_entry *) callback_data;
 
683
#ifdef DEBUG
 
684
  fprintf(stdout,"menu activated \"%s\"", 
 
685
          gtk_item_factory_path_from_widget (widget));
 
686
#endif 
 
687
  if ( m== NULL) return ;
 
688
  /* 
 
689
     fprintf(stdout,"name = %s ",m->name);
 
690
     fprintf(stdout,"status %d nsub=%d win=%d action=%d fname=%s\n",
 
691
     m->status,m->nsub,m->winid,m->action_type,m->fname);
 
692
  */
 
693
 
 
694
  if ( call_predefined_callbacks(m->fname, m->winid)==1) return ;
 
695
 
 
696
  if (m->action_type == 0) 
 
697
    { 
 
698
      /* Interpreted mode : we store the action on a queue */
 
699
      if ( m->winid < 0 ) 
 
700
        sprintf(buf,"execstr(%s(%d))",m->fname,m->nsub);
 
701
      else 
 
702
        sprintf(buf,"execstr(%s_%d(%d))",m->fname,m->winid,m->nsub);
 
703
      StoreCommand(buf);
 
704
    }
 
705
  else if (m->action_type == 2) 
 
706
    { 
 
707
      /* Interpreted mode : we store the action on a queue */
 
708
      if ( m->winid < 0 ) 
 
709
        sprintf(buf,"%s(%d)",m->fname,m->nsub);
 
710
      else 
 
711
        sprintf(buf,"%s(%d,%d)",m->fname,m->nsub,m->winid);
 
712
      StoreCommand(buf);
 
713
    }
 
714
  else 
 
715
    { 
 
716
      /* hard coded mode */
 
717
      int rep ;
 
718
      C2F(setfbutn)(m->fname,&rep);
 
719
      if ( rep == 0) 
 
720
        F2C(fbutn)((m->fname),&(m->winid),&(m->nsub));
 
721
    }
 
722
}
 
723
 
 
724
 
 
725
/*------------------------------------------------------
 
726
 * fill an item factory with a menu_entry description 
 
727
 *------------------------------------------------------*/
 
728
 
 
729
static void sci_menu_to_item_factory(GtkItemFactory *ifactory,menu_entry *m)
 
730
{
 
731
  while ( m != NULL) 
 
732
    {
 
733
      sci_factory_add_menu_entry(ifactory,m);
 
734
      m= m->next;
 
735
    }
 
736
}
 
737
 
 
738
/*-------------------------------------------------------------------
 
739
 * build items associated to the last menu_entry contained in m 
 
740
 * and add them in the factory ifactory 
 
741
 *-------------------------------------------------------------------*/
 
742
 
 
743
static void sci_factory_add_last_menu_entry(GtkItemFactory *ifactory,menu_entry *m)
 
744
{
 
745
  if ( m == NULL ) return ;
 
746
  while ( m->next != NULL) m = m->next ; 
 
747
  sci_factory_add_menu_entry(ifactory,m);
 
748
}
 
749
 
 
750
 
 
751
/*-------------------------------------------------------------------
 
752
 * build items associated to the first menu_entry contained in m 
 
753
 * and add them in the factory ifactory 
 
754
 *-------------------------------------------------------------------*/
 
755
 
 
756
static void sci_factory_add_menu_entry(GtkItemFactory *ifactory,menu_entry *m)
 
757
{
 
758
  char buf_path[128];
 
759
  static GtkItemFactoryEntry entry = { NULL,NULL, sci_menu_default_callback,0,NULL};
 
760
  if ( m == NULL ) return ;
 
761
  sprintf(buf_path,"/%s",m->name);
 
762
  entry.path = buf_path;
 
763
  entry.accelerator = m->accel;
 
764
  if ( m->subs == NULL) 
 
765
    {
 
766
      entry.item_type = "<Item>";
 
767
      gtk_item_factory_create_item(ifactory,&entry,(void *)m,1);
 
768
    }
 
769
  else 
 
770
    {
 
771
      menu_entry *loc;
 
772
      if ( is_menu_name(m->name,"Help")==0) 
 
773
        entry.item_type = "<LastBranch>";
 
774
      else 
 
775
        entry.item_type = "<Branch>";
 
776
      entry.callback = NULL;
 
777
      gtk_item_factory_create_item(ifactory,&entry,(void *)m,1);
 
778
      loc =  m->subs ; 
 
779
      entry.item_type = "<Item>";
 
780
      while ( loc != NULL) 
 
781
        {
 
782
          sprintf(buf_path,"/%s/%s",m->name,loc->name);
 
783
          entry.path = buf_path;
 
784
          entry.accelerator = loc->accel;
 
785
          entry.callback = sci_menu_default_callback;
 
786
          gtk_item_factory_create_item(ifactory,&entry,(void*)loc,1);
 
787
          loc = loc->next;
 
788
        }
 
789
    }
 
790
}
 
791
 
 
792
 
 
793
 
 
794
 
 
795
void * graphic_initial_menu(int winid) {
 
796
  menu_entry *m = NULL;
 
797
  char *file_entries[] = { "_Clear||$clear",
 
798
                           "_Select||$select",
 
799
                           "_Print|<control>P|$print",
 
800
                           "_Export|<control>E|$export",
 
801
                           "S_ave|<control>S|$save",
 
802
                           "L_oad|<control>L|$load",
 
803
                           "C_lose||$close" };
 
804
  sci_menu_add(&m,winid,"_File",file_entries,7,0,"$file");
 
805
  sci_menu_add(&m,winid,"_Zoom",NULL,0,0,"$zoom");
 
806
  sci_menu_add(&m,winid,"_UnZoom",NULL,0,0,"$unzoom");
 
807
  sci_menu_add(&m,winid,"3D _Rot.",NULL,0,0,"$rot3d");
 
808
  return m;
 
809
}
 
810
 
 
811
static void * sci_window_initial_menu() 
 
812
{
 
813
  menu_entry *m = NULL;
 
814
  int winid = -1;
 
815
  char *file_entries[] = { "File _Operations||$fileops",
 
816
                           "_Kill||$kill",
 
817
                           "_Quit|<control>Q|$quit" } ;
 
818
  char *control_entries[] = { "Resume||$resume",
 
819
                              "Abort||$abort",
 
820
                              "Restart||$restart",
 
821
                              "Stop||$stop" };
 
822
  char *graphic_entries[] = { "Create or Select||$gwselect",
 
823
                              "Raise||$gwraise", 
 
824
                              "Delete||$gwdelete",
 
825
                              "+||$gwplus" ,
 
826
                              "-||$gwminus" } ;
 
827
        
 
828
  char *help_entries[] = { "Scilab Help||$help",
 
829
                           "About||$about"};
 
830
  sci_menu_add(&m,winid,"_File",file_entries,3,0,"$file");
 
831
  sci_menu_add(&m,winid,"_Control",control_entries,4,0,"$zoom");
 
832
  sci_menu_add(&m,winid,"_Demos",NULL,0,0,"$demos");
 
833
  sci_menu_add(&m,winid,"Graphic Window 0",graphic_entries,5,0,"$graphic_window");
 
834
  sci_menu_add(&m,winid,"Help",help_entries,2,0,"$help");
 
835
  return m;
 
836
}
 
837
 
 
838
/**************************************************************
 
839
 * predefined actions for menus 
 
840
 **************************************************************/
 
841
 
 
842
/*-----------------------------------------------------------------
 
843
 * To clear the graphic window and clear the recorded graphics 
 
844
 * w and client_data are unused 
 
845
 *-----------------------------------------------------------------*/
 
846
 
 
847
static void scig_menu_erase(int winid) 
 
848
{
 
849
  scig_erase(winid);
 
850
}
 
851
 
 
852
/*----------------------------------------------
 
853
 * To select the graphic window 
 
854
 -----------------------------------------------*/
 
855
 
 
856
static void scig_menu_select(int winid)
 
857
{
 
858
  scig_sel(winid);
 
859
}
 
860
 
 
861
/*----------------------------------------------
 
862
 * To delete the graphic window 
 
863
 -----------------------------------------------*/
 
864
 
 
865
/* add handlers for delete action */
 
866
 
 
867
void scig_deletegwin_handler_none (win)int win; {};
 
868
 
 
869
void scig_deletegwin_handler_sci (int win)
 
870
 
 
871
{
 
872
  static char buf[256];
 
873
  struct BCG *SciGc;
 
874
 
 
875
  SciGc = GetWindowXgcNumber(win);
 
876
  if (strlen(SciGc->EventHandler)!=0) {
 
877
    sprintf(buf,"%s(%d,0,0,-1000)",SciGc->EventHandler,win);
 
878
    StoreCommand(buf);
 
879
    }
 
880
};
 
881
static Scig_deletegwin_handler scig_deletegwin_handler = scig_deletegwin_handler_sci;
 
882
/*static Scig_deletegwin_handler scig_deletegwin_handler = scig_deletegwin_handler_none;*/
 
883
 
 
884
Scig_deletegwin_handler set_scig_deletegwin_handler(f) 
 
885
     Scig_deletegwin_handler f;
 
886
{
 
887
  Scig_deletegwin_handler old = scig_deletegwin_handler;
 
888
  scig_deletegwin_handler = f;
 
889
  return old;
 
890
}
 
891
 
 
892
void reset_scig_deletegwin_handler() 
 
893
{
 
894
  scig_deletegwin_handler = scig_deletegwin_handler_sci;
 
895
}
 
896
 
 
897
/* delete action */
 
898
 
 
899
extern void  delete_sgwin_entities(int winid,int v_flag);
 
900
 
 
901
 
 
902
static void scig_menu_delete(int winid) 
 
903
{
 
904
  int v_flag = 1;
 
905
  scig_erase(winid);
 
906
  if (version_flag() == 0) {DeleteObjs(winid); v_flag = 0;}
 
907
  scig_deletegwin_handler(winid);
 
908
  DeleteSGWin(winid);
 
909
  delete_sgwin_entities(winid,v_flag);
 
910
}
 
911
 
 
912
/* for Fortran call */
 
913
 
 
914
int C2F(deletewin)(int *winid) 
 
915
{
 
916
  scig_menu_delete(*winid);
 
917
  return(0);
 
918
}
 
919
 
 
920
/*-----------------------------------------------------------------*
 
921
 * Replot in Postscript style and send to printer 
 
922
 *-----------------------------------------------------------------*/
 
923
 
 
924
static  char bufname[256];
 
925
static  char printer[128];
 
926
static  char file[256];
 
927
 
 
928
static void scig_menu_print(int winid)
 
929
{
 
930
  char *p1;
 
931
  integer colored,orientation,flag=1,ok;
 
932
  prtdlg(&flag,printer,&colored,&orientation,file,&ok);
 
933
  if (ok==1) 
 
934
    {
 
935
      if ( ( p1 = getenv("TMPDIR"))  == (char *) 0 )
 
936
        {
 
937
          sciprint("Cannot find environment variable TMPDIR\r\n");
 
938
        }
 
939
 
 
940
      sprintf(bufname,"%s/scilab-%d",p1,(int)winid);
 
941
      scig_tops(winid,colored,bufname,"Pos");
 
942
      sprintf(bufname,"$SCI/bin/scilab -%s %s/scilab-%d %s",
 
943
              (orientation == 1) ? "print_l" : "print_p",
 
944
              p1,(int)winid,printer);
 
945
      system(bufname);
 
946
  }
 
947
}
 
948
 
 
949
/* for use inside menus */
 
950
 
 
951
void scig_print(int winid) 
 
952
{
 
953
  scig_menu_print( winid);
 
954
}
 
955
 
 
956
/*-----------------------------------------------------------------
 
957
 * Replot in Postscript or Xfig style and save 
 
958
 *-----------------------------------------------------------------*/
 
959
 
 
960
static void scig_menu_saveps(int winid) 
 
961
{
 
962
  integer colored,orientation,flag=2,ok;
 
963
  prtdlg(&flag,printer,&colored,&orientation,file,&ok);
 
964
  if (ok==1) 
 
965
    {
 
966
      if (strncmp(printer,"Postscript",10)==0 ) 
 
967
        {
 
968
          /** Postscript*   **/
 
969
          scig_tops(winid,colored,file,"Pos");
 
970
        }
 
971
      else if (strcmp(printer,"Xfig")==0)
 
972
        {
 
973
          /** Xfig   **/
 
974
          scig_tops(winid,colored,file,"Fig");
 
975
        }
 
976
      else if (strcmp(printer,"Gif")==0)
 
977
        {
 
978
          /** Gif file **/
 
979
          scig_tops(winid,colored,file,"GIF");
 
980
        }
 
981
      else if (strcmp(printer,"PPM")==0)
 
982
        {
 
983
          /** PPM file **/
 
984
          scig_tops(winid,colored,file,"PPM");
 
985
        }
 
986
      if ( strcmp(printer,"Postscript No Preamble") != 0)
 
987
        {
 
988
          sprintf(bufname,"$SCI/bin/scilab -%s %s %s",
 
989
                  ( orientation == 1) ? "save_l" : "save_p",file,printer);
 
990
          system(bufname);
 
991
        }
 
992
  }
 
993
}
 
994
 
 
995
/* for use inside menus */
 
996
 
 
997
void scig_export(int winid)
 
998
{
 
999
  scig_menu_saveps(winid) ;
 
1000
}
 
1001
 
 
1002
/*-----------------------------------------------------------------*
 
1003
 * Binary File save 
 
1004
 *-----------------------------------------------------------------*/
 
1005
 
 
1006
static void scig_menu_save(int winid) 
 
1007
{
 
1008
  char *filename;
 
1009
  int ierr=0,rep;
 
1010
  static char *init ="*.scg";
 
1011
  rep=sci_get_file_window(init,&filename,".",0,0,&ierr,"Save Graphic File");
 
1012
  if ( ierr == 0 && rep == TRUE )
 
1013
    {
 
1014
      C2F(xsaveplots)(&winid,filename,0L);
 
1015
    }
 
1016
}
 
1017
 
 
1018
/*-----------------------------------------------------------------*
 
1019
 * Binary File load 
 
1020
 *-----------------------------------------------------------------*/
 
1021
 
 
1022
static void scig_menu_load(int winid) 
 
1023
{
 
1024
  char *filename;
 
1025
  int ierr=0,rep;
 
1026
  static char *init ="*.scg";
 
1027
  rep=sci_get_file_window(init,&filename,".",0,0,&ierr,"Load Graphic File");
 
1028
  if ( ierr == 0 && rep == TRUE )
 
1029
    {
 
1030
      scig_loadsg(winid, filename);
 
1031
    }
 
1032
}
 
1033
 
 
1034
/*-----------------------------------------------------------------*
 
1035
 * file operations 
 
1036
 *-----------------------------------------------------------------*/
 
1037
 
 
1038
static void sci_menu_fileops()
 
1039
{
 
1040
  static char * file = NULL ;
 
1041
  int rep,ierr;
 
1042
  rep = sci_get_file_window(NULL,&file,".",0,1,&ierr,"File operations");
 
1043
  if ( ierr == 0 && rep == TRUE ) 
 
1044
    { 
 
1045
      StoreCommand1(file,1);  /* we want the command to appear in the window */
 
1046
      free(file); 
 
1047
      file =NULL; 
 
1048
    }
 
1049
}
 
1050
 
 
1051
/*-----------------------------------------------------------------**
 
1052
 * 2D Zoom calback 
 
1053
 *-----------------------------------------------------------------*/
 
1054
 
 
1055
static void scig_menu_zoom(int winid) 
 
1056
{
 
1057
  integer ne=0;
 
1058
  SetUnsetMenu(&winid,"Zoom",&ne,False);
 
1059
  SetUnsetMenu(&winid,"3D Rot.",&ne,False);
 
1060
  SetUnsetMenu(&winid,"UnZoom",&ne,False);
 
1061
  SetUnsetMenu(&winid,"File",&ne,False);
 
1062
  if ( scig_2dzoom(winid)==1) return; /* the window has been closed */
 
1063
  SetUnsetMenu(&winid,"Zoom",&ne,True);
 
1064
  SetUnsetMenu(&winid,"3D Rot.",&ne,True);
 
1065
  SetUnsetMenu(&winid,"UnZoom",&ne,True);
 
1066
  SetUnsetMenu(&winid,"File",&ne,True);
 
1067
}
 
1068
 
 
1069
 
 
1070
/*-----------------------------------------------------------------
 
1071
 * Unzoom Callback 
 
1072
 *-----------------------------------------------------------------*/
 
1073
 
 
1074
static void scig_menu_unzoom(int winid) 
 
1075
{
 
1076
  integer ne=0;
 
1077
  SetUnsetMenu(&winid,"UnZoom",&ne,False);
 
1078
  scig_unzoom(winid);
 
1079
  SetUnsetMenu(&winid,"UnZoom",&ne,True);
 
1080
}
 
1081
 
 
1082
 
 
1083
/*-----------------------------------------------------------------
 
1084
 * 3D Rotation callback 
 
1085
 *-----------------------------------------------------------------*/
 
1086
 
 
1087
static void scig_menu_rot3d(int winid) 
 
1088
{
 
1089
  integer ne=0;
 
1090
  SetUnsetMenu(&winid,"3D Rot.",&ne,False);
 
1091
  SetUnsetMenu(&winid,"UnZoom",&ne,False);
 
1092
  SetUnsetMenu(&winid,"Zoom",&ne,False);
 
1093
  SetUnsetMenu(&winid,"File",&ne,False);
 
1094
  if (scig_3drot(winid)==1) return; /* the window has been closed */
 
1095
  SetUnsetMenu(&winid,"3D Rot.",&ne,True);
 
1096
  SetUnsetMenu(&winid,"UnZoom",&ne,True);
 
1097
  SetUnsetMenu(&winid,"Zoom",&ne,True);
 
1098
  SetUnsetMenu(&winid,"File",&ne,True);
 
1099
}
 
1100
 
 
1101
 
 
1102
/*-----------------------------------------------------------------
 
1103
 * kill scilab 
 
1104
 *-----------------------------------------------------------------*/
 
1105
 
 
1106
static void sci_menu_kill()
 
1107
{
 
1108
  sci_clear_and_exit(1);
 
1109
}
 
1110
 
 
1111
/*-----------------------------------------------------------------
 
1112
 * make a stop 
 
1113
 *-----------------------------------------------------------------*/
 
1114
 
 
1115
static void sci_menu_stop () 
 
1116
{
 
1117
  int j = SIGINT;
 
1118
  C2F(sigbas)(&j);
 
1119
  /* if (get_is_reading()) write_scilab(""); */
 
1120
}
 
1121
 
 
1122
/*-----------------------------------------------------------------
 
1123
 * run the help 
 
1124
 *-----------------------------------------------------------------*/
 
1125
 
 
1126
extern int  Sci_Help(char *name);
 
1127
 
 
1128
static void sci_menu_help()
 
1129
{
 
1130
  StoreCommand("help();");
 
1131
}
 
1132
 
 
1133
/*-----------------------------------------------------------------
 
1134
 * run the demos 
 
1135
 *-----------------------------------------------------------------*/
 
1136
 
 
1137
static void sci_menu_demos()
 
1138
{
 
1139
  StoreCommand( get_sci_data_strings(2));
 
1140
}
 
1141
 
 
1142
 
 
1143
/*-----------------------------------------------------------------
 
1144
 * Callbacks for the Graphic Window main menu 
 
1145
 *-----------------------------------------------------------------*/
 
1146
 
 
1147
static void sci_menu_gwplus() 
 
1148
{
 
1149
  MenuFixCurrentWin(lab_count+1); 
 
1150
}
 
1151
 
 
1152
static void sci_menu_gwminus() 
 
1153
{
 
1154
  MenuFixCurrentWin(lab_count-1); 
 
1155
}
 
1156
 
 
1157
static void sci_menu_gwcreate_or_select() 
 
1158
{
 
1159
  scig_sel(lab_count);
 
1160
}
 
1161
 
 
1162
static void sci_menu_gwraise() 
 
1163
{
 
1164
  scig_raise(lab_count);
 
1165
}
 
1166
 
 
1167
static void sci_menu_gwdelete() 
 
1168
{
 
1169
  scig_menu_delete(lab_count);
 
1170
}
 
1171
 
 
1172
/*-----------------------------------------------------------------
 
1173
 * Execute predefined callbacks 
 
1174
 *-----------------------------------------------------------------*/
 
1175
 
 
1176
static int call_predefined_callbacks(char *name, int winid)
 
1177
{
 
1178
  if      (strcmp(name,"$clear")== 0)  scig_menu_erase(winid) ;
 
1179
  else if (strcmp(name,"$select")== 0) scig_menu_select(winid) ;
 
1180
  else if (strcmp(name,"$print")== 0)  scig_menu_print(winid);
 
1181
  else if (strcmp(name,"$export")== 0) scig_export(winid);
 
1182
  else if (strcmp(name,"$save")== 0)   scig_menu_save(winid);
 
1183
  else if (strcmp(name,"$load")== 0)   scig_menu_load(winid);
 
1184
  else if (strcmp(name,"$close")== 0)  scig_menu_delete(winid);
 
1185
  else if (strcmp(name,"$zoom")== 0)   scig_menu_zoom(winid);
 
1186
  else if (strcmp(name,"$unzoom")== 0) scig_menu_unzoom(winid);
 
1187
  else if (strcmp(name,"$rot3d")== 0)  scig_menu_rot3d(winid);
 
1188
  else if (strcmp(name,"$help")== 0)   sci_menu_help();
 
1189
  else if (strcmp(name,"$stop")== 0)   sci_menu_stop();
 
1190
  else if (strcmp(name,"$kill")== 0)   sci_menu_kill();
 
1191
  else if (strcmp(name,"$demos")== 0)  sci_menu_demos();
 
1192
  else if (strcmp(name,"$fileops")== 0) sci_menu_fileops();
 
1193
  else if (strcmp(name,"$gwselect")== 0) sci_menu_gwcreate_or_select();
 
1194
  else if (strcmp(name,"$gwraise")== 0) sci_menu_gwraise();
 
1195
  else if (strcmp(name,"$gwdelete")== 0) sci_menu_gwdelete();
 
1196
  else if (strcmp(name,"$gwplus")== 0)  sci_menu_gwplus();
 
1197
  else if (strcmp(name,"$gwminus")== 0)  sci_menu_gwminus();
 
1198
  else if (strcmp(name,"$about")== 0)  create_scilab_about ();
 
1199
  else if (strcmp(name,"$resume")== 0) StoreCommand1("resume",1);
 
1200
  else if (strcmp(name,"$abort")== 0)  StoreCommand1("abort",1); 
 
1201
  else if (strcmp(name,"$restart")== 0) StoreCommand1("exec SCI/scilab.star;",1);
 
1202
  else if (strcmp(name,"$quit")== 0)  StoreCommand1("quit;",1);
 
1203
  else return 0;
 
1204
  return 1;
 
1205
}