PIPS
xv_select.c
Go to the documentation of this file.
1 /*
2 
3  $Id: xv_select.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <unistd.h>
31 
32 #include <sys/time.h>
33 #include <sys/resource.h>
34 #include <xview/xview.h>
35 #include <xview/panel.h>
36 #include <xview/notice.h>
37 #include <xview/text.h>
38 
39 #if (defined(TEXT))
40 #undef TEXT
41 #endif
42 
43 #if (defined(TEXT_TYPE))
44 #undef TEXT_TYPE
45 #endif
46 
47 #include "genC.h"
48 #include "linear.h"
49 #include "ri.h"
50 #include "ri-util.h"
51 #include "database.h"
52 
53 #include "misc.h"
54 #include "pipsdbm.h"
55 #include "pipsmake.h"
56 #include "top-level.h"
57 #include "wpips.h"
58 
59 #include "resources.h"
60 
61 
62 /* Maximum size of the module menu of the main frame: */
63 enum {
65 };
66 
67 
69 
71 
72 /* To enable or disable the menu items generated by generate_module_menu(): */
80 
81 
82 /* Try to select a main module (that is the PROGRAM in the Fortran
83  stuff) if no one is selected: */
84 void
86 {
88 
89  if (module_name == NULL) {
90  /* Ok, no current module, then find a main module (PROGRAM): */
91  string main_module_name = get_first_main_module();
92 
93  if (!string_undefined_p(main_module_name)) {
94  /* Ok, we got it ! Now we select it: */
95  module_name = main_module_name;
96  user_log("Main module PROGRAM \"%s\" found.\n", module_name);
98  /* GO: show_module() has already been called so return now */
99  return;
100  }
101  }
102 
103  /* Refresh the module name on the status window: */
104  show_module();
105 }
106 
107 
108 success
110 {
111  char *s;
112 
113 /* if (dir != NULL) {*/
114  if ((s = pips_change_directory(dir)) == NULL) {
115  user_log("Directory \"%s\" does not exist\n", dir);
116  prompt_user("Directory \"%s\" does not exist\n", dir);
117  show_directory();
118  return FALSE;
119  }
120  else {
121  user_log("Directory \"%s\" selected\n", dir);
122  show_directory();
123  return TRUE;
124  }
125 }
126 
127 
128 void
129 end_directory_text_notify(Panel_item text_item,
130  Event * event)
131 {
132  (void) end_directory_notify((char *) xv_get(text_item, PANEL_VALUE));
133 }
134 
135 /* FC: uses an external wish script
136  * I do not know how to activate this function safely...
137  */
138 void
140 {
141  char newdir[MAXPATHLEN];
142  char * tmp = strdup("/tmp/wpips.dir.XXXXXX");
143  int i=0, c;
144  FILE * tmph;
145 
146  (void) mkstemp(tmp);
147 
149  return; /* no cd in this state! */
150 
151  safe_system(concatenate("wpips-changedir -- ", get_cwd(), " > ", tmp, NULL));
152 
153  tmph = safe_fopen(tmp, "r");
154  while ((c=getc(tmph))!=EOF && i<MAXPATHLEN)
155  newdir[i++]=c;
156  newdir[i-1]='\0'; /* last was \n */
157  safe_fclose(tmph, tmp);
158 
159  end_directory_notify(newdir);
160 
161  unlink(tmp); free(tmp);
162 
163  return /* generate_workspace_menu(); */ ;
164 }
165 
166 Menu
168 {
170 }
171 
172 
173 void
175  Event * event)
176 {
177  /* First untype whatever the user typed: */
178  show_directory();
179  prompt_user("You have to close the current workspace"
180  " before changing directory.");
181 }
182 
183 
184 void start_directory_notify(menu, menu_item)
185  Menu menu;
186  Menu_item menu_item;
187 {
190  (Panel_item)NULL, (Event*)NULL);
191  else
192  start_query("Change Directory",
193  "Enter directory path: ",
194  "ChangeDirectory",
197 }
198 
199 
200 void
202 {
203  xv_set(directory_menu_item, MENU_INACTIVE, FALSE, NULL);
204 
205  /* Enable the normal notify mode: notify when return and so is
206  typed: */
208  PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
209  PANEL_NOTIFY_PROC, end_directory_text_notify,
210  PANEL_INACTIVE, FALSE,
211  NULL);
214 }
215 
216 
217 void
219 {
220  xv_set(directory_menu_item, MENU_INACTIVE, TRUE, NULL);
221 
222  /* In order to warn the user as soon as possible that (s)he can't
223  change the directory, notify for whatever character: */
225  PANEL_NOTIFY_LEVEL, PANEL_ALL,
227  PANEL_INACTIVE, TRUE,
228  NULL);
231 }
232 
233 
234 void static
236 {
239  else
241 }
242 
243 
245 
246 
247 void
249 {
250  xv_set(create_pgm,
251  MENU_INACTIVE, TRUE,
252  NULL);
254  xv_set(open_pgm,
255  MENU_INACTIVE, TRUE,
256  NULL);
258  PANEL_INACTIVE, TRUE,
259  NULL);
260 }
261 
262 
263 void
265 {
266  xv_set(create_pgm,
267  MENU_INACTIVE, FALSE,
268  NULL);
270  xv_set(open_pgm,
271  MENU_INACTIVE, FALSE,
272  NULL);
274  PANEL_INACTIVE, FALSE,
275  NULL);
276 }
277 
278 
279 void
281 {
282  /* Avoid also to delete a workspace during a creation in case the
283  name of the workspace is the same... */
287  PANEL_INACTIVE, TRUE,
288  NULL);
289 }
290 
291 
292 void
294 {
298  PANEL_INACTIVE, FALSE,
299  NULL);
300 }
301 
302 
303 void
305 {
306  xv_set(close_pgm, MENU_INACTIVE, TRUE, NULL);
308  /* For generate_module_menu(): */
310 }
311 
312 
313 void
315 {
316  xv_set(close_pgm, MENU_INACTIVE, FALSE, NULL);
317  /* For generate_module_menu(): */
319 }
320 
321 
322 void
324 {
326 }
327 
328 
329 void
331 {
332  xv_set(module_item, MENU_INACTIVE, TRUE, NULL);
333  xv_set(module_name_panel_item, PANEL_INACTIVE, TRUE, NULL);
338 }
339 
340 
341 void
343 {
344  xv_set(module_item, MENU_INACTIVE, FALSE, NULL);
345  xv_set(module_name_panel_item, PANEL_INACTIVE, FALSE, NULL);
346  /* Well, after a workspace creation without automatic module
347  selection successful, there is no module selected and thus the
348  following menus are not very interestiong, except for the option
349  part of the option selection. Anyway, there is a guard in each
350  of these menu, so, just do nothing... :-) */
355 }
356 
357 
358 void
360 {
361  schoose_close();
362 
363  if (db_get_current_workspace_name() != NULL
364  && strcmp(db_get_current_workspace_name(), name) == 0)
365  {
366  int result;
367  /* Send to emacs if we are in the emacs mode: */
368  if (wpips_emacs_mode)
369  send_notice_prompt_to_emacs("The workspace",
370  name,
371  "is currently opened!",
372  "Do you really want to close and remove it ?",
373  NULL);
374  result = notice_prompt(xv_find(main_frame, WINDOW, 0),
375  NULL,
376  NOTICE_MESSAGE_STRINGS,
377  "The workspace",
378  name,
379  "is currently opened!",
380  "Do you really want to close and remove it ?",
381  NULL,
382  NOTICE_BUTTON_YES, "Yes, remove the database",
383  NOTICE_BUTTON_NO, "No, cancel",
384  NULL);
385  if (result == NOTICE_NO)
386  goto do_not_delete_the_workspace;
387 
388  /* First close the workspace: */
389  if (!close_workspace_notify((Menu)NULL, (Menu_item)NULL))
390  /* Hmm... This may put WPips in a strange state if close
391  fails... */
392  goto do_not_delete_the_workspace;
393  }
394 
395  (void) delete_workspace(name);
396 
397  do_not_delete_the_workspace:
402 
404 }
405 
406 
407 void
409 {
410  /* Nothing to do. */
415 }
416 
417 
418 void
420  Menu_item menu_item)
421 {
422  gen_array_t workspace_list;
423  int workspace_list_length = 0;
424 
425  workspace_list = gen_array_make(0);
426  pips_get_workspace_list(workspace_list);
427  workspace_list_length = gen_array_nitems(workspace_list);
428 
429  if (workspace_list_length == 0) {
430  prompt_user("No workspace available in this directory.");
431  }
432  else {
437 
438  schoose("Select the Workspace to Delete",
439  workspace_list,
440  /* Choix initial sur le workspace courant si
441  possible : */
445  }
446  gen_array_full_free(workspace_list);
447 }
448 
449 
450 void
452  Menu_item menu_item)
453 {
457 
458  if (db_get_current_workspace_name() != NULL)
459  /* There is an open workspace: close it first: */
460  if (!close_workspace_notify((Menu) NULL, (Menu_item) NULL)) {
461  /* If it fails: */
462  cancel_create_workspace_notify((Panel_item) NULL, (Event*)NULL);
463  return;
464  }
465 
466  start_query("Create Workspace",
467  "Enter workspace name: ",
468  "CreateWorkspace",
470  /* Pas la peine de faire quelque chose si on appuie
471  sur cancel : */
473 }
474 
475 
476 void
478  Event * event)
479 {
480  /* Re'tablit le droit d'ouvrir ou de cre'er un autre worspace : */
484  cancel_query_notify(item, event);
485  show_workspace();
486 }
487 
488 
489 success
491 {
492  gen_array_t fortran_list;
493  int fortran_list_length = 0;
494 
495  /* Is the name a valid workspace name? */
496  if (! workspace_name_p(name)) {
498  }
499  else
500  {
501  fortran_list = gen_array_make(0);
502  pips_get_fortran_list(fortran_list);
503  fortran_list_length = gen_array_nitems(fortran_list);
504 
505  if (fortran_list_length == 0) {
506  prompt_user("No Fortran files in this directory");
507  }
508  else {
509  /* Code added to confirm for a database destruction before
510  opening a database with the same name.
511  RK 18/05/1993. */
512  if (workspace_exists_p(name))
513  {
514  int result;
515  /* Send to emacs if we are in the emacs mode: */
516  if (wpips_emacs_mode)
517  send_notice_prompt_to_emacs("The database",
518  name,
519  "already exists!",
520  "Do you really want to remove it?",
521  NULL);
522  result = notice_prompt(xv_find(main_frame, WINDOW, 0),
523  NULL,
524  NOTICE_MESSAGE_STRINGS,
525  "The database", name, "already exists!",
526  "Do you really want to remove it?",
527  NULL,
528  NOTICE_BUTTON_YES,
529  "Yes, remove the database",
530  NOTICE_BUTTON_NO, "No, cancel",
531  NULL);
532  if (result == NOTICE_NO)
533  goto continue_create_workspace_notify_failed;
534  }
535 
537 
538  /* To avoid passing the name through mchoose(): */
540 
541  if (fortran_list_length == 1) {
542  /* Only one Fortran program: use it without user
543  confirmation. */
544  user_log("There is only one Fortran program in the current directory.\n"
545  "\tCreating the workspace \"%s\" from the file \"%s\"...\n",
546  name,
547  gen_array_item(fortran_list, 0));
548  end_create_workspace_notify(fortran_list);
549  }
550  else {
551  mchoose("Create Workspace",
552  fortran_list,
554  (void (*)(void)) cancel_create_workspace_notify);
555  }
556  /* Memory leak if mchoose exit... */
557  gen_array_full_free(fortran_list);
558 
559  return(TRUE);
560  }
561  }
562 
563  /* If it failed, cancel the creation: */
564  continue_create_workspace_notify_failed:
565  cancel_create_workspace_notify((Panel_item)NULL, (Event*)NULL);
566 
567  return FALSE;
568 }
569 
570 
571 void
573 {
574  prompt_user("The name \"%s\" is not a valid workspace name!\n",
575  workspace_name);
579 }
580 
581 
582 void
584 {
585  /* If the user click quickly on OK, be sure
586  end_create_workspace_notify() is not reentrant by verifying
587  something as not been opened already: */
588  if (db_get_current_workspace_name() == NULL) {
589  /* Is the name a valid workspace name? */
592  /* The create workspace has been successful: */
593  /* open_log_file(); */
595 
596  if (create_workspace(files)) {
597  /* The processing of user files has been successful: */
599 
600  show_workspace();
604 
607 
608  /* Tell Emacs the new module list: */
610 
612 
613  return;
614  }
615  else
616  /* close_log_file(); */
617  ;
618  }
619  }
620  else
622 
623  /* The creation failed: */
627 
629  }
630 }
631 
632 
633 void
635 {
636  schoose_close();
637 
638  if ( open_workspace(name) ) {
639  /* open_log_file(); */
641  show_workspace();
645  /* Tell Emacs the new module list: */
647  }
648 
650 
652 }
653 
654 
655 void
657 {
660  show_workspace();
661 }
662 
663 
664 void
666  Menu_item menu_item)
667 {
668  gen_array_t workspace_list;
669  int workspace_list_length = 0;
670 
671  workspace_list = gen_array_make(0);
672  pips_get_workspace_list(workspace_list);
673  workspace_list_length = gen_array_nitems(workspace_list);
674 
675  if (workspace_list_length == 0) {
676  prompt_user("No workspace available in this directory.");
677  }
678  else if (workspace_list_length == 1) {
679  /* There is only workspace: open it without asking confirmation
680  to the user: */
681  user_log("There is only one workspace in the current directory.\n"
682  "\tOpening the workspace \"%s\"...\n",
683  gen_array_item(workspace_list, 0));
684  end_open_workspace_notify(gen_array_item(workspace_list, 0));
685  }
686  else {
688 
689  schoose("Select Workspace",
690  workspace_list,
691  /* Choix initial sur le workspace courant si
692  possible : */
696  }
697  gen_array_full_free(workspace_list);
698 }
699 
700 
701 success
703  Menu_item menu_item)
704 {
705  success return_value;
706 
707  return_value = close_workspace(FALSE);
708  debug(1, "close_workspace_notify", "return_value = %d\n", return_value);
709 
710  if (return_value ) {
711  /* The close has been successful: */
712  /* close_log_file(); */
714 
715  edit_close_notify(menu, menu_item);
716 
719 
720  /* It is the only place to enable a directory change, after a close
721  workspace: */
723 
725  /* Tell Emacs the new module list, that is nothing in fact: */
727  }
728 
730  show_workspace();
731  show_module();
733 
734  return return_value;
735 }
736 
737 
738 /* To be used with schoose_create_abbrev_menu_with_text from the main
739  panel: */
740 void
741 open_or_create_workspace(char * workspace_name_original)
742 {
743  int i;
744  gen_array_t workspace_list;
745  int workspace_list_length = 0;
746  char workspace_name[SMALL_BUFFER_LENGTH];
747 
748  /* If close_workspace_notify() is called below, show_workspace() will
749  set the name to "(* none *)" in the panel and
750  workspace_name_original is directly a pointer to it ! */
751  (void) strncpy(workspace_name,
752  workspace_name_original,
753  sizeof(workspace_name) - 1);
754 
755  if (! workspace_name_p(workspace_name)) {
756  /* Prompt the warning and restore the menu enable state: */
758  show_workspace();
759  return;
760  }
761 
762  if (db_get_current_workspace_name() != NULL)
763  /* There is an open workspace: close it first: */
764  if (!close_workspace_notify((Menu) NULL, (Menu_item) NULL))
765  return;
766 
767  /* To choose between open or create, look for the an existing
768  workspace with the same name: */
769  workspace_list = gen_array_make(0);
770  pips_get_workspace_list(workspace_list);
771  workspace_list_length = gen_array_nitems(workspace_list);
772 
773  for(i = 0; i < workspace_list_length; i++) {
774  string name = gen_array_item(workspace_list, i);
775  if (strcmp(workspace_name, name) == 0) {
776  /* OK, the workspace exists, open it: */
777  end_open_workspace_notify(workspace_name);
778  return;
779  }
780  }
781  /* The workspace does not exist, create it: */
783  gen_array_full_free(workspace_list);
784  (void) continue_create_workspace_notify(workspace_name);
785 }
786 
787 
788 /* To use with schoose_create_abbrev_menu_with_text: */
789 Menu
791 {
792  Menu menu;
793  Menu_item delete_menu_item;
794  int i;
795  gen_array_t workspace_list;
796  int workspace_list_length = 0;
797 
798  workspace_list = gen_array_make(0);
799  pips_get_workspace_list(workspace_list);
800  workspace_list_length = gen_array_nitems(workspace_list);
801 
802  menu = xv_create(XV_NULL, MENU,
803  MENU_TITLE_ITEM, " Select in the workspace list: ",
804  NULL);
805 
806  /* Replace the Select Workspace menu from the status window with
807  the following items: */
808  xv_set(menu, MENU_APPEND_ITEM,
809  xv_create(XV_NULL, MENUITEM,
810  MENU_STRING,
811  " Create Workspace...",
812  MENU_NOTIFY_PROC, start_create_workspace_notify,
813  MENU_RELEASE,
814  /* Always active since
815  start_create_workspace_notify() does the close
816  if necessary: */
818  NULL),
819  NULL);
820  xv_set(menu, MENU_APPEND_ITEM,
821  xv_create(XV_NULL, MENUITEM,
822  MENU_STRING,
823  " Close Workspace",
824  MENU_NOTIFY_PROC, close_workspace_notify,
825  MENU_RELEASE,
826  /* On can close only if there is something open: */
828  NULL),
829  NULL);
830  delete_menu_item = xv_create(XV_NULL, MENUITEM,
831  MENU_STRING,
832  " Delete Workspace...",
833  MENU_NOTIFY_PROC, start_delete_workspace_notify,
834  MENU_RELEASE,
836  NULL);
837 
838  xv_set(menu, MENU_APPEND_ITEM,
839  delete_menu_item,
840  NULL);
841 
842  /* Now complete with the list of the workspaces: */
843  if (workspace_list_length == 0) {
844  xv_set(menu, MENU_APPEND_ITEM,
845  xv_create(XV_NULL, MENUITEM,
846  MENU_STRING,
847  "* No workspace available in this directory *",
848  MENU_RELEASE,
849  MENU_INACTIVE, TRUE,
850  NULL),
851  NULL);
852  /* Well, since there is no workspace, there is nothing to
853  delete... */
854  xv_set(delete_menu_item,
855  MENU_INACTIVE, TRUE,
856  NULL);
857  }
858  else {
859  for(i = 0; i < workspace_list_length; i++)
860  {
861  string name = gen_array_item(workspace_list, i);
862  xv_set(menu, MENU_APPEND_ITEM,
863  xv_create(XV_NULL, MENUITEM,
864  MENU_STRING, strdup(name),
865  MENU_RELEASE,
866  /* The strdup'ed string will also be
867  freed when the menu is discarded: */
868  MENU_RELEASE_IMAGE,
869  MENU_INACTIVE, wpips_open_workspace_menu_inactive,
870  NULL),
871  NULL);
872  }
873  }
874 
875  gen_array_full_free(workspace_list);
876 
877  return menu;
878 }
879 
880 
881 void
883 {
884  gen_array_t module_list = db_get_module_list();
885  int module_list_length = gen_array_nitems(module_list);
886 
887  if (module_list_length == 0)
888  {
889  prompt_user("No module available in this workspace.");
890  }
891  else
892  {
893  bool module_found = FALSE;
894  int i;
895 
896  for(i = 0; i < module_list_length; i++) {
897  string mn = gen_array_item(module_list, i);
898  if (strcmp(name, mn) == 0) {
899  module_found = TRUE;
900  break;
901  }
902  }
903  if (module_found)
904  lazy_open_module(name);
905  else
906  prompt_user("The module \"%s\" does not exist in this workspace.",
907  name);
908  }
909 
910  show_module();
912  gen_array_full_free(module_list);
913 }
914 
916 {
917 }
918 
919 void
921  Menu_item menu_item)
922 {
923  gen_array_t module_list = db_get_module_list();
924  int module_list_length = gen_array_nitems(module_list);
925 
926  if (module_list_length == 0)
927  {
928  /* If there is no module... RK, 23/1/1993. */
929  prompt_user("No module available in this workspace.");
930  }
931  else
932  schoose("Select Module",
933  module_list,
934  /* Affiche comme choix courant le module
935  courant (c'est utile si on ferme la fenêtre
936  module entre temps) : */
940 
941  gen_array_full_free(module_list);
942 }
943 
944 
945 /* To use with schoose_create_abbrev_menu_with_text: */
946 Menu
948 {
949  Menu menu;
950  int i;
951  menu = xv_create(XV_NULL, MENU,
952  MENU_TITLE_ITEM, " Select in the module list: ",
953  NULL);
954 
955  if (db_get_current_workspace_name() == NULL) {
956  xv_set(menu, MENU_APPEND_ITEM,
957  xv_create(XV_NULL, MENUITEM,
958  MENU_STRING, "* No workspace yet! *",
959  MENU_RELEASE,
960  MENU_INACTIVE, TRUE,
961  NULL),
962  NULL);
963  }
964  else {
965  gen_array_t module_list = db_get_module_list();
966  int module_list_length = gen_array_nitems(module_list);
967 
968  if (module_list_length == 0) {
969  xv_set(menu, MENU_APPEND_ITEM,
970  xv_create(XV_NULL, MENUITEM,
971  MENU_STRING,
972  "* No module available in this workspace *",
973  MENU_RELEASE,
974  MENU_INACTIVE, TRUE,
975  NULL),
976  NULL);
977  }
978  else if (module_list_length > WPIPS_MAX_MODULE_MENU_SIZE) {
979  xv_set(menu,
980  MENU_TITLE_ITEM,
981  " Too many modules. Click on the Module Chooser: ",
982  NULL);
983  xv_set(menu, MENU_APPEND_ITEM,
984  xv_create(XV_NULL, MENUITEM,
985  MENU_STRING, "Module Chooser",
986  MENU_NOTIFY_PROC, select_module_notify,
987  MENU_RELEASE,
988  NULL),
989  NULL);
990  user_warning("generate_a_directory_menu",
991  "Too many modules in this workspace. "
992  "Click on the Module Chooser\n");
993  }
994  else {
995  for(i = 0; i < module_list_length; i++) {
996  string mn = gen_array_item(module_list, i);
997  xv_set(menu, MENU_APPEND_ITEM,
998  xv_create(XV_NULL, MENUITEM,
999  MENU_STRING, strdup(mn),
1000  MENU_RELEASE,
1001  /* The strdup'ed string will also be
1002  freed when the menu is discarded: */
1003  MENU_RELEASE_IMAGE,
1004  NULL),
1005  NULL);
1006  }
1007  }
1008  gen_array_full_free(module_list);
1009  }
1010 
1011  return menu;
1012 }
1013 
1014 
1015 void
1017 {
1018  Menu menu, pmenu;
1019 
1020  create_pgm = xv_create(XV_NULL, MENUITEM,
1021  MENU_STRING, "Create",
1022  MENU_NOTIFY_PROC, start_create_workspace_notify,
1023  MENU_RELEASE,
1024  NULL);
1025 
1026  open_pgm = xv_create(XV_NULL, MENUITEM,
1027  MENU_STRING, "Open",
1028  MENU_NOTIFY_PROC, open_workspace_notify,
1029  MENU_RELEASE,
1030  NULL);
1031 
1032  close_pgm = xv_create(XV_NULL, MENUITEM,
1033  MENU_STRING, "Close",
1034  MENU_NOTIFY_PROC, close_workspace_notify,
1035  MENU_INACTIVE, TRUE,
1036  MENU_RELEASE,
1037  NULL);
1038 
1039  module_item = xv_create(XV_NULL, MENUITEM,
1040  MENU_STRING, "Module",
1041  MENU_NOTIFY_PROC, select_module_notify,
1042  MENU_INACTIVE, TRUE,
1043  MENU_RELEASE,
1044  NULL);
1045 
1046  /* Exchange of the order of create_pgm & open_pgm on the screen
1047  for ergonomic reasons. :-) RK, 19/02/1993. */
1048  pmenu =
1049  xv_create(XV_NULL, MENU_COMMAND_MENU,
1050  MENU_TITLE_ITEM, "Deal with workspaces ",
1051  MENU_GEN_PIN_WINDOW, main_frame, "Workspace Menu",
1052  MENU_APPEND_ITEM, open_pgm,
1053  MENU_APPEND_ITEM, create_pgm,
1054  MENU_APPEND_ITEM, close_pgm,
1055  NULL);
1056 
1057  /* Exchange of the order of start_directory_notify &
1058  module_item on the screen for ergonomic reasons.
1059  :-) RK, 19/02/1993. */
1060  directory_menu_item = xv_create(XV_NULL, MENUITEM,
1061  MENU_ACTION_ITEM,
1062  "Directory",
1064  NULL);
1065 
1066  menu =
1067  xv_create(XV_NULL, MENU_COMMAND_MENU,
1068  MENU_TITLE_ITEM, "Selecting workspace & Fortran module ",
1069  MENU_GEN_PIN_WINDOW, main_frame, "Selection Menu",
1070  MENU_APPEND_ITEM, module_item,
1071  MENU_PULLRIGHT_ITEM, "Workspace", pmenu,
1072  MENU_APPEND_ITEM, directory_menu_item,
1073  NULL);
1074 
1075  /* Now all the functionality of the select menu are on the status
1076  panel but I could reinstall the select menu later. Since I do
1077  not want do change the code, put the select menu in a dummy
1078  spare frame: */
1079  /*
1080  (void) xv_create(main_panel, PANEL_BUTTON,
1081  PANEL_LABEL_STRING, "Select",
1082  PANEL_ITEM_MENU, menu,
1083  NULL);
1084  */
1085  {
1086  Frame select_button_frame;
1087  Panel select_button_panel;
1088 
1089  select_button_frame = xv_create(main_frame, FRAME,
1090  XV_SHOW, FALSE,
1091  NULL);
1092  select_button_panel = xv_create(select_button_frame, PANEL,
1093  NULL);
1094 
1095  (void) xv_create(select_button_panel, PANEL_BUTTON,
1096  PANEL_LABEL_STRING, "Select",
1097  PANEL_ITEM_MENU, menu,
1098  NULL);
1099  }
1100 }
void user_log(const char *format,...)
Definition: message.c:234
string db_get_current_module_name(void)
Also used to check whether set...
Definition: database.c:1059
size_t gen_array_nitems(const gen_array_t a)
Definition: array.c:131
void gen_array_full_free(gen_array_t a)
Definition: array.c:77
gen_array_t gen_array_make(size_t size)
declarations...
Definition: array.c:40
void * gen_array_item(const gen_array_t a, size_t i)
Definition: array.c:143
bool delete_workspace(const char *wname)
Definition: dbm.c:368
bool create_workspace(gen_array_t files)
FI: should be called "initialize_workspace()"; a previous call to db_create_workspace() is useful to ...
Definition: dbm.c:180
bool close_workspace(bool is_quit)
Definition: dbm.c:346
bool lazy_open_module(const char *name)
Do not open a module already opened :
Definition: dbm.c:289
bool open_workspace(const char *name)
should be: success (cf wpips.h)
Definition: dbm.c:309
void send_the_names_of_the_available_modules_to_emacs(void)
Tell Emacs about what are the modules available in the current workspace, if any:
Definition: emacs.c:137
bool wpips_emacs_mode
Here are all the stuff to interface Pips with Emacs.
Definition: emacs.c:65
void send_notice_prompt_to_emacs(char *first_line,...)
Definition: emacs.c:220
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
FILE * safe_fopen(const char *filename, const char *what)
Definition: file.c:67
char * get_cwd(void)
returns the current working directory name.
Definition: file.c:486
int safe_fclose(FILE *stream, const char *filename)
Definition: file.c:77
void free(void *)
#define SMALL_BUFFER_LENGTH
Definition: gpips-local.h:24
GtkWidget * main_frame
If we are in the Emacs mode, the log_frame is no longer really used:
Definition: gpips.c:60
bool success
Definition: gpips-local.h:59
GtkWidget * generate_a_directory_menu(char *directory)
gen_array_t db_get_module_list(void)
Get an array of all the modules (functions, procedures and compilation units) of a workspace.
Definition: database.c:1266
void disable_compile_selection()
Definition: gtk_compile.c:74
void enable_compile_selection()
Definition: gtk_compile.c:78
void disable_view_selection()
Definition: gtk_edit2.c:505
void enable_view_selection()
Definition: gtk_edit2.c:509
void edit_close_notify(GtkWidget *widget, gpointer data)
Definition: gtk_edit2.c:436
void prompt_user(string a_printf_format,...)
Definition: gtk_log.c:66
void mchoose(char *title, gen_array_t array, void(*function_ok)(gen_array_t), void(*function_cancel)(void))
Definition: gtk_mchoose.c:212
void enable_option_selection()
Definition: gtk_props.c:134
void disable_option_selection()
Definition: gtk_props.c:130
void start_query(char *window_title, char *query_title, char *help_topic, success(*ok_func)(const char *), void(*cancel_func)(GtkWidget *, gpointer))
Definition: gtk_query.c:47
void cancel_query_notify(GtkWidget *widget, gpointer data)
hides a window...
Definition: gtk_query.c:118
void schoose(char *title, gen_array_t array, char *initial_choice, void(*function_for_ok)(const char *), void(*function_for_cancel)(void))
Definition: gtk_schoose2.c:150
void schoose_close()
schoose_close() can be called even when schoose window is already closed.
Definition: gtk_schoose2.c:113
void show_workspace()
Definition: gtk_status.c:123
void show_directory()
Definition: gtk_status.c:118
void display_memory_usage()
Definition: gtk_status.c:84
void show_module()
Definition: gtk_status.c:134
void disable_transform_selection()
Definition: gtk_transform.c:91
void enable_transform_selection()
Definition: gtk_transform.c:95
gint hide_window(GtkWidget *window, GdkEvent *ev __attribute__((unused)), gpointer data __attribute__((unused)))
Definition: gtk_utils.c:89
#define user_warning(fn,...)
Definition: misc-local.h:262
#define MAXPATHLEN
MAXPATHLEN is defined in <sys/param.h> for SunOS...
Definition: misc-local.h:203
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
void safe_system(string)
system.c
Definition: system.c:38
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define string_undefined_p(s)
Definition: newgen_types.h:41
bool workspace_exists_p(const char *)
Definition: workspace.c:266
bool db_create_workspace(const char *)
Definition: workspace.c:282
string db_get_current_workspace_name(void)
the function is used to check that there is some current workspace...
Definition: workspace.c:82
bool workspace_name_p(const char *)
workspace.c
Definition: workspace.c:46
string get_first_main_module(void)
Should be able to handle Fortran applications, C applications and mixed Fortran/C applications.
Definition: pipsmake.c:1525
void pips_get_fortran_list(gen_array_t)
Select the true file with names ending in ".[fF]" and return a sorted arg list:
Definition: source_file.c:89
void pips_get_workspace_list(gen_array_t)
cproto-generated files
Definition: source_file.c:74
string pips_change_directory(const char *)
Change to the given directory if it exists and return a canonical name.
Definition: source_file.c:142
char * strdup()
Frame schoose_frame
Definition: wpips-local.h:38
void initialize_wpips_hpfc_hack_for_fabien_and_from_fabien()
Definition: xv_compile.c:214
void select_module_notify(Menu menu, Menu_item menu_item)
Definition: xv_select.c:920
bool wpips_delete_workspace_menu_inactive
Definition: xv_select.c:77
static Menu_item create_pgm
Definition: xv_select.c:244
void end_select_module_notify(string name)
Definition: xv_select.c:882
void disable_module_selection()
Definition: xv_select.c:330
bool wpips_close_workspace_menu_inactive_old
Definition: xv_select.c:74
Menu_item directory_menu_item
Definition: xv_select.c:68
void enable_module_selection()
Definition: xv_select.c:342
void end_delete_workspace_notify(char *name)
Definition: xv_select.c:359
void end_directory_text_notify(Panel_item text_item, Event *event)
Definition: xv_select.c:129
void prompt_user_not_allowed_to_change_directory(Panel_item text_item, Event *event)
Definition: xv_select.c:174
void user_prompt_not_a_valid_workspace_name(char *workspace_name)
Definition: xv_select.c:572
Menu generate_directory_menu()
Definition: xv_select.c:167
Menu generate_module_menu()
To use with schoose_create_abbrev_menu_with_text:
Definition: xv_select.c:947
void enable_workspace_create_or_open()
Definition: xv_select.c:264
void start_create_workspace_notify(Menu menu, Menu_item menu_item)
Definition: xv_select.c:451
void disable_workspace_delete_or_open()
Definition: xv_select.c:280
void cancel_select_module_notify()
Definition: xv_select.c:915
static Menu_item module_item
Definition: xv_select.c:244
void start_directory_notify(Menu menu, Menu_item menu_item)
Definition: xv_select.c:184
void open_workspace_notify(Menu menu, Menu_item menu_item)
Definition: xv_select.c:665
bool wpips_change_directory_inactive
Definition: xv_select.c:78
void disable_change_directory()
Definition: xv_select.c:218
void enable_workspace_close()
Definition: xv_select.c:314
void cancel_create_workspace_notify(Panel_item item, Event *event)
Definition: xv_select.c:477
static char * workspace_name_to_create
Definition: xv_select.c:70
void create_select_menu()
Definition: xv_select.c:1016
void select_a_module_by_default()
Try to select a main module (that is the PROGRAM in the Fortran stuff) if no one is selected:
Definition: xv_select.c:85
bool wpips_create_workspace_menu_inactive
Definition: xv_select.c:75
static Menu_item open_pgm
Definition: xv_select.c:244
void start_delete_workspace_notify(Menu menu, Menu_item menu_item)
Definition: xv_select.c:419
void disable_workspace_create_or_open()
Definition: xv_select.c:248
bool wpips_close_workspace_menu_inactive
To enable or disable the menu items generated by generate_module_menu():
Definition: xv_select.c:73
bool wpips_open_workspace_menu_inactive
Definition: xv_select.c:76
bool wpips_change_directory_inactive_old
Definition: xv_select.c:79
void end_create_workspace_notify(gen_array_t files)
Definition: xv_select.c:583
static void restore_enable_change_directory_state()
Definition: xv_select.c:235
void enable_change_directory()
Definition: xv_select.c:201
void cancel_open_workspace_notify()
Definition: xv_select.c:656
void enable_workspace_delete_or_open()
Definition: xv_select.c:293
void direct_change_directory()
FC: uses an external wish script I do not know how to activate this function safely....
Definition: xv_select.c:139
void end_open_workspace_notify(string name)
Definition: xv_select.c:634
success continue_create_workspace_notify(char *name)
Definition: xv_select.c:490
success end_directory_notify(char *dir)
Definition: xv_select.c:109
void open_or_create_workspace(char *workspace_name_original)
To be used with schoose_create_abbrev_menu_with_text from the main panel:
Definition: xv_select.c:741
void cancel_delete_workspace_notify()
Definition: xv_select.c:408
success close_workspace_notify(Menu menu, Menu_item menu_item)
Definition: xv_select.c:702
void restore_enable_workspace_close_state()
Definition: xv_select.c:323
static Menu_item close_pgm
Definition: xv_select.c:244
@ WPIPS_MAX_MODULE_MENU_SIZE
Definition: xv_select.c:64
void disable_workspace_close()
Definition: xv_select.c:304
Menu generate_workspace_menu()
To use with schoose_create_abbrev_menu_with_text:
Definition: xv_select.c:790
Panel_item module_name_panel_item
Definition: xv_status.c:70
Panel_item workspace_name_panel_item
Definition: xv_status.c:68
Panel_item directory_name_panel_item
Definition: xv_status.c:67