J5’s Blog

March 24, 2006

Gtk+ now has Printing

Filed under: Gnome, Linux, Recreation — J5 @ 5:53 pm

Alex Larsson has merged our work into the gtk-printing branch of gtk+ in gnome cvs. I am in the process of making an srpm so Fedora users can play with it and Matthias Clasen has created a gtk+/printing component in bugzilla. I am sure there are a lot of bugs. We should be doing a talk at GUADEC this summer on the new API.

To all those that are excited about the new dialog, keep your expectations in check. I’ll post screenshots this weekend but it looks a lot like the old gnome-print dialog. This is because printing in itself is unexciting (I sort of like it in that respect). While great work was done at the Boston Summit much has changed since then. Things may change more yet given the input of others.

The coolest part of the new API is the highlevel API itself. All one needs to do to print is show the dialog and then write to the cairo surface provided by the API. If your app is already using cairo it should be a snap to add the new printing API.

Other News:

I went with 1and1.com for my hosting. martianrock.com may be down for a bit as I need to transfer the domain. I have also registered a couple of other domains:

  • johnpalmieri.info will be an about me page that details things like my current projects, what the J5 means and current happenings for friends and family.
  • j5live.com and j5live.cc will both be repositories for my Creative Commons contributions but may expand to cover others. Not sure yet exactly what I want to do but it can be thought of as a place for content distribution.

Thailand:

I will be away in Thailand for two weeks starting the middle of next week. Chances are I will not be able to be reached after th 28th. If any Gnome or FOSS developer wants to meet up let me know. I’ll be all over but in Bangkok for the first few days. I’m not promising I’ll be free but it would be nice to see the community in action half way across the world.

[read this post in: ar de es fr it ja ko pt ru zh-CN ]

7 Comments

  1. I’m just wondering, is there any document somewhere stating and explaining the good reasons (that must exist… but which I can’t see) about why GTK+ printing API has been written from scratch instead of reusing libgnomeprint(ui) ?

    Comment by Colin — March 25, 2006 @ 7:51 am

  2. gnomeprintui uses threads, doesn’t work under Windows or MacOSX, and doesn’t use cairo for rendering. We went through all the API’s out there including Windows, Java and MacOSX and decided on this one. On the face of it it is a simple API that we feel will be suportable for years to come.

    Comment by J5 — March 25, 2006 @ 12:14 pm

  3. Cairo printing from Gtk+ is cool! I can’t wait.

    One thing troubles me, though: “All one needs to do to print is show the dialog and then write to the cairo surface provided by the API”.

    This is true for trivial examples, but the big issue with printing is pagination. I’ll hold off my celebration dance until I see how that was done.

    Another question is text. If you’re just drawing with Cairo commands, then printing is easy. But what if you have a lot of text to print? Can I pass, say, an HTML string to the Gtk+ printing system, and have it correctly formatted and paginated? Is there a way to intersperse it with my own Cairo drawing commands?

    Cairo printing is awesome — it’s a great graphics system to build a printing system upon. But by itself, it’s not a printing system. It’s not the correct layer of abstraction for most apps I’ve written.

    Comment by Ken — March 27, 2006 @ 3:11 pm

  4. The idea is if you write you app to display with cairo you would use the same commands (or similar) to print. Text in cairo is handled by Pango which has a markup language which is a very small subset of HTML but for the most part you mark up with attributes.

    Pagination is done by the app (Pango has the ability to do layouts). A signal is emitted for each page which give a cairo context to draw on. Check out printedit a simple text editor for details:

    http://cvs.gnome.org/viewcvs/libegg/libegg/print-operation/printedit.c?rev=1.8&view=markup

    Comment by J5 — March 28, 2006 @ 12:35 am

  5. The new printing API is interesting, but for the project I was working on all of the drawing was done using GDK.

    Is there a way to either save the gdkPixbuf and then have the image drawn to the cairo surface, or could I draw the gdkPixbuf straight to the cairo surface.

    Thanks for any help.

    Comment by jsmith — August 11, 2008 @ 11:13 am

  6. if you have a new enough glib then there should be a method called gdk_cairo_set_source_pixbuf

    http://library.gnome.org/devel/gdk/stable/gdk-Cairo-Interaction.html#gdk-cairo-set-source-pixbuf

    If not then I suggest copy and pasting the code, but make sure you abide by the LGPL license if you are not a GPL’ed or LGPL’ed app.

    Comment by J5 — August 11, 2008 @ 11:37 am

  7. I thought that function would set cairo drawing calls to draw to the pixbuf, not the other way around.

    I’ll try it though. Thank you.

    Comment by jsmith — August 11, 2008 @ 11:58 am

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress