Updated copyright text/header in most source files.
[geda-gaf/peter-b.git] / gschem / src / x_print.c
blob3de22058af472fb0af159b71a63cd77e535a0e0e
1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 1998-2010 Ales Hvezda
4 * Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
20 #include <config.h>
22 #include <stdio.h>
23 #ifdef HAVE_STDLIB_H
24 #include <stdlib.h>
25 #endif
26 #ifdef HAVE_STRING_H
27 #include <string.h>
28 #endif
30 #include "gschem.h"
32 #ifdef HAVE_LIBDMALLOC
33 #include <dmalloc.h>
34 #endif
36 enum
38 PROP_FILENAME = 1,
39 PROP_COMMAND,
40 PROP_PAPERSIZE,
41 PROP_ORIENTATION,
42 PROP_TYPE,
43 PROP_USEFILE
46 /* Private functions */
48 static void print_dialog_action_radio_toggled (GtkWidget * w,
49 PrintDialog * dialog);
51 static void print_dialog_init (PrintDialog * dialog);
52 static void print_dialog_init_paper_combobox (PrintDialog * d);
53 static void print_dialog_init_type_combobox (PrintDialog * d);
54 static void print_dialog_init_orient_combobox (PrintDialog * d);
55 static void print_dialog_set_property (GObject * object, guint property_id,
56 const GValue * value,
57 GParamSpec * pspec);
58 static void print_dialog_set_property_comboboxes (PrintDialog *dialog,
59 GtkComboBox *cbox,
60 const GValue * value);
61 static void print_dialog_get_property (GObject * object, guint property_id,
62 GValue * value, GParamSpec * pspec);
63 static void print_dialog_get_property_comboboxes (PrintDialog * dialog,
64 GtkComboBox * cbox,
65 GValue * value);
66 static void print_dialog_class_init (PrintDialogClass * class);
70 /*!
71 * \brief Callback function to show file chooser dialog
73 * \par Shows file chooser dialog for user to select PostScript file
74 * to print to.
75 * \par Private callback function, should not be called by any code
76 * outside x_print.c
78 static void
79 print_dialog_action_choosefile (GtkWidget * w, PrintDialog * dialog)
81 GtkWidget *filechooser;
82 const gchar *filename;
83 const gchar *newfilename;
84 filechooser = gtk_file_chooser_dialog_new (_("Select PostScript Filename..."),
85 GTK_WINDOW (dialog),
86 GTK_FILE_CHOOSER_ACTION_SAVE,
87 GTK_STOCK_CANCEL,
88 GTK_RESPONSE_CANCEL,
89 GTK_STOCK_OK,
90 GTK_RESPONSE_ACCEPT, NULL);
92 /* Set the alternative button order (ok, cancel, help) for other systems */
93 gtk_dialog_set_alternative_button_order(GTK_DIALOG(filechooser),
94 GTK_RESPONSE_ACCEPT,
95 GTK_RESPONSE_CANCEL,
96 -1);
98 filename = gtk_entry_get_text (GTK_ENTRY (dialog->fnfield));
99 gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filechooser), filename);
101 gtk_dialog_set_default_response(GTK_DIALOG(filechooser),
102 GTK_RESPONSE_ACCEPT);
104 if (gtk_dialog_run (GTK_DIALOG (filechooser)) == GTK_RESPONSE_ACCEPT)
106 newfilename =
107 gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
108 gtk_entry_set_text (GTK_ENTRY (dialog->fnfield), newfilename);
111 gtk_widget_destroy (filechooser);
116 * \brief Create, initialize and populate a combobox for selecting
117 * what paper size to print to.
118 * \par Private function, should not be
119 * called by any code outside x_print.c
121 static void
122 print_dialog_init_paper_combobox (PrintDialog * d)
124 GtkComboBox *combobox;
125 gchar *string;
126 gint i;
128 combobox = GTK_COMBO_BOX (gtk_combo_box_new_text ());
129 gtk_combo_box_set_active (combobox, -1);
131 /* Populate combo box with available paper sizes */
132 i = 0;
133 string = (gchar *) s_papersizes_get (i);
134 while (string != NULL)
136 gtk_combo_box_insert_text (GTK_COMBO_BOX (combobox), i, string);
138 i++;
139 string = (gchar *) s_papersizes_get (i);
142 d->papercbox = combobox;
146 * \brief Create, initialize and populate a combobox for selecting
147 * the type of printout to produce.
148 * \par Private function, should not be called by any code
149 * outside x_print.c
151 static void
152 print_dialog_init_type_combobox (PrintDialog * d)
154 GtkListStore *model;
155 GtkTreeIter iter;
156 GtkCellRenderer *renderer;
158 GtkWidget *combobox;
160 model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
162 gtk_list_store_append (model, &iter);
163 gtk_list_store_set (model, &iter,
164 0, _("Extents with margins"),
165 1, EXTENTS,
166 -1);
168 gtk_list_store_append (model, &iter);
169 gtk_list_store_set (model, &iter,
170 0, _("Extents no margins"),
171 1, EXTENTS_NOMARGINS,
172 -1);
174 gtk_list_store_append (model, &iter);
175 gtk_list_store_set (model, &iter,
176 0, _("Current Window"),
177 1, WINDOW,
178 -1);
180 combobox = gtk_combo_box_new_with_model (GTK_TREE_MODEL (model));
182 renderer = gtk_cell_renderer_text_new ();
183 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
184 renderer, TRUE);
185 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combobox),
186 renderer, "text", 0);
188 d->typecbox = GTK_COMBO_BOX (combobox);
192 * \brief Create, initialize and populate a combobox for selecting
193 * paper orientation.
194 * \par Private function, should not be called by any code
195 * outside x_print.c
197 static void
198 print_dialog_init_orient_combobox (PrintDialog * d)
200 GtkListStore *model;
201 GtkTreeIter iter;
202 GtkCellRenderer *renderer;
204 GtkWidget *combobox;
206 model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
208 gtk_list_store_append (model, &iter);
209 gtk_list_store_set (model, &iter,
210 0, _("Landscape"),
211 1, LANDSCAPE,
212 -1);
214 gtk_list_store_append (model, &iter);
215 gtk_list_store_set (model, &iter,
216 0, _("Portrait"),
217 1, PORTRAIT,
218 -1);
220 combobox = gtk_combo_box_new_with_model (GTK_TREE_MODEL (model));
222 renderer = gtk_cell_renderer_text_new ();
223 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
224 renderer, TRUE);
225 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combobox),
226 renderer, "text", 0);
228 d->orientcbox = GTK_COMBO_BOX (combobox);
232 * \brief Handle the user clicking on radio buttons to select print
233 * destination.
235 * \par Private callback function, should not be called by any code
236 * outside x_print.c
238 static void
239 print_dialog_action_radio_toggled (GtkWidget * w, PrintDialog * dialog)
241 if (w == GTK_WIDGET (dialog->cmdradio))
243 gtk_widget_set_sensitive (GTK_WIDGET (dialog->cmdfield),
244 gtk_toggle_button_get_active
245 (GTK_TOGGLE_BUTTON (w)));
247 else if (w == GTK_WIDGET (dialog->fileradio))
249 gtk_widget_set_sensitive (GTK_WIDGET (dialog->fnfield),
250 gtk_toggle_button_get_active
251 (GTK_TOGGLE_BUTTON (w)));
252 gtk_widget_set_sensitive (GTK_WIDGET (dialog->saveasbutton),
253 gtk_toggle_button_get_active
254 (GTK_TOGGLE_BUTTON (w)));
259 /*! \todo Finish function documentation
260 * \brief
261 * \par Function Description
264 static void
265 print_dialog_init (PrintDialog * dialog)
267 GtkWidget *box;
268 GtkWidget *frame;
269 GtkWidget *settingstable, *desttable;
270 GtkWidget *label;
271 GtkWidget *print_button;
273 /* Initialize properties */
274 g_object_set (G_OBJECT (dialog),
275 /* GtkWindow */
276 "title", _("Print..."),
277 "modal", TRUE, "destroy-with-parent", TRUE, NULL);
279 /* Setup hbox for two main panes */
280 box = gtk_vbox_new (FALSE, 2);
281 gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), box);
283 /* Upper frame */
284 frame = gtk_frame_new (_("Settings"));
285 gtk_container_set_border_width (GTK_CONTAINER (frame), 3);
286 gtk_container_add (GTK_CONTAINER (box), frame);
288 /* Upper table with drop-down menus & labels
289 * Left-hand column contains labels, right-hand contains comboboxes*/
290 settingstable = gtk_table_new (2, 3, FALSE);
291 gtk_table_set_col_spacings (GTK_TABLE (settingstable), 5);
292 gtk_table_set_row_spacings (GTK_TABLE (settingstable), 5);
293 gtk_container_set_border_width (GTK_CONTAINER (settingstable), 5);
294 gtk_container_add (GTK_CONTAINER (frame), settingstable);
296 label = gtk_label_new (_("Output paper size:"));
297 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
298 gtk_table_attach (GTK_TABLE (settingstable),
299 label,
300 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND, 0, 0);
302 print_dialog_init_paper_combobox (dialog);
303 gtk_table_attach (GTK_TABLE (settingstable),
304 GTK_WIDGET (dialog->papercbox),
305 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
307 label = gtk_label_new (_("Type:"));
308 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
309 gtk_table_attach (GTK_TABLE (settingstable),
310 label,
311 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND, 0, 0);
313 print_dialog_init_type_combobox (dialog);
314 gtk_table_attach (GTK_TABLE (settingstable),
315 GTK_WIDGET (dialog->typecbox),
316 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
318 label = gtk_label_new (_("Orientation:"));
319 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
320 gtk_table_attach (GTK_TABLE (settingstable),
321 label,
322 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND, 0, 0);
324 print_dialog_init_orient_combobox (dialog);
325 gtk_table_attach (GTK_TABLE (settingstable),
326 GTK_WIDGET (dialog->orientcbox),
327 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
329 /* Lower frame */
330 frame = gtk_frame_new (_("Destination"));
331 gtk_container_set_border_width (GTK_CONTAINER (frame), 3);
332 gtk_container_add (GTK_CONTAINER (box), frame);
334 /* Table with destination selectors */
335 desttable = gtk_table_new (3, 2, FALSE);
336 gtk_table_set_col_spacings (GTK_TABLE (desttable), 5);
337 gtk_table_set_row_spacings (GTK_TABLE (desttable), 5);
338 gtk_container_set_border_width (GTK_CONTAINER (desttable), 5);
339 gtk_container_add (GTK_CONTAINER (frame), desttable);
341 /* Widgets for printing to file */
342 dialog->fileradio =
343 GTK_RADIO_BUTTON (gtk_radio_button_new_with_label (NULL, _("File:")));
344 gtk_table_attach (GTK_TABLE (desttable),
345 GTK_WIDGET (dialog->fileradio),
346 0, 1, 0, 1, GTK_FILL, GTK_EXPAND, 0, 0);
347 g_signal_connect (dialog->fileradio,
348 "toggled",
349 GTK_SIGNAL_FUNC (print_dialog_action_radio_toggled),
350 dialog);
352 dialog->fnfield = GTK_ENTRY (gtk_entry_new ());
353 gtk_table_attach (GTK_TABLE (desttable),
354 GTK_WIDGET (dialog->fnfield),
355 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
357 dialog->saveasbutton = GTK_BUTTON(gtk_button_new());
358 gtk_container_add(GTK_CONTAINER(dialog->saveasbutton),
359 gtk_image_new_from_stock(GTK_STOCK_OPEN,
360 GTK_ICON_SIZE_SMALL_TOOLBAR));
361 gtk_button_set_relief(GTK_BUTTON(dialog->saveasbutton), GTK_RELIEF_NONE);
363 gtk_table_attach (GTK_TABLE (desttable),
364 GTK_WIDGET (dialog->saveasbutton), 2, 3, 0, 1,
365 GTK_FILL, 0, 0, 0);
366 g_signal_connect (dialog->saveasbutton,
367 "clicked",
368 GTK_SIGNAL_FUNC (print_dialog_action_choosefile), dialog);
370 /* Widgets for printing to command */
371 dialog->cmdradio =
372 GTK_RADIO_BUTTON (gtk_radio_button_new_with_label_from_widget
373 (dialog->fileradio, _("Command:")));
374 gtk_table_attach (GTK_TABLE (desttable),
375 GTK_WIDGET (dialog->cmdradio),
376 0, 1, 1, 2, GTK_FILL, GTK_EXPAND, 0, 0);
377 g_signal_connect (dialog->cmdradio,
378 "toggled",
379 GTK_SIGNAL_FUNC (print_dialog_action_radio_toggled),
380 dialog);
382 dialog->cmdfield = GTK_ENTRY (gtk_entry_new ());
383 gtk_table_attach (GTK_TABLE (desttable), GTK_WIDGET (dialog->cmdfield),
384 1, 3, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0);
386 /* Add "Cancel" and "Print" buttons */
387 gtk_dialog_add_button (GTK_DIALOG (dialog),
388 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
389 print_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
390 GTK_STOCK_PRINT, GTK_RESPONSE_ACCEPT);
391 gtk_widget_grab_focus(print_button);
393 /* Set the alternative button order (ok, cancel, help) for other systems */
394 gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog),
395 GTK_RESPONSE_ACCEPT,
396 GTK_RESPONSE_REJECT,
397 -1);
399 /* Set initial radiobutton selection */
400 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->cmdradio), TRUE);
403 /*! \todo Finish function documentation
404 * \brief
405 * \par Function Description
408 static void
409 print_dialog_set_property (GObject * object,
410 guint property_id,
411 const GValue * value, GParamSpec * pspec)
413 PrintDialog *dialog = PRINT_DIALOG (object);
414 gboolean file_active = FALSE;
416 switch (property_id)
418 case PROP_FILENAME:
419 gtk_entry_set_text (dialog->fnfield,
420 (char *) g_value_get_string (value));
421 return;
423 case PROP_COMMAND:
424 gtk_entry_set_text (dialog->cmdfield,
425 (char *) g_value_get_string (value));
426 return;
428 case PROP_PAPERSIZE:
429 gtk_combo_box_set_active (dialog->papercbox,
430 g_value_get_int (value));
431 return;
433 case PROP_ORIENTATION:
434 print_dialog_set_property_comboboxes (dialog,
435 dialog->orientcbox,
436 value);
437 return;
439 case PROP_TYPE:
440 print_dialog_set_property_comboboxes (dialog,
441 dialog->typecbox,
442 value);
443 return;
445 case PROP_USEFILE:
446 file_active = g_value_get_boolean (value);
447 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->fileradio),
448 file_active);
449 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->cmdradio),
450 !file_active);
451 return;
453 default:
454 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
458 /*! \todo Finish function documentation
459 * \brief
460 * \par Function Description
463 static void
464 print_dialog_set_property_comboboxes (PrintDialog * dialog,
465 GtkComboBox * cbox,
466 const GValue * value)
468 GtkTreeIter iter;
469 GtkTreeModel *model;
471 model = gtk_combo_box_get_model (cbox);
472 gtk_tree_model_get_iter_first (model, &iter);
474 do {
475 GValue temp_value = {0, }; /* Make sure it's blank*/
476 gtk_tree_model_get_value (model, &iter, 1, &temp_value);
478 if (g_value_get_int (&temp_value) == g_value_get_int (value))
480 gtk_combo_box_set_active_iter (cbox, &iter);
481 return;
484 } while (gtk_tree_model_iter_next (model, &iter));
486 gtk_combo_box_set_active (cbox, 0);
489 /*! \todo Finish function documentation
490 * \brief
491 * \par Function Description
494 static void
495 print_dialog_get_property (GObject * object,
496 guint property_id,
497 GValue * value, GParamSpec * pspec)
499 PrintDialog *dialog = PRINT_DIALOG (object);
500 gboolean file_active = FALSE;
502 switch (property_id)
504 case PROP_FILENAME:
505 g_value_set_string (value,
506 gtk_entry_get_text (GTK_ENTRY (dialog->fnfield)));
507 return;
509 case PROP_COMMAND:
510 g_value_set_string (value,
511 gtk_entry_get_text (GTK_ENTRY (dialog->cmdfield)));
512 return;
514 case PROP_PAPERSIZE:
515 g_value_set_int (value, gtk_combo_box_get_active (dialog->papercbox));
516 return;
518 case PROP_ORIENTATION:
519 print_dialog_get_property_comboboxes (dialog,
520 dialog->orientcbox,
521 value);
522 return;
524 case PROP_TYPE:
525 print_dialog_get_property_comboboxes (dialog,
526 dialog->typecbox,
527 value);
528 return;
530 case PROP_USEFILE:
531 file_active =
532 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->fileradio));
533 g_value_set_boolean (value, file_active);
534 return;
536 default:
537 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
541 /*! \todo Finish function documentation
542 * \brief
543 * \par Function Description
546 static void
547 print_dialog_get_property_comboboxes (PrintDialog * dialog,
548 GtkComboBox * cbox,
549 GValue * value)
551 GValue temp_value = {0, };
552 GtkTreeModel *model;
553 GtkTreeIter iter;
555 model = gtk_combo_box_get_model (cbox);
557 gtk_combo_box_get_active_iter (cbox, &iter);
558 gtk_tree_model_get_value (model, &iter, 1, &temp_value);
559 g_value_copy (&temp_value, value);
560 g_value_unset (&temp_value);
563 /*! \todo Finish function documentation
564 * \brief
565 * \par Function Description
566 * \bug Hardcoded 'magic' numbers in this function
569 static void
570 print_dialog_class_init (PrintDialogClass * class)
572 GObjectClass *gobject_class = G_OBJECT_CLASS (class);
574 gobject_class->set_property = print_dialog_set_property;
575 gobject_class->get_property = print_dialog_get_property;
577 g_object_class_install_property (gobject_class, PROP_FILENAME,
578 g_param_spec_string ("filename",
579 "", "", "",
580 G_PARAM_READWRITE));
582 g_object_class_install_property (gobject_class, PROP_COMMAND,
583 g_param_spec_string ("command",
584 "", "", "lpr",
585 G_PARAM_READWRITE));
587 g_object_class_install_property (gobject_class, PROP_PAPERSIZE,
588 g_param_spec_int ("papersize",
589 "", "", 0, G_MAXINT, 0,
590 G_PARAM_READWRITE));
592 g_object_class_install_property (gobject_class, PROP_ORIENTATION,
593 g_param_spec_int ("orientation",
594 "", "", 0, G_MAXINT, 0,
595 G_PARAM_READWRITE));
597 g_object_class_install_property (gobject_class, PROP_TYPE,
598 g_param_spec_int ("type",
599 "", "", 0, G_MAXINT, 0,
600 G_PARAM_READWRITE));
602 g_object_class_install_property (gobject_class, PROP_USEFILE,
603 g_param_spec_boolean ("usefile",
604 "", "", FALSE,
605 G_PARAM_READWRITE));
608 /*! \todo Finish function documentation
609 * \brief
610 * \par Function Description
613 GType
614 print_dialog_get_type ()
616 static GType print_dialog_type = 0;
618 if (!print_dialog_type)
620 static const GTypeInfo print_dialog_info = {
621 sizeof (PrintDialogClass),
622 NULL, /* base_init */
623 NULL, /* base_finalize */
624 (GClassInitFunc) print_dialog_class_init,
625 NULL, /* class_finalize */
626 NULL, /* class_data */
627 sizeof (PrintDialog),
628 0, /* n_preallocs */
629 (GInstanceInitFunc) print_dialog_init,
631 print_dialog_type = g_type_register_static (GSCHEM_TYPE_DIALOG,
632 "PrintDialog",
633 &print_dialog_info, 0);
636 return print_dialog_type;
639 /*! \todo Finish function documentation
640 * \brief
641 * \par Function Description
644 void
645 x_print_setup (GSCHEM_TOPLEVEL *w_current, char *filename)
647 TOPLEVEL *toplevel = w_current->toplevel;
648 gchar * command = w_current->print_command;
649 gint orient = toplevel->print_orientation;
650 gint type = toplevel->print_output_type;
651 gint paperidx, x, y, result;
652 gchar *string, *destination;
653 gboolean usefile = FALSE;
654 GtkDialog *dialog;
655 GtkWidget *popup_message;
657 /* Work out current paper size by iterating through available paper
658 * sizes. Set the default paper size as the active selection */
660 /* FIXME: ought to have a TOPLEVEL property containing
661 * default paper size name, this is somewhat hackish. No
662 * better way of doing it with current implementation of
663 * varying paper size though. */
664 paperidx = 0;
665 while (TRUE)
667 string = (gchar *) s_papersizes_get (paperidx);
668 s_papersizes_get_size (string, &x, &y);
670 if ((x == toplevel->paper_width)
671 && (y == toplevel->paper_height))
673 break;
675 if (string == NULL)
677 paperidx = 0;
678 break;
680 paperidx++;
683 /* Create a print dialog, find out whether the user clicks Print or
684 Cancel, and then print or return accordingly */
685 dialog = GTK_DIALOG (g_object_new (TYPE_PRINT_DIALOG,
686 "command", command,
687 "filename", filename,
688 "papersize", paperidx,
689 "orientation", orient,
690 "type", type,
691 "usefile", usefile,
692 /* GschemDialog */
693 "settings-name", "print",
694 "gschem-toplevel", w_current,
695 NULL));
696 gtk_widget_show_all (GTK_WIDGET (dialog));
698 gtk_dialog_set_default_response(GTK_DIALOG(dialog),
699 GTK_RESPONSE_ACCEPT);
700 gtk_window_set_transient_for(GTK_WINDOW(dialog),
701 GTK_WINDOW(w_current->main_window));
703 result = gtk_dialog_run (dialog);
705 if (result == GTK_RESPONSE_ACCEPT)
707 /* Extract values from dialog and set the paper size */
708 g_object_get (dialog,
709 "command", &command,
710 "filename", &filename,
711 "papersize", &paperidx,
712 "orientation", &toplevel->print_orientation,
713 "type", &toplevel->print_output_type,
714 "usefile", &usefile,
715 NULL);
717 s_papersizes_get_size (s_papersizes_get (paperidx),
718 &toplevel->paper_width,
719 &toplevel->paper_height);
721 /* de select everything first */
722 o_select_unselect_all( w_current );
724 if (usefile && filename[0])
725 /* Print to file */
727 destination = filename;
728 result = f_print_file (toplevel, filename);
730 else if (command[0])
731 /* Print to command and save command for later use. */
733 destination = command;
734 result = f_print_command (toplevel, command);
736 g_free (w_current->print_command);
737 w_current->print_command = g_strdup (command);
739 else
741 s_log_message (_("No print destination specified\n"));
742 return;
745 /* Check whether it worked */
746 if (result)
748 s_log_message (_("Cannot print current schematic to [%s]\n"),
749 destination);
751 /* Pop up a message warning the user */
752 popup_message =
753 gtk_message_dialog_new (GTK_WINDOW(dialog),
754 GTK_DIALOG_DESTROY_WITH_PARENT,
755 GTK_MESSAGE_ERROR,
756 GTK_BUTTONS_CLOSE,
757 _("Error printing to file '%s'\n"
758 "Check the log window for more information"),
759 destination);
760 gtk_dialog_run (GTK_DIALOG (popup_message));
762 else
764 s_log_message (_("Printed current schematic to [%s]\n"),
765 destination);
769 /* We don't need the dialog any more */
770 gtk_widget_destroy (GTK_WIDGET (dialog));