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 512369 - Port to GtkPrint
Port to GtkPrint
Status: RESOLVED FIXED
Product: tomboy
Classification: Applications
Component: General
unspecified
Other Linux
: High normal
: ---
Assigned To: Tomboy Maintainers
Tomboy Maintainers
: 520747 559236 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-01-27 14:34 UTC by Vincent Untz
Modified: 2009-04-23 02:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GTK Print Extension (136.68 KB, patch)
2008-04-17 06:19 UTC, John M. Anderson
none Details | Review
Output from note with long paragraphs. (20.40 KB, application/octet-stream)
2008-04-17 14:48 UTC, Sandy Armstrong
  Details
The note I was trying to print. (5.95 KB, text/plain)
2008-04-17 14:50 UTC, Sandy Armstrong
  Details
Basic printing, handling paragraphs and pages. (138.96 KB, patch)
2008-05-12 07:04 UTC, Sandy Armstrong
committed Details | Review
Support for printing using the gtk 2.10 api (7.31 KB, patch)
2009-01-31 19:55 UTC, Benjamin Podszun
needs-work Details | Review
My absolutely wicked test note (8.88 KB, text/plain)
2009-01-31 20:52 UTC, Sandy Armstrong
  Details
PDF output of printing my wicked test note with the old addin (126.24 KB, application/pdf)
2009-01-31 21:52 UTC, Sandy Armstrong
  Details
PDF output of printing my wicked test note with the new addin (89.57 KB, application/pdf)
2009-01-31 21:59 UTC, Sandy Armstrong
  Details
Support for printing using the gtk 2.10 api (19.74 KB, patch)
2009-02-01 14:47 UTC, Benjamin Podszun
committed Details | Review
PDF output of printing my wicked test note with my working copy (34.61 KB, application/pdf)
2009-02-15 21:26 UTC, Benjamin Podszun
  Details
Support for printing using the gtk 2.10 api (11.14 KB, patch)
2009-02-15 22:21 UTC, Benjamin Podszun
committed Details | Review

Description Vincent Untz 2008-01-27 14:34:05 UTC
Tomboy should not depend on libgnomeprint anymore and should use the GtkPrint API.

I believe only the only place where print api is needed is the PrintNotes addin. Looking at it, it seems to use some code from gtksourceview/gedit, so maybe the new gtksourceview/gedit code could be used.
Comment 1 Sandy Armstrong 2008-01-27 14:45:22 UTC
I'd like to avoid using gtksourceview/gedit code as the licensing situation is a little murky there, but yes, this needs to be addressed.  Unfortunately, there is no time until next release cycle.
Comment 2 Boyd Timothy 2008-02-26 19:15:37 UTC
Setting the default assignee and QA Contact to "tomboy-maint@gnome.bugs".
Comment 3 Sebastian Dröge (slomo) 2008-03-06 13:38:15 UTC
*** Bug 520747 has been marked as a duplicate of this bug. ***
Comment 4 Sebastian Dröge (slomo) 2008-03-06 13:40:17 UTC
Also, if using GtkPrint, we could get rid of the native library (requires Gtk# 2.10 though).

All that is required should be perfectly possible in managed land and the GtkPrintOperation API looks fairly easy to use too, we just need something that renders the note content on a cairo canvas ;)
Comment 5 Stefan Schweizer 2008-03-28 17:14:15 UTC
I will start to work on the port this development cycle.
Comment 6 John M. Anderson 2008-04-17 06:19:25 UTC
Created attachment 109403 [details] [review]
GTK Print Extension

This modifies the current printing extension to use GTK instsead of gnomeprint. This currently doesn't handle styles but I'm hoping to do that soon.

Let me know if its ok to commit.
Comment 7 Sandy Armstrong 2008-04-17 14:46:11 UTC
Not quite yet, I see some issues...

1. Doesn't seem to handle paragraphs correctly.  I drafted a blog post in a Tomboy note, and when I went to print it each paragraph was shown as one line cut off at the end of the page.  I'll attach the note and the resultant PDF.

2. Some coding style things, like spaces in the right places, braces on the same line as the if/for/whatever, you know.

Otherwise, I'm not worried about print styles, I'm sure we'll get that fixed quickly once it's in SVN.  Just take care of issues 1 and 2, post a new diff, and we should be good to go.
Comment 8 Sandy Armstrong 2008-04-17 14:48:30 UTC
Created attachment 109429 [details]
Output from note with long paragraphs.
Comment 9 Sandy Armstrong 2008-04-17 14:50:18 UTC
Created attachment 109430 [details]
The note I was trying to print.
Comment 10 Stefan Schweizer 2008-05-01 10:50:45 UTC
Thanks for starting this, John! Unfortunately I did not find much time to work on it.
Comment 11 Sandy Armstrong 2008-05-12 07:03:22 UTC
Using John's patch and an earlier test version he wrote [1], I corrected the issues with paragraphs.  Fonts, styles, and other formatting issues are not currently handled, and the font is hard-coded to "sans 12".

Outstanding issues:
- Fonts/styles/formatting
- Preferences for font size/scaling, including linked notes, etc?
- Figure out why we get this message: "Cairo.Context: called from finalization thread programmer is missing a call to Dispose".  John thinks it might just be an internal pango/cairo/gtk-sharp issue.

Anyone is welcome to jump in and fix!  I'm going to commit as an incentive.  ;-)

[1] http://lists.ximian.com/pipermail/gtk-sharp-list/2008-April/008569.html
Comment 12 Sandy Armstrong 2008-05-12 07:04:24 UTC
Created attachment 110753 [details] [review]
Basic printing, handling paragraphs and pages.
Comment 13 Sandy Armstrong 2008-05-12 07:13:16 UTC
Committed in r1997.  Trunk now requires gtk-sharp >= 2.10.
Comment 14 André Klapper 2008-06-29 02:28:26 UTC
So can we close this now?
Comment 15 Sandy Armstrong 2008-07-01 19:41:57 UTC
(In reply to comment #14)
> So can we close this now?

The work is not yet complete.  We no longer use libgnomeprint, but there is still work to do, as discussed in comment #11.
Comment 16 Sandy Armstrong 2008-10-14 21:37:11 UTC
Backed-out before 0.12.0 because there were too many problems.
Comment 17 Sandy Armstrong 2008-11-04 13:29:24 UTC
*** Bug 559236 has been marked as a duplicate of this bug. ***
Comment 18 Andreas Proschofsky 2009-01-09 23:48:10 UTC
Just out of interest: What is the status of this?
Comment 19 Sandy Armstrong 2009-01-10 00:37:10 UTC
No news.  Volunteers welcome.  I think I lost the improvements I had been working on...
Comment 20 André Klapper 2009-01-20 22:30:10 UTC
Current state:

$:andre\> grep -r gnomeprint .
./Tomboy/Addins/PrintNotes/gtksourceprintjob.c:#include <libgnomeprint/gnome-print-pango.h>
./Tomboy/Addins/PrintNotes/gtksourceprintjob.h:#include <libgnomeprint/gnome-print-config.h>
./Tomboy/Addins/PrintNotes/gtksourceprintjob.h:#include <libgnomeprint/gnome-print-job.h>
./Tomboy/Addins/PrintNotes/gedit-print.c:#include <libgnomeprintui/gnome-print-dialog.h>
./Tomboy/Addins/PrintNotes/gedit-print.c:#include <libgnomeprintui/gnome-print-job-preview.h>
./configure.in:		  libgnomeprint-2.2
./configure.in:		  libgnomeprintui-2.2
Comment 21 Sandy Armstrong 2009-01-20 23:09:18 UTC
Yup. May not get fixed this cycle. :-(
Comment 22 Benjamin Podszun 2009-01-31 19:55:56 UTC
Created attachment 127646 [details] [review]
Support for printing using the gtk 2.10 api

This is for review/feedback mostly. Works for me, but it's only tested on 2.12 and Windows XP. In addition I haven't commented it and could clean it up a little.
Credit where it's due: The implementation is in large parts stolen from the gtksourceview implementation
Comment 23 Sandy Armstrong 2009-01-31 20:52:31 UTC
Created attachment 127654 [details]
My absolutely wicked test note

This patch is looking good!  I really hope we can get this close enough before Monday that we can confidently finish it for 0.14.0.

I'm attaching one of my messiest notes, which should be good for testing.

Here are the issues I saw:

Standards etc:

* Lots of extra whitespace that needs to be cleaned up.
* NOTE: This patch doesn't include necessary build updates for Windows, Mac, or Linux. I can take care of that, though.
* Need to make sure you follow http://live.gnome.org/Tomboy/CodingGuidelines
* You are using some gtk-sharp 2.12-only API: Pango.Units.FromDouble. Instead, use FromPixels and cast the input parameter to an int.

Functionality:

* Bullets are not indented (at any level), and sometimes I saw an extra missing character inserted after the bullet (looked like a box with an X in it).
* If you try to print my attached test note, you should see some examples of "shifted" formatting.  For example, if I have text like: "this is <b>bold</b>", it might come out like "this <b>is bo</b>ld".  See how it's shifted two to the left?  Look at how the text "Iteration Meeting Notes" loses some of its formatting to the phone number on the line above it.
* Spelling mistake squiggles do not match all the same characters. I think this should probably be disabled during printing, though.

I am not able to get this to work at all using gtk-sharp 2.10 on Windows (which I think has known printing bugs).  I get SEHException {"External component has thrown an exception."} on line 44 (op.Run).  As I've mentioned before, I am not opposed to requiring 2.12 on Windows, but I need to test this a bit more.
Comment 24 Sandy Armstrong 2009-01-31 21:52:47 UTC
Created attachment 127665 [details]
PDF output of printing my wicked test note with the old addin
Comment 25 Sandy Armstrong 2009-01-31 21:59:57 UTC
Created attachment 127667 [details]
PDF output of printing my wicked test note with the new addin

Biggest regressions:
* Spelling squigglies
* Weird character/symbol near the first bullet
* Shifted formatting

Things I like in the old one:
* Wider margins and taller header/footer area
* Footer with page/date info

It's hard for me to tell, really, but does the older text look "cleaner" to anybody else?

Anyway, given this comparison, I'll happily accept this patch once it's cleaned up a bit as discussed in a previous comment.  All of these regressions should be easy to fix (and won't be affected by upcoming UI/string freezes).  Shouldn't be long before this is clearly superior to the current addin. :-)
Comment 26 Benjamin Podszun 2009-02-01 14:47:27 UTC
Created attachment 127700 [details] [review]
Support for printing using the gtk 2.10 api

I'm still looking into this, especially regarding comments/formatting/styles, but I'd like to drop it here to a) remove the old stuff and b) get some feedback on linux, if possible.

To comment on your notes:

Standards:
* I'm fighting VisualStudio here regarding Whitespaces. If that doesn't work out, I'll reformat the stuff on my netbook using MD or vi
* I'd be glad if you could look into build setups, at least for Mac/Linux
* I tried following the codestyle better this time, but I'm willing to reformat the patch if you point me to some mistakes
* Pango.Units.FromDouble was removed/replaced

Functionality:

* Bullets are indented now. The weird character doesn't show up for me anymore
* Messed up formatting is fixed/doesn't happen anymore
* "Spelling mistake squiggles" are the biggest issue for me right now, since I don't see them here. I guess there's no spelling support on Windows. I know how to fix it, but I need to build/test it on a system with spell check. I'll try to fix that tonight.

Things you like in the old one:
* There are some margins now. Unfortunately they are fixed/magic numbers. I work on that.
* There's a similar footer to the old one. Again, fixed (not localized for example). On my list though.

Feedback is welcome. Since these are the first patches I submit to anything I'm pretty sure there's something wrong again. ;)
Comment 27 Sandy Armstrong 2009-02-01 15:52:13 UTC
As I mentioned in IRC, this is not working correctly for me in Linux on US Letter (though I can't choose page size, I only assume it's set to my default):

* The top/bottom margins are huge, and eventually text runs off the page.
* I get some sort of black bar at the bottom of each page, but no legible footer.
* Squigglies are still there for me.

That being said, the text is looking great! We just need to get the margins fixed...the footer isn't the most vital thing right now.

As for localizing the footer, yeah we should do that (the old one did):

#: ../Tomboy/Addins/PrintNotes/gedit-print.c:434
msgid "Page %N of %Q"
msgstr "Page %N sur %Q"

#: ../Tomboy/Addins/PrintNotes/gedit-print.c:437
#, no-c-format
msgid "%A %x, %X"
msgstr "%A %x, %X"


Fixing spelling squigglies should be easy...just don't copy over underline attributes when tag.Underline == Pango.Underline.Error .  I can implement and test that, since I'm already on Linux...don't worry about it.

I'll commit this tonight in whatever shape it's in; I think it's pretty clear we can fix whatever the current bugs are.  All I'll need to do is make sure it has build support on all platforms, and I'll fix up the translatable strings so that they are ready as soon as possible (and I can send just *one* "I changed strings" email!).
Comment 28 Sandy Armstrong 2009-02-02 06:16:01 UTC
I committed a somewhat modified version of your patch.  Changes I made:

* We use tabs instead of spaces...I wouldn't be surprised if you misread the coding guidelines to mean the opposite (I did that once, and we converted all tabs in Tomboy to spaces, and then back...eek!)
* Fixed the squigglies
* Took care of the translatable strings
* Enabled in build, deleted old C code from SVN

Committed for Linux in r2313.  Will update Windows and Mac builds now.

Leaving this bug open until we fix the margin problems.
Comment 29 Sandy Armstrong 2009-02-02 07:58:49 UTC
Committed for Windows in r2314.  Please note that I made a few more minor changes to the addin.  A less minor change is that it displays an error dialog if an exception occurs during printing (happens for me on Windows with gtk-sharp 2.10).  Make sure you submit patches against latest SVN. :-)
Comment 30 Sandy Armstrong 2009-02-02 08:24:24 UTC
In the Mac build in r2317.
Comment 31 Andreas Proschofsky 2009-02-03 16:00:21 UTC
configure is still checking for libgnomeprint|ui, shouldn't that be gone now?
Comment 32 Sandy Armstrong 2009-02-03 16:37:18 UTC
Good catch suka.  Fixed in r2322.
Comment 33 André Klapper 2009-02-03 17:21:00 UTC
The dependency on libgnomeprint has been removed (great, thanks so much), hence I updated the wikipage and set this to "done" state.
Comment 34 Benjamin Podszun 2009-02-15 21:26:12 UTC
Created attachment 128795 [details]
PDF output of printing my wicked test note with my working copy

Okay, I think I finally fixed the issues. There are however still some things that bug me a lot: Margins are fixed (I want to add a configuration panel for that), indentation for bullet-lists doesn't look good if the list item is wrapped. It's

  * foo bar baz imaginelotsoftext
  continues below the bullet

instead of

  * foo bar baz imaginelotsoftext
    continues aligned with the item text

In addition the code is still too heavily related to the C source from gtksourceview. It could be simplified (and C#-ified) in quite some ways. If the maintainer(s) agree I'll get back to this plugin as soon as the code and string freeze is over again.

Cleaning the patch up now and submitting it later tonight.
Comment 35 Benjamin Podszun 2009-02-15 22:21:29 UTC
Created attachment 128797 [details] [review]
Support for printing using the gtk 2.10 api

Last version of the migration to the gtk print api. This version works for me (tm) on Windows and Linux. The wicked/weird test note renders correctly. Some issues remain, but those (see my pdf attachment + comments) are cosmetic and no regression imo.
Comment 36 Sandy Armstrong 2009-02-16 03:41:38 UTC
Your PDF looks great Benjamin! Unfortunately it doesn't look as perfect on my system, so we'll have to figure out what's up.  But I'm going to commit this patch in just a bit anyway (and I'll also attach my PDF output to show you what's going on).

Thanks for the great work!
Comment 37 Sandy Armstrong 2009-02-16 15:31:36 UTC
Committed in r2339.

Actually, I am going to close this bug.  There are still some issues, but they will not stop me from shipping it.  I really hope we can fix them before 0.14.0 but I consider the port to GtkPrint to be a done deal now, regardless.

Thanks Benjamin for the awesome work.  I'm going to open a new bug about the margin problems I am experiencing.
Comment 38 Sandy Armstrong 2009-02-16 15:39:19 UTC
Margin (or page size?) problems documented in bug #572024.
Comment 39 André Klapper 2009-02-16 15:42:37 UTC
Also a big "Thank you!" to Benjamin!