PIPS
gtk_transform.c
Go to the documentation of this file.
1 /*
2 
3  $Id: gtk_transform.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 
30 #include <sys/time.h>
31 #include <sys/resource.h>
32 
33 #if (defined(TEXT))
34 #undef TEXT
35 #endif
36 
37 #if (defined(TEXT_TYPE))
38 #undef TEXT_TYPE
39 #endif
40 
41 #include "genC.h"
42 
43 #include "constants.h"
44 #include "misc.h"
45 #include "linear.h"
46 #include "ri.h"
47 #include "ri-util.h"
48 #include "top-level.h"
49 #include "database.h"
50 #include "pipsmake.h"
51 #include "pipsdbm.h"
52 
53 #undef test_undefined // also defined in glib included from gtk
54 #include <gtk/gtk.h>
55 #include "gpips.h"
56 
57 /* Include the label names: */
58 #include "gpips-labels.h"
59 
60 #include "resources.h"
61 #include "phases.h"
62 
64 #include "wpips_transform_menu_layout.h"
65  /* No more transformations */
66  { NULL, NULL } };
67 
68 /* To pass arguments to execute_safe_apply_outside_the_notifyer(): */
69 static string
71  NULL;
73 
74 /* The transform menu: */
76 
77 static void apply_on_each_transform_menu_item(GtkWidget * widget,
78  gpointer _func) {
79  void (*func)(GtkWidget *);
80  func = (void(*)(GtkWidget *)) _func;
81  func(widget);
82 }
83 
84 void apply_on_each_transform_item(void(* function_to_apply_on_each_menu_item)(
85  GtkWidget *)) {
86  gtk_container_foreach(GTK_CONTAINER(transform_menu), (GtkCallback)
88  function_to_apply_on_each_menu_item);
89 }
90 
93 }
94 
97 }
98 
100  (void) safe_apply(
105 
107 }
108 
109 void safe_apply_outside_the_notifyer(string transformation_name_to_apply,
110  string module_name) {
112  = strdup(transformation_name_to_apply);
114  /* Ask to execute the execute_safe_apply_outside_the_notifyer(): */
116  /* I guess the function above does not return... */
117 }
118 
119 static void transform_notify(GtkWidget * menu_item, gpointer data __attribute__((unused))) {
120  const char * label = gpips_gtk_menu_item_get_label(menu_item);
121 
122  char * modulename = db_get_current_module_name();
123 
124  /* FI: borrowed from edit_notify() */
125  if (modulename == NULL) {
126  prompt_user("No module selected");
127  } else {
128  gpips_transform_menu_layout_line * current_transformation;
129 
130  /* Find the transformation to apply: */
131  for (current_transformation = &gpips_transform_menu_layout[0]; current_transformation->menu_entry_string
132  != NULL; current_transformation++)
133  if (strcmp(label, current_transformation->menu_entry_string) == 0)
134  break;
135 
136  if (current_transformation->menu_entry_string != NULL)
137  /* Apply the transformation: */
139  current_transformation->transformation_name_to_apply,
140  modulename);
141  /* I guess the function above does not return... */
142  else
143  pips_user_error("What is this \"%s\" entry you ask for?", label);
144  }
145 
147 }
148 
150  GtkWidget * menu_item;
151 
152  gpips_transform_menu_layout_line * current_transformation;
153 
154  edit_menu_item = gtk_menu_item_new_with_label(EDIT_VIEW);
155  g_signal_connect(G_OBJECT(edit_menu_item), "activate", G_CALLBACK(
156  edit_notify), NULL);
157 
158  transform_menu = gtk_menu_new();
159  transform_menu_item = gtk_menu_item_new_with_label("Transform/Edit");
160  gtk_menu_item_set_submenu(GTK_MENU_ITEM(transform_menu_item), transform_menu);
161  gtk_menu_bar_append(GTK_MENU_BAR(main_window_menu_bar), transform_menu_item);
162 
163  /* Now add all the transformation entries: */
164  for (current_transformation = &gpips_transform_menu_layout[0]; current_transformation->menu_entry_string
165  != NULL; current_transformation++) {
166  if (strcmp(current_transformation->menu_entry_string,
167  GPIPS_MENU_SEPARATOR_ID) == 0) {
168  gtk_menu_append(GTK_MENU(transform_menu),
169  gtk_separator_menu_item_new());
170  } else {
171  menu_item = gtk_menu_item_new_with_label(
172  current_transformation->menu_entry_string);
173  g_signal_connect(G_OBJECT(menu_item), "activate",
174  G_CALLBACK(transform_notify), NULL);
175  gtk_menu_append(GTK_MENU(transform_menu), menu_item);
176  }
177  }
178 
179  /* Add the Edit entry as the last one: */
180  gtk_menu_append(GTK_MENU(transform_menu), gtk_separator_menu_item_new());
181 
182  gtk_menu_append(GTK_MENU(transform_menu), edit_menu_item);
183 
184  gtk_widget_show_all(transform_menu);
185  gtk_widget_show(transform_menu_item);
186 }
float a2sf[2] __attribute__((aligned(16)))
USER generates a user error (i.e., non fatal) by printing the given MSG according to the FMT.
Definition: 3dnow.h:3
string db_get_current_module_name(void)
Also used to check whether set...
Definition: database.c:1059
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
void free(void *)
#define EDIT_VIEW
A special view that gives the .f source mainly for edition:
Definition: gpips-labels.h:46
@ GPIPS_SAFE_APPLY
Definition: gpips-local.h:63
#define GPIPS_MENU_SEPARATOR_ID
How it is specified in the layout .h:
Definition: gpips-local.h:84
GtkWidget * main_window_menu_bar
Definition: gpips.c:62
void execute_main_loop_command(gpips_main_loop_command_type command)
To ask pipsmake to stop as soon as possible:
Definition: gpips.c:267
void edit_notify(GtkWidget *widget, gpointer data)
Definition: gtk_edit2.c:101
GtkWidget * edit_menu_item
Definition: gtk_edit2.c:90
void disable_item(GtkWidget *item)
Definition: gtk_edit2.c:461
void enable_item(GtkWidget *item)
Definition: gtk_edit2.c:465
void prompt_user(string a_printf_format,...)
Definition: gtk_log.c:66
void display_memory_usage()
Definition: gtk_status.c:84
gpips_transform_menu_layout_line gpips_transform_menu_layout[]
Include the label names:
Definition: gtk_transform.c:63
GtkWidget * transform_menu
The transform menu:
Definition: gtk_transform.c:75
void create_transform_menu()
static void apply_on_each_transform_menu_item(GtkWidget *widget, gpointer _func)
Definition: gtk_transform.c:77
void disable_transform_selection()
Definition: gtk_transform.c:91
static void transform_notify(GtkWidget *menu_item, gpointer data __attribute__((unused)))
void execute_safe_apply_outside_the_notifier()
Definition: gtk_transform.c:99
void safe_apply_outside_the_notifyer(string transformation_name_to_apply, string module_name)
static string execute_safe_apply_outside_the_notifyer_module_name
Definition: gtk_transform.c:72
GtkWidget * transform_menu_item
Definition: gtk_transform.c:75
static string execute_safe_apply_outside_the_notifyer_transformation_name_to_apply
To pass arguments to execute_safe_apply_outside_the_notifyer():
Definition: gtk_transform.c:70
void enable_transform_selection()
Definition: gtk_transform.c:95
void apply_on_each_transform_item(void(*function_to_apply_on_each_menu_item)(GtkWidget *))
Definition: gtk_transform.c:84
const char * gpips_gtk_menu_item_get_label(GtkWidget *w)
Definition: gtk_utils.c:43
#define pips_user_error
Definition: misc-local.h:147
bool safe_apply(const char *phase_n, const char *module_n)
Definition: pipsmake.c:1723
char * strdup()
The type describing a Transform menu entry:
Definition: gpips-local.h:67