GNOME Bugzilla – Bug 512369
Port to GtkPrint
Last modified: 2009-04-23 02:14:35 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.
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.
Setting the default assignee and QA Contact to "tomboy-maint@gnome.bugs".
*** Bug 520747 has been marked as a duplicate of this bug. ***
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 ;)
I will start to work on the port this development cycle.
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.
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.
Created attachment 109429 [details] Output from note with long paragraphs.
Created attachment 109430 [details] The note I was trying to print.
Thanks for starting this, John! Unfortunately I did not find much time to work on it.
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
Created attachment 110753 [details] [review] Basic printing, handling paragraphs and pages.
Committed in r1997. Trunk now requires gtk-sharp >= 2.10.
So can we close this now?
(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.
Backed-out before 0.12.0 because there were too many problems.
*** Bug 559236 has been marked as a duplicate of this bug. ***
Just out of interest: What is the status of this?
No news. Volunteers welcome. I think I lost the improvements I had been working on...
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
Yup. May not get fixed this cycle. :-(
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
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.
Created attachment 127665 [details] PDF output of printing my wicked test note with the old addin
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. :-)
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. ;)
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!).
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.
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. :-)
In the Mac build in r2317.
configure is still checking for libgnomeprint|ui, shouldn't that be gone now?
Good catch suka. Fixed in r2322.
The dependency on libgnomeprint has been removed (great, thanks so much), hence I updated the wikipage and set this to "done" state.
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.
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.
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!
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.
Margin (or page size?) problems documented in bug #572024.
Also a big "Thank you!" to Benjamin!