GNOME Bugzilla – Bug 513291
add Page Setup menu entry
Last modified: 2008-08-20 18:11:42 UTC
we have a serious problem with the Print plug-in on the Windows platform. See bug #480086. As it seems this is unlikely to ever get fixed in GTK+, so we should do something about it in our code for GIMP 2.6. The obvious solution is to remove the "Adjust Page size and Orientation" button from the Print plug-in dialog and to add "Page Setup" to the Image->File menu. This menu entry will be provided by the Print plug-in and it will set the page settings stored as an image parasite. Shouldn't be too difficult as most of this code already exists and just needs to be reorganized a little.
Created attachment 104212 [details] [review] patch for print plug-in Here is a patch that implements a separate Page Setup dialog. A few notes concerning the approach: 1) The general concept in GtkPrintOperation is that the parameters in Page Setup describe the printer, and therefore apply to all images, while the parameters in Print Settings are specific to an individual item. Following this logic, I coded Page Setup to *not* create an image parasite (as Print Settings does), but only to save a resource file called "print-page-setup". This makes sense for most parameters, but is questionable for orientation, which really does often apply to an individual item. In fact, the treatment of orientation in the GtkPrint system is a bit schizophrenic: it appears both in Page Setup and in Print Settings. Perhaps the best solution would be to add an orientation control on the custom page, which would override the one in Page Setup. However, other approaches are possible, and I am certainly open to changing this. 2) My ability to test this code is limited. I don't have a printer at home, so I could only test using PDF output. Also, I don't have a Windows setup, so I can't test that the usage of native Windows printing stuff works correctly (This is pretty much all Gtk stuff, though.) 3) The fact that we will now have a menu entry called Page Setup, as well as a page within the Print dialog called Page Setup (which has a completely different function), sucks. We don't have any ability to relabel the page in the Print dialog, unfortunately. I filed a GtkPrint bug report about this some time ago, but it didn't go anywhere, so presumably we have to live with it for now. 4) I hesitate to say this, but bug #480086 could probably have been solved without this change, by using gtk_print_run_page_setup_dialog_async instead of gtk_print_run_page_setup_dialog. However, I believe, as discussed in gimp-developer, that having a separate menu item is the correct approach anyway, if we are going to use the GtkPrint system. It is really designed to work that way.
No, it couldn't have been solved using gtk_print_run_page_setup_dialog_async() as that function doesn't work asynchronously on Windows. As I already announced earlier, I am working on a patch for this and even started to commit my changes to SVN already. Your work unfortunately duplicates this effort.
Some of this code is based on Bill's patch. The general idea is the same: 2008-02-04 Sven Neumann <sven@gimp.org> * plug-ins/print/Makefile.am * plug-ins/print/print-page-setup.[ch]: new files. * plug-ins/print/print-page-layout.c * plug-ins/print/print-settings.c * plug-ins/print/print.c: first draft of a Page Setup menu entry instead of the "Adjust Page Size" button (bug #513291). * plug-ins/print/print.h * plug-ins/print/print-draw-page.c: removed unused code. What's missing is a temporary procedure to notify the Print plug-in dialog about the changed Page Setup. This will follow next...
The logic in GtkPrintOperation is that the Page Setup applies to all pages of a print job, not to all documents that you will ever print. So this needs to become an image parasite in addition to the resource file. This is the other change that needs to be done here.
I have now added the code that notifies the print procedure about changes to the page setup. This can currently cause an error dialog because calling gimp_procedure_run() on a non-existent procedure raises an error at the PDB level and there is currently no way for the plug-in to suppress this error. This is supposed to be added with bug #344818.
This commit adds the code to store the page setup information in an image parasite: 2008-02-25 Sven Neumann <sven@gimp.org> * plug-ins/print/Makefile.am * plug-ins/print/print-utils.[ch]: added new files with utility functions. * plug-ins/print/print-settings.c: use the new utility functions for loading and saving GKeyFile. * plug-ins/print/print-page-setup.[ch] * plug-ins/print/print.c: also store the page setup in an image parasite. Fixes most of what remained to be done for bug #513291. What remains to be done now is getting rid of the error message when the non-existant temporary procedure is called. This depends on bug #344818.
2008-04-06 Sven Neumann <sven@gimp.org> * plug-ins/print/print.c (page_setup): do a query for the temporary procedure installed by the 'file-print-gtk' procedure. Temporary solution until bug #344818 has been addressed.
Let's close this as FIXED. We can always implement the better solution as soon as bug #344818 has been addressed.
2008-08-20 Sven Neumann <sven@gimp.org> * plug-ins/print/print.c (page_setup): use the new API to set the PDB error handler in order to suppress a warning if the temporary procedure does not exist (see bug #513291).