PIPS
xv_help.c
Go to the documentation of this file.
1 /*
2 
3  $Id: xv_help.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 <stdlib.h>
29 #include <stdio.h>
30 
31 #include <sys/time.h>
32 #include <sys/resource.h>
33 #include <xview/xview.h>
34 #include <xview/panel.h>
35 #include <xview/text.h>
36 
37 #include "genC.h"
38 #include "top-level.h"
39 #include "wpips.h"
40 #include "xv_sizes.h"
41 
42 #include "genC.h"
43 #include "misc.h"
44 
45 #define min(a,b) ((a) < (b) ? (a) : (b))
46 #define HELP_LINES 32
47 
48 /* The URL of the PIPS documentation at the École des Mines de Paris: */
49 #define PIPS_DOCUMENTATION_URL "http://www.cri.ensmp.fr/pips"
50 
51 static Panel_item lines[HELP_LINES]; /* GRRRRRRRR FC. */
53 
54 void
55 display_help(char * topic)
56 {
57  int i, n;
58 
59  if (!help_list) /* lazy */
61 
62  get_help_topic(topic, help_list);
64 
65  for (i = 0; i < min(HELP_LINES, n); i++) {
66  xv_set(lines[i], PANEL_LABEL_STRING,
67  gen_array_item(help_list, i), 0);
68  }
69 
70  for (i = min(HELP_LINES, n); i < HELP_LINES; i++) {
71  xv_set(lines[i], PANEL_LABEL_STRING, "", 0);
72  }
73 
75 }
76 
77 
78 
79 static void
80 close_help_notify(Panel_item item,
81  Event * event)
82 {
85 }
86 
87 
88 
89 void
91 {
92  int i;
93  Panel help_panel;
94 
95  help_panel = xv_create(help_frame, PANEL,
96  NULL);
97 
98  for (i = 0; i < HELP_LINES; i++) {
99  lines[i] = xv_create(help_panel, PANEL_MESSAGE,
100  XV_X, 15,
101  XV_Y, 15*(i+1),
102  0);
103  }
104 
105  (void) xv_create(help_panel, PANEL_BUTTON,
106  PANEL_LABEL_STRING, "CLOSE",
107  XV_X, HELP_WIDTH/2-28,
108  XV_Y, 15*(HELP_LINES+1),
109  PANEL_NOTIFY_PROC, close_help_notify,
110  0);
111 
112 
113 }
114 
115 static void
116 help_notify(Menu menu,
117  Menu_item menu_item)
118 {
119  display_help((char *) xv_get(menu_item, MENU_CLIENT_DATA));
120 }
121 
122 
123 static void
125  Menu_item menu_item)
126 {
127  system("netscape " PIPS_DOCUMENTATION_URL " &");
128 }
129 
130 
131 static void
133  Menu_item menu_item)
134 {
135  system("xmosaic " PIPS_DOCUMENTATION_URL " &");
136 }
137 
138 
139 void
141 {
142  Menu menu;
143 
144  menu = xv_create(XV_NULL, MENU_COMMAND_MENU,
145  MENU_TITLE_ITEM,
146  "The PIPS documentation",
147  MENU_GEN_PIN_WINDOW, main_frame, "Help Menu",
148  MENU_ITEM,
149  MENU_STRING, "A few introductory words...",
150  MENU_CLIENT_DATA, strdup("Introduction"),
151  MENU_NOTIFY_PROC, help_notify,
152  NULL,
153  MENU_ITEM,
154  MENU_STRING, "A few words about \"Workspace\"...",
155  MENU_CLIENT_DATA, strdup("Workspace"),
156  MENU_NOTIFY_PROC, help_notify,
157  NULL,
158  MENU_ITEM,
159  MENU_STRING, "A few words about \"Module\"...",
160  MENU_CLIENT_DATA, strdup("Module"),
161  MENU_NOTIFY_PROC, help_notify,
162  NULL,
163  MENU_ITEM,
164  MENU_STRING, "A few words about \"Directory\"...",
165  MENU_CLIENT_DATA, strdup("Directory"),
166  MENU_NOTIFY_PROC, help_notify,
167  NULL,
168  MENU_ITEM,
169  MENU_STRING, "A few words about \"View\"...",
170  MENU_CLIENT_DATA, strdup("View"),
171  MENU_NOTIFY_PROC, help_notify,
172  NULL,
173  MENU_ITEM,
174  MENU_STRING, "A few words about \"Transform/Edit\"...",
175  MENU_CLIENT_DATA, strdup("Transform/Edit"),
176  MENU_NOTIFY_PROC, help_notify,
177  NULL,
178  MENU_ITEM,
179  MENU_STRING, "A few words about \"Compile\"...",
180  MENU_CLIENT_DATA, strdup("Compile"),
181  MENU_NOTIFY_PROC, help_notify,
182  NULL,
183  MENU_ITEM,
184  MENU_STRING, "A few words about \"Options\"...",
185  MENU_CLIENT_DATA, strdup("Options"),
186  MENU_NOTIFY_PROC, help_notify,
187  NULL,
188  MENU_ITEM,
189  MENU_STRING, "A few words about \"Log\"...",
190  MENU_CLIENT_DATA, strdup("Log"),
191  MENU_NOTIFY_PROC, help_notify,
192  NULL,
193  /* Just a separator: */
195  MENU_ACTION_ITEM, "The PIPS documentation on Internet with Netscape...",
197  MENU_ACTION_ITEM, "The PIPS documentation on Internet with XMosaic...",
199  NULL);
200 
201  (void) xv_create(main_panel, PANEL_BUTTON,
202  PANEL_LABEL_STRING, "Help ",
203  PANEL_ITEM_MENU, menu,
204  /* Align the Help button with the Quit button:
205  XV_X, xv_get(quit_button, XV_X), */
206  NULL);
207 }
size_t gen_array_nitems(const gen_array_t a)
Definition: array.c:131
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
GtkWidget * main_frame
If we are in the Emacs mode, the log_frame is no longer really used:
Definition: gpips.c:60
GtkWidget * help_frame
Definition: gpips-local.h:43
#define HELP_WIDTH
Definition: gtk_sizes.h:40
gint hide_window(GtkWidget *window, GdkEvent *ev __attribute__((unused)), gpointer data __attribute__((unused)))
Definition: gtk_utils.c:89
void get_help_topic(string topic, gen_array_t array)
Definition: help.c:64
struct _gen_array_chunk_t * gen_array_t
Definition: newgen_array.h:24
char * strdup()
Panel help_panel
Definition: wpips-local.h:51
Panel main_panel
Definition: wpips.c:63
#define WPIPS_MENU_SEPARATOR
Define the menu separator:
Definition: wpips-local.h:94
static void close_help_notify(Panel_item item, Event *event)
Definition: xv_help.c:80
void create_help_menu()
Definition: xv_help.c:140
void create_help_window()
Definition: xv_help.c:90
#define PIPS_DOCUMENTATION_URL
The URL of the PIPS documentation at the École des Mines de Paris:
Definition: xv_help.c:49
void display_help(char *topic)
Definition: xv_help.c:55
#define HELP_LINES
Definition: xv_help.c:46
static void help_launch_pips_xmosaic(Menu menu, Menu_item menu_item)
Definition: xv_help.c:132
static gen_array_t help_list
GRRRRRRRR FC.
Definition: xv_help.c:52
static Panel_item lines[HELP_LINES]
Definition: xv_help.c:51
#define min(a, b)
Definition: xv_help.c:45
static void help_notify(Menu menu, Menu_item menu_item)
Definition: xv_help.c:116
static void help_launch_pips_netscape(Menu menu, Menu_item menu_item)
Definition: xv_help.c:124
void unhide_window(Frame frame)
map a frame on the screen
Definition: xv_utils.c:55