PIPS
xv_status.c
Go to the documentation of this file.
1 /*
2 
3  $Id: xv_status.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 #include <stdlib.h>
28 #include <stdio.h>
29 #include <stdarg.h>
30 #include <sys/time.h>
31 #include <sys/resource.h>
32 
33 #include <sys/time.h>
34 #include <sys/resource.h>
35 #include <xview/xview.h>
36 #include <xview/panel.h>
37 #include <xview/text.h>
38 #include <xview/svrimage.h>
39 
40 #if (defined(TEXT))
41 #undef TEXT
42 #endif
43 
44 #if (defined(TEXT_TYPE))
45 #undef TEXT_TYPE
46 #endif
47 
48 #include "genC.h"
49 #include "linear.h"
50 #include "ri.h"
51 #include "database.h"
52 
53 #include "misc.h"
54 #include "ri-util.h"
55 #include "pipsdbm.h"
56 
57 #include "wpips.h"
58 
59 enum {DECALAGE_STATUS = 100
60 };
61 
62 /* Max number of digits displayed in the status panel: */
63 enum {CPU_USAGE_LENGTH = 8
64 };
65 
66 
71 Panel_item cpu_usage_item;
72 
74 
75 /* Strange, "man end" says that end is a function! */
76 extern etext, edata, end;
77 
78 void
80 {
81  char memory_string[17];
82  char cpu_string[CPU_USAGE_LENGTH + 1];
83  struct rusage an_rusage;
84 
85  /* etext, edata and end are only address symbols... */
86  debug(6, "display_memory_usage",
87  "_text %#x, _data %#x, _end %#x, _brk %#x\n",
88  &etext, &edata, &end, sbrk(0));
89 
90  sprintf(memory_string, "%10.3f", (sbrk(0) - (int) &etext)/(double)(1 << 20));
91 
92  xv_set(memory_name,
93  PANEL_VALUE, memory_string,
94  NULL);
95 
96  if (getrusage(RUSAGE_SELF, &an_rusage) == 0) {
97  double the_cpu_time =
98  an_rusage.ru_utime.tv_sec + an_rusage.ru_stime.tv_sec
99  + (an_rusage.ru_utime.tv_usec + an_rusage.ru_stime.tv_usec)*1e-6;
100  sprintf(cpu_string, "%*.*g",
101  CPU_USAGE_LENGTH, CPU_USAGE_LENGTH - 2, the_cpu_time);
102  }
103  else
104  /* getrusage() failed: */
105  sprintf(cpu_string, "%*s", CPU_USAGE_LENGTH, "?");
106 
107  xv_set(cpu_usage_item,
108  PANEL_VALUE, cpu_string,
109  NULL);
110 }
111 
112 
113 void
114 window_number_notify(Panel_item item, int value, Event *event)
115 {
116  number_of_wpips_windows = (int) xv_get(item, PANEL_VALUE);
117 
118  if (wpips_emacs_mode)
120 
122 }
123 
124 
125 void
127 {
128  xv_set(directory_name_panel_item, PANEL_VALUE, get_cwd(), NULL);
130 }
131 
132 
133 
134 void
136 {
137  static char *none = "(* none *)";
138  char *name = db_get_current_workspace_name();
139 
140  if (name == NULL)
141  name = none;
142 
143  xv_set(workspace_name_panel_item, PANEL_VALUE, name, 0);
145 }
146 
147 
148 void
150 {
151  static char *none = "(* none *)";
152  char *module_name_content = db_get_current_module_name();
153 
154  if (module_name_content == NULL)
155  module_name_content = none;
156 
157  xv_set(module_name_panel_item, PANEL_VALUE, module_name_content, 0);
159 }
160 
161 
162 void
164 {
165  if ((Server_image) xv_get(status_window_pips_image, PANEL_LABEL_IMAGE) ==
168  PANEL_LABEL_IMAGE, wpips_positive_server_image,
169  NULL);
170  else
172  PANEL_LABEL_IMAGE, wpips_negative_server_image,
173  NULL);
174 
175 }
176 
177 
178 void
180 {
182  PANEL_LABEL_IMAGE, wpips_positive_server_image,
183  NULL);
184 }
185 
186 
187 void
188 show_message(string message_buffer /*, ...*/)
189 {
190  /* va_list some_arguments;
191  static char message_buffer[SMALL_BUFFER_LENGTH]; */
192 
193  /* va_start(some_arguments, a_printf_format); */
194 
195  /* (void) vsprintf(message_buffer, a_printf_format, some_arguments);*/
196 
197  xv_set(message, PANEL_VALUE, message_buffer, 0);
199 }
200 
201 
202 void
204 {
205  /* Maintenant on n'utilise plus qu'un seul panel pour la fene^tre
206  principale. En effet, sinon il y a des proble`mes de retrac,age
207  sur e'cran couleur. RK, 15/03/1994. */
208  Server_image pips_icon_server_image;
209 
210  message =
211  xv_create(main_panel, PANEL_TEXT,
212  PANEL_VALUE_X, DECALAGE_STATUS,
213  PANEL_VALUE_Y, xv_rows(main_panel, 1),
214  PANEL_LABEL_STRING, "Message:",
215  PANEL_READ_ONLY, TRUE,
216  PANEL_VALUE_DISPLAY_LENGTH, 64,
217  PANEL_VALUE_STORED_LENGTH, 1000,
218  NULL);
219 /*
220  directory_name_panel_item =
221  xv_create(main_panel, PANEL_TEXT,
222  PANEL_VALUE_X, DECALAGE_STATUS,
223  PANEL_VALUE_Y, xv_rows(main_panel, 2),
224  PANEL_LABEL_STRING, "Directory:",
225  PANEL_READ_ONLY, FALSE,
226  PANEL_NOTIFY_PROC, end_directory_text_notify,
227  PANEL_VALUE_DISPLAY_LENGTH, 64,
228  PANEL_VALUE_STORED_LENGTH, 256,
229  NULL);
230  */
233  main_panel,
234  "Directory:",
235  61,
237  xv_rows(main_panel, 2),
239  /* Ignore the return code of end_directory_notify: */
240  (void (*)(char *)) end_directory_notify);
241 
243  PANEL_VALUE_STORED_LENGTH, 512,
244  NULL);
245 
248  "Workspace:",
249  20,
251  xv_rows(main_panel, 3),
254 
257  "Module:",
258  20,
260  xv_rows(main_panel, 4),
263 
264  memory_name =
265  xv_create(main_panel, PANEL_TEXT,
266  PANEL_ITEM_X_GAP, DECALAGE_STATUS,
267  PANEL_VALUE_X, xv_col(main_panel, 50),
268  PANEL_VALUE_Y, xv_rows(main_panel, 3),
269  PANEL_LABEL_STRING, "Memory (MB):",
270  PANEL_VALUE_DISPLAY_LENGTH, 9,
271  PANEL_READ_ONLY, TRUE,
272  NULL);
273 
274  cpu_usage_item = xv_create(main_panel, PANEL_TEXT,
275  PANEL_LABEL_STRING, "CPU (s):",
276  PANEL_VALUE_DISPLAY_LENGTH, CPU_USAGE_LENGTH,
277  PANEL_READ_ONLY, TRUE,
278  PANEL_VALUE_X, xv_col(main_panel, 68),
279  PANEL_VALUE_Y, xv_rows(main_panel, 3),
280  NULL);
281 
282  window_number =
283  xv_create(main_panel, PANEL_NUMERIC_TEXT,
284  /*PANEL_ITEM_X_GAP, DECALAGE_STATUS,
285  PANEL_VALUE_Y, xv_rows(main_panel, 4),*/
286  PANEL_VALUE_X, xv_col(main_panel, 50),
287  PANEL_VALUE_Y, xv_rows(main_panel, 4),
288  PANEL_LABEL_STRING, "# windows:",
289  PANEL_MIN_VALUE, 1,
290  PANEL_MAX_VALUE, MAX_NUMBER_OF_WPIPS_WINDOWS,
291  PANEL_VALUE, number_of_wpips_windows,
292  PANEL_VALUE_DISPLAY_LENGTH, 2,
293  PANEL_NOTIFY_PROC, window_number_notify,
294  NULL);
295 
297 
299  xv_create(main_panel, PANEL_BUTTON,
300  PANEL_LABEL_IMAGE,
302  PANEL_NOTIFY_PROC, wpips_interrupt_pipsmake,
303  /* Put the Pixmap above the Help button: */
304  XV_X, xv_get(quit_button, XV_X) + (xv_get(quit_button, XV_WIDTH) - xv_get(pips_icon_server_image, XV_WIDTH))/2,
305  XV_Y, xv_rows(main_panel, 3) + 20,
306  NULL);
307 
308  window_fit(main_panel);
309  window_fit(main_frame);
310 
311  show_directory();
312  show_workspace();
313  show_module();
315 }
string db_get_current_module_name(void)
Also used to check whether set...
Definition: database.c:1059
void const char const char const int
bool wpips_emacs_mode
Here are all the stuff to interface Pips with Emacs.
Definition: emacs.c:65
void send_window_number_to_emacs(int number)
Definition: emacs.c:209
char * get_cwd(void)
returns the current working directory name.
Definition: file.c:486
GtkWidget * main_frame
If we are in the Emacs mode, the log_frame is no longer really used:
Definition: gpips.c:60
static Server_image pips_icon_server_image[LAST_ICON]
Definition: xv_icons.c:48
Server_image wpips_positive_server_image
To store the negative image for a blinking icon in the interrupt button:
Definition: xv_icons.c:46
Server_image create_status_window_pips_image()
Definition: xv_icons.c:84
Server_image wpips_negative_server_image
Definition: xv_icons.c:46
GtkWidget * generate_module_menu()
participe Ã&#160; la génération du menu associés aux modules dans la fenetre principale
Definition: gtk_select.c:749
GtkWidget * generate_workspace_menu()
To use with schoose_create_abbrev_menu_with_text:
Definition: gtk_select.c:625
success end_directory_notify(const char *dir)
Definition: gtk_select.c:103
GtkWidget * generate_directory_menu()
Definition: gtk_select.c:153
void open_or_create_workspace(const char *workspace_name_original)
To be used with schoose_create_abbrev_menu_with_text from the main panel:
Definition: gtk_select.c:570
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
string db_get_current_workspace_name(void)
the function is used to check that there is some current workspace...
Definition: workspace.c:82
#define MAX_NUMBER_OF_WPIPS_WINDOWS
How many display wondows can be opened :
Definition: wpips-local.h:30
Panel main_panel
Definition: wpips.c:63
int number_of_wpips_windows
Definition: xv_edit2.c:77
void wpips_interrupt_pipsmake(Panel_item item, Event *event)
To ask pipsmake to stop as soon as possible:
Definition: wpips.c:299
Panel_item quit_button
Definition: xv_quit.c:52
Panel_item schoose_create_abbrev_menu_with_text(Panel main_panel, char *label_string, int value_display_length, int x, int y, Menu(*generate_menu)(void), void(*after_selection)(char *))
Create an abbreviation menu attached with a text item.
Definition: xv_schoose2.c:365
void end_select_module_notify(string name)
Definition: xv_select.c:882
void wpips_interrupt_button_restore()
Definition: xv_status.c:179
Panel_item window_number
Definition: xv_status.c:69
Panel_item module_name_panel_item
Definition: xv_status.c:70
@ DECALAGE_STATUS
Definition: xv_status.c:59
void show_workspace()
Definition: xv_status.c:135
void wpips_interrupt_button_blink()
Definition: xv_status.c:163
Panel_item workspace_name_panel_item
Definition: xv_status.c:68
void show_directory()
Definition: xv_status.c:126
void display_memory_usage()
Definition: xv_status.c:79
Panel_item cpu_usage_item
Definition: xv_status.c:71
Panel_item memory_name
Definition: xv_status.c:69
void show_module()
Definition: xv_status.c:149
edata
Definition: xv_status.c:76
Server_image status_window_pips_image
Definition: xv_status.c:73
void show_message(string message_buffer)
Definition: xv_status.c:188
Panel_item directory_name_panel_item
Definition: xv_status.c:67
@ CPU_USAGE_LENGTH
Definition: xv_status.c:63
void create_status_subwindow()
Definition: xv_status.c:203
etext
Strange, "man end" says that end is a function!
Panel_item message
Definition: xv_status.c:69
void window_number_notify(Panel_item item, int value, Event *event)
Definition: xv_status.c:114
end
Definition: xv_status.c:76