PIPS
gtk_props.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/resource.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 <gtk/gtk.h>
#include "gpips.h"
+ Include dependency graph for gtk_props.c:

Go to the source code of this file.

Data Structures

struct  option_type
 lint More...
 
struct  LabelAndVbox
 

Enumerations

enum  { 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 apply_on_each_options_menu_item (GtkWidget *widget, gpointer _func)
 
void apply_on_each_options_frame_choice (GtkWidget *widget, gpointer _func)
 
void apply_on_each_option_item (void(*function_to_apply_on_each_menu_item)(GtkWidget *), void(*function_to_apply_on_each_frame_choice)(GtkWidget *))
 
void disable_option_selection ()
 
void enable_option_selection ()
 
void update_options ()
 
void options_select (const char *aliased_phase)
 
void options_combo_box_change_callback (GtkWidget *item, gpointer data __attribute__((unused)))
 "value" is already used for a typedef... More...
 
void options_frame_to_view_menu_gateway (GtkWidget *widget, gpointer data __attribute__((unused)))
 
void options_menu_callback (GtkWidget *widget, gpointer data __attribute__((unused)))
 
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...
 
static void synch_viewmenu_and_opframe_search_in_view (GtkWidget *widget, gpointer data)
 
static void synch_viewmenu_and_opframe (GtkWidget *widget, gpointer data)
 
void build_options_menu_and_panel (GtkWidget *menu_options, GtkWidget *frame_vbox)
 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 ()
 Construct a table linking PIPS phase name to more human names, the aliases defined in pipsmake-rc.tex. More...
 
void display_or_hide_options_frame (GtkWidget *menu_item, gpointer data)
 
static void options_window_done_procedure (GtkWidget *window, gpointer data)
 Hide and restore the menu item to reopen the option panel: More...
 
void create_options_menu_and_window ()
 

Variables

char vcid_xv_props [] = "$Id: gtk_props.c 23065 2016-03-02 09:05:50Z coelho $"
 
static GtkWidget * smenu_options
 
static GtkWidget * options_menu
 
static GtkWidget * options_menu_item
 
static GtkWidget * options_frame_menu_item
 
GtkWidget * options_frame
 
static hash_table aliases
 
static hash_table menu_item_to_combo_box
 
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...
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
BSIZE_HERE 

Definition at line 75 of file gtk_props.c.

75  {
76  BSIZE_HERE = 256
77 };
@ BSIZE_HERE
Definition: gtk_props.c:76

Function Documentation

◆ apply_on_each_option_item()

void apply_on_each_option_item ( void(*)(GtkWidget *)  function_to_apply_on_each_menu_item,
void(*)(GtkWidget *)  function_to_apply_on_each_frame_choice 
)

Walk through items of options_menu

Now walk through the options frame:

Definition at line 116 of file gtk_props.c.

118  {
119  /* Walk through items of options_menu */
120  gtk_container_foreach(GTK_CONTAINER(options_menu), (GtkCallback)
122  function_to_apply_on_each_menu_item);
123 
124  /* Now walk through the options frame: */
125  gtk_container_foreach(GTK_CONTAINER(options_frame), (GtkCallback)
127  function_to_apply_on_each_frame_choice);
128 }
static GtkWidget * options_menu
Definition: gtk_props.c:65
void apply_on_each_options_frame_choice(GtkWidget *widget, gpointer _func)
Definition: gtk_props.c:109
void apply_on_each_options_menu_item(GtkWidget *widget, gpointer _func)
Definition: gtk_props.c:98
GtkWidget * options_frame
Definition: gtk_props.c:67

References apply_on_each_options_frame_choice(), apply_on_each_options_menu_item(), options_frame, and options_menu.

Referenced by disable_option_selection(), and enable_option_selection().

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

◆ apply_on_each_options_frame_choice()

void apply_on_each_options_frame_choice ( GtkWidget *  widget,
gpointer  _func 
)

Definition at line 109 of file gtk_props.c.

109  {
110  void (*func)(GtkWidget *);
111  func = (void(*)(GtkWidget *)) _func;
112  if (GTK_IS_COMBO_BOX(widget))
113  func(widget);
114 }

Referenced by apply_on_each_option_item().

+ Here is the caller graph for this function:

◆ apply_on_each_options_menu_item()

void apply_on_each_options_menu_item ( GtkWidget *  widget,
gpointer  _func 
)

Definition at line 98 of file gtk_props.c.

98  {
99  void (*func)(GtkWidget *);
100  func = (void(*)(GtkWidget *)) _func;
101  const char * label;
102  label = gpips_gtk_menu_item_get_label(widget);
103  if (label == NULL || strcmp(label, display_options_panel) == 0 || strcmp(
104  label, hide_options_panel) == 0)
105  return;
106  func(widget);
107 }
static char hide_options_panel[]
Definition: gtk_props.c:73
static char display_options_panel[]
Definition: gtk_props.c:72
const char * gpips_gtk_menu_item_get_label(GtkWidget *w)
Definition: gtk_utils.c:43

References display_options_panel, gpips_gtk_menu_item_get_label(), and hide_options_panel.

Referenced by apply_on_each_option_item().

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

◆ build_aliases()

void build_aliases ( )

Construct a table linking PIPS phase name to more human names, the aliases defined in pipsmake-rc.tex.

Definition at line 461 of file gtk_props.c.

461  {
462  static int runs = 0;
463  runs++;
464  char buffer[BSIZE_HERE];
465  char true_name[BSIZE_HERE], alias_name[BSIZE_HERE];
466  FILE *fd;
467 
469 
470  fd = fopen_config(WPIPS_RC, NULL,NULL);
471 
472  while (fgets(buffer, BSIZE_HERE, fd) != NULL) {
473  if (buffer[0] == '-')
474  continue;
475 
476  sscanf(buffer, "alias%s '%[^']", true_name, alias_name);
477 
478  string stored_name;
479  if ((stored_name = hash_get(aliases, alias_name))
481  pips_internal_error("Aliases must not be ambiguous\n"
482  "\talias '%s' seems ambiguous "
483  "because of previous '%s'!\n", true_name, stored_name);
484  } else {
485  char * upper = strdup(true_name);
486  hash_put(aliases, strdup(alias_name), strupper(upper, upper));
487  }
488  }
489  safe_fclose(fd, WPIPS_RC);
490 }
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
static hash_table aliases
Definition: gtk_props.c:69
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

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 ( GtkWidget *  menu_options,
GtkWidget *  frame_vbox 
)

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 created 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.

Add a sub-option entry in the menu:

Attach the sub-menu to an Option menu:

... And in the Option panel:

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

Definition at line 324 of file gtk_props.c.

325  {
326  int i;
327  option_type *all_the_options;
328  makefile m = parse_makefile();
329  //int max_item_width = 0;
330 
331  int number_of_options = 0;
332  hash_table phase_by_made_htp = hash_table_make(hash_string, 0);
333  // attention on libÚre jamais la mémoire de la hash_table ci dessous
335 
336  smenu_options = menu_options;
337 
338  /* walking thru rules */
339  MAPL(pr, {
340  rule r = RULE(CAR(pr));
341 
342  /* walking thru resources made by this particular rule */
343  MAPL(pvr, {
345  string vrn = virtual_resource_name(vr);
346  list p = CONS(STRING, rule_phase(r), NIL);
347  list l = (list) hash_get(phase_by_made_htp, vrn);
348 
349  if ( l == (list) HASH_UNDEFINED_VALUE ) {
350  hash_put(phase_by_made_htp, vrn, (char *)p);
351  }
352  else {
353  (void) gen_nconc(l, p);
354  }
355  }, rule_produced(r));
356 
357  }, makefile_rules(m));
358 
359  /* walking thru phase_by_made_htp */
360 
361  /* First, try to do some measurements on the options item to be
362  able to sort and align menu items later: */
363  HASH_MAP(k, v, {
364  string alias1 = hash_get_key_by_value(aliases, k);
365  list l = (list) v;
366 
367  if ((alias1 != HASH_UNDEFINED_VALUE) && (gen_length(l) >= 2))
368  number_of_options++;
369  }, phase_by_made_htp);
370 
371  all_the_options = (option_type *) malloc(number_of_options
372  * sizeof(option_type));
373 
374  /* Now generate an array of the Options: */
375  i = 0;
376  HASH_MAP(k, v, {
377  string alias1 = hash_get_key_by_value(aliases, k);
378  list l = (list) v;
379 
380  if ((alias1 != HASH_UNDEFINED_VALUE) && (gen_length(l) >= 2)) {
381  all_the_options[i].name = alias1;
382  all_the_options[i].choices = l;
383  i++;
384  }
385  }, phase_by_made_htp);
386 
387  /* Sort the Options: */
388  qsort((char *) all_the_options, number_of_options, sizeof(option_type),
390 
391  /* Create the Options in the Option menu and option panel: */
392  GtkWidget * table = gtk_table_new(number_of_options, 2, TRUE);
393  gtk_box_pack_start(GTK_BOX(frame_vbox), table, TRUE, FALSE, 0);
394  for (i = 0; i < number_of_options; i++) {
395  GtkWidget * sub_menu_option, *sub_menu_option_item;
396  //GtkWidget * menu_options_item;
397  GtkWidget * choices_combobox;
398 
399  /* Create the sub-menu entry of an option: */
400  sub_menu_option = gtk_menu_new();
401  sub_menu_option_item = gtk_menu_item_new_with_label(
402  all_the_options[i].name);
403  gtk_menu_item_set_submenu(GTK_MENU_ITEM(sub_menu_option_item),
404  sub_menu_option);
405 
406 // g_signal_connect(GTK_OBJECT(sub_menu_option_item), "activate",
407 // G_CALLBACK(options_menu_callback), NULL);
408  gtk_menu_append(GTK_MENU(menu_options), sub_menu_option_item);
409 
410  /* PANEL_CLIENT_DATA is used to link the PANEL_CHOICE_STACK
411  to its dual MENU_PULLRIGHT. RK, 11/06/1993. */
412  choices_combobox = gtk_combo_box_new_text();
413  gtk_signal_connect(GTK_OBJECT(choices_combobox), "changed",
414  GTK_SIGNAL_FUNC(options_combo_box_change_callback), NULL);
415  gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new(
416  all_the_options[i].name), 0, 1, i, i + 1);
417  gtk_table_attach_defaults(GTK_TABLE(table), choices_combobox, 1, 2, i,
418  i + 1);
419 
420  GtkWidget * subsubmenu_option_item;
421  MAPL(vrn, {
422  string alias2 = hash_get_key_by_value(aliases,
423  STRING(CAR(vrn)));
424 
425  if (alias2 != HASH_UNDEFINED_VALUE) {
426  /* Add a sub-option entry in the menu: */
427  /* Attach the sub-menu to an Option menu: */
428  subsubmenu_option_item = gtk_menu_item_new_with_label(alias2);
429  gtk_menu_append(GTK_MENU(sub_menu_option), subsubmenu_option_item);
430  g_signal_connect(GTK_OBJECT(subsubmenu_option_item), "activate",
431  G_CALLBACK(options_menu_callback), NULL);
432 
433  /* ... And in the Option panel: */
434  gtk_combo_box_append_text(GTK_COMBO_BOX(choices_combobox), alias2);
435  }
436  }, all_the_options[i].choices);
437 
438  // on indique la combobox associée à sub_menu_option menu dans une hash_table dédiée
439  hash_put(menu_item_to_combo_box, sub_menu_option, choices_combobox);
440 
441  gtk_widget_show(sub_menu_option_item);
442  gtk_widget_show_all(sub_menu_option);
443  gtk_widget_show_all(choices_combobox);
444  }
445  gtk_widget_show_all(table);
446 
447  /* According to a suggestion from Guillaume Oget, it should be nice
448  to be able to select a view also from the Option panel: */
449 
450  //char * option_item_label;
451 
452  LabelAndVbox lav;
453  lav.vbox = frame_vbox;
454  gtk_container_foreach(GTK_CONTAINER(options_frame), (GtkCallback)
456 }
#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
static hash_table menu_item_to_combo_box
Definition: gtk_props.c:70
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: gtk_props.c:284
void options_combo_box_change_callback(GtkWidget *item, gpointer data __attribute__((unused)))
"value" is already used for a typedef...
Definition: gtk_props.c:265
static GtkWidget * smenu_options
Definition: gtk_props.c:64
void options_menu_callback(GtkWidget *widget, gpointer data __attribute__((unused)))
Definition: gtk_props.c:277
static void synch_viewmenu_and_opframe(GtkWidget *widget, gpointer data)
Definition: gtk_props.c:304
string hash_get_key_by_value(hash_table htp, string svp)
returns the first key which value is svp.
Definition: gtk_props.c:89
#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
@ hash_pointer
Definition: newgen_hash.h:32
struct cons * list
Definition: newgen_types.h:106
makefile parse_makefile(void)
GtkWidget * vbox
Definition: gtk_props.c:82
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

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_pointer, hash_put(), hash_string, hash_table_make(), HASH_UNDEFINED_VALUE, makefile_rules, malloc(), MAPL, menu_item_to_combo_box, option_type::name, NIL, options_combo_box_change_callback(), options_frame, options_menu_callback(), parse_makefile(), RULE, rule_phase, rule_produced, smenu_options, STRING, synch_viewmenu_and_opframe(), LabelAndVbox::vbox, 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 284 of file gtk_props.c.

284  {
285  return strcmp(((option_type *) x)->name, ((option_type *) y)->name);
286 }
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 ( )

Trap the FRAME_DONE event:

Definition at line 516 of file gtk_props.c.

516  {
517  GtkWidget * vbox;
518  options_frame = gtk_frame_new(NULL);
519  vbox = gtk_vbox_new(FALSE, 0);
520  gtk_container_add(GTK_CONTAINER(options_frame), vbox);
521  gtk_container_add(GTK_CONTAINER(options_window), options_frame);
522 
523  /* Trap the FRAME_DONE event: */
524  gtk_signal_connect(GTK_OBJECT(options_window), "delete-event",
525  GTK_SIGNAL_FUNC(options_window_done_procedure), NULL);
526 
527  options_frame_menu_item = gtk_menu_item_new_with_label(
529  g_signal_connect(G_OBJECT(options_frame_menu_item), "activate", G_CALLBACK(
531 
532  options_menu = gtk_menu_new();
533  gtk_menu_append(GTK_MENU(options_menu), options_frame_menu_item);
534 
535  build_aliases();
537  gtk_widget_show_all(options_frame);
538 
539  options_menu_item = gtk_menu_item_new_with_label("Options");
540  gtk_menu_item_set_submenu(GTK_MENU_ITEM(options_menu_item), options_menu);
541 
542  gtk_menu_bar_append(GTK_MENU_BAR(main_window_menu_bar), options_menu_item);
543 }
GtkWidget * options_window
Definition: gpips-local.h:38
GtkWidget * main_window_menu_bar
Definition: gpips.c:62
static void options_window_done_procedure(GtkWidget *window, gpointer data)
Hide and restore the menu item to reopen the option panel:
Definition: gtk_props.c:510
void build_options_menu_and_panel(GtkWidget *menu_options, GtkWidget *frame_vbox)
Build the option menu by looking at the pipsmake.rc file and searching if there are several way to bu...
Definition: gtk_props.c:324
void display_or_hide_options_frame(GtkWidget *menu_item, gpointer data)
Definition: gtk_props.c:492
static GtkWidget * options_frame_menu_item
Definition: gtk_props.c:66
static GtkWidget * options_menu_item
Definition: gtk_props.c:65
void build_aliases()
Construct a table linking PIPS phase name to more human names, the aliases defined in pipsmake-rc....
Definition: gtk_props.c:461

References build_aliases(), build_options_menu_and_panel(), display_options_panel, display_or_hide_options_frame(), main_window_menu_bar, options_frame, options_frame_menu_item, options_menu, options_menu_item, options_window, and options_window_done_procedure().

Referenced by create_menus().

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

◆ disable_option_selection()

void disable_option_selection ( )

Definition at line 130 of file gtk_props.c.

130  {
132 }
void disable_item(GtkWidget *item)
Definition: gtk_edit2.c:461
void apply_on_each_option_item(void(*function_to_apply_on_each_menu_item)(GtkWidget *), void(*function_to_apply_on_each_frame_choice)(GtkWidget *))
Definition: gtk_props.c:116

References apply_on_each_option_item(), and disable_item().

Referenced by disable_module_selection(), gpips_main(), and wpips_main().

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

◆ display_or_hide_options_frame()

void display_or_hide_options_frame ( GtkWidget *  menu_item,
gpointer  data 
)

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

Definition at line 492 of file gtk_props.c.

492  {
493  const char *message_string;
494 
495  /* Should be added : when the options panel is destroyed by the
496  window manager, toggle the menu. RK, 7/6/93. */
497 
498  message_string = gpips_gtk_menu_item_get_label(menu_item);
499  if (message_string != NULL && strcmp(message_string, display_options_panel)
500  == 0) {
501  gtk_widget_show_all(options_window);
503  } else {
504  hide_window(options_window, NULL, NULL);
506  }
507 }
gint hide_window(GtkWidget *window, GdkEvent *ev __attribute__((unused)), gpointer data __attribute__((unused)))
Definition: gtk_utils.c:89
void gpips_gtk_menu_item_set_label(GtkWidget *w, gchar *text)
Definition: gtk_utils.c:64

References display_options_panel, gpips_gtk_menu_item_get_label(), gpips_gtk_menu_item_set_label(), hide_options_panel, hide_window(), and options_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 134 of file gtk_props.c.

134  {
136 }
void enable_item(GtkWidget *item)
Definition: gtk_edit2.c:465

References apply_on_each_option_item(), and enable_item().

Referenced by enable_module_selection().

+ Here is the call graph for this function:
+ 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 89 of file gtk_props.c.

89  {
90  HASH_MAP(kp, vp, {
91  if (strcmp(vp, svp) == 0)
92  return kp;
93  }, htp);
94 
95  return HASH_UNDEFINED_VALUE;
96 }

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_combo_box_change_callback()

void options_combo_box_change_callback ( GtkWidget *  item,
gpointer data   __attribute__(unused) 
)

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

:-) RK, 11/06/1993.

Definition at line 265 of file gtk_props.c.

267 {
268  char * aliased_phase = gtk_combo_box_get_active_text(GTK_COMBO_BOX(item));
269  options_select(aliased_phase);
270 }
void options_select(const char *aliased_phase)
Definition: gtk_props.c:243

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_frame_to_view_menu_gateway()

void options_frame_to_view_menu_gateway ( GtkWidget *  widget,
gpointer data   __attribute__(unused) 
)

Definition at line 272 of file gtk_props.c.

272  {
273  const gchar * label = gtk_button_get_label(GTK_BUTTON(widget));
275 }
void gpips_execute_and_display_something_from_alias(const char *alias_name)
To execute something and display some Pips output with gpips by knowing its alias:
Definition: gtk_edit2.c:410

References gpips_execute_and_display_something_from_alias().

Referenced by synch_viewmenu_and_opframe_search_in_view().

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

◆ options_menu_callback()

void options_menu_callback ( GtkWidget *  widget,
gpointer data   __attribute__(unused) 
)

Definition at line 277 of file gtk_props.c.

277  {
278  const char* aliased_phase = gpips_gtk_menu_item_get_label(widget);
279  options_select(aliased_phase);
280 }

References gpips_gtk_menu_item_get_label(), and 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_select()

void options_select ( const char *  aliased_phase)

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

Definition at line 243 of file gtk_props.c.

243  {
244  string phase = hash_get(aliases, aliased_phase);
245 
246  if (phase == (string) HASH_UNDEFINED_VALUE) {
247  pips_internal_error("aliases badly managed !!!\n");
248  } else {
250  prompt_user("No workspace opened. Options not accounted.\n");
251  } else {
252  debug_on("GPIPS_DEBUG_LEVEL");
253  activate(phase);
254  debug_off();
255  user_log("Options: phase %s (%s) set on.\n", aliased_phase, phase);
256  }
257  }
258  /* To have the options panel consistent with the real phase set :
259  RK, 05/07/1993. */
261  update_options();
263 }
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
int verbose_update_options
Flag allowing update_options also to select a option :
Definition: gtk_props.c:86
void update_options()
Definition: gtk_props.c:138
#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

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_combo_box_change_callback(), and options_menu_callback().

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

◆ options_window_done_procedure()

static void options_window_done_procedure ( GtkWidget *  window,
gpointer  data 
)
static

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

Definition at line 510 of file gtk_props.c.

References display_options_panel, gpips_gtk_menu_item_set_label(), hide_window(), options_frame_menu_item, and options_window.

Referenced by create_options_menu_and_window().

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

◆ synch_viewmenu_and_opframe()

static void synch_viewmenu_and_opframe ( GtkWidget *  widget,
gpointer  data 
)
static

Definition at line 304 of file gtk_props.c.

304  {
305  const char * label;
306  LabelAndVbox * lav = (LabelAndVbox *) data;
307 
308  if (GTK_IS_LABEL(widget)) {
309  label = gtk_label_get_text(GTK_LABEL(widget));
310  // on cherche ds le viewmenu un menu_item avec le même label
311  // si yen a un on rajoute un bouton
312  lav->label = label;
313  gtk_container_child_get_property(GTK_CONTAINER(lav->vbox), widget,
314  "position", (GValue*)&(lav->position));
315  gtk_container_foreach(GTK_CONTAINER(view_menu), (GtkCallback)
317  }
318 }
GtkWidget * view_menu
The menu "View" on the main panel:
Definition: gtk_edit2.c:93
static void synch_viewmenu_and_opframe_search_in_view(GtkWidget *widget, gpointer data)
Definition: gtk_props.c:288
int position
Definition: gtk_props.c:81
const char * label
Definition: gtk_props.c:80

References LabelAndVbox::label, LabelAndVbox::position, synch_viewmenu_and_opframe_search_in_view(), LabelAndVbox::vbox, and view_menu.

Referenced by build_options_menu_and_panel().

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

◆ synch_viewmenu_and_opframe_search_in_view()

static void synch_viewmenu_and_opframe_search_in_view ( GtkWidget *  widget,
gpointer  data 
)
static

Definition at line 288 of file gtk_props.c.

289  {
290  LabelAndVbox * lav = (LabelAndVbox *) data;
291  GtkWidget * button;
292  if (GTK_IS_MENU_ITEM(widget)) {
293  // if the currently processed menu_item has got the same label than the currently processed option
294  if (strcmp(data, gpips_gtk_menu_item_get_label(widget)) == 0) {
295  button = gtk_button_new_with_label(lav->label); // creating a "link-button" toward View
296  gtk_box_pack_start(GTK_BOX(lav->vbox), button, FALSE, FALSE, 5); // packing
297  gtk_box_reorder_child(GTK_BOX(lav->vbox), button, lav->position + 1); // positioning
298  gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC( // connecting
300  }
301  }
302 }
void options_frame_to_view_menu_gateway(GtkWidget *widget, gpointer data __attribute__((unused)))
Definition: gtk_props.c:272

References gpips_gtk_menu_item_get_label(), LabelAndVbox::label, options_frame_to_view_menu_gateway(), LabelAndVbox::position, and LabelAndVbox::vbox.

Referenced by synch_viewmenu_and_opframe().

+ 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

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

walk through items of special_prop_m to select the activated one

Update the dual options panel entry :

Definition at line 138 of file gtk_props.c.

138  {
139  gint i, j;
140  const char * child_resource_alias;
141  const char * phase_alias_n;
142  string res_true_n, phase_true_n;
143  GtkWidget * menu_options, *special_prop_menu;
144  GtkWidget *spm_item;
145 
146  debug_on("GPIPS_DEBUG_LEVEL");
147 
148  menu_options = smenu_options;
149 
150  /* walk through items of menu_options */
151  GtkWidget * child;
152  GList * menu_options_children = gtk_container_get_children(GTK_CONTAINER(
153  menu_options));
154  for (i = 0; i < g_list_length(menu_options_children); i++) {
155  child = (GtkWidget *) g_list_nth_data(menu_options_children, i);
156  if (!GTK_IS_MENU_ITEM(child))
157  continue;
158  if (GTK_IS_SEPARATOR(child))
159  continue;
160 
161  child_resource_alias = gpips_gtk_menu_item_get_label(child);
162  if (child_resource_alias == NULL || strcmp(child_resource_alias,
163  display_options_panel) == 0 || strcmp(child_resource_alias,
164  hide_options_panel) == 0)
165  /* It must be the pin item, or the item controlling the
166  options panel. RK, 4/06/1993. */
167  continue;
168 
169  if ((res_true_n = (string) hash_get(aliases, child_resource_alias))
171  pips_internal_error("Hash table aliases no more consistent\n");
172  // -------------
173 
174  /* find special prop menu containing item corresponding to active
175  phase*/
176  special_prop_menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(child));
177  // (Menu) xv_get(child, MENU_PULLRIGHT);
178 
179  GList * spm_children = gtk_container_get_children(GTK_CONTAINER(
180  special_prop_menu));
181  /* find active phase which produces resource res_true_n */
182  phase_true_n = rule_phase(find_rule_by_resource(res_true_n));
183  if ((phase_alias_n = hash_get_key_by_value(aliases, phase_true_n))
185  /* There is no alias for currently selected phase: phase_true_n
186  We have to activate another phase
187  */
188  gtk_menu_set_active(GTK_MENU(special_prop_menu), 0);
189  spm_item = (GtkWidget *) g_list_nth_data(spm_children, 0);
190  phase_alias_n = gpips_gtk_menu_item_get_label(spm_item);
191  user_warning(
192  "update_options",
193  "No alias available for selected phase `%s'; selecting `%s'\n",
194  phase_true_n, phase_alias_n);
195  phase_true_n = hash_get(aliases, phase_alias_n);
196  activate(phase_true_n);
197  // /* It does not seem to work (the doc does not talk about
198  // xv_set for MENU_SELECTED by the way...): */
199  // xv_set(special_prop_menu_item, MENU_SELECTED, TRUE, NULL);
200  // /* Then, try harder : */
201  // xv_set(special_prop_menu, MENU_DEFAULT_ITEM,
202  // special_prop_menu_item, NULL);
203  debug(2, "update_options",
204  "Rule `%s' selected to produce resource `%s'\n",
205  phase_alias_n, child_resource_alias);
206  } else {
207  /* walk through items of special_prop_m to select the activated
208  one */
209  for (j = g_list_length(spm_children) - 1; j >= 0; j--) {
210  const char * spm_item_label;
211  spm_item = (GtkWidget *) g_list_nth_data(spm_children, j);
212  if (!GTK_IS_MENU_ITEM(spm_item))
213  continue;
214  if (GTK_IS_SEPARATOR(spm_item))
215  continue;
216  spm_item_label = gpips_gtk_menu_item_get_label(spm_item);
217  debug(9, "update_options", "Menu item tested:\"%s\"\n",
218  spm_item_label);
219  if (strcmp(spm_item_label, phase_alias_n) == 0) {
220  gtk_menu_set_active(GTK_MENU(special_prop_menu), j);
221  /* Update the dual options panel entry : */
222  GtkWidget * combobox = hash_get(menu_item_to_combo_box,
223  special_prop_menu);
224  if (GTK_IS_COMBO_BOX(combobox))
225  gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), j);
226 
228  user_log("Options: phase %s set on.\n", phase_alias_n);
229  debug(2, "update_options",
230  "Rule `%s' selected to produce resource `%s'\n",
231  phase_alias_n, child_resource_alias);
232  }
233  }
234  }
235  g_list_free(spm_children);
236  }
237  g_list_free(menu_options_children);
239 
240  debug_off();
241 }
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(), gpips_gtk_menu_item_get_label(), hash_get(), hash_get_key_by_value(), HASH_UNDEFINED_VALUE, hide_options_panel, menu_item_to_combo_box, pips_internal_error, rule_phase, smenu_options, user_log(), user_warning, and verbose_update_options.

Referenced by gpips_main(), options_select(), and wpips_main().

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

Variable Documentation

◆ aliases

◆ display_options_panel

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

◆ hide_options_panel

char hide_options_panel[] = "Hide options panel"
static

◆ menu_item_to_combo_box

hash_table menu_item_to_combo_box
static

Definition at line 70 of file gtk_props.c.

Referenced by build_options_menu_and_panel(), and update_options().

◆ options_frame

◆ options_frame_menu_item

GtkWidget* options_frame_menu_item
static

Definition at line 66 of file gtk_props.c.

Referenced by create_options_menu_and_window(), and options_window_done_procedure().

◆ options_menu

GtkWidget* options_menu
static

Definition at line 65 of file gtk_props.c.

Referenced by apply_on_each_option_item(), and create_options_menu_and_window().

◆ options_menu_item

GtkWidget * options_menu_item
static

Definition at line 65 of file gtk_props.c.

Referenced by create_options_menu_and_window().

◆ smenu_options

GtkWidget* smenu_options
static

Definition at line 64 of file gtk_props.c.

Referenced by build_options_menu_and_panel(), and update_options().

◆ vcid_xv_props

char vcid_xv_props[] = "$Id: gtk_props.c 23065 2016-03-02 09:05:50Z coelho $"

Definition at line 29 of file gtk_props.c.

◆ verbose_update_options

int verbose_update_options = 1

Flag allowing update_options also to select a option :

Definition at line 86 of file gtk_props.c.

Referenced by options_select(), and update_options().