PIPS
xv_props.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <xview/xview.h>
#include <xview/frame.h>
#include <xview/panel.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "top-level.h"
#include "database.h"
#include "misc.h"
#include "ri-util.h"
#include "pipsdbm.h"
#include "pipsmake.h"
#include "complexity_ri.h"
#include "constants.h"
#include "resources.h"
#include "properties.h"
#include "wpips.h"
+ Include dependency graph for xv_props.c:

Go to the source code of this file.

Data Structures

struct  option_type
 lint More...
 

Macros

#define OPTION_PANEL_BUTTONS_ALIGNED
 
#define BSIZE_HERE   (256)
 

Functions

string hash_get_key_by_value (hash_table htp, string svp)
 returns the first key which value is svp. More...
 
void disable_panel_item (Panel_item item)
 
void enable_panel_item (Panel_item item)
 
void apply_on_each_option_item (void(*function_to_apply_on_each_menu_item)(Menu_item), void(*function_to_apply_on_each_panel_item)(Panel_item))
 
void disable_option_selection ()
 
void enable_option_selection ()
 
void update_options ()
 
void options_select (char *aliased_phase)
 The following procedure is never used ! I have removed it. More...
 
void options_panel_notify (Panel_item item, int valeur, Event *event)
 "value" is already used for a typedef... More...
 
void options_panel_to_view_menu_gateway (Panel_item item, Event *event)
 
void options_menu_notify (Menu menu, Menu_item menu_item)
 
static int compare_option_type_for_qsort (const void *x, const void *y)
 The function used by qsort to compare 2 option_type structures according to their name string: More...
 
void build_options_menu_and_panel (Menu menu_options, Panel options_panel)
 Build the option menu by looking at the pipsmake.rc file and searching if there are several way to build a ressource: More...
 
void build_aliases ()
 
void display_or_hide_options_panel (Menu menu, Menu_item menu_item)
 
static void options_frame_done_procedure (Frame frame)
 Hide and restore the menu item to reopen the option panel: More...
 
void create_options_menu_and_window ()
 

Variables

static Menu smenu_options
 
static Menu options_menu
 
static Menu_item options_panel_menu_item
 
Panel options_panel
 
static hash_table aliases
 
static char display_options_panel [] = "Options panel..."
 
static char hide_options_panel [] = "Hide options panel"
 
int verbose_update_options = 1
 Flag allowing update_options also to select a option : More...
 

Macro Definition Documentation

◆ BSIZE_HERE

#define BSIZE_HERE   (256)

Definition at line 660 of file xv_props.c.

◆ OPTION_PANEL_BUTTONS_ALIGNED

#define OPTION_PANEL_BUTTONS_ALIGNED

Definition at line 56 of file xv_props.c.

Function Documentation

◆ apply_on_each_option_item()

void apply_on_each_option_item ( void(*)(Menu_item)  function_to_apply_on_each_menu_item,
void(*)(Panel_item)  function_to_apply_on_each_panel_item 
)

Walk through items of menu_options

find resource corresponding to the item

Skip the title item:

It must be the pin item, or the item controlling the options panel.

Now walk through the options panel:

Only on the PANEL_CHOICE_STACK:

Definition at line 109 of file xv_props.c.

111 {
112  int i;
113 
114  /* Walk through items of menu_options */
115  for (i = (int) xv_get(options_menu, MENU_NITEMS); i > 0; i--) {
116  char * res_alias_n;
117 
118  /* find resource corresponding to the item */
119  Menu_item menu_item = (Menu_item) xv_get(options_menu, MENU_NTH_ITEM, i);
120 
121  if ((bool) xv_get(menu_item, MENU_TITLE))
122  /* Skip the title item: */
123  break;
124 
125  res_alias_n = (string) xv_get(menu_item, MENU_STRING);
126  if (res_alias_n == NULL
127  || strcmp(res_alias_n, display_options_panel) == 0
128  || strcmp(res_alias_n, hide_options_panel) == 0)
129  /* It must be the pin item, or the item controlling the
130  options panel. */
131  continue;
132 
133  function_to_apply_on_each_menu_item(menu_item);
134  }
135 
136  /* Now walk through the options panel: */
137  {
138  Panel_item panel_item;
139 
140  PANEL_EACH_ITEM(options_panel, panel_item)
141  /* Only on the PANEL_CHOICE_STACK: */
142  if ((Panel_item_type) xv_get(panel_item, PANEL_ITEM_CLASS) ==
143  PANEL_CHOICE_ITEM)
144  function_to_apply_on_each_panel_item(panel_item);
145  PANEL_END_EACH
146  }
147 }
char * string
STRING.
Definition: newgen_types.h:39
static Menu options_menu
Definition: xv_props.c:67
static char hide_options_panel[]
Definition: xv_props.c:74
static char display_options_panel[]
Definition: xv_props.c:73
Panel options_panel
Definition: xv_props.c:69

References display_options_panel, hide_options_panel, options_menu, and options_panel.

Referenced by disable_option_selection(), and enable_option_selection().

+ Here is the caller graph for this function:

◆ build_aliases()

void build_aliases ( )

Definition at line 663 of file xv_props.c.

664 {
665  char buffer[BSIZE_HERE];
666  char true_name[BSIZE_HERE], alias_name[BSIZE_HERE];
667  FILE *fd;
668 
670 
671  fd = fopen_config(WPIPS_RC, NULL,NULL);
672 
673  while (fgets(buffer, BSIZE_HERE, fd) != NULL) {
674  if (buffer[0] == '-')
675  continue;
676 
677  sscanf(buffer, "alias%s '%[^']", true_name, alias_name);
678 
679  if (hash_get(aliases, alias_name) != HASH_UNDEFINED_VALUE) {
680  pips_internal_error("Aliases must not be ambiguous\n"
681  "\talias '%s' seems ambiguous!\n", true_name);
682  }
683  else {
684  char upper[128];
685 
686  hash_put(aliases,
687  strdup(alias_name),
688  strdup(strupper(upper, true_name)));
689  }
690  }
691  safe_fclose(fd, WPIPS_RC);
692 }
int safe_fclose(FILE *stream, const char *filename)
Definition: file.c:77
FILE * fopen_config(const char *canonical_name, const char *cproperty, const char *cenv)
Definition: file.c:952
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:449
void hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
Definition: hash.c:364
#define pips_internal_error
Definition: misc-local.h:149
string strupper(string, const char *)
Definition: string.c:213
@ hash_string
Definition: newgen_hash.h:32
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
Definition: newgen_hash.h:56
char * strdup()
static string buffer
Definition: string.c:113
#define BSIZE_HERE
Definition: xv_props.c:660
static hash_table aliases
Definition: xv_props.c:71

References aliases, BSIZE_HERE, buffer, fopen_config(), hash_get(), hash_put(), hash_string, hash_table_make(), HASH_UNDEFINED_VALUE, pips_internal_error, safe_fclose(), strdup(), and strupper().

Referenced by create_options_menu_and_window().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ build_options_menu_and_panel()

void build_options_menu_and_panel ( Menu  menu_options,
Panel  options_panel 
)

Build the option menu by looking at the pipsmake.rc file and searching if there are several way to build a ressource:

The option panel use the definition of the edit menu and so needs to be create after it:

walking thru rules

walking thru resources made by this particular rule

walking thru phase_by_made_htp

First, try to do some measurements on the options item to be able to sort and align menu items later:

Now generate an array of the Options:

Sort the Options:

Create the Options in the Option menu and option panel:

Create the sub-menu entry of an option:

PANEL_CLIENT_DATA is used to link the PANEL_CHOICE_STACK to its dual MENU_PULLRIGHT. RK, 11/06/1993.

Nothing selected yet:

Add a sub-option entry in the menu:

Attach the sub-menu to an Option menu:

... And in the Option panel:

Create the Option Item for this alias:

Attach the Option Item to the Option menu:

Add a link information from the sub_menu_option to the equivalent panel_choice_item for update_props():

Now we set the width of the PANEL_CHOICE_STACK items the same to have a nicer vertical alignment:

If I want something with the buttons vertically aligned:

It looks on my screen that this width is 8:7 larger. Apply a pifometric scaling factor... :-)

According to a suggestion from Guillaume Oget, it should be nice to be able to select a view also from the Option panel:

Find if the View menu has an item with the same value:

Do not create the menu item if it does not exist:

OK, there is also a View menu with the same name.

Shift a little bit the PANEL_LABEL to align with other text of the menu buttons:

Definition at line 373 of file xv_props.c.

375 {
376  int i, j;
377  option_type *all_the_options;
378  makefile m = parse_makefile();
379  int max_item_width = 0;
380 
381  int number_of_options = 0;
382  hash_table phase_by_made_htp = hash_table_make(hash_string, 0);
383 
384  smenu_options = menu_options;
385 
386  /* walking thru rules */
387  MAPL(pr, {
388  rule r = RULE(CAR(pr));
389 
390  /* walking thru resources made by this particular rule */
391  MAPL(pvr, {
393  string vrn = virtual_resource_name(vr);
394  list p = CONS(STRING, rule_phase(r), NIL);
395  list l = (list) hash_get(phase_by_made_htp, vrn);
396 
397  if ( l == (list) HASH_UNDEFINED_VALUE ) {
398  hash_put(phase_by_made_htp, vrn, (char *)p);
399  }
400  else {
401  (void) gen_nconc(l, p);
402  }
403  }, rule_produced(r));
404 
405  }, makefile_rules(m));
406 
407  /* walking thru phase_by_made_htp */
408 
409  /* First, try to do some measurements on the options item to be
410  able to sort and align menu items later: */
411  HASH_MAP(k, v, {
412  string alias1 = hash_get_key_by_value(aliases, k);
413  list l = (list) v;
414 
415  if ((alias1 != HASH_UNDEFINED_VALUE) && (gen_length(l) >= 2))
416  number_of_options++;
417  }, phase_by_made_htp);
418 
419  all_the_options = (option_type *)
420  malloc(number_of_options*sizeof(option_type));
421 
422  /* Now generate an array of the Options: */
423  i = 0;
424  HASH_MAP(k, v, {
425  string alias1 = hash_get_key_by_value(aliases, k);
426  list l = (list) v;
427 
428  if ((alias1 != HASH_UNDEFINED_VALUE) && (gen_length(l) >= 2)) {
429  all_the_options[i].name = alias1;
430  all_the_options[i].choices = l;
431  i++;
432  }
433  }, phase_by_made_htp);
434 
435  /* Sort the Options: */
436  qsort((char *)all_the_options,
437  number_of_options,
438  sizeof(option_type),
440 
441  /* Create the Options in the Option menu and option panel: */
442  for(i = 0; i < number_of_options; i++) {
443  Menu sub_menu_option;
444  Menu_item menu_options_item;
445  Panel_item panel_choice_item;
446 
447  /* Create the sub-menu entry of an option: */
448  sub_menu_option =
449  (Menu) xv_create(NULL, MENU_CHOICE_MENU,
450  MENU_NOTIFY_PROC, options_menu_notify,
451  NULL);
452 
453  /* PANEL_CLIENT_DATA is used to link the PANEL_CHOICE_STACK
454  to its dual MENU_PULLRIGHT. RK, 11/06/1993. */
455  panel_choice_item = xv_create(options_panel, PANEL_CHOICE_STACK,
456  PANEL_LAYOUT, PANEL_HORIZONTAL,
457  PANEL_LABEL_STRING,
458  all_the_options[i].name,
459  PANEL_CLIENT_DATA, sub_menu_option,
460  /* Nothing selected yet: */
461  PANEL_VALUE, 0,
462  PANEL_NOTIFY_PROC, options_panel_notify,
463  NULL);
464  j = 0;
465  MAPL(vrn, {
466  string alias2 = hash_get_key_by_value(aliases,
467  STRING(CAR(vrn)));
468  Menu_item sub_menu_option_item;
469 
470  if (alias2 != HASH_UNDEFINED_VALUE) {
471  /* Add a sub-option entry in the menu: */
472  sub_menu_option_item = (Menu_item) xv_create(NULL, MENUITEM,
473  MENU_STRING,
474  alias2,
475  MENU_RELEASE,
476  NULL);
477  /* Attach the sub-menu to an Option menu: */
478  xv_set(sub_menu_option,
479  MENU_APPEND_ITEM, sub_menu_option_item,
480  NULL);
481  /* ... And in the Option panel: */
482  xv_set(panel_choice_item,
483  PANEL_CHOICE_STRING,
484  j++,
485  alias2,
486  NULL);
487  }
488  }, all_the_options[i].choices);
489  /* Create the Option Item for this alias: */
490  menu_options_item = (Menu_item) xv_create(NULL, MENUITEM,
491  MENU_STRING,
492  all_the_options[i].name,
493  MENU_PULLRIGHT,
494  sub_menu_option,
495  MENU_RELEASE,
496  NULL);
497  /* Attach the Option Item to the Option menu: */
498  xv_set(menu_options, MENU_APPEND_ITEM, menu_options_item, NULL);
499  /* Add a link information from the sub_menu_option to the
500  equivalent panel_choice_item for update_props(): */
501  xv_set(sub_menu_option,
502  MENU_CLIENT_DATA, panel_choice_item,
503  NULL);
504  }
505 
506  /* Now we set the width of the PANEL_CHOICE_STACK items the same to
507  have a nicer vertical alignment: */
508  {
509  Panel_item item;
510 
511 #ifdef OPTION_PANEL_BUTTONS_ALIGNED
512  /* If I want something with the buttons vertically aligned: */
513  PANEL_EACH_ITEM(options_panel, item)
514  max_item_width = MAX(max_item_width,
515  (int) xv_get(item, PANEL_LABEL_WIDTH));
516  PANEL_END_EACH
517 
518  /* It looks on my screen that this width is 8:7 larger. Apply
519  a pifometric scaling factor... :-) */
520  max_item_width = (max_item_width*7)/8;
521 
522  PANEL_EACH_ITEM(options_panel, item)
523  xv_set(item, PANEL_LABEL_WIDTH,
524  max_item_width,
525  NULL);
526  PANEL_END_EACH
527 #else
528  /* If I want something a` la TeX, justified on the left and
529  on the right: */
530  PANEL_EACH_ITEM(options_panel, item)
531  max_item_width = MAX(max_item_width,
532  (int) xv_get(item, XV_WIDTH));
533  PANEL_END_EACH
534 
535  PANEL_EACH_ITEM(options_panel, item)
536  xv_set(item, PANEL_LABEL_WIDTH,
537  (int) xv_get(item, PANEL_LABEL_WIDTH)
538  + max_item_width
539  - (int) xv_get(item, XV_WIDTH),
540  NULL);
541  PANEL_END_EACH
542 #endif
543  }
544 
545  /* According to a suggestion from Guillaume Oget, it should be nice
546  to be able to select a view also from the Option panel: */
547  {
548  Panel_item option_item;
549  char * option_item_label;
550 
551  PANEL_EACH_ITEM(options_panel, option_item)
552  if ((Panel_item_type) xv_get(option_item, PANEL_ITEM_CLASS) ==
553  PANEL_CHOICE_ITEM) {
554  Menu_item view_menu_item;
555 
556  option_item_label = (char *) xv_get(option_item,
557  PANEL_LABEL_STRING);
558 
559  /* Find if the View menu has an item with the same value: */
561  (Menu_item) xv_find(view_menu, MENUITEM,
562  MENU_STRING, option_item_label,
563  /* Do not create the menu item if it
564  does not exist: */
565  XV_AUTO_CREATE, FALSE,
566  NULL);
567  if (view_menu_item != XV_NULL) {
568  /* OK, there is also a View menu with the same name. */
569  xv_create(options_panel, PANEL_BUTTON,
570  PANEL_NOTIFY_PROC, options_panel_to_view_menu_gateway,
571  PANEL_LABEL_STRING, option_item_label,
572  XV_X, xv_get(option_item, XV_X),
573  XV_Y, xv_get(option_item, XV_Y),
574  NULL);
575 
576  xv_set(option_item,
577  PANEL_LABEL_STRING, NULL,
578  PANEL_LABEL_WIDTH, 0,
579  PANEL_VALUE_X, xv_get(option_item, PANEL_VALUE_X),
580  NULL);
581  }
582  else {
583  /* Shift a little bit the PANEL_LABEL to align with
584  other text of the menu buttons: */
585  xv_set(option_item,
586  PANEL_VALUE_X, xv_get(option_item, PANEL_VALUE_X),
587  PANEL_LABEL_X, xv_get(option_item, PANEL_LABEL_X) + 8,
588  NULL);
589 
590  }
591  }
592  PANEL_END_EACH
593  }
594 
595 #if 0
596  {
597  Panel_item option_item;
598  char * option_item_label;
599  Panel_item * the_option_panel_items;
600  int number_of_options_to_link_with_the_view_menu;
601  int i = 0;
602 
603  /* A conservative allocation... */
604  the_option_panel_items = (Panel_item *) calloc(number_of_options,
605  sizeof(Panel_item *));
606 
607  PANEL_EACH_ITEM(options_panel, option_item)
608  {
609  Menu_item view_menu_item;
610 
611  option_item_label = (char *) xv_get(option_item,
612  PANEL_LABEL_STRING);
613 
614  /* Find if the View menu has an item with the same value: */
616  (Menu_item) xv_find(view_menu, MENUITEM,
617  MENU_STRING, option_item_label,
618  /* Do not create the menu item if it
619  does not exist: */
620  XV_AUTO_CREATE, FALSE,
621  NULL);
622  if (view_menu_item != XV_NULL) {
623  /* OK, there is also a View menu with the same name. */
624  /* Put it in the array of panel items to create. We
625  cannot create it directly since it would confuse
626  PANEL_EACH_ITEM: */
627  the_option_panel_items[i++] = option_item;
628  }
629  }
630  PANEL_END_EACH
631  number_of_options_to_link_with_the_view_menu = i;
632 
633  window_fit(options_panel);
634  window_fit(options_frame);
635 
636  for(i = 0; i < number_of_options_to_link_with_the_view_menu; i++) {
637  /* Overlay the label of an option item with a button
638  with the same name to select the View item: */
639  xv_create(options_panel, PANEL_BUTTON,
640  PANEL_NOTIFY_PROC, options_panel_to_view_menu_gateway,
641  PANEL_LABEL_STRING, xv_get(the_option_panel_items[i],
642  PANEL_LABEL_STRING),
643  XV_X, xv_get(the_option_panel_items[i],
644  XV_X),
645  XV_Y, xv_get(the_option_panel_items[i],
646  XV_Y),
647  NULL);
648 
649  xv_set(the_option_panel_items[i],
650  PANEL_LABEL_STRING, NULL,
651  PANEL_LABEL_WIDTH, 0,
652  PANEL_VALUE_X, xv_get(the_option_panel_items[i],
653  PANEL_VALUE_X),
654  NULL);
655  }
656  }
657 #endif
658 }
#define STRING(x)
Definition: genC.h:87
void * malloc(YYSIZE_T)
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
size_t gen_length(const list l)
Definition: list.c:150
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203
GtkWidget * view_menu
The menu "View" on the main panel:
Definition: gtk_edit2.c:93
GtkWidget * view_menu_item
Definition: gtk_edit2.c:93
GtkWidget * options_frame
Definition: gtk_props.c:67
#define rule_phase(x)
Definition: makefile.h:244
#define RULE(x)
RULE.
Definition: makefile.h:209
#define virtual_resource_name(x)
Definition: makefile.h:290
#define rule_produced(x)
Definition: makefile.h:248
#define VIRTUAL_RESOURCE(x)
VIRTUAL_RESOURCE.
Definition: makefile.h:260
#define makefile_rules(x)
Definition: makefile.h:82
#define HASH_MAP(k, v, code, ht)
Definition: newgen_hash.h:60
struct cons * list
Definition: newgen_types.h:106
makefile parse_makefile(void)
#define MAX(x, y)
Definition: string.c:110
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
static Menu smenu_options
Definition: xv_props.c:66
static int compare_option_type_for_qsort(const void *x, const void *y)
The function used by qsort to compare 2 option_type structures according to their name string:
Definition: xv_props.c:360
void options_panel_to_view_menu_gateway(Panel_item item, Event *event)
Definition: xv_props.c:339
void options_menu_notify(Menu menu, Menu_item menu_item)
Definition: xv_props.c:349
string hash_get_key_by_value(hash_table htp, string svp)
returns the first key which value is svp.
Definition: xv_props.c:81
void options_panel_notify(Panel_item item, int valeur, Event *event)
"value" is already used for a typedef...
Definition: xv_props.c:316

References aliases, CAR, option_type::choices, compare_option_type_for_qsort(), CONS, gen_length(), gen_nconc(), hash_get(), hash_get_key_by_value(), HASH_MAP, hash_put(), hash_string, hash_table_make(), HASH_UNDEFINED_VALUE, makefile_rules, malloc(), MAPL, MAX, option_type::name, NIL, options_frame, options_menu_notify(), options_panel, options_panel_notify(), options_panel_to_view_menu_gateway(), parse_makefile(), RULE, rule_phase, rule_produced, smenu_options, STRING, view_menu, view_menu_item, VIRTUAL_RESOURCE, and virtual_resource_name.

Referenced by create_options_menu_and_window().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compare_option_type_for_qsort()

static int compare_option_type_for_qsort ( const void *  x,
const void *  y 
)
static

The function used by qsort to compare 2 option_type structures according to their name string:

Definition at line 360 of file xv_props.c.

362 {
363  return strcmp(((option_type *) x)->name, ((option_type *) y)->name);
364 }
static char * x
Definition: split_file.c:159

References x.

Referenced by build_options_menu_and_panel().

+ Here is the caller graph for this function:

◆ create_options_menu_and_window()

void create_options_menu_and_window ( )

RK, 11/06/1993. There is no room :

Trap the FRAME_DONE event:

Definition at line 728 of file xv_props.c.

729 {
730  options_panel = (Panel) xv_create(options_frame, PANEL,
731  PANEL_LAYOUT, PANEL_VERTICAL,
732  /* RK, 11/06/1993. There is no room : */
733  PANEL_ITEM_Y_GAP, 0,
734  PANEL_ITEM_X_GAP, 0,
735  NULL);
736 
737  /* Trap the FRAME_DONE event: */
738  xv_set(options_frame, FRAME_DONE_PROC, options_frame_done_procedure, NULL);
739 
741  (Menu_item) xv_create(NULL, MENUITEM,
742  MENU_STRING, display_options_panel,
743  MENU_NOTIFY_PROC, display_or_hide_options_panel,
744  NULL);
745  options_menu = (Menu) xv_create(XV_NULL, MENU_COMMAND_MENU,
746  MENU_TITLE_ITEM, "Selecting PIPS Options ",
747  MENU_GEN_PIN_WINDOW, main_frame, "Options Menu",
748  MENU_APPEND_ITEM, options_panel_menu_item,
749  NULL);
750 
751  build_aliases();
753 
754  (void) xv_create(main_panel, PANEL_BUTTON,
755  PANEL_LABEL_STRING, "Options",
756  PANEL_ITEM_MENU, options_menu,
757  NULL);
758 
759  window_fit(options_panel);
760  window_fit(options_frame);
761 }
GtkWidget * main_frame
If we are in the Emacs mode, the log_frame is no longer really used:
Definition: gpips.c:60
Panel main_panel
Definition: wpips.c:63
void build_options_menu_and_panel(Menu menu_options, Panel options_panel)
Build the option menu by looking at the pipsmake.rc file and searching if there are several way to bu...
Definition: xv_props.c:373
static void options_frame_done_procedure(Frame frame)
Hide and restore the menu item to reopen the option panel:
Definition: xv_props.c:720
static Menu_item options_panel_menu_item
Definition: xv_props.c:68
void display_or_hide_options_panel(Menu menu, Menu_item menu_item)
Definition: xv_props.c:695
void build_aliases()
Definition: xv_props.c:663

References build_aliases(), build_options_menu_and_panel(), display_options_panel, display_or_hide_options_panel(), main_frame, main_panel, options_frame, options_frame_done_procedure(), options_menu, options_panel, and options_panel_menu_item.

+ Here is the call graph for this function:

◆ disable_option_selection()

void disable_option_selection ( )

Definition at line 151 of file xv_props.c.

152 {
154 }
void disable_menu_item(Menu_item item)
Definition: xv_edit2.c:558
void apply_on_each_option_item(void(*function_to_apply_on_each_menu_item)(Menu_item), void(*function_to_apply_on_each_panel_item)(Panel_item))
Definition: xv_props.c:109
void disable_panel_item(Panel_item item)
Definition: xv_props.c:95

References apply_on_each_option_item(), disable_menu_item(), and disable_panel_item().

+ Here is the call graph for this function:

◆ disable_panel_item()

void disable_panel_item ( Panel_item  item)

Definition at line 95 of file xv_props.c.

96 {
97  xv_set(item, PANEL_INACTIVE, TRUE, 0);
98 }

Referenced by disable_option_selection(), and disable_view_selection().

+ Here is the caller graph for this function:

◆ display_or_hide_options_panel()

void display_or_hide_options_panel ( Menu  menu,
Menu_item  menu_item 
)

Should be added : when the options panel is destroyed by the window manager, toggle the menu. RK, 7/6/93.

Definition at line 695 of file xv_props.c.

697 {
698  char *message_string;
699 
700 
701  /* Should be added : when the options panel is destroyed by the
702  window manager, toggle the menu. RK, 7/6/93. */
703 
704  message_string = (char *) xv_get(menu_item, MENU_STRING);
705  if (strcmp(message_string, display_options_panel) == 0)
706  {
708  xv_set(menu_item, MENU_STRING, hide_options_panel, NULL);
709  }
710  else
711  {
713  xv_set(menu_item, MENU_STRING, display_options_panel, NULL);
714  }
715 }
gint hide_window(GtkWidget *window, GdkEvent *ev __attribute__((unused)), gpointer data __attribute__((unused)))
Definition: gtk_utils.c:89
void unhide_window(Frame frame)
map a frame on the screen
Definition: xv_utils.c:55

References display_options_panel, hide_options_panel, hide_window(), options_frame, and unhide_window().

Referenced by create_options_menu_and_window().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enable_option_selection()

void enable_option_selection ( )

Definition at line 158 of file xv_props.c.

159 {
161 }
void enable_menu_item(Menu_item item)
Definition: xv_edit2.c:565
void enable_panel_item(Panel_item item)
Definition: xv_props.c:102

References apply_on_each_option_item(), enable_menu_item(), and enable_panel_item().

+ Here is the call graph for this function:

◆ enable_panel_item()

void enable_panel_item ( Panel_item  item)

Definition at line 102 of file xv_props.c.

103 {
104  xv_set(item, PANEL_INACTIVE, FALSE, 0);
105 }

Referenced by enable_option_selection(), and enable_view_selection().

+ Here is the caller graph for this function:

◆ hash_get_key_by_value()

string hash_get_key_by_value ( hash_table  htp,
string  svp 
)

returns the first key which value is svp.

when not found, returns NULL

Definition at line 81 of file xv_props.c.

84 {
85  HASH_MAP(kp, vp, {
86  if (strcmp(vp, svp) == 0)
87  return kp;
88  }, htp);
89 
90  return HASH_UNDEFINED_VALUE;
91 }

References HASH_MAP, and HASH_UNDEFINED_VALUE.

Referenced by build_options_menu_and_panel(), and update_options().

+ Here is the caller graph for this function:

◆ options_frame_done_procedure()

static void options_frame_done_procedure ( Frame  frame)
static

Hide and restore the menu item to reopen the option panel:

Definition at line 720 of file xv_props.c.

721 {
723  xv_set(options_panel_menu_item, MENU_STRING, display_options_panel, NULL);
724 }

References display_options_panel, hide_window(), options_frame, and options_panel_menu_item.

Referenced by create_options_menu_and_window().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ options_menu_notify()

void options_menu_notify ( Menu  menu,
Menu_item  menu_item 
)

Definition at line 349 of file xv_props.c.

351 {
352  string aliased_phase = (char *) xv_get(menu_item, MENU_STRING);
353  options_select(aliased_phase);
354 }
void options_select(char *aliased_phase)
The following procedure is never used ! I have removed it.
Definition: xv_props.c:285

References options_select().

Referenced by build_options_menu_and_panel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ options_panel_notify()

void options_panel_notify ( Panel_item  item,
int  valeur,
Event *  event 
)

"value" is already used for a typedef...

:-) RK, 11/06/1993.

Look at the corresponding (dual) item in the options menu to get the value. RK, 11/06/1993.

Argh ! MENU_NTH_ITEM begins from 1 but PANEL_VALUE begins from 0... RK, 02/07/1993.

Definition at line 316 of file xv_props.c.

320 {
321 
322  Menu menu_special_prop;
323  Menu_item menu_item;
324  string aliased_phase;
325 
326  menu_special_prop = (Menu) xv_get(item, PANEL_CLIENT_DATA);
327  /* Look at the corresponding (dual) item in the options menu to
328  get the value. RK, 11/06/1993. */
329  /* Argh ! MENU_NTH_ITEM begins from 1 but
330  PANEL_VALUE begins from 0... RK, 02/07/1993. */
331  menu_item = (Menu_item) xv_get(menu_special_prop,
332  MENU_NTH_ITEM, valeur + 1);
333  aliased_phase = (string) xv_get(menu_item, MENU_STRING);
334  options_select(aliased_phase);
335 }
Entier valeur(Tableau *tp, int i, int j, Entier D)
Definition: traiter.c:178

References options_select(), and valeur().

Referenced by build_options_menu_and_panel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ options_panel_to_view_menu_gateway()

void options_panel_to_view_menu_gateway ( Panel_item  item,
Event *  event 
)

Definition at line 339 of file xv_props.c.

341 {
342  char * label = (char *) xv_get(item, PANEL_LABEL_STRING);
343 
345 }
void wpips_execute_and_display_something_from_alias(char *alias_name)
To execute something and display some Pips output with wpips or epips by knowing its alias:
Definition: xv_edit2.c:493

References wpips_execute_and_display_something_from_alias().

Referenced by build_options_menu_and_panel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ options_select()

void options_select ( char *  aliased_phase)

The following procedure is never used ! I have removed it.

RK, 11/06/1993.

To have the options panel consistent with the real phase set : RK, 05/07/1993.

Definition at line 285 of file xv_props.c.

287 {
288  string phase = hash_get(aliases, aliased_phase);
289 
290  if (phase == (string) HASH_UNDEFINED_VALUE)
291  {
292  pips_internal_error("aliases badly managed !!!\n");
293  }
294  else {
296  prompt_user("No workspace opened. Options not accounted.\n");
297  }
298  else {
299  debug_on("WPIPS_DEBUG_LEVEL");
300  activate(phase);
301  debug_off();
302  user_log("Options: phase %s (%s) set on.\n",
303  aliased_phase,
304  phase);
305  }
306  }
307  /* To have the options panel consistent with the real phase set :
308  RK, 05/07/1993. */
310  update_options();
312 }
void user_log(const char *format,...)
Definition: message.c:234
const char * activate(const char *phase)
Definition: activate.c:214
void prompt_user(string a_printf_format,...)
Definition: gtk_log.c:66
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
string db_get_current_workspace_name(void)
the function is used to check that there is some current workspace...
Definition: workspace.c:82
int verbose_update_options
Flag allowing update_options also to select a option :
Definition: xv_props.c:77
void update_options()
Definition: xv_props.c:165

References activate(), aliases, db_get_current_workspace_name(), debug_off, debug_on, hash_get(), HASH_UNDEFINED_VALUE, pips_internal_error, prompt_user(), update_options(), user_log(), and verbose_update_options.

Referenced by options_menu_notify(), and options_panel_notify().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update_options()

void update_options ( )

walk through items of menu_options

find resource corresponding to the item

Skip the title item:

It must be the pin item, or the item controlling the options panel. RK, 4/06/1993.

find special prop menu containing item corresponding to active phase

find active phase which produces resource res_true_n

There is no alias for currently selected phase: phase_true_n We have to activate another phase

It does not seem to work (the doc does not talk about xv_set for MENU_SELECTED by the way...):

Then, try harder :

walk through items of special_prop_m to select the activated one

Update the dual options panel entry :

Definition at line 165 of file xv_props.c.

166 {
167  string res_alias_n, res_true_n ,phase_alias_n ,phase_true_n;
168  Menu menu_options, special_prop_m;
169  Menu_item options_mi, special_prop_mi;
170  int i, j;
171 
172  debug_on("WPIPS_DEBUG_LEVEL");
173 
174  menu_options = smenu_options;
175 
176  /* walk through items of menu_options */
177  for (i = (int) xv_get(menu_options, MENU_NITEMS); i > 0; i--) {
178 
179  /* find resource corresponding to the item */
180  options_mi = (Menu_item) xv_get(menu_options, MENU_NTH_ITEM, i);
181 
182  if ((bool) xv_get(options_mi, MENU_TITLE))
183  /* Skip the title item: */
184  break;
185 
186  res_alias_n = (string) xv_get(options_mi, MENU_STRING);
187  if (res_alias_n == NULL
188  || strcmp(res_alias_n, display_options_panel) == 0
189  || strcmp(res_alias_n, hide_options_panel) == 0)
190  /* It must be the pin item, or the item controlling the
191  options panel. RK, 4/06/1993. */
192  continue;
193  if ((res_true_n = (string) hash_get(aliases, res_alias_n))
195  pips_internal_error("Hash table aliases no more consistent\n");
196 
197  /* find special prop menu containing item corresponding to active
198  phase*/
199  special_prop_m = (Menu) xv_get (options_mi, MENU_PULLRIGHT);
200 
201  /* find active phase which produces resource res_true_n */
202  phase_true_n = rule_phase(find_rule_by_resource(res_true_n));
203  if ( (phase_alias_n=hash_get_key_by_value(aliases, phase_true_n))
204  == HASH_UNDEFINED_VALUE ) {
205  /* There is no alias for currently selected phase: phase_true_n
206  We have to activate another phase
207  */
208  special_prop_mi = xv_get(special_prop_m, MENU_NTH_ITEM, 1);
209  phase_alias_n = (string) xv_get(special_prop_mi, MENU_STRING);
210  user_warning("update_options",
211  "No alias available for selected phase `%s'; selecting `%s'\n",
212  phase_true_n, phase_alias_n);
213  phase_true_n = hash_get(aliases, phase_alias_n);
214  activate(phase_true_n);
215  /* It does not seem to work (the doc does not talk about
216  xv_set for MENU_SELECTED by the way...): */
217  xv_set(special_prop_mi, MENU_SELECTED, TRUE, NULL);
218  /* Then, try harder : */
219  xv_set(special_prop_m,
220  MENU_DEFAULT_ITEM, special_prop_mi,
221  NULL);
222  debug(2, "update_options",
223  "Rule `%s' selected to produce resource `%s'\n",
224  phase_alias_n, res_alias_n);
225  }
226  else {
227  /* walk through items of special_prop_m to select the activated
228  one */
229  for (j = (int) xv_get(special_prop_m, MENU_NITEMS); j > 0; j--) {
230  Panel_item panel_choice_item;
231 
232  special_prop_mi = xv_get(special_prop_m, MENU_NTH_ITEM, j);
233  debug(9, "update_options", "Menu item tested:\"%s\"\n",
234  (string) xv_get(special_prop_mi, MENU_STRING));
235  if (strcmp((string)xv_get(special_prop_mi, MENU_STRING),
236  phase_alias_n ) ==0 ) {
237  xv_set(special_prop_mi, MENU_SELECTED, TRUE, NULL);
238  /* Update the dual options panel entry : */
239  panel_choice_item = (Panel_item) xv_get(special_prop_m,
240  MENU_CLIENT_DATA);
241  xv_set(panel_choice_item, PANEL_VALUE, j - 1, NULL);
242 
244  user_log("Options: phase %s set on.\n", phase_alias_n);
245  debug(2, "update_options",
246  "Rule `%s' selected to produce resource `%s'\n",
247  phase_alias_n, res_alias_n);
248  }
249  }
250  }
251  }
252 
254 
255  debug_off();
256 }
void display_memory_usage()
Definition: gtk_status.c:84
#define user_warning(fn,...)
Definition: misc-local.h:262
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
rule find_rule_by_resource(const char *rname)
This function returns the active rule to produce resource rname.
Definition: pipsmake.c:694

References activate(), aliases, debug(), debug_off, debug_on, display_memory_usage(), display_options_panel, find_rule_by_resource(), hash_get(), hash_get_key_by_value(), HASH_UNDEFINED_VALUE, hide_options_panel, pips_internal_error, rule_phase, smenu_options, user_log(), user_warning, and verbose_update_options.

Referenced by options_select().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ aliases

hash_table aliases
static

◆ display_options_panel

char display_options_panel[] = "Options panel..."
static

◆ hide_options_panel

char hide_options_panel[] = "Hide options panel"
static

◆ options_menu

Menu options_menu
static

Definition at line 67 of file xv_props.c.

Referenced by apply_on_each_option_item(), and create_options_menu_and_window().

◆ options_panel

◆ options_panel_menu_item

Menu_item options_panel_menu_item
static

Definition at line 68 of file xv_props.c.

Referenced by create_options_menu_and_window(), and options_frame_done_procedure().

◆ smenu_options

Menu smenu_options
static

Definition at line 66 of file xv_props.c.

Referenced by build_options_menu_and_panel(), and update_options().

◆ verbose_update_options

int verbose_update_options = 1

Flag allowing update_options also to select a option :

Definition at line 77 of file xv_props.c.

Referenced by options_select(), and update_options().