1 /* handle_menu.c */
2 /* COPYRIGHT (C) 2000 THE VICTORIA UNIVERSITY OF MANCHESTER and John Levon
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the Free
5 * Software Foundation; either version 2 of the License, or (at your option)
6 * any later version.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307, USA.
16 */
17 /* various menu functions handled */
18 /*
19 * $Log: handle_menu.c,v $
20 * Revision 1.7 2001/01/31 15:38:06 movement
21 * pre11 - fix netscape, add metapost support, credit foggy
22 *
23 * Revision 1.7 2001/01/29 20:57:28 moz
24 * Make netscape work again, metapost support.
25 *
26 * Revision 1.6 2000/12/17 00:57:42 moz
27 * examples, filled open splines, highlight_objects
28 *
29 * Revision 1.5 2000/12/08 22:33:33 moz
30 * Clean up possibly unsafe tmp file handling.
31 *
32 * Revision 1.4 2000/12/08 02:45:54 moz
33 * Quit even if user saved on the way out.
34 *
35 * Minor webpage fixes
36 *
37 * Revision 1.3 2000/12/06 20:56:02 moz
38 * GPL stuff.
39 *
40 * Revision 1.2 2000/09/05 00:54:50 moz
41 * Make system() calls secure.
42 *
43 * Revision 1.1.1.1 2000/08/21 01:05:31 moz
44 *
45 *
46 * Revision 1.1.1.1 2000/07/19 22:45:31 moz
47 * CVS Import
48 *
49 * Revision 1.26 2000/05/03 21:41:20 moz
50 * Was dropping the percent on title on save ...
51 *
52 * Revision 1.25 2000/03/22 15:37:17 moz
53 * Fix stupid typo.
54 *
55 * Revision 1.24 2000/03/07 21:40:16 moz
56 * Compile fixes.
57 *
58 * Revision 1.23 2000/03/01 18:38:27 moz
59 * If $BROWSER is netscape, still use -remote.
60 *
61 * Revision 1.22 2000/01/30 17:20:39 moz
62 * Set check_dial to 0 to show it's closed.
63 *
64 * Revision 1.21 2000/01/26 18:12:38 moz
65 * Make sure to call stk_clear_textlist
66 * where appropriate.
67 *
68 * Revision 1.20 1999/11/15 02:09:34 moz
69 * Name change.
70 *
71 * Revision 1.19 1999/08/08 20:54:56 moz
72 * From clean up of structs.
73 *
74 * Revision 1.18 1999/06/16 00:56:12 moz
75 * Use netscape -remote when possible.
76 *
77 * Revision 1.17 1999/05/19 17:10:28 moz
78 * 1.0 Checkin.
79 *
80 * Revision 1.16 1999/05/05 12:28:51 moz
81 * Print dialog.
82 *
83 * Revision 1.15 1999/05/04 15:49:17 moz
84 * Moved duplicate_object() and kill_object() to object.c
85 *
86 * Revision 1.14 1999/05/03 06:21:26 moz
87 * fill_in_file takes .fig filter option.
88 *
89 * Revision 1.13 1999/04/29 22:06:24 moz
90 * Removed notify_compound_undo.
91 *
92 * Revision 1.12 1999/04/29 22:01:52 moz
93 * Move move_object to remove duplicate objects on paste_object.
94 *
95 * Revision 1.11 1999/04/28 23:47:29 moz
96 * Place paste with move_object.
97 * Set pasted object's depth to correct value.
98 *
99 * Revision 1.10 1999/04/28 15:11:40 moz
100 * Strip trailing slash from FIGURINEDIR env var.
101 *
102 * Revision 1.9 1999/04/27 07:39:48 moz
103 * When copying compound, link into undo stack.
104 *
105 * Revision 1.8 1999/04/27 06:45:32 moz
106 * load and insert_file need cmdline==FALSE
107 *
108 * Revision 1.7 1999/04/27 04:10:50 moz
109 * -Wall appeased.
110 *
111 * Revision 1.6 1999/04/25 19:44:22 moz
112 * Copy text angle in duplicate_object
113 *
114 * Revision 1.5 1999/04/23 00:39:39 moz
115 * redraw_view_window change.
116 *
117 * Revision 1.4 1999/04/22 22:16:25 moz
118 * Check there's something to paste in paste_object.
119 *
120 * Revision 1.3 1999/04/04 01:49:47 moz
121 * Correct help implementation.
122 * Export dialog functionality.
123 *
124 * Revision 1.2 1999/04/03 21:12:50 moz
125 * start_help function.
126 *
127 * Revision 1.1 1999/03/30 00:05:08 moz
128 * Initial revision
129 *
130 */
131
132 #include "include/figurine.h"
133 #include "include/extern.h"
134
135 Object *buffer=NULL; /* our cut buffer */
136
137 void
cut_object(View * view,Object * ob)138 cut_object(View *view, Object *ob)
139 {
140 register_undo(UNDO_CUT,ob,view->doc);
141 view->doc->o = trash_object(view->doc->o,&view->doc->lo,ob);
142 /* if buffer's full already, delete the buffer */
143 if (buffer!=NULL)
144 kill_object(buffer);
145
146 buffer = ob;
147 }
148
149 void
copy_object(Object * ob)150 copy_object(Object *ob)
151 {
152 /* if buffer's full already, delete the buffer */
153 if (buffer!=NULL)
154 kill_object(buffer);
155
156 buffer = duplicate_object(ob);
157
158 }
159
160 void
paste_object(View * view,long x,long y)161 paste_object(View *view, long x, long y)
162 {
163 Object *ob;
164
165 if (view->highlighted_object!=NULL)
166 send_redraw_object(view,view->highlighted_object->ob);
167
168 if (buffer==NULL)
169 return;
170
171 ob = duplicate_object(buffer);
172
173 ob->depth = view->doc->ob_depth--;
174
175 view->doc->o = add_object(view->doc->o, &view->doc->lo, ob);
176 /* move pasted object to current cursor position */
177 move_object(view,ob,x-ob->bbox.x1,y-ob->bbox.y1);
178
179 view->selected_object = get_object_node(view->doc->o, ob);
180 view->highlighted_object = view->selected_object;
181 send_redraw_object(view,ob);
182 register_undo(UNDO_PASTE,ob,view->doc);
183 }
184
185 /* user asked for Help ^H */
186 void
start_help()187 start_help()
188 {
189 char *e;
190 char *f;
191 char s[FIGURINE_PATH_MAX];
192 char t[FIGURINE_PATH_MAX];
193
194 e = getenv("FIGURINEDIR");
195 f = getenv("BROWSER");
196
197 /* if user has already set netscape, we'd like to
198 still use remote functionality */
199 if (f && streq(f,"netscape"))
200 f=NULL;
201
202 /* strip terminating / if there */
203 if (e && strlen(e) && e[strlen(e)-1]=='/')
204 {
205 strncpy(t,e,FIGURINE_PATH_MAX);
206 t[strlen(t)-1]='\0';
207 e = t;
208 };
209
210 if (e)
211 {
212 /* FIGURINEDIR has been set */
213 if (f)
214 sprintf(s,"%s '%s/index.html' &",f,e);
215 else
216 sprintf(s, "sh -c 'netscape -remote \"openURL(%s/index.html,new-window)\"; if test \"$?\" -ne 0 ; then (netscape \"%s/index.html\" &) ; fi'",e,e);
217 }
218 else
219 {
220 /* use compiled in FIGINTDIR instead */
221 if (f)
222 sprintf(s,"%s '%s/index.html' &",f,FIGINTDIR);
223 else
224 sprintf(s, "sh -c 'netscape -remote \"openURL(%s/index.html,new-window)\"; if test \"$?\" -ne 0 ; then (netscape \"%s/index.html\" &) ; fi'",FIGINTDIR,FIGINTDIR);
225 };
226
227 /* spawn browser */
228 system(s);
229 }
230
231 /* a button has been pressed on a dialog.
232 determine the dialog, the button, and react
233 appropriately */
234 void
handle_dialog(XEvent report,ulong dw)235 handle_dialog(XEvent report, ulong dw)
236 {
237 View *v;
238 char a[FIGURINE_PATH_MAX];
239
240 /******************** file dialog */
241 if (dw==(ulong)file_dialog)
242 {
243 if (report.xclient.window==file_ok)
244 {
245
246 stk_get_text_entry(file_entry, a);
247 if (is_directory(a))
248 {
249 if (streq("../",a))
250 strip_end_dir(state.cwd);
251 else
252 {
253 strcpy(state.cwd, a);
254 };
255 stk_clear_textlist(lfile_text);
256 stk_clear_textlist(rfile_text);
257 stk_unselect_textlist(lfile_text);
258 stk_unselect_textlist(rfile_text);
259
260 chdir(state.cwd);
261 fill_in_file(lfile_text,rfile_text,state.show_fig_files_only);
262 stk_set_text_entry(file_entry, state.cwd);
263 }
264 else
265 {
266 load(a,FALSE);
267 stk_clear_textlist(lfile_text);
268 stk_clear_textlist(rfile_text);
269 stk_close_dialog(file_dialog);
270 };
271 }
272 else if (report.xclient.window==file_cancel)
273 {
274 stk_clear_textlist(lfile_text);
275 stk_clear_textlist(rfile_text);
276 stk_close_dialog(file_dialog);
277 };
278 }
279 /************** savefile dialog */
280 else if (dw==(ulong)savefile_dialog)
281 {
282 if (report.xclient.window==savefile_ok)
283 {
284
285 stk_get_text_entry(savefile_entry, a);
286 if (is_directory(a))
287 {
288 if (streq("../",a))
289 strip_end_dir(state.cwd);
290 else
291 {
292 strcpy(state.cwd, a);
293 };
294 stk_clear_textlist(savelfile_text);
295 stk_clear_textlist(saverfile_text);
296 stk_unselect_textlist(savelfile_text);
297 stk_unselect_textlist(saverfile_text);
298
299 chdir(state.cwd);
300 fill_in_file(savelfile_text,saverfile_text,state.show_fig_files_only);
301 stk_set_text_entry(savefile_entry, state.cwd);
302 }
303 else
304 {
305 char s[FIGURINE_PATH_MAX];
306 char a2[20];
307 int c = strlen(a);
308 v=((View *)report.xclient.data.l[1]);
309
310 save_name(v->doc,a);
311 strcpy(s,a);
312 while (strlen(s) && s[strlen(s)-1]!='/')
313 {
314 s[strlen(s)-1] = '\0';
315 c--;
316 };
317
318 strcpy(v->doc->pathname,s);
319 strcpy(v->doc->filename,a+c);
320 sprintf(a2," (%.1f%%)",v->zoom_factor*100);
321 strcat(a, a2);
322 set_window_name(&v->window,a);
323 stk_clear_textlist(savelfile_text);
324 stk_clear_textlist(saverfile_text);
325 stk_close_dialog(savefile_dialog);
326 };
327 }
328 else if (report.xclient.window==savefile_cancel)
329 {
330 stk_clear_textlist(savelfile_text);
331 stk_clear_textlist(saverfile_text);
332 stk_close_dialog(savefile_dialog);
333 };
334 }
335 /************** insertfile dialog */
336 else if (dw==(ulong)insertfile_dialog)
337 {
338 if (report.xclient.window==insertfile_ok)
339 {
340
341 stk_get_text_entry(insertfile_entry, a);
342 if (is_directory(a))
343 {
344 if (streq("../",a))
345 strip_end_dir(state.cwd);
346 else
347 {
348 strcpy(state.cwd, a);
349 };
350 stk_clear_textlist(insertlfile_text);
351 stk_clear_textlist(insertrfile_text);
352 stk_unselect_textlist(insertlfile_text);
353 stk_unselect_textlist(insertrfile_text);
354
355 chdir(state.cwd);
356 fill_in_file(insertlfile_text,insertrfile_text,state.show_fig_files_only);
357 stk_set_text_entry(insertfile_entry, state.cwd);
358 }
359 else
360 {
361 List l;
362
363 insert_file(((View *)report.xclient.data.l[1])->doc,a,FALSE,FALSE);
364 stk_clear_textlist(insertlfile_text);
365 stk_clear_textlist(insertrfile_text);
366 stk_close_dialog(insertfile_dialog);
367 l = ((View *)report.xclient.data.l[1])->doc->views;
368 while (l!=NULL)
369 {
370 redraw_view_window(VIEW(l));
371 l = l->next;
372 };
373 };
374 }
375 else if (report.xclient.window==insertfile_cancel)
376 {
377 stk_clear_textlist(insertlfile_text);
378 stk_clear_textlist(insertrfile_text);
379 stk_close_dialog(insertfile_dialog);
380 };
381 }
382 /************** exportfile dialog */
383 else if (dw==(ulong)exportfile_dialog)
384 {
385 if (report.xclient.window==exportfile_ok)
386 {
387
388 stk_get_text_entry(exportfile_entry, a);
389 if (is_directory(a))
390 {
391 if (streq("../",a))
392 strip_end_dir(state.cwd);
393 else
394 {
395 strcpy(state.cwd, a);
396 };
397 stk_clear_textlist(exportlfile_text);
398 stk_clear_textlist(exportrfile_text);
399 stk_unselect_textlist(exportlfile_text);
400 stk_unselect_textlist(exportrfile_text);
401
402 chdir(state.cwd);
403 fill_in_file(exportlfile_text,exportrfile_text,FALSE);
404 stk_set_text_entry(exportfile_entry, state.cwd);
405 }
406 else
407 {
408 export_name(((View *)report.xclient.data.l[1])->doc,a,stk_get_textlist_selection_num(exportformat_text));
409 stk_clear_textlist(exportlfile_text);
410 stk_clear_textlist(exportrfile_text);
411 stk_close_dialog(exportfile_dialog);
412 };
413 }
414 else if (report.xclient.window==exportfile_cancel)
415 {
416 stk_clear_textlist(exportlfile_text);
417 stk_clear_textlist(exportrfile_text);
418 stk_close_dialog(exportfile_dialog);
419 };
420 }
421 /******************** view dialog */
422 else if (dw==(ulong)view_dialog)
423 {
424 if (report.xclient.window==view_ok || report.xclient.window==view_apply)
425 {
426 double d,dy;
427
428 v = (View *)report.xclient.data.l[1];
429 stk_get_text_entry(view_gridx_entry, a);
430 sscanf(a,"%lf",&d);
431 stk_get_text_entry(view_gridy_entry, a);
432 sscanf(a,"%lf",&dy);
433 if (stk_get_choice(view_units,1)!=v->in_mm)
434 {
435 v->in_mm = !v->in_mm;
436 REDRAW_ALL_WINDOW(v->ruler_x_window);
437 REDRAW_ALL_WINDOW(v->ruler_y_window);
438 };
439
440 if (stk_get_choice(view_guides,0)!=v->guide_lines)
441 {
442 v->guide_lines = !v->guide_lines;
443 v->guide_lines_displayed = FALSE;
444 redraw_view_window(v);
445 };
446
447 if (stk_get_choice(view_highlight,0)!=v->highlight_objects)
448 {
449 v->highlight_objects = !v->highlight_objects;
450 redraw_view_window(v);
451 };
452
453 if (stk_get_choice(view_compounds,0)!=v->show_compounds)
454 {
455 v->show_compounds = !v->show_compounds;
456 redraw_view_window(v);
457 };
458
459 if (v->grid_x != (long)min(2400,max(10,v->doc->ppi*d)) ||
460 v->grid_y != (long)min(2400,max(10,v->doc->ppi*dy)))
461 {
462 v->grid_x = (long)min(2400,max(10,v->doc->ppi*d));
463 v->grid_y = (long)min(2400,max(10,v->doc->ppi*dy));
464 if (v->showgrid)
465 redraw_view_window(v);
466 };
467 if (report.xclient.window==view_ok)
468 stk_close_dialog(view_dialog);
469 }
470 else if (report.xclient.window==view_cancel)
471 stk_close_dialog(view_dialog);
472 }
473 /************* lw dialog */
474 else if (dw==(ulong)lw_dialog)
475 {
476 if (report.xclient.window==lw_ok || report.xclient.window==lw_apply)
477 {
478 long val;
479
480 v = (View *)report.xclient.data.l[1];
481
482 stk_get_text_entry(lw_entry,a);
483
484 sscanf(a,"%ld",&val);
485
486 if (val<0)
487 val = 0;
488
489 if (val>40)
490 val = 40;
491
492 if (v->selected_object!=NULL)
493 {
494 register_undo(UNDO_OB_PROP,v->selected_object->ob,v->doc);
495 store_redraw_object(v->selected_object->ob);
496 v->selected_object->ob->lw = val;
497 if (v->selected_object->ob->type==TEXT &&
498 v->selected_object->ob->ob.text.node)
499 {
500 v->selected_object->ob->ob.text.ellipse->lw = val;
501 };
502 send_stored_redraw_object(v,v->selected_object->ob);
503 }
504 else
505 {
506 v->linewidth = val;
507 v->farrow.lw = val;
508 v->barrow.lw = val;
509 };
510
511 if (report.xclient.window==lw_apply)
512 {
513 sprintf(a,"%ld",val);
514 stk_set_text_entry(lw_entry,a);
515 }
516 else if (report.xclient.window==lw_ok)
517 stk_close_dialog(lw_dialog);
518 }
519 else
520 stk_close_dialog(lw_dialog);
521 }
522 /************ roundbox dialog */
523 else if (dw==(ulong)roundbox_dialog)
524 {
525 if (report.xclient.window==roundbox_ok || report.xclient.window==roundbox_apply)
526 {
527 long val;
528
529 v = (View *)report.xclient.data.l[1];
530
531 v->roundbox = stk_get_choice(roundbox_choice,0);
532 stk_get_text_entry(roundbox_entry,a);
533
534 sscanf(a,"%ld",&val);
535
536 if (val<1)
537 val = 1;
538
539 if (val>40)
540 val = 40;
541
542 if (v->selected_object!=NULL && v->selected_object->ob->type==ROUNDBOX)
543 {
544 register_undo(UNDO_OB_PROP,v->selected_object->ob,v->doc);
545 store_redraw_object(v->selected_object->ob);
546 v->selected_object->ob->ob.roundbox.radius = val;
547 send_stored_redraw_object(v,v->selected_object->ob);
548 }
549 else
550 v->roundsize = val;
551
552 if (report.xclient.window==roundbox_apply)
553 {
554 sprintf(a,"%ld",val);
555 stk_set_text_entry(roundbox_entry,a);
556 }
557 else if (report.xclient.window==roundbox_ok)
558 stk_close_dialog(roundbox_dialog);
559 }
560 else
561 stk_close_dialog(roundbox_dialog);
562 }
563 /************ polygon dialog */
564 else if (dw==(ulong)polygon_dialog)
565 {
566 if (report.xclient.window==polygon_ok || report.xclient.window==polygon_apply)
567 {
568 long val;
569
570 v = (View *)report.xclient.data.l[1];
571
572 v->regular = stk_get_choice(polygon_choice,0);
573 stk_get_text_entry(polygon_entry,a);
574
575 sscanf(a,"%ld",&val);
576
577 if (val<3)
578 val = 3;
579
580 if (val>128)
581 val = 128;
582
583 v->sides = val;
584 v->side_angle = (PI*2.0)/v->sides;
585
586 if (report.xclient.window==polygon_apply)
587 {
588 sprintf(a,"%ld",val);
589 stk_set_text_entry(polygon_entry,a);
590 }
591 else if (report.xclient.window==polygon_ok)
592 stk_close_dialog(polygon_dialog);
593 }
594 else
595 stk_close_dialog(polygon_dialog);
596 }
597 /************ spline dialog */
598 else if (dw==(ulong)spline_dialog)
599 {
600 if (report.xclient.window==spline_ok || report.xclient.window==spline_apply)
601 {
602 double val;
603
604 v = (View *)report.xclient.data.l[1];
605
606 v->closed = stk_get_choice(spline_choice,0);
607
608 stk_get_text_entry(spline_entry,a);
609
610 sscanf(a,"%lf",&val);
611 v->current_sfactor = max(-1.0,min(1.0,val));
612
613 if (report.xclient.window==spline_apply)
614 {
615 sprintf(a,"%.2f",v->current_sfactor);
616 stk_set_text_entry(spline_entry, a);
617 stk_set_slider_pos(spline_slider,(v->current_sfactor+1.0)/2.0);
618 }
619 else if (report.xclient.window==spline_ok)
620 stk_close_dialog(spline_dialog);
621 }
622 else
623 stk_close_dialog(spline_dialog);
624 }
625 /************ font dialog */
626 else if (dw==(ulong)font_dialog)
627 {
628 int val;
629
630 v = (View *)report.xclient.data.l[1];
631
632 stk_get_text_entry(font_entry,a);
633
634 sscanf(a,"%d",&val);
635 v->fontsize = max(5,min(300,val));
636
637 v->fontnum = stk_get_textlist_selection_num(font_typeface_text);
638
639 stk_close_dialog(font_dialog);
640 }
641 /************* arrow dialog */
642 else if (dw==(ulong)arrow_dialog)
643 {
644 v = (View *)report.xclient.data.l[1];
645
646 if (report.xclient.window==arrow_cancel)
647 {
648 stk_close_dialog(arrow_dialog);
649 return;
650 };
651
652 if (v->selected_object!=NULL)
653 {
654 Arrow ar;
655 Object *ob = v->selected_object->ob;
656
657 register_undo(UNDO_OB_PROP,v->selected_object->ob,v->doc);
658 store_redraw_object(ob);
659
660 if (stk_get_choice(rarrow_choice,0))
661 {
662 ar.filled = stk_get_choice(rarrow_fillchoice,0);
663 stk_get_text_entry(rarrow_thickness,a);
664 sscanf(a,"%ld",&ar.lw);
665 stk_get_text_entry(rarrow_width,a);
666 sscanf(a,"%ld",&ar.w);
667 stk_get_text_entry(rarrow_height,a);
668 sscanf(a,"%ld",&ar.h);
669 if (stk_get_choice(rarrow_type,1))
670 ar.type = ARROWSTICK;
671 else if (stk_get_choice(rarrow_type,2))
672 ar.type = ARROWFLAT;
673 else if (stk_get_choice(rarrow_type,3))
674 ar.type = ARROWINDENTED;
675 else
676 ar.type = ARROWPOINTED;
677
678 if (ob->farrow!=NULL)
679 free(ob->farrow);
680 ob->farrow = make_arrow(ar);
681 }
682 else
683 {
684 if (ob->farrow!=NULL)
685 free (ob->farrow);
686 };
687 if (stk_get_choice(larrow_choice,0))
688 {
689 ar.filled = stk_get_choice(larrow_fillchoice,0);
690 stk_get_text_entry(larrow_thickness,a);
691 sscanf(a,"%ld",&ar.lw);
692 stk_get_text_entry(larrow_width,a);
693 sscanf(a,"%ld",&ar.w);
694 stk_get_text_entry(larrow_height,a);
695 sscanf(a,"%ld",&ar.h);
696 if (stk_get_choice(larrow_type,1))
697 ar.type = ARROWSTICK;
698 else if (stk_get_choice(larrow_type,2))
699 ar.type = ARROWFLAT;
700 else if (stk_get_choice(larrow_type,3))
701 ar.type = ARROWINDENTED;
702 else
703 ar.type = ARROWPOINTED;
704
705 if (ob->barrow!=NULL)
706 free(ob->barrow);
707 ob->barrow = make_arrow(ar);
708 }
709 else
710 {
711 if (ob->barrow!=NULL)
712 free (ob->barrow);
713 };
714 send_stored_redraw_object(v,ob);
715 }
716 else
717 {
718 v->farrow_on = stk_get_choice(rarrow_choice,0);
719 v->barrow_on = stk_get_choice(larrow_choice,0);
720 v->farrow.filled = stk_get_choice(rarrow_fillchoice,0);
721 v->barrow.filled = stk_get_choice(larrow_fillchoice,0);
722 stk_get_text_entry(rarrow_thickness,a);
723 sscanf(a,"%ld",&v->farrow.lw);
724 stk_get_text_entry(larrow_thickness,a);
725 sscanf(a,"%ld",&v->barrow.lw);
726 stk_get_text_entry(rarrow_width,a);
727 sscanf(a,"%ld",&v->farrow.w);
728 stk_get_text_entry(larrow_width,a);
729 sscanf(a,"%ld",&v->barrow.w);
730 stk_get_text_entry(rarrow_height,a);
731 sscanf(a,"%ld",&v->farrow.h);
732 stk_get_text_entry(larrow_height,a);
733 sscanf(a,"%ld",&v->barrow.h);
734 if (stk_get_choice(rarrow_type,1))
735 v->farrow.type = ARROWSTICK;
736 else if (stk_get_choice(rarrow_type,2))
737 v->farrow.type = ARROWFLAT;
738 else if (stk_get_choice(rarrow_type,3))
739 v->farrow.type = ARROWINDENTED;
740 else
741 v->farrow.type = ARROWPOINTED;
742
743 if (stk_get_choice(larrow_type,1))
744 v->barrow.type = ARROWSTICK;
745 else if (stk_get_choice(larrow_type,2))
746 v->barrow.type = ARROWFLAT;
747 else if (stk_get_choice(larrow_type,3))
748 v->barrow.type = ARROWINDENTED;
749 else
750 v->barrow.type = ARROWPOINTED;
751 };
752 if (report.xclient.window==arrow_ok)
753 stk_close_dialog(arrow_dialog);
754 }
755 /* ******* print file dialog */
756 else if (dw==(ulong)printfile_dialog)
757 {
758 v=((View *)report.xclient.data.l[1]);
759 stk_get_text_entry(printfile_entry,a);
760 strncpy(state.print,a,100);
761 if (report.xclient.window==printfile_cancel)
762 stk_close_dialog(dw);
763 else
764 {
765 char b[FIGURINE_PATH_MAX];
766 char *name;
767 v->doc->centred = stk_get_choice(printfile_choice,1);
768 stk_close_dialog(dw);
769 name = export_name(v->doc,NULL,EXPORT_PS);
770 if (name!=NULL)
771 {
772 sprintf(b,"sh -c \"'%s' '%s'\"",state.print,name);
773 if (system(b)!=0)
774 {
775 strcpy(a,"Could not print using command ");
776 strcat(a,b);
777 strcat(a,"\n");
778 stk_open_info(a);
779 };
780 free(name);
781 };
782 };
783 }
784 /********* save check message */
785 else
786 {
787 List l = docs;
788
789 while (l!=NULL)
790 {
791 if (report.xclient.window==DOC(l)->check_save)
792 {
793 DOC(l)->check_dial=0;
794 save(DOC(l));
795 really_close_doc(DOC(l));
796 stk_close_dialog(dw);
797 if (quitting)
798 close_down();
799 break;
800 }
801 else if (report.xclient.window==DOC(l)->check_close)
802 {
803 DOC(l)->check_dial=0;
804 really_close_doc(DOC(l));
805 stk_close_dialog(dw);
806 if (quitting)
807 close_down();
808 break;
809 }
810 else if (report.xclient.window==DOC(l)->check_cancel)
811 {
812 if (quitting)
813 quitting=FALSE;
814 DOC(l)->check_dial=0;
815 stk_close_dialog(dw);
816 break;
817 };
818
819 l = l->next;
820 };
821
822 if (l==NULL)
823 stk_close_dialog(dw);
824 };
825 }
826