diff options
Diffstat (limited to 'src/drivers/Posix/Fl_Posix_Printer_Driver.cxx')
| -rw-r--r-- | src/drivers/Posix/Fl_Posix_Printer_Driver.cxx | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/src/drivers/Posix/Fl_Posix_Printer_Driver.cxx b/src/drivers/Posix/Fl_Posix_Printer_Driver.cxx index bf206070e..dbb966a76 100644 --- a/src/drivers/Posix/Fl_Posix_Printer_Driver.cxx +++ b/src/drivers/Posix/Fl_Posix_Printer_Driver.cxx @@ -1,6 +1,4 @@ // -// "$Id$" -// // PostScript priting support for the Fast Light Tool Kit (FLTK). // // Copyright 2010-2016 by Bill Spitzak and others. @@ -9,11 +7,11 @@ // the file "COPYING" which should have been included with this file. If this // file is missing or damaged, see the license at: // -// http://www.fltk.org/COPYING.php +// https://www.fltk.org/COPYING.php // -// Please report all bugs and problems to: +// Please see the following page on how to report bugs and issues: // -// http://www.fltk.org/str.php +// https://www.fltk.org/bugs.php // #include "../../config_lib.h" @@ -54,14 +52,14 @@ public: typedef struct _GtkPrintJob GtkPrintJob; typedef struct _GtkWidget GtkWidget; struct GError; - + GtkPrintJob *pjob; // data shared between begin_job() and end_job() char tmpfilename[50]; // name of temporary PostScript file containing to-be-printed data virtual int begin_job(int pagecount = 0, int *frompage = NULL, int *topage = NULL, char **perr_message=NULL); virtual void end_job(); static bool probe_for_GTK(); static void *ptr_gtk; // points to the GTK dynamic lib or NULL - + typedef GtkPrintUnixDialog* (*gtk_print_unix_dialog_new_t)(const char*, void*); typedef int (*gtk_dialog_run_t)(GtkDialog*); typedef GtkPrintSettings *(*gtk_print_unix_dialog_get_settings_t)(GtkPrintUnixDialog*); @@ -106,7 +104,7 @@ bool Fl_GTK_Printer_Driver::probe_for_GTK() { int Fl_GTK_Printer_Driver::begin_job(int pagecount, int *firstpage, int *lastpage, char **perr_message) { enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4; enum Fl_Paged_Device::Page_Layout layout = Fl_Paged_Device::PORTRAIT ; - + GtkPrintUnixDialog *pdialog = CALL_GTK(gtk_print_unix_dialog_new)(Fl_Printer::dialog_title, NULL); //2.10 if (dlsym(ptr_gtk, "gtk_get_major_version") || !CALL_GTK(gtk_check_version)(2, 18, 0)) CALL_GTK(gtk_print_unix_dialog_set_embed_page_setup)(pdialog, true); //2.18 @@ -236,7 +234,7 @@ Fl_Paged_Device* Fl_Printer::newPrinterDriver(void) int Fl_Posix_Printer_Driver::begin_job(int pages, int *firstpage, int *lastpage, char **perr_message) { enum Fl_Paged_Device::Page_Format format; enum Fl_Paged_Device::Page_Layout layout; - + // first test version for print dialog if (!print_panel) make_print_panel(); printing_style style = print_load(); @@ -247,12 +245,12 @@ int Fl_Posix_Printer_Driver::begin_job(int pages, int *firstpage, int *lastpage, { char tmp[10]; snprintf(tmp, sizeof(tmp), "%d", pages); print_to->value(tmp); } print_panel->show(); // this is modal while (print_panel->shown()) Fl::wait(); - + if (!print_start) // user clicked cancel return 1; - + // get options - + switch (print_page_size->value()) { case 0: format = Fl_Paged_Device::LETTER; @@ -281,7 +279,7 @@ int Fl_Posix_Printer_Driver::begin_job(int pages, int *firstpage, int *lastpage, default: format = Fl_Paged_Device::A4; } - + { // page range choice int from = 1, to = pages; if (print_pages->value()) { @@ -295,29 +293,29 @@ int Fl_Posix_Printer_Driver::begin_job(int pages, int *firstpage, int *lastpage, if (lastpage) *lastpage = to; if (pages > 0) pages = to - from + 1; } - + if (print_output_mode[0]->value()) layout = Fl_Paged_Device::PORTRAIT; else if (print_output_mode[1]->value()) layout = Fl_Paged_Device::LANDSCAPE; else if (print_output_mode[2]->value()) layout = Fl_Paged_Device::PORTRAIT; else layout = Fl_Paged_Device::LANDSCAPE; - - int print_pipe = print_choice->value(); // 0 = print to file, >0 = printer (pipe) - + + int print_pipe = print_choice->value(); // 0 = print to file, >0 = printer (pipe) + const char *media = print_page_size->text(print_page_size->value()); const char *printer = (const char *)print_choice->menu()[print_choice->value()].user_data(); if (!print_pipe) printer = "<File>"; - + if (!print_pipe) // fall back to file printing return Fl_PostScript_File_Device::begin_job (pages, format, layout); - + // Print: pipe the output into the lp command... - + char command[1024]; if (style == SystemV) snprintf(command, sizeof(command), "lp -s -d %s -n %d -t '%s' -o media=%s", printer, print_collate_button->value() ? 1 : (int)(print_copies->value() + 0.5), "FLTK", media); else snprintf(command, sizeof(command), "lpr -h -P%s -#%d -T FLTK ", printer, print_collate_button->value() ? 1 : (int)(print_copies->value() + 0.5)); - + Fl_PostScript_Graphics_Driver *ps = driver(); ps->output = popen(command, "w"); if (!ps->output) { @@ -333,8 +331,3 @@ int Fl_Posix_Printer_Driver::begin_job(int pages, int *firstpage, int *lastpage, } #endif // defined(FL_CFG_PRN_PS) && !defined(FL_NO_PRINT_SUPPORT) - - -// -// End of "$Id$". -// |
