After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 686109 - gtk_print_context_get_hard_margins should return page size specific hard margins
gtk_print_context_get_hard_margins should return page size specific hard margins
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Printing
3.6.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 683984
 
 
Reported: 2012-10-14 11:04 UTC by Adrian Johnson
Modified: 2018-04-26 12:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add gtk_printer_get_hard_margins_for_page_setup (9.49 KB, patch)
2012-10-14 11:06 UTC, Adrian Johnson
none Details | Review
Add gtk_printer_get_hard_margins_for_page_setup (9.49 KB, patch)
2012-10-14 11:19 UTC, Adrian Johnson
needs-work Details | Review
Adrian's patch modified by Marek (10.36 KB, patch)
2018-03-16 15:52 UTC, Marek Kašík
none Details | Review
Adrian's patch modified by Marek (10.24 KB, patch)
2018-04-12 09:36 UTC, Marek Kašík
none Details | Review
Adrian's patch modified by Marek (9.19 KB, patch)
2018-04-16 12:02 UTC, Marek Kašík
committed Details | Review

Description Adrian Johnson 2012-10-14 11:04:43 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.
Comment 1 Adrian Johnson 2012-10-14 11:06:56 UTC
Created attachment 226408 [details] [review]
Add gtk_printer_get_hard_margins_for_page_setup
Comment 2 Adrian Johnson 2012-10-14 11:19:43 UTC
Created attachment 226409 [details] [review]
Add gtk_printer_get_hard_margins_for_page_setup
Comment 3 Adrian Johnson 2012-10-14 11:21:20 UTC
Comment on attachment 226408 [details] [review]
Add gtk_printer_get_hard_margins_for_page_setup

remove duplicate
Comment 4 Matthias Clasen 2018-02-10 05:17:59 UTC
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.
Comment 5 Marek Kašík 2018-02-28 17:19:45 UTC
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.
Comment 6 Marek Kašík 2018-03-16 15:52:36 UTC
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 7 Matthias Clasen 2018-04-11 16:55:20 UTC
Comment on attachment 369792 [details] [review]
Adrian's patch modified by Marek

please add the new vfunc after all exisiting vfuncs
Comment 8 Marek Kašík 2018-04-12 09:36:09 UTC
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.
Comment 9 Matthias Clasen 2018-04-15 23:47:09 UTC
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 ?
Comment 10 Marek Kašík 2018-04-16 12:02:24 UTC
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?
Comment 11 Matthias Clasen 2018-04-25 14:14:23 UTC
Looks good to me now
Comment 12 Marek Kašík 2018-04-25 14:30:16 UTC
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.
Comment 13 Marek Kašík 2018-04-26 12:24:30 UTC
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.