GNOME Bugzilla – Bug 686109
gtk_print_context_get_hard_margins should return page size specific hard margins
Last modified: 2018-04-26 12:24:30 UTC
On unix gtk_print_context_get_hard_margins calls gtk_printer_get_hard_margins to get the hard margins. The cups implementation of this function returns the custom margins (HWMargins in the PPD). But on some printers HWMargins are smaller than the hard margins for some paper sizes (ImageableArea in the PPD). The attached patch adds a new GtkPrinter function gtk_printer_get_hard_margins_for_page_setup to get the hard margins for a specific page size along with a CUPS backend implementation. gtkprintoperation-unix is updated to first try this function before falling back to calling gtk_print_context_get_hard_margins.
Created attachment 226408 [details] [review] Add gtk_printer_get_hard_margins_for_page_setup
Created attachment 226409 [details] [review] Add gtk_printer_get_hard_margins_for_page_setup
Comment on attachment 226408 [details] [review] Add gtk_printer_get_hard_margins_for_page_setup remove duplicate
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
Review of attachment 226409 [details] [review]: Hi, thank you for the patch. I think that the function gtk_printer_get_hard_margins_for_page_setup() should be named gtk_printer_get_hard_margins_for_paper_size() because you are getting margins for the paper size actually. ::: gtk/gtkprintbackend.h @@ +108,3 @@ gdouble *left, gdouble *right); + gboolean (*printer_get_hard_margins_for_page_setup) (GtkPrinter *printer, You have to use one of those paddings at the end of the class declaration. ::: gtk/gtkprinter.h @@ +141,3 @@ gdouble *left, gdouble *right); +gboolean gtk_printer_get_hard_margins_for_page_setup (GtkPrinter *printer, This should be added to gtk3-sections.txt too (and gtk4-sections.txt for master). ::: modules/printbackends/cups/gtkprintbackendcups.c @@ +4796,3 @@ + + paper_size = gtk_page_setup_get_paper_size (page_setup); + paper_name = gtk_paper_size_get_ppd_name (paper_size); I'm getting warning about discarding "const" here.
Created attachment 369792 [details] [review] Adrian's patch modified by Marek Adrian, do you agree with the changes I made to your patch? I would like to get it in gtk+.
Comment on attachment 369792 [details] [review] Adrian's patch modified by Marek please add the new vfunc after all exisiting vfuncs
Created attachment 370837 [details] [review] Adrian's patch modified by Marek (In reply to Matthias Clasen from comment #7) > Comment on attachment 369792 [details] [review] [review] > Adrian's patch modified by Marek > > please add the new vfunc after all exisiting vfuncs Thank you for the review. I've moved the vfunc.
Review of attachment 370837 [details] [review]: So, for gtk3, we don't want to add new api. I see this patch uses the new function in gtkprintoperation - is that useful without making the api public ?
Created attachment 370987 [details] [review] Adrian's patch modified by Marek (In reply to Matthias Clasen from comment #9) > Review of attachment 370837 [details] [review] [review]: > > So, for gtk3, we don't want to add new api. I see this patch uses the new > function in gtkprintoperation - is that useful without making the api public > ? Yes, making the function private by placing it into gtkprinter-private.h and using it in gtkprintoperation-unix.c still helps to set correct borders for actual printcontext. But it still needs to be listed in GtkPrintBackendClass to be able to use it. Is that ok?
Looks good to me now
Comment on attachment 370987 [details] [review] Adrian's patch modified by Marek (In reply to Matthias Clasen from comment #11) > Looks good to me now Thank you for the review. I've pushed the patch to 3-22 branch and will push its version with added API to gtk4 tomorrow.
I've pushed the patch to master branch today. It adds the API to GtkPrinter in comparison with the version for 3.22 branch. Thank you all.