720a8fb7 |
1 | /* |
2 | * gtk.c: GTK front end for my puzzle collection. |
3 | */ |
4 | |
5 | #include <stdio.h> |
fd1a1a2b |
6 | #include <assert.h> |
720a8fb7 |
7 | #include <stdlib.h> |
2ef96bd6 |
8 | #include <time.h> |
720a8fb7 |
9 | #include <stdarg.h> |
10 | |
83680571 |
11 | #include <gtk/gtk.h> |
1482ee76 |
12 | #include <gdk/gdkkeysyms.h> |
83680571 |
13 | |
720a8fb7 |
14 | #include "puzzles.h" |
15 | |
83680571 |
16 | /* ---------------------------------------------------------------------- |
17 | * Error reporting functions used elsewhere. |
18 | */ |
19 | |
720a8fb7 |
20 | void fatal(char *fmt, ...) |
21 | { |
22 | va_list ap; |
23 | |
24 | fprintf(stderr, "fatal error: "); |
25 | |
26 | va_start(ap, fmt); |
27 | vfprintf(stderr, fmt, ap); |
28 | va_end(ap); |
29 | |
30 | fprintf(stderr, "\n"); |
31 | exit(1); |
32 | } |
83680571 |
33 | |
34 | /* ---------------------------------------------------------------------- |
35 | * GTK front end to puzzles. |
36 | */ |
37 | |
4efb3868 |
38 | struct font { |
39 | GdkFont *font; |
40 | int type; |
41 | int size; |
42 | }; |
43 | |
83680571 |
44 | /* |
45 | * This structure holds all the data relevant to a single window. |
46 | * In principle this would allow us to open multiple independent |
47 | * puzzle windows, although I can't currently see any real point in |
48 | * doing so. I'm just coding cleanly because there's no |
49 | * particularly good reason not to. |
50 | */ |
2ef96bd6 |
51 | struct frontend { |
83680571 |
52 | GtkWidget *window; |
7f77ea24 |
53 | GtkWidget *area; |
fd1a1a2b |
54 | GtkWidget *statusbar; |
55 | guint statusctx; |
2ef96bd6 |
56 | GdkPixmap *pixmap; |
57 | GdkColor *colours; |
58 | int ncolours; |
59 | GdkColormap *colmap; |
60 | int w, h; |
7f77ea24 |
61 | midend_data *me; |
2ef96bd6 |
62 | GdkGC *gc; |
63 | int bbox_l, bbox_r, bbox_u, bbox_d; |
20ee89e3 |
64 | int timer_active, timer_id; |
4efb3868 |
65 | struct font *fonts; |
66 | int nfonts, fontsize; |
83680571 |
67 | }; |
68 | |
2ef96bd6 |
69 | void frontend_default_colour(frontend *fe, float *output) |
70 | { |
71 | GdkColor col = fe->window->style->bg[GTK_STATE_NORMAL]; |
72 | output[0] = col.red / 65535.0; |
73 | output[1] = col.green / 65535.0; |
74 | output[2] = col.blue / 65535.0; |
75 | } |
76 | |
fd1a1a2b |
77 | void status_bar(frontend *fe, char *text) |
78 | { |
79 | assert(fe->statusbar); |
80 | |
81 | gtk_statusbar_pop(GTK_STATUSBAR(fe->statusbar), fe->statusctx); |
82 | gtk_statusbar_push(GTK_STATUSBAR(fe->statusbar), fe->statusctx, text); |
83 | } |
84 | |
2ef96bd6 |
85 | void start_draw(frontend *fe) |
86 | { |
87 | fe->gc = gdk_gc_new(fe->area->window); |
88 | fe->bbox_l = fe->w; |
89 | fe->bbox_r = 0; |
90 | fe->bbox_u = fe->h; |
91 | fe->bbox_d = 0; |
92 | } |
93 | |
4efb3868 |
94 | void clip(frontend *fe, int x, int y, int w, int h) |
95 | { |
96 | GdkRectangle rect; |
97 | |
98 | rect.x = x; |
99 | rect.y = y; |
100 | rect.width = w; |
101 | rect.height = h; |
102 | |
103 | gdk_gc_set_clip_rectangle(fe->gc, &rect); |
104 | } |
105 | |
106 | void unclip(frontend *fe) |
107 | { |
108 | GdkRectangle rect; |
109 | |
110 | rect.x = 0; |
111 | rect.y = 0; |
112 | rect.width = fe->w; |
113 | rect.height = fe->h; |
114 | |
115 | gdk_gc_set_clip_rectangle(fe->gc, &rect); |
116 | } |
117 | |
118 | void draw_text(frontend *fe, int x, int y, int fonttype, int fontsize, |
119 | int align, int colour, char *text) |
120 | { |
121 | int i; |
122 | |
123 | /* |
124 | * Find or create the font. |
125 | */ |
126 | for (i = 0; i < fe->nfonts; i++) |
127 | if (fe->fonts[i].type == fonttype && fe->fonts[i].size == fontsize) |
128 | break; |
129 | |
130 | if (i == fe->nfonts) { |
131 | if (fe->fontsize <= fe->nfonts) { |
132 | fe->fontsize = fe->nfonts + 10; |
133 | fe->fonts = sresize(fe->fonts, fe->fontsize, struct font); |
134 | } |
135 | |
136 | fe->nfonts++; |
137 | |
138 | fe->fonts[i].type = fonttype; |
139 | fe->fonts[i].size = fontsize; |
140 | |
141 | /* |
142 | * FIXME: Really I should make at least _some_ effort to |
143 | * pick the correct font. |
144 | */ |
145 | fe->fonts[i].font = gdk_font_load("variable"); |
146 | } |
147 | |
148 | /* |
149 | * Find string dimensions and process alignment. |
150 | */ |
151 | { |
152 | int lb, rb, wid, asc, desc; |
153 | |
154 | gdk_string_extents(fe->fonts[i].font, text, |
155 | &lb, &rb, &wid, &asc, &desc); |
156 | if (align & ALIGN_VCENTRE) |
157 | y += asc - (asc+desc)/2; |
158 | |
159 | if (align & ALIGN_HCENTRE) |
160 | x -= wid / 2; |
161 | else if (align & ALIGN_HRIGHT) |
162 | x -= wid; |
163 | |
164 | } |
165 | |
166 | /* |
167 | * Set colour and actually draw text. |
168 | */ |
169 | gdk_gc_set_foreground(fe->gc, &fe->colours[colour]); |
170 | gdk_draw_string(fe->pixmap, fe->fonts[i].font, fe->gc, x, y, text); |
171 | } |
172 | |
2ef96bd6 |
173 | void draw_rect(frontend *fe, int x, int y, int w, int h, int colour) |
174 | { |
175 | gdk_gc_set_foreground(fe->gc, &fe->colours[colour]); |
176 | gdk_draw_rectangle(fe->pixmap, fe->gc, 1, x, y, w, h); |
177 | } |
178 | |
179 | void draw_line(frontend *fe, int x1, int y1, int x2, int y2, int colour) |
180 | { |
181 | gdk_gc_set_foreground(fe->gc, &fe->colours[colour]); |
182 | gdk_draw_line(fe->pixmap, fe->gc, x1, y1, x2, y2); |
183 | } |
184 | |
185 | void draw_polygon(frontend *fe, int *coords, int npoints, |
186 | int fill, int colour) |
187 | { |
188 | GdkPoint *points = snewn(npoints, GdkPoint); |
189 | int i; |
190 | |
191 | for (i = 0; i < npoints; i++) { |
192 | points[i].x = coords[i*2]; |
193 | points[i].y = coords[i*2+1]; |
194 | } |
195 | |
196 | gdk_gc_set_foreground(fe->gc, &fe->colours[colour]); |
197 | gdk_draw_polygon(fe->pixmap, fe->gc, fill, points, npoints); |
198 | |
199 | sfree(points); |
200 | } |
201 | |
202 | void draw_update(frontend *fe, int x, int y, int w, int h) |
203 | { |
204 | if (fe->bbox_l > x ) fe->bbox_l = x ; |
205 | if (fe->bbox_r < x+w) fe->bbox_r = x+w; |
206 | if (fe->bbox_u > y ) fe->bbox_u = y ; |
207 | if (fe->bbox_d < y+h) fe->bbox_d = y+h; |
208 | } |
209 | |
210 | void end_draw(frontend *fe) |
211 | { |
212 | gdk_gc_unref(fe->gc); |
213 | fe->gc = NULL; |
214 | |
215 | if (fe->bbox_l < fe->bbox_r && fe->bbox_u < fe->bbox_d) { |
216 | gdk_draw_pixmap(fe->area->window, |
217 | fe->area->style->fg_gc[GTK_WIDGET_STATE(fe->area)], |
218 | fe->pixmap, |
219 | fe->bbox_l, fe->bbox_u, |
220 | fe->bbox_l, fe->bbox_u, |
221 | fe->bbox_r - fe->bbox_l, fe->bbox_d - fe->bbox_u); |
222 | } |
223 | } |
224 | |
83680571 |
225 | static void destroy(GtkWidget *widget, gpointer data) |
226 | { |
227 | gtk_main_quit(); |
228 | } |
229 | |
2ef96bd6 |
230 | static gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data) |
7f77ea24 |
231 | { |
2ef96bd6 |
232 | frontend *fe = (frontend *)data; |
1482ee76 |
233 | int keyval; |
7f77ea24 |
234 | |
2ef96bd6 |
235 | if (!fe->pixmap) |
236 | return TRUE; |
7f77ea24 |
237 | |
1482ee76 |
238 | if (event->string[0] && !event->string[1]) |
239 | keyval = (unsigned char)event->string[0]; |
c71454c0 |
240 | else if (event->keyval == GDK_Up || event->keyval == GDK_KP_Up || |
241 | event->keyval == GDK_KP_8) |
1482ee76 |
242 | keyval = CURSOR_UP; |
c71454c0 |
243 | else if (event->keyval == GDK_Down || event->keyval == GDK_KP_Down || |
244 | event->keyval == GDK_KP_2) |
1482ee76 |
245 | keyval = CURSOR_DOWN; |
c71454c0 |
246 | else if (event->keyval == GDK_Left || event->keyval == GDK_KP_Left || |
247 | event->keyval == GDK_KP_4) |
1482ee76 |
248 | keyval = CURSOR_LEFT; |
c71454c0 |
249 | else if (event->keyval == GDK_Right || event->keyval == GDK_KP_Right || |
250 | event->keyval == GDK_KP_6) |
1482ee76 |
251 | keyval = CURSOR_RIGHT; |
c71454c0 |
252 | else if (event->keyval == GDK_KP_Home || event->keyval == GDK_KP_7) |
253 | keyval = CURSOR_UP_LEFT; |
254 | else if (event->keyval == GDK_KP_End || event->keyval == GDK_KP_1) |
255 | keyval = CURSOR_DOWN_LEFT; |
256 | else if (event->keyval == GDK_KP_Page_Up || event->keyval == GDK_KP_9) |
257 | keyval = CURSOR_UP_RIGHT; |
258 | else if (event->keyval == GDK_KP_Page_Down || event->keyval == GDK_KP_3) |
259 | keyval = CURSOR_DOWN_RIGHT; |
1482ee76 |
260 | else |
261 | keyval = -1; |
262 | |
263 | if (keyval >= 0 && |
264 | !midend_process_key(fe->me, 0, 0, keyval)) |
2ef96bd6 |
265 | gtk_widget_destroy(fe->window); |
7f77ea24 |
266 | |
267 | return TRUE; |
268 | } |
269 | |
2ef96bd6 |
270 | static gint button_event(GtkWidget *widget, GdkEventButton *event, |
271 | gpointer data) |
7f77ea24 |
272 | { |
2ef96bd6 |
273 | frontend *fe = (frontend *)data; |
274 | int button; |
275 | |
276 | if (!fe->pixmap) |
277 | return TRUE; |
278 | |
279 | if (event->type != GDK_BUTTON_PRESS) |
280 | return TRUE; |
7f77ea24 |
281 | |
b0f06719 |
282 | if (event->button == 2 || (event->state & GDK_SHIFT_MASK)) |
2ef96bd6 |
283 | button = MIDDLE_BUTTON; |
b0f06719 |
284 | else if (event->button == 1) |
285 | button = LEFT_BUTTON; |
2ef96bd6 |
286 | else if (event->button == 3) |
287 | button = RIGHT_BUTTON; |
288 | else |
289 | return FALSE; /* don't even know what button! */ |
290 | |
291 | if (!midend_process_key(fe->me, event->x, event->y, button)) |
292 | gtk_widget_destroy(fe->window); |
7f77ea24 |
293 | |
294 | return TRUE; |
295 | } |
296 | |
2ef96bd6 |
297 | static gint expose_area(GtkWidget *widget, GdkEventExpose *event, |
298 | gpointer data) |
83680571 |
299 | { |
2ef96bd6 |
300 | frontend *fe = (frontend *)data; |
301 | |
302 | if (fe->pixmap) { |
303 | gdk_draw_pixmap(widget->window, |
304 | widget->style->fg_gc[GTK_WIDGET_STATE(widget)], |
305 | fe->pixmap, |
306 | event->area.x, event->area.y, |
307 | event->area.x, event->area.y, |
308 | event->area.width, event->area.height); |
309 | } |
310 | return TRUE; |
311 | } |
312 | |
fd1a1a2b |
313 | static gint map_window(GtkWidget *widget, GdkEvent *event, |
314 | gpointer data) |
315 | { |
316 | frontend *fe = (frontend *)data; |
317 | |
318 | /* |
319 | * Apparently we need to do this because otherwise the status |
320 | * bar will fail to update immediately. Annoying, but there we |
321 | * go. |
322 | */ |
323 | gtk_widget_queue_draw(fe->window); |
324 | |
325 | return TRUE; |
326 | } |
327 | |
2ef96bd6 |
328 | static gint configure_area(GtkWidget *widget, |
329 | GdkEventConfigure *event, gpointer data) |
330 | { |
331 | frontend *fe = (frontend *)data; |
332 | GdkGC *gc; |
333 | |
eb2ad6f1 |
334 | if (fe->pixmap) |
335 | gdk_pixmap_unref(fe->pixmap); |
336 | |
2ef96bd6 |
337 | fe->pixmap = gdk_pixmap_new(widget->window, fe->w, fe->h, -1); |
338 | |
339 | gc = gdk_gc_new(fe->area->window); |
340 | gdk_gc_set_foreground(gc, &fe->colours[0]); |
341 | gdk_draw_rectangle(fe->pixmap, gc, 1, 0, 0, fe->w, fe->h); |
342 | gdk_gc_unref(gc); |
343 | |
344 | midend_redraw(fe->me); |
345 | |
346 | return TRUE; |
347 | } |
348 | |
349 | static gint timer_func(gpointer data) |
350 | { |
351 | frontend *fe = (frontend *)data; |
352 | |
353 | if (fe->timer_active) |
354 | midend_timer(fe->me, 0.02); /* may clear timer_active */ |
355 | |
356 | return fe->timer_active; |
357 | } |
358 | |
359 | void deactivate_timer(frontend *fe) |
360 | { |
20ee89e3 |
361 | if (fe->timer_active) |
362 | gtk_timeout_remove(fe->timer_id); |
2ef96bd6 |
363 | fe->timer_active = FALSE; |
364 | } |
365 | |
366 | void activate_timer(frontend *fe) |
367 | { |
20ee89e3 |
368 | if (!fe->timer_active) |
369 | fe->timer_id = gtk_timeout_add(20, timer_func, fe); |
2ef96bd6 |
370 | fe->timer_active = TRUE; |
371 | } |
372 | |
eb2ad6f1 |
373 | static void menu_key_event(GtkMenuItem *menuitem, gpointer data) |
374 | { |
375 | frontend *fe = (frontend *)data; |
376 | int key = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(menuitem), |
377 | "user-data")); |
378 | if (!midend_process_key(fe->me, 0, 0, key)) |
379 | gtk_widget_destroy(fe->window); |
380 | } |
381 | |
382 | static void menu_preset_event(GtkMenuItem *menuitem, gpointer data) |
383 | { |
384 | frontend *fe = (frontend *)data; |
385 | game_params *params = |
386 | (game_params *)gtk_object_get_data(GTK_OBJECT(menuitem), "user-data"); |
387 | int x, y; |
388 | |
389 | midend_set_params(fe->me, params); |
390 | midend_new_game(fe->me, NULL); |
391 | midend_size(fe->me, &x, &y); |
392 | gtk_drawing_area_size(GTK_DRAWING_AREA(fe->area), x, y); |
393 | fe->w = x; |
394 | fe->h = y; |
395 | } |
396 | |
397 | static GtkWidget *add_menu_item_with_key(frontend *fe, GtkContainer *cont, |
398 | char *text, int key) |
399 | { |
400 | GtkWidget *menuitem = gtk_menu_item_new_with_label(text); |
401 | gtk_container_add(cont, menuitem); |
402 | gtk_object_set_data(GTK_OBJECT(menuitem), "user-data", |
403 | GINT_TO_POINTER(key)); |
404 | gtk_signal_connect(GTK_OBJECT(menuitem), "activate", |
405 | GTK_SIGNAL_FUNC(menu_key_event), fe); |
406 | gtk_widget_show(menuitem); |
407 | return menuitem; |
408 | } |
409 | |
410 | static void add_menu_separator(GtkContainer *cont) |
411 | { |
412 | GtkWidget *menuitem = gtk_menu_item_new(); |
413 | gtk_container_add(cont, menuitem); |
414 | gtk_widget_show(menuitem); |
415 | } |
416 | |
2ef96bd6 |
417 | static frontend *new_window(void) |
418 | { |
419 | frontend *fe; |
eb2ad6f1 |
420 | GtkBox *vbox; |
421 | GtkWidget *menubar, *menu, *menuitem; |
422 | int x, y, n; |
83680571 |
423 | |
2ef96bd6 |
424 | fe = snew(frontend); |
83680571 |
425 | |
2ef96bd6 |
426 | fe->me = midend_new(fe); |
427 | midend_new_game(fe->me, NULL); |
7f77ea24 |
428 | |
2ef96bd6 |
429 | fe->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
0c490335 |
430 | gtk_window_set_title(GTK_WINDOW(fe->window), game_name); |
ff2f787b |
431 | #if 0 |
432 | gtk_window_set_resizable(GTK_WINDOW(fe->window), FALSE); |
433 | #else |
434 | gtk_window_set_policy(GTK_WINDOW(fe->window), FALSE, FALSE, TRUE); |
435 | #endif |
eb2ad6f1 |
436 | vbox = GTK_BOX(gtk_vbox_new(FALSE, 0)); |
437 | gtk_container_add(GTK_CONTAINER(fe->window), GTK_WIDGET(vbox)); |
438 | gtk_widget_show(GTK_WIDGET(vbox)); |
439 | |
440 | menubar = gtk_menu_bar_new(); |
441 | gtk_box_pack_start(vbox, menubar, FALSE, FALSE, 0); |
442 | gtk_widget_show(menubar); |
443 | |
444 | menuitem = gtk_menu_item_new_with_label("Game"); |
445 | gtk_container_add(GTK_CONTAINER(menubar), menuitem); |
446 | gtk_widget_show(menuitem); |
447 | |
448 | menu = gtk_menu_new(); |
449 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); |
450 | |
451 | add_menu_item_with_key(fe, GTK_CONTAINER(menu), "New", 'n'); |
452 | add_menu_item_with_key(fe, GTK_CONTAINER(menu), "Restart", 'r'); |
453 | |
454 | if ((n = midend_num_presets(fe->me)) > 0) { |
455 | GtkWidget *submenu; |
456 | int i; |
457 | |
458 | menuitem = gtk_menu_item_new_with_label("Type"); |
459 | gtk_container_add(GTK_CONTAINER(menu), menuitem); |
460 | gtk_widget_show(menuitem); |
461 | |
462 | submenu = gtk_menu_new(); |
463 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); |
464 | |
465 | for (i = 0; i < n; i++) { |
466 | char *name; |
467 | game_params *params; |
468 | |
469 | midend_fetch_preset(fe->me, i, &name, ¶ms); |
470 | |
471 | menuitem = gtk_menu_item_new_with_label(name); |
472 | gtk_container_add(GTK_CONTAINER(submenu), menuitem); |
473 | gtk_object_set_data(GTK_OBJECT(menuitem), "user-data", params); |
474 | gtk_signal_connect(GTK_OBJECT(menuitem), "activate", |
475 | GTK_SIGNAL_FUNC(menu_preset_event), fe); |
476 | gtk_widget_show(menuitem); |
477 | } |
478 | } |
479 | |
480 | add_menu_separator(GTK_CONTAINER(menu)); |
481 | add_menu_item_with_key(fe, GTK_CONTAINER(menu), "Undo", 'u'); |
482 | add_menu_item_with_key(fe, GTK_CONTAINER(menu), "Redo", '\x12'); |
483 | add_menu_separator(GTK_CONTAINER(menu)); |
484 | add_menu_item_with_key(fe, GTK_CONTAINER(menu), "Exit", 'q'); |
7f77ea24 |
485 | |
2ef96bd6 |
486 | { |
487 | int i, ncolours; |
488 | float *colours; |
489 | gboolean *success; |
7f77ea24 |
490 | |
2ef96bd6 |
491 | fe->colmap = gdk_colormap_get_system(); |
492 | colours = midend_colours(fe->me, &ncolours); |
493 | fe->ncolours = ncolours; |
494 | fe->colours = snewn(ncolours, GdkColor); |
495 | for (i = 0; i < ncolours; i++) { |
496 | fe->colours[i].red = colours[i*3] * 0xFFFF; |
497 | fe->colours[i].green = colours[i*3+1] * 0xFFFF; |
498 | fe->colours[i].blue = colours[i*3+2] * 0xFFFF; |
499 | } |
500 | success = snewn(ncolours, gboolean); |
501 | gdk_colormap_alloc_colors(fe->colmap, fe->colours, ncolours, |
502 | FALSE, FALSE, success); |
503 | for (i = 0; i < ncolours; i++) { |
504 | if (!success[i]) |
505 | g_error("couldn't allocate colour %d (#%02x%02x%02x)\n", |
506 | i, fe->colours[i].red >> 8, |
507 | fe->colours[i].green >> 8, |
508 | fe->colours[i].blue >> 8); |
509 | } |
510 | } |
7f77ea24 |
511 | |
fd1a1a2b |
512 | if (midend_wants_statusbar(fe->me)) { |
513 | fe->statusbar = gtk_statusbar_new(); |
514 | gtk_box_pack_end(vbox, fe->statusbar, FALSE, FALSE, 0); |
515 | gtk_widget_show(fe->statusbar); |
516 | fe->statusctx = gtk_statusbar_get_context_id |
517 | (GTK_STATUSBAR(fe->statusbar), "game"); |
518 | gtk_statusbar_push(GTK_STATUSBAR(fe->statusbar), fe->statusctx, |
519 | ""); |
520 | } else |
521 | fe->statusbar = NULL; |
522 | |
2ef96bd6 |
523 | fe->area = gtk_drawing_area_new(); |
524 | midend_size(fe->me, &x, &y); |
525 | gtk_drawing_area_size(GTK_DRAWING_AREA(fe->area), x, y); |
526 | fe->w = x; |
527 | fe->h = y; |
528 | |
eb2ad6f1 |
529 | gtk_box_pack_end(vbox, fe->area, FALSE, FALSE, 0); |
2ef96bd6 |
530 | |
531 | fe->pixmap = NULL; |
4efb3868 |
532 | fe->fonts = NULL; |
533 | fe->nfonts = fe->fontsize = 0; |
2ef96bd6 |
534 | |
20ee89e3 |
535 | fe->timer_active = FALSE; |
536 | |
2ef96bd6 |
537 | gtk_signal_connect(GTK_OBJECT(fe->window), "destroy", |
538 | GTK_SIGNAL_FUNC(destroy), fe); |
539 | gtk_signal_connect(GTK_OBJECT(fe->window), "key_press_event", |
540 | GTK_SIGNAL_FUNC(key_event), fe); |
541 | gtk_signal_connect(GTK_OBJECT(fe->area), "button_press_event", |
542 | GTK_SIGNAL_FUNC(button_event), fe); |
543 | gtk_signal_connect(GTK_OBJECT(fe->area), "expose_event", |
544 | GTK_SIGNAL_FUNC(expose_area), fe); |
fd1a1a2b |
545 | gtk_signal_connect(GTK_OBJECT(fe->window), "map_event", |
546 | GTK_SIGNAL_FUNC(map_window), fe); |
2ef96bd6 |
547 | gtk_signal_connect(GTK_OBJECT(fe->area), "configure_event", |
548 | GTK_SIGNAL_FUNC(configure_area), fe); |
549 | |
550 | gtk_widget_add_events(GTK_WIDGET(fe->area), GDK_BUTTON_PRESS_MASK); |
551 | |
552 | gtk_widget_show(fe->area); |
553 | gtk_widget_show(fe->window); |
554 | |
555 | return fe; |
83680571 |
556 | } |
557 | |
558 | int main(int argc, char **argv) |
559 | { |
2ef96bd6 |
560 | srand(time(NULL)); |
561 | |
83680571 |
562 | gtk_init(&argc, &argv); |
563 | (void) new_window(); |
564 | gtk_main(); |
565 | |
566 | return 0; |
567 | } |