PIPS
gtk_compile.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "misc.h"
#include "phases.h"
#include "database.h"
#include "pipsdbm.h"
#include "pipsmake.h"
#include "top-level.h"
#include "preprocessor.h"
#include <gtk/gtk.h>
#include "gpips.h"
+ Include dependency graph for gtk_compile.c:

Go to the source code of this file.

Macros

#define HPFC_COMPILE   "Compile an HPF program"
 
#define HPFC_MAKE   "Make an HPF program"
 
#define HPFC_RUN   "Run an HPF program"
 

Functions

void apply_on_each_compile_item (void(*function_to_apply_on_each_menu_item)(GtkWidget *))
 
void disable_compile_selection ()
 
void enable_compile_selection ()
 
void notify_hpfc_file_view (GtkWidget *widget, gpointer data)
 
void generate_a_menu_with_HPF_output_files (GtkWidget *widget, gpointer data)
 
void initialize_gpips_hpfc_hack_for_fabien_and_from_fabien ()
 
void hpfc_notify (GtkWidget *menu_item, gpointer data)
 
void create_compile_menu ()
 

Variables

static GtkWidget * compile_menu
 
static GtkWidget * compile_menu_item
 
static GtkWidget * dynamic_hpf_output_files_menu
 
static GtkWidget * dynamic_hpf_output_files_menu_item
 
static bool gpips_hpfc_install_was_performed_hack = FALSE
 quick fix around pipsmake, FC, 23/10/95 More...
 

Macro Definition Documentation

◆ HPFC_COMPILE

#define HPFC_COMPILE   "Compile an HPF program"

Definition at line 48 of file gtk_compile.c.

◆ HPFC_MAKE

#define HPFC_MAKE   "Make an HPF program"

Definition at line 49 of file gtk_compile.c.

◆ HPFC_RUN

#define HPFC_RUN   "Run an HPF program"

Definition at line 50 of file gtk_compile.c.

Function Documentation

◆ apply_on_each_compile_item()

void apply_on_each_compile_item ( void(*)(GtkWidget *)  function_to_apply_on_each_menu_item)

Definition at line 56 of file gtk_compile.c.

57  {
58  guint i;
59 
60  GtkWidget * child;
61  GList * compile_menu_children = gtk_container_get_children(GTK_CONTAINER(
62  compile_menu));
63  for (i = 0; i < g_list_length(compile_menu_children); i++) {
64  child = (GtkWidget *) g_list_nth_data(compile_menu_children, i);
65  if (!GTK_IS_MENU_ITEM(child))
66  continue;
67  if (GTK_IS_SEPARATOR(child))
68  continue;
69  function_to_apply_on_each_menu_item(child);
70  }
71  g_list_free(compile_menu_children);
72 }
static GtkWidget * compile_menu
Definition: gtk_compile.c:52

References compile_menu.

Referenced by disable_compile_selection(), and enable_compile_selection().

+ Here is the caller graph for this function:

◆ create_compile_menu()

void create_compile_menu ( )

Definition at line 190 of file gtk_compile.c.

190  {
191  GtkWidget *hpfc_compile_menu_item, *hpfc_make_menu_item,
192  *hpfc_run_menu_item;
193 
194  compile_menu = gtk_menu_new();
195 
196  hpfc_compile_menu_item = gtk_menu_item_new_with_label(HPFC_COMPILE);
197  hpfc_make_menu_item = gtk_menu_item_new_with_label(HPFC_MAKE);
198  hpfc_run_menu_item = gtk_menu_item_new_with_label(HPFC_RUN);
199 
200  g_signal_connect(G_OBJECT(hpfc_compile_menu_item), "activate",
201  G_CALLBACK(hpfc_notify), NULL);
202  g_signal_connect(G_OBJECT(hpfc_make_menu_item), "activate",
203  G_CALLBACK(hpfc_notify), NULL);
204  g_signal_connect(G_OBJECT(hpfc_run_menu_item), "activate",
205  G_CALLBACK(hpfc_notify), NULL);
206 
207  gtk_menu_shell_append(GTK_MENU_SHELL(compile_menu), hpfc_compile_menu_item);
208  gtk_menu_shell_append(GTK_MENU_SHELL(compile_menu), hpfc_make_menu_item);
209  gtk_menu_shell_append(GTK_MENU_SHELL(compile_menu), hpfc_run_menu_item);
210  gtk_menu_shell_append(GTK_MENU_SHELL(compile_menu),
211  gtk_separator_menu_item_new());
212 
213  dynamic_hpf_output_files_menu = gtk_menu_new();
214  dynamic_hpf_output_files_menu_item = gtk_menu_item_new_with_label(
215  "View the HPF Compiler Output");
216  gtk_menu_item_set_submenu(
217  GTK_MENU_ITEM(dynamic_hpf_output_files_menu_item),
219 
220  gtk_menu_shell_append(GTK_MENU_SHELL(compile_menu),
222  // each time the menu is accessed, it is regenerated
223  g_signal_connect(G_OBJECT(dynamic_hpf_output_files_menu_item), "activate",
224  G_CALLBACK(generate_a_menu_with_HPF_output_files), NULL);
225 
226  compile_menu_item = gtk_menu_item_new_with_label("Compile");
227  gtk_menu_item_set_submenu(GTK_MENU_ITEM(compile_menu_item), compile_menu);
228 
229  gtk_menu_bar_append(GTK_MENU_BAR(main_window_menu_bar), compile_menu_item);
230  gtk_widget_show(compile_menu_item);
231  gtk_widget_show_all(compile_menu);
232 }
GtkWidget * main_window_menu_bar
Definition: gpips.c:62
#define HPFC_COMPILE
Definition: gtk_compile.c:48
#define HPFC_RUN
Definition: gtk_compile.c:50
static GtkWidget * compile_menu_item
Definition: gtk_compile.c:52
static GtkWidget * dynamic_hpf_output_files_menu
Definition: gtk_compile.c:53
static GtkWidget * dynamic_hpf_output_files_menu_item
Definition: gtk_compile.c:54
void generate_a_menu_with_HPF_output_files(GtkWidget *widget, gpointer data)
Definition: gtk_compile.c:92
void hpfc_notify(GtkWidget *menu_item, gpointer data)
Definition: gtk_compile.c:158
#define HPFC_MAKE
Definition: gtk_compile.c:49

References compile_menu, compile_menu_item, dynamic_hpf_output_files_menu, dynamic_hpf_output_files_menu_item, generate_a_menu_with_HPF_output_files(), HPFC_COMPILE, HPFC_MAKE, hpfc_notify(), HPFC_RUN, and main_window_menu_bar.

Referenced by create_menus().

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

◆ disable_compile_selection()

void disable_compile_selection ( )

Definition at line 74 of file gtk_compile.c.

74  {
76 }
void apply_on_each_compile_item(void(*function_to_apply_on_each_menu_item)(GtkWidget *))
Definition: gtk_compile.c:56
void disable_item(GtkWidget *item)
Definition: gtk_edit2.c:461

References apply_on_each_compile_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:

◆ enable_compile_selection()

void enable_compile_selection ( )

Definition at line 78 of file gtk_compile.c.

78  {
80 }
void enable_item(GtkWidget *item)
Definition: gtk_edit2.c:465

References apply_on_each_compile_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:

◆ generate_a_menu_with_HPF_output_files()

void generate_a_menu_with_HPF_output_files ( GtkWidget *  widget,
gpointer  data 
)

Create a new menu with the content of the hpfc directory:

First, free the old menu if it exist:

We can remove all the menu it now:

Definition at line 92 of file gtk_compile.c.

92  {
93  guint i;
94  GtkWidget * menu_item;
95 
96  gen_array_t file_names = gen_array_make(0);
97  int file_number = 0;
98 
99  int return_code;
100  char *hpfc_directory;
101 
102  /* Create a new menu with the content of the hpfc directory: */
103 
104  if (dynamic_hpf_output_files_menu != NULL)
105  /* First, free the old menu if it exist: */
106  /* We can remove all the menu it now: */
107  gtk_menu_item_remove_submenu(GTK_MENU_ITEM(
109 
110  return_code = hpfc_get_file_list(file_names, &hpfc_directory);
111 
112  dynamic_hpf_output_files_menu = gtk_menu_new();
113 
114  if (return_code == -1) {
115  user_warning("generate_a_menu_with_HPF_output_files",
116  "Directory \"%s\" not found... \n"
117  " Have you run the HPFC compiler from the Compile menu?\n",
118  hpfc_directory);
119 
120  menu_item = gtk_menu_item_new_with_label(
121  "*** No HPFC directory found ! ***");
122  gtk_menu_shell_append(GTK_MENU_SHELL(dynamic_hpf_output_files_menu),
123  menu_item);
124  } else if (file_number == 0) {
125  user_warning("generate_a_menu_with_HPF_output_files",
126  "No file found in the directory \"%s\"... \n"
127  " Have you run the HPFC compiler from the Compile menu?\n",
128  hpfc_directory);
129 
130  menu_item
131  = gtk_menu_item_new_with_label("*** No HPFC file found ! ***");
132  gtk_menu_shell_append(GTK_MENU_SHELL(dynamic_hpf_output_files_menu),
133  menu_item);
134  } else {
135  for (i = 0; i < file_number; i++) {
136  menu_item = gtk_menu_item_new_with_label(gen_array_item(file_names,
137  i));
138  gtk_menu_append(GTK_MENU(dynamic_hpf_output_files_menu), menu_item);
139  g_signal_connect(G_OBJECT(menu_item), "activate", G_CALLBACK(
140  notify_hpfc_file_view), NULL);
141  }
142 
143  gen_array_full_free(file_names);
144  }
145  gtk_menu_item_set_submenu(
146  GTK_MENU_ITEM(dynamic_hpf_output_files_menu_item),
148 }
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
void notify_hpfc_file_view(GtkWidget *widget, gpointer data)
Definition: gtk_compile.c:82
#define user_warning(fn,...)
Definition: misc-local.h:262
int hpfc_get_file_list(gen_array_t, char **)
Definition: source_file.c:106

References dynamic_hpf_output_files_menu, dynamic_hpf_output_files_menu_item, gen_array_full_free(), gen_array_item(), gen_array_make(), hpfc_get_file_list(), notify_hpfc_file_view(), and user_warning.

Referenced by create_compile_menu().

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

◆ hpfc_notify()

void hpfc_notify ( GtkWidget *  menu_item,
gpointer  data 
)

I apply the installation only once, whatever... Quick fix because the right dependences expressed for pipsmake do not seem to work. It seems that the verification of up to date resources is too clever... FC.

Definition at line 158 of file gtk_compile.c.

158  {
159  const char *label;
160  char *modulename;
161 
162  modulename = db_get_current_module_name();
163  if (!modulename) {
164  prompt_user("No module selected");
165  return;
166  }
167 
168  label = gpips_gtk_menu_item_get_label(menu_item);
169 
170  /* I apply the installation only once, whatever...
171  * Quick fix because the right dependences expressed for pipsmake
172  * do not seem to work. It seems that the verification of up to date
173  * resources is too clever... FC.
174  */
176  safe_apply(BUILDER_HPFC_INSTALL, modulename);
178  }
179 
180  if (same_string_p(label, HPFC_COMPILE))
181  ;
182  else if (same_string_p(label, HPFC_MAKE))
183  safe_apply_outside_the_notifyer(BUILDER_HPFC_MAKE, modulename);
184  else if (same_string_p(label, HPFC_RUN))
185  safe_apply_outside_the_notifyer(BUILDER_HPFC_RUN, modulename);
186  else
187  pips_internal_error("Bad choice: %s", label);
188 }
string db_get_current_module_name(void)
Also used to check whether set...
Definition: database.c:1059
static bool gpips_hpfc_install_was_performed_hack
quick fix around pipsmake, FC, 23/10/95
Definition: gtk_compile.c:152
void prompt_user(string a_printf_format,...)
Definition: gtk_log.c:66
void safe_apply_outside_the_notifyer(string transformation_name_to_apply, string module_name)
const char * gpips_gtk_menu_item_get_label(GtkWidget *w)
Definition: gtk_utils.c:43
#define pips_internal_error
Definition: misc-local.h:149
#define same_string_p(s1, s2)
bool safe_apply(const char *phase_n, const char *module_n)
Definition: pipsmake.c:1723

References db_get_current_module_name(), gpips_gtk_menu_item_get_label(), gpips_hpfc_install_was_performed_hack, HPFC_COMPILE, HPFC_MAKE, HPFC_RUN, pips_internal_error, prompt_user(), safe_apply(), safe_apply_outside_the_notifyer(), and same_string_p.

Referenced by create_compile_menu().

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

◆ initialize_gpips_hpfc_hack_for_fabien_and_from_fabien()

void initialize_gpips_hpfc_hack_for_fabien_and_from_fabien ( )

Definition at line 154 of file gtk_compile.c.

154  {
156 }

References gpips_hpfc_install_was_performed_hack.

Referenced by close_workspace_notify().

+ Here is the caller graph for this function:

◆ notify_hpfc_file_view()

void notify_hpfc_file_view ( GtkWidget *  widget,
gpointer  data 
)

Definition at line 82 of file gtk_compile.c.

82  {
83  const char * file_name = gpips_gtk_menu_item_get_label(widget);
85 
86  (void) alloc_first_initialized_window(FALSE);
87 
88  gpips_file_view(path_name, file_name, "HPFC File", "HPFC", "HPFC");
89  user_log("HPFC View of \"%s\" done.\n", file_name);
90 }
void user_log(const char *format,...)
Definition: message.c:234
int alloc_first_initialized_window(bool the_same_as_previous)
Find the first free window if any.
Definition: gtk_edit2.c:215
void gpips_file_view(char *file_name, const char *title_module_name, char *title_label, char *icon_name, char *icon_title)
Display a file in a gpips window:
Definition: gtk_edit2.c:271
string hpfc_generate_path_name_of_file_name(const char *)
Return the path of an HPFC file name relative to the current PIPS directory.
Definition: source_file.c:97
static string file_name

References alloc_first_initialized_window(), file_name, gpips_file_view(), gpips_gtk_menu_item_get_label(), hpfc_generate_path_name_of_file_name(), and user_log().

Referenced by generate_a_menu_with_HPF_output_files().

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

Variable Documentation

◆ compile_menu

GtkWidget* compile_menu
static

Definition at line 52 of file gtk_compile.c.

Referenced by apply_on_each_compile_item(), and create_compile_menu().

◆ compile_menu_item

GtkWidget * compile_menu_item
static

Definition at line 52 of file gtk_compile.c.

Referenced by create_compile_menu().

◆ dynamic_hpf_output_files_menu

GtkWidget* dynamic_hpf_output_files_menu
static

Definition at line 53 of file gtk_compile.c.

Referenced by create_compile_menu(), and generate_a_menu_with_HPF_output_files().

◆ dynamic_hpf_output_files_menu_item

GtkWidget * dynamic_hpf_output_files_menu_item
static

Definition at line 54 of file gtk_compile.c.

Referenced by create_compile_menu(), and generate_a_menu_with_HPF_output_files().

◆ gpips_hpfc_install_was_performed_hack

bool gpips_hpfc_install_was_performed_hack = FALSE
static

quick fix around pipsmake, FC, 23/10/95

Definition at line 152 of file gtk_compile.c.

Referenced by hpfc_notify(), and initialize_gpips_hpfc_hack_for_fabien_and_from_fabien().