Author: manolo
Date: 2010-11-23 04:13:17 -0800 (Tue, 23 Nov 2010)
New Revision: 7885
Log:
Improves the usability of member function: Fl_PostScript_File_Device::start_job 
(FILE *,...

Modified:
   branches/branch-1.3/src/Fl_PostScript.cxx
   branches/branch-1.3/src/print_panel.cxx

Modified: branches/branch-1.3/src/Fl_PostScript.cxx
===================================================================
--- branches/branch-1.3/src/Fl_PostScript.cxx   2010-11-22 18:17:51 UTC (rev 
7884)
+++ branches/branch-1.3/src/Fl_PostScript.cxx   2010-11-23 12:13:17 UTC (rev 
7885)
@@ -105,11 +105,13 @@
   return 0;
 }
 
+static int dont_close(FILE *f) {}
+
 /**
  @brief Begins the session where all graphics requests will go to FILE pointer.
  *
- @param ps_output A writable FILE pointer that will receive PostScript output 
and that will be closed
- when end_job() will be called.
+ @param ps_output A writable FILE pointer that will receive PostScript output 
and that should not be closed
+ until after end_job() has been called.
  @param pagecount The total number of pages to be created.
  @param format Desired page format.
  @param layout Desired page layout.
@@ -121,6 +123,7 @@
   ps->output = ps_output;
   ps->ps_filename_ = NULL;
   ps->start_postscript(pagecount, format, layout);
+  ps->close_command(dont_close); // so that end_job() doesn't close the file
   this->set_current();
   return 0;
 }
@@ -1467,20 +1470,16 @@
   if(ferror(ps->output)) {
     fl_alert ("Error during PostScript data output.");
     }
-#if ! (defined(__APPLE__) || defined(WIN32) )
-  if (print_pipe)
-    pclose(ps->output);
-  else
+  if (ps->close_cmd_) {
+    (*ps->close_cmd_)(ps->output);
+  } else {
     fclose(ps->output);
-#else
-  fclose(ps->output);
-#endif
+    }
   while (ps->clip_){
     Fl_PostScript_Graphics_Driver::Clip * c= ps->clip_;
     ps->clip_= ps->clip_->prev;
     delete c;
   }
-  if (ps->close_cmd_) (*ps->close_cmd_)(ps->output);
   Fl_Display_Device::display_device()->set_current();
 }
 
@@ -1525,7 +1524,7 @@
   else if (print_output_mode[2]->value()) layout = 
Fl_PostScript_Graphics_Driver::PORTRAIT;
   else layout = Fl_PostScript_Graphics_Driver::LANDSCAPE;
 
-  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();
@@ -1547,6 +1546,7 @@
     fl_alert("could not run command: %s\n",command);
     return 1;
   }
+  ps->close_command(pclose);
   this->set_current();
   return ps->start_postscript(pages, format, layout); // start printing
 }

Modified: branches/branch-1.3/src/print_panel.cxx
===================================================================
--- branches/branch-1.3/src/print_panel.cxx     2010-11-22 18:17:51 UTC (rev 
7884)
+++ branches/branch-1.3/src/print_panel.cxx     2010-11-23 12:13:17 UTC (rev 
7885)
@@ -67,7 +67,6 @@
 static Fl_Spinner *print_copies=(Fl_Spinner *)0;
 
 static int print_start = 0;    // 1 if print_okay has been clicked
-static int print_pipe = 0;     // 0 = file, 1 = pipe (lp)
 
 static void cb_print_choice(Fl_Choice*, void*) {
   print_update_status();

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to