PIPS
gtk_windows.c
Go to the documentation of this file.
1 /*
2 
3  $Id: gtk_windows.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 <stdio.h>
28 
29 #include <sys/time.h>
30 #include <sys/resource.h>
31 
32 #include "genC.h"
33 #include "misc.h"
34 
35 #undef test_undefined // also defined in glib included from gtk
36 #include <gtk/gtk.h>
37 #include "gtk_sizes.h"
38 #include "gpips.h"
39 
40 #if 0
41 #define BOUND(x,lb,ub) \
42  ((x)<(lb)) ? (lb) :\
43  ((x)>(ub)) ? (ub) : (x)
44 #define MAX(a, b) ((a)>(b) ? (a) : (b))
45 #endif
46 
47 //static int display_width, display_height;
48 
49 //void event_procedure(Xv_Window window, Event *event, Notify_arg arg) {
50 // debug_on("GPIPS_EVENT_DEBUG_LEVEL");
51 // debug(2, "event_procedure", "Event_id %d, event_action %d\n",
52 // event_id(event), event_action(event));
53 // switch (event_id(event)) {
54 // case LOC_WINENTER:
55 // win_set_kbd_focus(window, xv_get(window, XV_XID));
56 // debug(2, "event_procedure", "LOC_WINENTER\n");
57 // break;
58 // }
59 // debug_off();
60 //}
61 
62 //void install_event_procedure(Xv_Window window) {
63 // // au final uniquement pour du debug
64 // // et changement de focus window par focus souris (à l'ancienne)
65 // // on va comment tous les appels!
66 // xv_set(window, WIN_EVENT_PROC, event_procedure, WIN_CONSUME_EVENTS,
67 // LOC_WINENTER, NULL, NULL);
68 //}
69 
70 //void place_frame(frame, l, t)
71 // Frame frame;int l, t; {
72 // Rect rect;
73 //
74 // frame_get_rect(frame, &rect);
75 //
76 // /* We need to estimate the size of the decor added by the widow
77 // manager, Y_WM_DECOR_SIZE & X_WM_DECOR_SIZE. RK, 9/10/1993. */
78 // rect.r_top
79 // = BOUND(t, 0, MAX(0,display_height-rect.r_height-Y_WM_DECOR_SIZE));
80 // rect.r_left
81 // = BOUND(l, 0, MAX(0,display_width-rect.r_width-X_WM_DECOR_SIZE));
82 //
83 // frame_set_rect(frame, &rect);
84 //}
85 
87  guint i;
88 
89  main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
90  gtk_window_set_title(GTK_WINDOW(main_window), "gpips");
91 
92  // install_event_procedure(main_frame);
93 
94  log_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
95  gtk_window_set_transient_for(GTK_WINDOW(log_window), GTK_WINDOW(main_window));
96  gtk_window_set_default_size(GTK_WINDOW(log_window), 300, 300);
97 // gtk_window_set_default_size(log_window, defaults_get_integer(
98 // GPIPS_LOG_WINDOW_WIDTH_RESSOURCE_NAME,
99 // GPIPS_LOG_WINDOW_WIDTH_RESSOURCE_CLASS,
100 // GPIPS_LOG_WINDOW_WIDTH_DEFAULT), defaults_get_integer(
101 // GPIPS_LOG_WINDOW_HEIGHT_RESSOURCE_NAME,
102 // GPIPS_LOG_WINDOW_HEIGHT_RESSOURCE_CLASS,
103 // GPIPS_LOG_WINDOW_HEIGHT_DEFAULT));
104  gtk_window_set_title(GTK_WINDOW(log_window), "gpips - Log Window");
105 
106  /* Footers added to edit window.
107  RK, 21/05/1993. */
108  for (i = 0; i < MAX_NUMBER_OF_GPIPS_WINDOWS; i++) {
109  // edit_frame[i] = xv_create(main_frame, FRAME, XV_SHOW, FALSE,
110  // FRAME_DONE_PROC, hide_window, XV_WIDTH, EDIT_WIDTH, XV_HEIGHT,
111  // EDIT_HEIGHT, FRAME_SHOW_FOOTER, TRUE, FRAME_LEFT_FOOTER, "<",
112  // FRAME_RIGHT_FOOTER, ">", NULL);
113  edit_window[i] = gtk_window_new(GTK_WINDOW_TOPLEVEL);
114  gtk_window_set_transient_for(GTK_WINDOW(edit_window[i]), GTK_WINDOW(main_window));
115  gtk_window_set_default_size(GTK_WINDOW(edit_window[i]), EDIT_WIDTH, EDIT_HEIGHT);
116  // On bind "hide window" sur la fermeture d'une de ces fenêtres
117  gtk_signal_connect(GTK_OBJECT(edit_window[i]), "delete-event",
118  GTK_SIGNAL_FUNC(hide_window), NULL);
119  }
120 
121  help_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
122  mchoose_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
123  schoose_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
124  query_dialog = gtk_dialog_new();
125  options_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
126 
127  gtk_window_set_title(GTK_WINDOW(help_window), "pips online help facility");
128  gtk_window_set_default_size(GTK_WINDOW(help_window), HELP_WIDTH, HELP_HEIGHT);
129  gtk_window_set_default_size(GTK_WINDOW(query_dialog), QUERY_WIDTH, QUERY_HEIGHT);
130  gtk_window_set_title(GTK_WINDOW(options_window), "gpips options");
131 
132  g_signal_connect(GTK_OBJECT(log_window), "delete-event",
133  GTK_SIGNAL_FUNC(hide_window), NULL);
134  g_signal_connect(GTK_OBJECT(help_window), "delete-event",
135  GTK_SIGNAL_FUNC(hide_window), NULL);
136  g_signal_connect(GTK_OBJECT(mchoose_window), "delete-event",
137  GTK_SIGNAL_FUNC(hide_window), NULL);
138  g_signal_connect(GTK_OBJECT(schoose_window), "delete-event",
139  GTK_SIGNAL_FUNC(hide_window), NULL);
140  g_signal_connect(GTK_OBJECT(query_dialog), "delete-event",
141  GTK_SIGNAL_FUNC(hide_window), NULL);
142  g_signal_connect(GTK_OBJECT(options_window), "delete-event",
143  GTK_SIGNAL_FUNC(hide_window), NULL);
144  g_signal_connect(GTK_OBJECT(main_window), "delete-event",
145  GTK_SIGNAL_FUNC(quit_notify), NULL);
146 
147 // gtk_widget_show_all(help_window);
148 // gtk_widget_show_all(mchoose_window);
149 // gtk_widget_show_all(schoose_window);
150 // gtk_widget_show_all(query_dialog);
151 // gtk_widget_show_all(options_window);
152 
153  gtk_window_set_transient_for(GTK_WINDOW(help_window), GTK_WINDOW(main_window));
154  gtk_window_set_transient_for(GTK_WINDOW(mchoose_window), GTK_WINDOW(main_window));
155  gtk_window_set_transient_for(GTK_WINDOW(schoose_window), GTK_WINDOW(main_window));
156  gtk_window_set_transient_for(GTK_WINDOW(query_dialog), GTK_WINDOW(main_window));
157  gtk_window_set_transient_for(GTK_WINDOW(options_window), GTK_WINDOW(main_window));
158 }
159 
160 //void place_frames() {
161 // Rect rect;
162 // int main_l, main_t, main_w, main_h;
163 // int main_center_l, main_center_t;
164 // int i;
165 //
166 // Frame full_frame;
167 // Xv_Screen screen;
168 // Display *dpy;
169 // int screen_no;
170 //
171 // /* get the display dimensions */
172 // full_frame = (Frame) xv_create(XV_NULL, FRAME, NULL);
173 // dpy = (Display *) xv_get(full_frame, XV_DISPLAY);
174 // screen = (Xv_Screen) xv_get(full_frame, XV_SCREEN);
175 // screen_no = (int) xv_get(screen, SCREEN_NUMBER);
176 // xv_destroy(full_frame);
177 //
178 // display_width = DisplayWidth(dpy, screen_no);
179 // display_height = DisplayHeight(dpy, screen_no);
180 //
181 // /* warning: some window managers do NOT place the top frame (main_frame)
182 // themselves. In this case add this fonction call and modify the call
183 // to place_frames().
184 //
185 // place_frame(main_frame,
186 // (display_width-WPIPS_WIDTH)/2,
187 // (display_height-WPIPS_HEIGHT)/2);
188 // */
189 // /* in the bottom left : */
190 // place_frame(log_frame, 0, display_height);
191 //
192 // frame_get_rect(log_frame, &rect);
193 //
194 // main_t = rect.r_top;
195 // main_w = rect.r_width;
196 // main_h = rect.r_height;
197 // main_l = rect.r_left;
198 //
199 // place_frame(main_frame, 0, main_t - xv_get(main_frame, XV_HEIGHT)
200 // - Y_WM_DECOR_SIZE);
201 //
202 // frame_get_rect(main_frame, &rect);
203 //
204 // main_t = rect.r_top;
205 // main_w = rect.r_width;
206 // main_h = rect.r_height;
207 // main_l = rect.r_left;
208 //
209 // main_center_t = main_t + main_h / 2;
210 // main_center_l = main_l + main_w / 2;
211 //
212 // /* Above the main frame : */
213 // place_frame(options_frame, 0, main_t - xv_get(options_frame, XV_HEIGHT)
214 // - Y_WM_DECOR_SIZE);
215 //
216 // /* in the upper right corner, in the bottom right corner, etc : */
217 // for (i = 0; i < MAX_NUMBER_OF_WPIPS_WINDOWS; i++)
218 // /* According to the 2 least bits of the window number... */
219 // place_frame(edit_frame[i], display_width * (1 - ((i >> 1) & 1)),
220 // display_height * (i & 1));
221 //
222 // /* in the upper */
223 // place_frame(help_frame, main_l + (main_w - HELP_WIDTH) / 2, main_t
224 // - HELP_HEIGHT);
225 //
226 // /* in the upper left corner : */
227 // place_frame(mchoose_frame, 0, 0);
228 //
229 // /* in the upper left corner : */
230 // place_frame(schoose_frame, 0, 0);
231 //
232 // /* in the upper left corner */
233 // place_frame(query_frame, main_l - QUERY_WIDTH + MIN(main_w, QUERY_WIDTH)
234 // / 3, main_t - QUERY_HEIGHT - Y_WM_DECOR_SIZE);
235 //}
GtkWidget * edit_window[MAX_NUMBER_OF_GPIPS_WINDOWS]
Definition: gpips-local.h:37
GtkWidget * options_window
Definition: gpips-local.h:38
GtkWidget * query_dialog
Definition: gpips-local.h:37
GtkWidget * main_window
Definition: gpips.c:54
GtkWidget * schoose_window
Definition: gpips-local.h:36
GtkWidget * log_window
Definition: gpips-local.h:36
#define MAX_NUMBER_OF_GPIPS_WINDOWS
How many display wondows can be opened :
Definition: gpips-local.h:30
GtkWidget * mchoose_window
Definition: gpips-local.h:36
GtkWidget * help_window
Definition: gpips-local.h:37
void quit_notify(GtkWidget *widget, gpointer data)
Definition: gtk_quit.c:57
#define EDIT_HEIGHT
#define EDIT_HEIGHT 400
Definition: gtk_sizes.h:35
#define HELP_HEIGHT
Definition: gtk_sizes.h:41
#define QUERY_WIDTH
Definition: gtk_sizes.h:50
#define EDIT_WIDTH
Definition: gtk_sizes.h:33
#define QUERY_HEIGHT
Definition: gtk_sizes.h:49
#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 create_windows()
Definition: gtk_windows.c:86