1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 /*----------------------------------------------------------------------
5 gpiv - Graphic program for Particle Image Velocimetry, based on gtk/gnome
8 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
11 This file is part of gpiv.
13 Gpiv is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2, or (at your option)
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ----------------------------------------------------------------------*/
31 * Revision 1.9 2008-04-28 12:00:58 gerber
32 * hdf-formatted files are now with .hdf extension (previously: .gpi)
34 * Revision 1.8 2007-11-23 16:24:08 gerber
35 * release 0.5.0: Kafka
37 * Revision 1.7 2007-06-06 17:00:48 gerber
38 * Retreives images/data from URI using Gnome Virtual File System.
40 * Revision 1.6 2007-01-29 11:27:44 gerber
41 * added image formats png, gif, tif png, bmp, improved buffer display
43 * Revision 1.5 2006/01/31 14:28:13 gerber
46 * Revision 1.4 2005/06/15 09:40:40 gerber
49 * Revision 1.3 2004/10/15 19:24:05 gerber
50 * GPIV_ and Gpiv prefix to defines and structure names of libgpiv
52 * Revision 1.2 2004/06/14 21:19:23 gerber
53 * Image depth up to 16 bits.
54 * Improvement "single int" and "drag int" in Eval tab.
55 * Viewer's pop-up menu.
56 * Adaption for gpiv_matrix_* and gpiv_vector_*.
58 * See Changelog for further info.
60 * Revision 1.1 2003/09/04 13:31:55 gerber
61 * init of printing (unfinished)
73 /* #include "console_menus.h" */
74 /* #include "display.h" */
78 create_print_dialog (GpivConsole
*gpiv
80 /*-----------------------------------------------------------------------------
81 ttp://developer.gnome.org/doc/API/2.0/gtk/GtkDialog.html#GtkDialogFlags
84 PrintDialog
* pri
= g_new0(PrintDialog
, 1);
85 /* g_snprintf(pri->var.label_printer_state, GPIV_MAX_CHARS, "Printer is ready to print"); */
86 /* g_snprintf(pri->var.label_printer_state, GPIV_MAX_CHARS, "Printer is offline"); */
87 g_snprintf(pri
->var
.label_printer_state
,
89 "Printer state is unknown");
90 pri
->var
.print_to_printer
= FALSE
;
91 pri
->var
.select_range
= TRUE
;
95 * Main window of print dialog
97 if (gpiv_par
->verbose
) g_warning("create_print_dialog:: 1");
104 pri
->dialog
= GTK_DIALOG( gtk_dialog_new_with_buttons
106 /* GNOME_APP ( */ /* gpiv->console */ NULL
,
107 GTK_DIALOG_DESTROY_WITH_PARENT
,
108 GTK_STOCK_CANCEL
, GTK_RESPONSE_CANCEL
,
109 GTK_STOCK_PRINT_PREVIEW
, GTK_RESPONSE_APPLY
,
110 GTK_STOCK_PRINT
, GTK_RESPONSE_ACCEPT
,
113 gtk_dialog_set_default_response (pri
->dialog
,
114 GTK_RESPONSE_REJECT
);
115 g_signal_connect_swapped (pri
->dialog
,
117 G_CALLBACK (gtk_widget_destroy
),
119 g_signal_connect (pri
->dialog
,
121 G_CALLBACK (on_print_response
),
124 gtk_object_set_data (GTK_OBJECT (pri
->dialog
),
130 gtk_window_set_policy (GTK_WINDOW (pri
->dialog
),
134 if (gpiv_par
->verbose
) g_warning("create_print_dialog:: 1.3");
135 gtk_window_set_wmclass (GTK_WINDOW (pri
->dialog
),
139 if (gpiv_par
->verbose
) g_warning("create_print_dialog:: 1.4");
146 /* pri->vbox_dialog = GTK_DIALOG (pri->dialog)->vbox; */
147 /* gtk_object_set_data (GTK_OBJECT (pri->dialog), */
149 /* pri->vbox_dialog); */
150 /* gtk_widget_show (pri->vbox_dialog); */
154 pri
->frame_print
= gtk_frame_new (_("Select printer"));
155 gtk_widget_ref (pri
->frame_print
);
156 gtk_object_set_data_full (GTK_OBJECT (pri
->dialog
),
159 (GtkDestroyNotify
) gtk_widget_unref
);
160 gtk_widget_show (pri
->frame_print
);
161 gtk_container_add (GTK_CONTAINER (GTK_DIALOG(pri
->dialog
)->vbox
),
164 /* gtk_box_pack_start( GTK_BOX (pri->vbox_dialog), */
165 /* pri->frame_print, */
173 pri
->table_print
= gtk_table_new (2,
176 gtk_widget_ref (pri
->table_print
);
177 gtk_object_set_data_full (GTK_OBJECT (pri
->dialog
),
180 (GtkDestroyNotify
) gtk_widget_unref
);
181 gtk_widget_show (pri
->table_print
);
182 gtk_container_add (GTK_CONTAINER (pri
->frame_print
),
187 pri
->radiobutton_printer
=
188 gtk_radio_button_new_with_label(pri
->printer_group
,
191 gtk_radio_button_group(GTK_RADIO_BUTTON
192 (pri
->radiobutton_printer
));
193 gtk_widget_ref(pri
->radiobutton_printer
);
194 gtk_object_set_data_full(GTK_OBJECT(pri
->dialog
),
195 "radiobutton_printer",
196 pri
->radiobutton_printer
,
197 (GtkDestroyNotify
) gtk_widget_unref
);
198 gtk_widget_show(pri
->radiobutton_printer
);
199 gtk_table_attach (GTK_TABLE (pri
->table_print
),
200 pri
->radiobutton_printer
,
205 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
206 (GtkAttachOptions
) (GTK_FILL
),
210 gtk_object_set_data(GTK_OBJECT(pri
->radiobutton_printer
),
217 pri
->entry_printer
= gtk_entry_new();
218 gtk_widget_ref(pri
->entry_printer
);
219 gtk_object_set_data_full(GTK_OBJECT(pri
->dialog
),
222 (GtkDestroyNotify
) gtk_widget_unref
);
223 gtk_widget_show(pri
->entry_printer
);
224 gtk_table_attach(GTK_TABLE(pri
->table_print
),
230 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
231 (GtkAttachOptions
) (0),
234 gtk_entry_set_text(GTK_ENTRY (pri
->entry_printer
), DEFAULT_PRINT_CMD
);
235 gtk_object_set_data(GTK_OBJECT(pri
->entry_printer
),
243 pri
->radiobutton_file
=
244 gtk_radio_button_new_with_label(pri
->printer_group
,
247 gtk_radio_button_group(GTK_RADIO_BUTTON
248 (pri
->radiobutton_file
));
249 gtk_widget_ref(pri
->radiobutton_file
);
250 gtk_object_set_data_full(GTK_OBJECT(pri
->dialog
),
252 pri
->radiobutton_file
,
253 (GtkDestroyNotify
) gtk_widget_unref
);
254 gtk_widget_show(pri
->radiobutton_file
);
255 gtk_table_attach (GTK_TABLE (pri
->table_print
),
256 pri
->radiobutton_file
,
261 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
262 (GtkAttachOptions
) (GTK_FILL
),
266 gtk_object_set_data(GTK_OBJECT(pri
->radiobutton_file
),
273 pri
->entry_file
= gtk_entry_new();
274 gtk_widget_ref(pri
->entry_file
);
275 gtk_object_set_data_full(GTK_OBJECT(pri
->dialog
),
278 (GtkDestroyNotify
) gtk_widget_unref
);
279 gtk_widget_show(pri
->entry_file
);
280 gtk_table_attach(GTK_TABLE(pri
->table_print
),
286 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
287 (GtkAttachOptions
) (0),
290 gtk_entry_set_text(GTK_ENTRY (pri
->entry_file
), DEFAULT_FNAME_PRINT
);
291 /* gtk_object_set_data(GTK_OBJECT(pri->entry_file), */
299 pri
->button_browse
= gtk_button_new_with_label(_("Browse"));
300 gtk_widget_ref(pri
->button_browse
);
301 gtk_object_set_data_full(GTK_OBJECT(pri
->dialog
),
304 (GtkDestroyNotify
) gtk_widget_unref
);
305 gtk_widget_show(pri
->button_browse
);
306 gtk_table_attach(GTK_TABLE(pri
->table_print
),
312 (GtkAttachOptions
) (GTK_FILL
),
313 (GtkAttachOptions
) (GTK_FILL
),
316 gtk_tooltips_set_tip(gpiv
->tooltips
,
318 _("Launches a file selector to browse a file"),
320 gtk_object_set_data(GTK_OBJECT(pri
->button_browse
),
326 pri
->label_label_printerstate
= gtk_label_new(_("State: "));
327 gtk_widget_ref(pri
->label_label_printerstate
);
328 gtk_object_set_data_full(GTK_OBJECT(pri
->dialog
),
329 "label_label_printerstate",
330 pri
->label_label_printerstate
,
331 (GtkDestroyNotify
) gtk_widget_unref
);
332 gtk_widget_show(pri
->label_label_printerstate
);
333 gtk_table_attach(GTK_TABLE(pri
->table_print
),
334 pri
->label_label_printerstate
,
339 (GtkAttachOptions
) (GTK_FILL
),
340 (GtkAttachOptions
) (GTK_FILL
),
346 pri
->label_printerstate
= gtk_label_new(pri
->var
.label_printer_state
);
347 gtk_widget_ref(pri
->label_printerstate
);
348 gtk_object_set_data_full(GTK_OBJECT(pri
->dialog
),
349 "label_printerstate",
350 pri
->label_printerstate
,
351 (GtkDestroyNotify
) gtk_widget_unref
);
352 gtk_widget_show(pri
->label_printerstate
);
353 gtk_table_attach(GTK_TABLE(pri
->table_print
),
354 pri
->label_printerstate
,
359 (GtkAttachOptions
) (GTK_FILL
),
360 (GtkAttachOptions
) (GTK_FILL
),
369 pri
->frame_range
= gtk_frame_new (_("Print range"));
370 gtk_widget_ref (pri
->frame_range
);
371 gtk_object_set_data_full (GTK_OBJECT (pri
->dialog
),
374 (GtkDestroyNotify
) gtk_widget_unref
);
375 gtk_widget_show (pri
->frame_range
);
376 gtk_container_add (GTK_CONTAINER (GTK_DIALOG(pri
->dialog
)->vbox
),
379 /* gtk_box_pack_start( GTK_BOX (pri->vbox_dialog), */
380 /* pri->frame_range, */
388 pri
->table_range
= gtk_table_new (2,
391 gtk_widget_ref (pri
->table_range
);
392 gtk_object_set_data_full (GTK_OBJECT (pri
->dialog
),
395 (GtkDestroyNotify
) gtk_widget_unref
);
396 gtk_widget_show (pri
->table_range
);
397 gtk_container_add (GTK_CONTAINER (pri
->frame_range
),
403 pri
->radiobutton_all
=
404 gtk_radio_button_new_with_label(pri
->range_group
,
407 gtk_radio_button_group(GTK_RADIO_BUTTON
408 (pri
->radiobutton_all
));
409 gtk_widget_ref(pri
->radiobutton_all
);
410 gtk_object_set_data_full(GTK_OBJECT(pri
->dialog
),
412 pri
->radiobutton_all
,
413 (GtkDestroyNotify
) gtk_widget_unref
);
414 gtk_widget_show(pri
->radiobutton_all
);
415 gtk_table_attach (GTK_TABLE (pri
->table_range
),
416 pri
->radiobutton_all
,
421 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
422 (GtkAttachOptions
) (GTK_FILL
),
425 gtk_object_set_data(GTK_OBJECT(pri
->radiobutton_all
),
432 pri
->radiobutton_range
=
433 gtk_radio_button_new_with_label(pri
->range_group
,
436 gtk_radio_button_group(GTK_RADIO_BUTTON
437 (pri
->radiobutton_range
));
438 gtk_widget_ref(pri
->radiobutton_range
);
439 gtk_object_set_data_full(GTK_OBJECT(pri
->dialog
),
441 pri
->radiobutton_range
,
442 (GtkDestroyNotify
) gtk_widget_unref
);
443 gtk_widget_show(pri
->radiobutton_range
);
444 gtk_table_attach (GTK_TABLE (pri
->table_range
),
445 pri
->radiobutton_range
,
450 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
451 (GtkAttachOptions
) (GTK_FILL
),
454 gtk_object_set_data(GTK_OBJECT(pri
->radiobutton_range
),
461 pri
->label_range_from
= gtk_label_new(_("From: "));
462 gtk_widget_ref(pri
->label_range_from
);
463 gtk_object_set_data_full(GTK_OBJECT(pri
->dialog
),
465 pri
->label_range_from
,
466 (GtkDestroyNotify
) gtk_widget_unref
);
467 gtk_widget_show(pri
->label_range_from
);
468 gtk_table_attach(GTK_TABLE(pri
->table_range
),
469 pri
->label_range_from
,
474 (GtkAttachOptions
) (GTK_FILL
),
475 (GtkAttachOptions
) (GTK_FILL
),
481 pri
->spinbutton_adj_range_start
=
482 gtk_adjustment_new(gpiv
->first_selected_row
,
489 pri
->spinbutton_range_start
=
490 gtk_spin_button_new(GTK_ADJUSTMENT(pri
->spinbutton_adj_range_start
),
491 gpiv
->first_selected_row
,
493 gtk_widget_ref(pri
->spinbutton_range_start
);
494 gtk_widget_show(pri
->spinbutton_range_start
);
495 gtk_table_attach (GTK_TABLE (pri
->table_range
),
496 pri
->spinbutton_range_start
,
501 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
502 (GtkAttachOptions
) (GTK_FILL
),
505 gtk_entry_set_editable(GTK_ENTRY(pri
->spinbutton_range_start
),
507 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(pri
->spinbutton_range_start
),
509 gtk_object_set_data(GTK_OBJECT(pri
->spinbutton_range_start
),
515 pri
->label_range_end
= gtk_label_new(_("To: "));
516 gtk_widget_ref(pri
->label_range_end
);
517 gtk_object_set_data_full(GTK_OBJECT(pri
->dialog
),
519 pri
->label_range_end
,
520 (GtkDestroyNotify
) gtk_widget_unref
);
521 gtk_widget_show(pri
->label_range_end
);
522 gtk_table_attach(GTK_TABLE(pri
->table_range
),
523 pri
->label_range_end
,
528 (GtkAttachOptions
) (GTK_FILL
),
529 (GtkAttachOptions
) (GTK_FILL
),
535 pri
->spinbutton_adj_range_end
=
536 gtk_adjustment_new(gpiv
->last_selected_row
,
543 pri
->spinbutton_range_end
=
544 gtk_spin_button_new(GTK_ADJUSTMENT(pri
->spinbutton_adj_range_end
),
545 gpiv
->last_selected_row
,
547 gtk_widget_ref(pri
->spinbutton_range_end
);
548 gtk_widget_show(pri
->spinbutton_range_end
);
549 gtk_table_attach (GTK_TABLE (pri
->table_range
),
550 pri
->spinbutton_range_end
,
555 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
556 (GtkAttachOptions
) (GTK_FILL
),
559 gtk_entry_set_editable(GTK_ENTRY(pri
->spinbutton_range_end
),
561 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(pri
->spinbutton_range_end
),
563 gtk_object_set_data(GTK_OBJECT(pri
->spinbutton_range_end
),
570 * Dialog area with "Print", "Preview" and "Cancel" buttons
573 /* pri->dialog_action_area = GTK_DIALOG (pri->dialog)->action_area; */
574 /* gtk_object_set_data (GTK_OBJECT (pri->dialog), */
575 /* "dialog_action_area", */
576 /* pri->dialog_action_area); */
577 /* gtk_widget_show (pri->dialog_action_area); */
578 /* gtk_button_box_set_layout (GTK_BUTTON_BOX (pri->dialog_action_area), */
579 /* GTK_BUTTONBOX_END); */
580 /* gtk_button_box_set_spacing (GTK_BUTTON_BOX (pri->dialog_action_area), */
585 /* gnome_dialog_append_button (GNOME_DIALOG (pri->dialog), */
587 /* pri->button_print = */
588 /* GTK_WIDGET (g_list_last (GNOME_DIALOG (pri->dialog)->buttons)->data); */
591 /* pri->button_print = */
592 /* (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-print"); */
593 /* gtk_box_pack_start (GTK_BOX (GTK_DIALOG (pri)->action_area), */
594 /* pri->button_print, TRUE, TRUE, 0); */
596 /* gtk_widget_ref (pri->button_print); */
597 /* gtk_object_set_data_full (GTK_OBJECT (pri->dialog), */
598 /* "button_print", */
599 /* pri->button_print, */
600 /* (GtkDestroyNotify) gtk_widget_unref); */
601 /* gtk_widget_show (pri->button_print); */
602 /* GTK_WIDGET_SET_FLAGS (pri->button_print, */
603 /* GTK_CAN_DEFAULT); */
604 /* gtk_tooltips_set_tip(gpiv->tooltips, pri->button_print, */
605 /* _("Prints the content of the actual buffer display"), */
608 /* gtk_object_set_data(GTK_OBJECT(pri->button_print), */
611 /* g_signal_connect (GTK_OBJECT (pri->button_print), "clicked", */
612 /* G_CALLBACK (on_button_print), */
614 /* gtk_widget_set_sensitive(pri->button_print, FALSE); */
619 /* pri->button_preview = */
620 /* (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-print_preview"); */
621 /* gtk_box_pack_start (GTK_BOX (GTK_DIALOG (pri)->action_area), */
622 /* pri->button_preview, TRUE, TRUE, 0); */
623 /* gtk_widget_ref (pri->button_preview); */
624 /* gtk_object_set_data_full (GTK_OBJECT (pri->dialog), */
625 /* "button_preview", */
626 /* pri->button_preview, */
627 /* (GtkDestroyNotify) gtk_widget_unref); */
628 /* gtk_widget_show (pri->button_preview); */
629 /* GTK_WIDGET_SET_FLAGS (pri->button_preview, GTK_CAN_DEFAULT); */
630 /* gtk_tooltips_set_tip(gpiv->tooltips, pri->button_preview, */
631 /* _("Shows a preview of the output to be printed"), */
634 /* gtk_object_set_data(GTK_OBJECT(pri->button_preview), */
637 /* g_signal_connect (GTK_OBJECT (pri->button_preview), "clicked", */
638 /* G_CALLBACK (on_button_preview), */
640 /* gtk_widget_set_sensitive(pri->button_preview, FALSE); */
644 /* gnome_dialog_append_button (GNOME_DIALOG (pri->dialog), */
645 /* GTK_STOCK_CANCEL); */
646 /* pri->button_print_cancel = */
647 /* GTK_WIDGET (g_list_last (GNOME_DIALOG (pri->dialog)->buttons)->data); */
649 /* pri->button_print_cancel = */
650 /* (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-cancel"); */
651 /* gtk_box_pack_start (GTK_BOX (GTK_DIALOG (pri)->action_area), */
652 /* pri->button_print_cancel, TRUE, TRUE, 0); */
653 /* gtk_widget_ref (pri->button_print_cancel); */
654 /* gtk_object_set_data_full (GTK_OBJECT (pri->dialog), */
655 /* "button_print_cancel", */
656 /* pri->button_print_cancel, */
657 /* (GtkDestroyNotify) gtk_widget_unref); */
658 /* gtk_widget_show (pri->button_print_cancel); */
659 /* GTK_WIDGET_SET_FLAGS (pri->button_print_cancel, */
660 /* GTK_CAN_DEFAULT); */
661 /* gtk_tooltips_set_tip(gpiv->tooltips, */
662 /* pri->button_print_cancel, */
663 /* _("Close pri->dialog window"), */
666 /* gtk_object_set_data(GTK_OBJECT(pri->button_print_cancel), */
669 /* g_signal_connect (GTK_OBJECT (pri->button_print_cancel), */
671 /* G_CALLBACK (on_button_print_cancel), */
678 * Connecting to callback functions
682 g_signal_connect (GTK_OBJECT(pri
->radiobutton_printer
),
684 G_CALLBACK(on_radiobutton_printer
),
687 g_signal_connect(GTK_OBJECT(pri
->entry_printer
),
689 G_CALLBACK(on_entry_printer
),
692 g_signal_connect (GTK_OBJECT(pri
->radiobutton_file
),
694 G_CALLBACK(on_radiobutton_file
),
697 g_signal_connect(GTK_OBJECT(pri
->entry_file
),
699 G_CALLBACK(on_entry_file
),
702 g_signal_connect(GTK_OBJECT(pri
->button_browse
),
704 G_CALLBACK(on_button_browse
),
707 g_signal_connect (GTK_OBJECT(pri
->radiobutton_all
),
709 G_CALLBACK(on_radiobutton_all
),
712 g_signal_connect (GTK_OBJECT(pri
->radiobutton_range
),
714 G_CALLBACK(on_radiobutton_range
),
717 g_signal_connect(GTK_OBJECT(pri
->spinbutton_range_start
),
719 G_CALLBACK(on_spinbutton_range_start
),
720 pri
->spinbutton_range_start
);
722 g_signal_connect(GTK_OBJECT(pri
->spinbutton_range_end
),
724 G_CALLBACK(on_spinbutton_range_end
),
725 pri
->spinbutton_range_end
);
730 * Initialize settings
732 if (pri
->var
.print_to_printer
) {
733 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
734 (pri
->radiobutton_printer
),
737 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
738 (pri
->radiobutton_file
),
743 if (pri
->var
.select_range
) {
744 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
745 (pri
->radiobutton_range
),
748 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
749 (pri
->radiobutton_range
),
751 /* gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON */
752 /* (pri->radiobutton_all), */
764 file_ok_sel(GtkWidget
* widget
,
765 GtkFileSelection
* fs
767 /* ----------------------------------------------------------------------------
768 * Print file selection
771 PrintDialog
*pri
= gtk_object_get_data(GTK_OBJECT(widget
), "pri");
773 pri
->var
.fname_print
=
774 g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs
)));
775 gtk_entry_set_text(GTK_ENTRY (pri
->entry_file
), pri
->var
.fname_print
);
781 print(PrintDialog
*pri
783 /*-----------------------------------------------------------------------------
784 * prints and closes print dialog
787 g_warning(_("Button \"Print\" pressed"));
788 g_free(pri
->var
.print_cmd
);
789 g_free(pri
->var
.fname_print
);
790 /* gnome_dialog_close(GNOME_DIALOG(gpiv_print_dialog)); */
794 /* gtk_widget_destroy(GTK_DIALOG(pri->dialog)); */
799 #ifdef HAVE_GNOME_PRINT
801 print_on_context(/* gpaint_image * image, */
802 /* const gchar * name, */
803 GnomePrintContext
* pc
805 /* ----------------------------------------------------------------------------
808 double matrix
[6] = { 1, 0, 0, 1, 0, 0 };
809 gnome_print_beginpage(pc
, display_act
->file_uri_name
);
811 gnome_print_concat(pc
, matrix
);
812 gnome_print_translate(pc
, 0, 0);
813 gnome_print_scale(pc
, display_act
->img
->image
->header
->ncolumns
,
814 display_act
->img
->image
->header
->nrows
);
816 gnome_print_rgbaimage(pc
,
817 gdk_pixbuf_get_pixels(display_act
->img
->pixbuf1
),
818 display_act
->img
->image
->header
->ncolumns
,
819 display_act
->img
->image
->header
->nrows
,
820 display_act
->img
->rgb_img_width
);
822 gnome_print_showpage(pc
);
831 /* ----------------------------------------------------------------------------
832 * preview print from gpaint: do_print_preview
835 GtkWidget
*toplevel
, *canvas
, *sw
;
836 GnomePrintContext
*pc
= 0;
837 GnomePrintConfig
*cfg
= NULL
;
838 GnomePrintJob
*job
= NULL
;
839 GnomePrintJobPreview
*pmp
= NULL
;
840 GnomePrintContext
*ctx
= NULL
;
842 cfg
= gnome_print_config_default();
843 job
= gnome_print_job_new(cfg
);
846 /* transfer dialog data to output context */
848 ctx
= gnome_print_job_get_context(job
);
849 print_on_context(/* image, name, */ctx
);
850 gnome_print_job_close(job
);
852 pmp
= GNOME_PRINT_JOB_PREVIEW
853 (gnome_print_job_preview_new(job
,
855 g_signal_connect((gpointer
)pmp
,
857 G_CALLBACK(gtk_widget_destroy
),
859 gtk_window_set_modal(GTK_WINDOW(pmp
),
861 gtk_widget_show(GTK_WIDGET(pmp
));
872 /* ----------------------------------------------------------------------------
873 * preview print from gpaint: do_print_preview
876 g_warning(_("Button \"Preview\" pressed"));
884 cancel(PrintDialog
*pri
885 /* GtkDialog *dialog */
886 /* GtkWidget *widget, */
889 /* ----------------------------------------------------------------------------
890 * closes print dialog
893 g_warning(_("Button \"Cancel\" pressed"));
894 g_free(pri
->var
.print_cmd
);
895 g_free(pri
->var
.fname_print
);
896 /* gnome_dialog_close(GNOME_DIALOG(gpiv_print_dialog)); */
900 gtk_widget_destroy(GTK_WIDGET(pri
->dialog
));
909 dialog_action(GtkDialog
*dialog
,
912 /*-----------------------------------------------------------------------------
915 PrintDialog
*pri
= gtk_object_get_data(GTK_OBJECT(dialog
), "pri");
917 g_assert(response
== GTK_RESPONSE_ACCEPT
918 || response
== GTK_RESPONSE_APPLY
919 || response
== GTK_RESPONSE_CANCEL
);
921 gint result
= gtk_dialog_run (GTK_DIALOG (dialog
));
924 case GTK_RESPONSE_ACCEPT
:
927 case GTK_RESPONSE_APPLY
:
930 case GTK_RESPONSE_CANCEL
:
931 /* do_nothing_since_dialog_was_cancelled (); */
935 g_warning("dialog_action: should not arrive here");
938 /* gtk_widget_destroy (dialog); */
944 on_radiobutton_printer(GtkWidget
*widget
,
947 /*-----------------------------------------------------------------------------
950 PrintDialog
*pri
= gtk_object_get_data(GTK_OBJECT(widget
), "pri");
952 if (GTK_TOGGLE_BUTTON(widget
)->active
) {
953 pri
->var
.print_to_printer
= TRUE
;
954 gtk_widget_set_sensitive(pri
->entry_printer
, TRUE
);
956 pri
->var
.print_to_printer
= FALSE
;
957 gtk_widget_set_sensitive(pri
->entry_printer
, FALSE
);
964 on_entry_printer(GtkSpinButton
*widget
,
967 /*-----------------------------------------------------------------------------
970 PrintDialog
*pri
= gtk_object_get_data(GTK_OBJECT(widget
), "pri");
972 /* snprintf(printer_name, GPIV_MAX_CHARS,"%s", */
973 /* gtk_entry_get_text(GTK_ENTRY(entry))); */
975 g_strdup(gtk_entry_get_text(GTK_ENTRY (pri
->entry_file
)));
976 g_warning("print_cmd = %s", pri
->var
.print_cmd
);
982 on_radiobutton_file(GtkWidget
*widget
,
985 /*-----------------------------------------------------------------------------
988 PrintDialog
*pri
= gtk_object_get_data(GTK_OBJECT(widget
), "pri");
990 if (GTK_TOGGLE_BUTTON(widget
)->active
) {
991 gtk_widget_set_sensitive(pri
->entry_file
, TRUE
);
992 gtk_widget_set_sensitive(pri
->button_browse
, TRUE
);
994 gtk_widget_set_sensitive(pri
->entry_file
, FALSE
);
995 gtk_widget_set_sensitive(pri
->button_browse
, FALSE
);
996 pri
->var
.print_to_printer
= TRUE
;
1003 on_entry_file(GtkSpinButton
*widget
,
1006 /*-----------------------------------------------------------------------------
1009 /* snprintf(file_name, GPIV_MAX_CHARS,"%s", */
1010 /* gtk_entry_get_text(GTK_ENTRY(entry))); */
1017 on_button_browse(GtkWidget
*widget
,
1020 /*-----------------------------------------------------------------------------
1023 PrintDialog
*pri
= gtk_object_get_data(GTK_OBJECT(widget
), "pri");
1024 GtkWidget
*filew
= NULL
;
1026 filew
= gtk_file_selection_new("gpiv: print file");
1027 g_signal_connect(GTK_OBJECT(filew
), "destroy",
1028 G_CALLBACK( destroy
), &filew
);
1029 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew
)->ok_button
),
1030 "clicked", G_CALLBACK( file_ok_sel
),
1032 g_signal_connect_swapped(GTK_OBJECT(GTK_FILE_SELECTION(filew
)->ok_button
),
1034 G_CALLBACK( gtk_widget_destroy
),
1036 gtk_object_set_data(GTK_OBJECT(GTK_FILE_SELECTION(filew
)->ok_button
),
1039 g_signal_connect_swapped(GTK_OBJECT
1040 (GTK_FILE_SELECTION(filew
)->cancel_button
),
1042 G_CALLBACK( gtk_widget_destroy
),
1044 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew
),
1045 gpiv_var
->fname_last_print
);
1046 gtk_widget_show(filew
);
1047 gtk_object_set_data(GTK_OBJECT(GTK_FILE_SELECTION(filew
)),
1056 on_radiobutton_all(GtkWidget
*widget
,
1059 /*-----------------------------------------------------------------------------
1062 PrintDialog
*pri
= gtk_object_get_data(GTK_OBJECT(widget
), "pri");
1064 if (GTK_TOGGLE_BUTTON(widget
)->active
) {
1065 pri
->var
.select_range
= FALSE
;
1072 on_radiobutton_range(GtkWidget
*widget
,
1075 /*-----------------------------------------------------------------------------
1078 PrintDialog
*pri
= gtk_object_get_data(GTK_OBJECT(widget
), "pri");
1080 if (GTK_TOGGLE_BUTTON(widget
)->active
) {
1081 pri
->var
.select_range
= TRUE
;
1082 gtk_widget_set_sensitive(pri
->spinbutton_range_start
, TRUE
);
1083 gtk_widget_set_sensitive(pri
->spinbutton_range_end
, TRUE
);
1085 gtk_widget_set_sensitive(pri
->spinbutton_range_start
, FALSE
);
1086 gtk_widget_set_sensitive(pri
->spinbutton_range_end
, FALSE
);
1087 pri
->var
.select_range
= FALSE
;
1094 on_spinbutton_range_start(GtkSpinButton
* widget
,
1097 /*-----------------------------------------------------------------------------
1100 PrintDialog
*pri
= gtk_object_get_data(GTK_OBJECT(widget
), "pri");
1102 pri
->var
.print_start
= gtk_spin_button_get_value_as_int(widget
);
1103 GTK_ADJUSTMENT(pri
->spinbutton_adj_range_end
)->lower
=
1104 (gint
) pri
->var
.print_start
;
1110 on_spinbutton_range_end(GtkSpinButton
* widget
,
1113 /*-----------------------------------------------------------------------------
1116 PrintDialog
*pri
= gtk_object_get_data(GTK_OBJECT(widget
), "pri");
1118 pri
->var
.print_end
= gtk_spin_button_get_value_as_int(widget
);
1119 GTK_ADJUSTMENT(pri
->spinbutton_adj_range_start
)->upper
=
1120 (gint
) pri
->var
.print_end
;
1126 on_print_response(GtkDialog
*dialog
,
1130 /*-----------------------------------------------------------------------------
1133 /* GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT(dialog), "gpiv"); */
1134 PrintDialog
*pri
= gtk_object_get_data(GTK_OBJECT(dialog
), "print_dialog");
1135 g_assert( response
== GTK_RESPONSE_OK
1136 || response
== GTK_RESPONSE_APPLY
1137 || response
== GTK_RESPONSE_CANCEL
);
1140 case GTK_RESPONSE_OK
:
1141 g_warning(_("Button \"Print\" pressed"));
1142 g_free(pri
->var
.print_cmd
);
1143 g_free(pri
->var
.fname_print
);
1146 case GTK_RESPONSE_APPLY
:
1147 g_warning(_("Button \"Preview\" pressed"));
1150 case GTK_RESPONSE_CANCEL
:
1151 g_warning(_("Button \"Cancel\" pressed"));
1152 g_free(pri
->var
.print_cmd
);
1153 g_free(pri
->var
.fname_print
);
1157 g_warning("on_preferences_response: should not arrive here");
1164 * BUGFIX: obsolete functions: on_button_...; cleanup
1167 on_button_print(GtkWidget
*widget
,
1170 /*-----------------------------------------------------------------------------
1171 * prints and closes print dialog
1174 PrintDialog
*pri
= gtk_object_get_data(GTK_OBJECT(widget
), "pri");
1176 g_warning(_("Button \"Print\" pressed"));
1177 g_free(pri
->var
.print_cmd
);
1178 g_free(pri
->var
.fname_print
);
1179 /* gnome_dialog_close(GNOME_DIALOG(gpiv_print_dialog)); */
1183 gtk_widget_destroy(GTK_WIDGET (pri
->dialog
));
1189 on_button_preview(GtkWidget
*widget
,
1192 /* ----------------------------------------------------------------------------
1196 g_warning(_("Button \"Preview\" pressed"));
1202 on_button_print_cancel(GtkWidget
*widget
,
1205 /* ----------------------------------------------------------------------------
1206 * closes print dialog
1209 PrintDialog
*pri
= gtk_object_get_data(GTK_OBJECT(widget
), "pri");
1211 g_warning(_("Button \"Cancel\" pressed"));
1212 g_free(pri
->var
.print_cmd
);
1213 g_free(pri
->var
.fname_print
);
1214 /* gnome_dialog_close(GNOME_DIALOG(gpiv_print_dialog)); */
1218 gtk_widget_destroy(GTK_WIDGET(pri
->dialog
));