Bug 24796 - DCR - No printing on Linux GTK
Summary: DCR - No printing on Linux GTK
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.0.2   Edit
Hardware: PC Linux-GTK
: P3 enhancement with 46 votes (vote)
Target Milestone: 3.3 M1   Edit
Assignee: Carolyn MacLeod CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 43284 48107 53367 77695 80683 95995 107715 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-10-15 12:32 EDT by Mark CLA
Modified: 2007-04-16 16:40 EDT (History)
55 users (show)

See Also:


Attachments
Postscript output produced by a SWT Print snippet (GTK port) (2.67 KB, application/postscript)
2004-04-17 15:13 EDT, christophe dufaza CLA
no flags Details
SWT snippet patched to involve printing multi page documents (3.58 KB, text/x-java)
2004-04-17 15:20 EDT, christophe dufaza CLA
no flags Details
Archive that contains source files and ps exemples for SWT/GTK Print (141.44 KB, application/x-java-archive)
2004-04-20 05:51 EDT, christophe dufaza CLA
no flags Details
Image of how I set up kwrite to do printing (69.93 KB, image/jpeg)
2005-11-26 15:15 EST, Kim Lux CLA
no flags Details
Screen snap of print dialog (39.28 KB, image/png)
2006-05-17 17:25 EDT, Carolyn MacLeod CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark CLA 2002-10-15 12:32:39 EDT
The print option is greyed out on the File menu, on the toolbar, and Ctl-P
doesn't work to print.

I was running 2.0.1, but upgraded to 2.1 to see if that made a difference.  I am
using SuSE 8.0
Comment 1 Steve Northover CLA 2002-10-16 12:34:50 EDT
Printing is not implemented yet on GTK.  Not sure GTK even provides an API.  
Felipe to investigate and advise.
Comment 2 Felipe Heidrich CLA 2002-10-17 10:51:21 EDT
As far as I know gnome applications can use gnome-print or gimp-print.
There are other options like CUPS, anyway I don't know if any of these options 
can be integrated with our SWT/GTK port.

I'll look at this issue in the future.
Comment 3 Roland Mainz CLA 2002-10-19 02:51:17 EDT
Felipe Heidrich:
Can the existing (AFAIK Xprint-based) printing code be reused for the GTK+ port
?
Comment 4 Felipe Heidrich CLA 2002-10-23 09:50:22 EDT
We've thought about it, but it's not going to work.
It would be a option if we could access some of the X resources that Gtk is 
using underneath. I'm afraid is not possible.

Comment 5 Ricardo Jorge PC de Almeida CLA 2002-11-08 10:14:25 EST
What about the option to use an external program?
At least for me would be great just to have a print button that calls:
    enscript -Ejava <filename>
Comment 6 Felipe Heidrich CLA 2002-11-08 11:26:37 EST
Ricardo, this solution does work for SWT at all, but maybe you could suggest 
this for the UI team (I don't think they will accept it though).

If I were you I would write my own printing pluging using this idea.


Comment 7 Daniel Küstner CLA 2003-02-01 15:43:00 EST
Can see this also on linux-motif with 20021218304 (M4).
Comment 8 Veronika Irvine CLA 2003-03-28 09:29:39 EST
Adding Nick to this bug report.

Nick,

There is no GTK API for printing.

The proposal here is to use another application for printing.  This is not 
something SWT would provide access to, however, is it possible that the 
workbench could use this mechanism?
Comment 9 Nick Edgar CLA 2003-03-28 09:56:24 EST
Since there appears to be no native means of printing on GTK that can be 
provided by SWT, I'm moving this PR to Platform UI as an enhancement request.

The Workbench currently only provide the File / Print retargetable action, and 
no concrete implementations.  The only concrete implementation is in the text 
editor, provided by Platform-Text, so I'm adding Kai to the cc list.

If the Workbench were to adopt a printing story which allows external programs, 
then we could provide the preference page for configuring it, but clients like 
the Text Editor would now have to handle two different ways of printing (SWT 
vs. external program).

Note that with the External Tools support, it would be straightforward to have 
an external program to print the selected file.

Comment 10 David J. Orme CLA 2003-03-28 11:17:33 EST
Could someone point me to the SWT printing APIs that are unimplemented on GTK. 
I'd like to take a look at this problem a bit before we punt and say it can't be
done.

Also, could Felipe explain what he found wrong with either the gimp-print or
gnome-print APIs (both built on top of GTK) such that these were not usable. 
Having this context would really help me get started faster so I don't duplicate
effort that Felipe already did.


Thanks,

Dave Orme
Comment 11 Nick Edgar CLA 2003-03-28 11:39:42 EST
Felipe, can you address Dave's last comment?
Comment 12 Nick Edgar CLA 2003-03-28 15:05:25 EST
Moving back to SWT since David is interested in pursuing an SWT-based printing 
solution on GTK.
Comment 13 Veronika Irvine CLA 2003-03-31 11:31:17 EST
Printer is a subclass of Device and must be able to be used as a Device.  In 
order for SWT to support printing, you need to be able to create a GC on the 
printer device and support all the GC calls. I do not think this is what gimp-
print or gnome-print provide.


To see the unimplemented behaviour, start with 
org.eclipse.swt.printing.Printer.
Comment 14 Felipe Heidrich CLA 2003-03-31 12:21:22 EST
Dave, when I locked into gimp-print and gnome-print I could not figure out how 
I could use this libraries to render GdkGC calls to a print device. 
Anyhow, take a look in org.eclipse.swt.printing.Printer, specially the method 
internal_new_GC. I don't know much about gimp-print and gnome-print, you won't 
be duplicating any effort looking at this problem.

Comment 15 David J. Orme CLA 2003-04-02 11:58:52 EST
Preliminary results:  There are two approaches that are both probably feasable:

- Gnome-print

- Write a Printer device that passes Postscript to the platform printing system
(on Unix, normally via lpr or equivalent)


Advantages of Gnome-print: 

- Handles basic alpha channels (transparencey) automatically.  I don't know if
we care about this.

- Can output Postscript, the standard for Unix printing.

- Supports generating printer bitmaps directly, the way Windows printer drivers
work.

- Supports generating PDF files as printer output.

- More likely to work across all desktop platforms supported by GTK including
non-Unix-based ones.


Disadvantages of Gnome-print:

- Introduces quite a few dependencies:
       for libgnomeprint:    Pango/Glib/libart/libxml
       for libgnomeprintui:  above plus: gtk+/libgnomecanvas
           (We can probably get away without using libgnomeprintui since
            we provide our own print dialogs, etc.)

- Introduces another layer between SWT and the actual printing.  

owen@redhat.com writes (on IRC):

<owen> djo: gnome-print is not a bad idea, though you'll have to cover the
difference between that and GdkDrawable (they are entirely different) yourself.



Advantages of writing a Printer-to-Postscript filter:

- Architecturally, the simplest solution

- Matches the native Unix way of doing things

- Does not require additional libraries

- Many examples (in C, C++, and Java) of how to do this are available.


Disadvantages of writing a Printer-to-Postscript filter:

- It's potentially another layer to code and maintain.

- Would not support native printing on Windows unless the Windows user had a
Postscript printer.  Otherwise, it would require filtering through Ghostscript
on Windows.  As Scott Stanchfield would say, "EEEeeeeewwwww."



Conclusions:

Right now I'm leaning toward the printer to Postscript solution.  Gnome-print
depends on a bunch of libraries that may not be on a lot of people's computers
who have GTK+.  Just making people install all these other libraries (in correct
versions) gives me headaches thinking about all the mailing list and newsgroup
traffic it would generate.

Going with outputing a printer language file such as Postscript is the standard
for printing in the Unix world, the main people who will use SWT with GTK+ 

(Windows users should use the Windows version of SWT.  On the other hand, if
they want to use a Unixy library, they should be prepared to deal with the Unixy
way that it does things.)

Although I haven't evaluated the code yet, there appears to be a few decent open
source libraries for generating Postscript output using graphics calls.  These
have all been written to AWT-style calls, but that should provide a decent
starting place for an SWT rewrite.


Postscript:

If we provide a Postscript printer meta-language output, we also can probably
provide PDF output relatively easily (assuming appropriate abstractions are
introduced to support the SWT-to-AWT drawing conversions) as there are PDF
output open source libraries available.


What does everyone here think so far?
Comment 16 David J. Orme CLA 2003-04-02 18:12:27 EST
One more observation about the above proposal:

Providing a PostscriptPrinter object or a PDFPrinter object benefits all
platforms, not just SWT/GTK.

It just so happens that the standard way to print on Unixen is to pipe
Postscript to the lpr program, which is why I am proposing this as a likely
solution to printing using SWT on GTK.
Comment 17 Felipe Heidrich CLA 2003-04-03 10:31:34 EST
Dave, SWT team has already consider the idea of generating postscript, which is 
a very generic solution and would work, but we prefer to have a GTK solution 
for printing. If GTK doesn't not have support for printing we are afraid that 
there will be no print support for SWT-GTK port.
How does a GTK app print ? Do they need to use different libraries/packages ?

Please see Bug#15146
Comment 18 David J. Orme CLA 2003-04-03 15:50:14 EST
>>If GTK doesn't not have support for printing we are afraid that there will be
no print support for SWT-GTK port. How does a GTK app print ? Do they need to
use different libraries/packages?<<

Well, this has been the subject of quite a bit of debate in the Unix community
for some time.  Although I have never heard it explained this way, here is the
reason I believe that Postscript output has been and remains the de facto
standard way to print on Unixes (no matter what UI toolkit is being used):


The whole Unix mindset is that everything, even network protocols and the whole
graphical system, is just a file:  preferably an ASCII file that is
straightforward to parse.  Once you make that design choice, a whole bunch of
other things fall out of it naturally:

- Most coding problems ultimately boil down to one of three things:

 a) How to generate some language (that will be stored in a file)
 b) How to parse some language (from a file).
 c) How to translate some file from language C to language D and store it in
another file.

- The algorithms required to code all of this corresponds really nicely with the
categories of things you might want to do from theoretical computer science:

 a) Parse/generate/translate regular languages (regular expressions/finite state
automata).
 b) Parse/generate/translate/interpret context-free languages (context-free
grammars/push-down automata).
 c) Parse/generate/translate/interpret Turing-complete languages (Turing machines)

These are all well-understood problems with stable solutions that we can reason
about in a rigorous mathematical way if we want/need to.  So these are very
attractive features to have in an operating system for those who understand
theoretical computer science--most of the people who created and still use Unix
and Linux.

Consequently, you see that a huge number of the common Unix command-line tools
and scripting languages are really optimized for generating or parsing files:

ls, ps, 
grep, sed, awk, perl, lex, yacc,

CGI scripting is really just a way to reduce dynamic web scripting down to the
well-understood problem of how to dynamically generate a file.


- This explains why Postscript has been widely accepted as the "Unix"-way to
print: it fits neatly into the above view of the world.  Just generate an ASCII
file in some simple standardized page description language (ie: postscript),
then provide filter programs that can translate that language into any printer's
native language and copy the result to the printer's file descriptor.  It's a
known, well-studied problem and because it corresponds nicely to the underlying
theory, we can potentially reason about our solutions more rigorously and
accurately.


On the other hand, the other side of the argument contends that it's easier
intuitively to print if you just use your UI toolkit's normal drawing commands
to draw graphics on some drawable that conceptually corresponds to the printed
page.  This matches the Windows way of printing that appears to be where SWT got
much of its base design.


Personally, I think the whole argument is a wash from the application
programmer's point of view.  Really, generating something like:

/Times-Roman findfont
12 scalefont setfont
72 72 moveto
(Hello world!) show
showpage

or manipulating objects to do the equivalent of the above is going to require
code of similar length and complexity in either case.  Conceptually, it's just a
different representation for exactly the same commands.  In this case, I think
that both beauty and ugliness are in the eye of the beholder.


However, while researching this problem, I read additional arguments for
generating Postscript beyond the theoretical ones explained above:  In a number
of mailing list threads, people argued that if *applications* rasterize their
own page images, that you have two huge drawbacks:

1) Since the printed data stream is encoded in some opaque format, there is no
way to write print spooler software that allows IT to automatically account for
printer/paper usage.  However, when you generate Postscript, the print spooler
can interpret the Postscript just enough to count number of pages in print jobs,
etc., to bill printing costs back to departments automatically.  Or just so that
Jane knows that Joe started a 200 page job so she should take a coffee break
before sending her 2 page print job (or send the job to a different printer).

2) Under certain circumstances you can saturate the network if the printer is
connected remotely via some print server.  This also results in sub-optimal
printing speeds when the page size is huge (think fast HP inkjet plotters) or
when the DPI is high (think pre-press typesetters).


So that brings us to where we are today:

1) We have Gnome-canvas, a Windows-like printing API that is usable, but not
widely adopted across Unix applications.  As I noted yesterday, it also has a
number of library dependencies that we might want to think twice about requiring.

2) The Gimp and gimp-print, by themselves, are a red herring.  Gimp normally
just outputs Postscript, but can also use gimp-print as a plug-in to generate
nicely optimized output for a wide variety of consumer-level color inkjet
printers.  However, I found a number of mailing list messages indicating that
the gimp-print drivers are being migrated into Ghostscript.  The result is that
gimp-print isn't viable long-term as a way to generate printed output from some
standalone application.

3) Lastly, we have the majority of Unix applications--from WordPerfect,
OpenOffice, and Netscape to `enscript` (a command-line utility to translate
plain text files into Postscript) and everything in between--that just generates
Postscript output to be interpreted either by Ghostscript or by a Postscript
printer.  This appears not only to be the de facto standard way to do things on
Unix, but based on the mailing list traffic I described above, also appears to
be the best way to handle enterprise-level scalability needs.


All of that to explain two things:

1) That the answer to your questions ("How does a GTK app print? Do they need to
use different libraries/packages?") isn't totally straightforward because people
disagree within the Unix and Linux community about the correct answer.

2) However, the majority of Unix shops still prefer just to generate, translate,
and/or interpret Postscript from all of their Unix applications, GTK or not.


In conclusion, I believe that SWT-driven GTK apps ideally should print just like
any other well-behaved Unix citizen: by generating Postscript output.  Yes, this
probably means that the SWT for GTK port by itself may not provide printing
services.

However, as I pointed out yesterday, from the SWT point of view this doesn't
matter.  We can adapt any of the freely-available open source Java printing
solutions that generate Postscript using an API similar to SWT.  Or we could
implement the SWT printing API on top of any of the C or C++
Postscript-generating libraries just like the rest of SWT is implemented.



If this means that the GTK port doesn't have its own printing support, I don't
have a problem with that as long as a Postscript output driver for SWT is
provided instead and the Postscript output driver is selected by default on SWT/GTK.


Comment 19 David J. Orme CLA 2003-04-03 15:56:02 EST
>>We have Gnome-canvas, a Windows-like printing API that is usable, but not
widely adopted across Unix applications.  As I noted yesterday, it also has a
number of library dependencies that we might want to think twice about requiring.<<

I meant to say, "We have Gnome-print..."
Comment 20 David J. Orme CLA 2003-04-03 16:03:50 EST
One last thought:

One design goal of SWT is to provide a native platform experience as much as
possible.  With regard to printing, this means that there needs to be a
preference page somewhere or a place on the SWT print dialog on GTK where the
print command (usually "lpr") is configured.  Looking at other Unix-based apps
may be useful here:

Netscape: Put the print command on the print dialog itself.

WordPerfect: Configure the print command as a part of the printer.


Alternatively, we may just want to provide a property on an object where the
print command is set and leave it to platform/UI and the standalone developers
to set this value properly from a preference page.

Comment 21 David J. Orme CLA 2003-04-03 18:02:50 EST
Some Java drawing to Postscript/PDF libraries links:

http://www.geocities.com/morris_hirsch/java/how_to_print.html

http://www.geocities.com/marcoschmidt.geo/java-document-libraries.html

I haven't evaluated these yet; I'm just sticking them here so everyone knows
what I've found so far.


Comment 22 Steve Northover CLA 2003-04-14 10:38:33 EDT
FH to track this.
Comment 23 Nick Edgar CLA 2003-09-22 12:07:39 EDT
*** Bug 43284 has been marked as a duplicate of this bug. ***
Comment 24 Andrig T Miller CLA 2003-10-26 01:18:13 EST
I just started working in earnest with Eclipse on Linux, using the GTK version,
since I use GNOME.  I also just discovered that you cannot print!  Having
tracked this down, to this enchancment request, I see that nothing appears to
have been done since April of this year.  Is there anyone still working on this
issue?
Comment 25 Mark CLA 2003-10-27 12:06:49 EST
Unfortunately, I have had seen no activity outside this watchlist.  I would 
love to help, but I would cause more trouble than I could fix.
Comment 26 Felipe Heidrich CLA 2003-10-27 14:15:16 EST
Unfortunately, printing on GTK is not in the Eclipse 3.0 plan.
Further, we still don't have a solution for this problem, none of available 
technologies that I looked at (gimp-print, gnome-print, cups, etc) address the 
problem that need to be solved by SWT, which is: given a gdkgc render all the 
drawing to a printer instead of a window/display.
Comment 27 David Joham CLA 2003-10-27 14:18:27 EST
Can you be more specific about what you mean please? If I understand correctly, what 
you need is something that doesn't require SWT to render the print job into a printer 
language (i.e. postscript) - you want the printing system to do that. 
 
Am I correct? If so, what would you expect to send to the printing system? 
Comment 28 Felipe Heidrich CLA 2003-10-27 14:39:08 EST
Yes, you are correct.
What is send to the printing system is up to the toolkit underneath swt, on X 
swt uses exactly the same X calls to draw either on a window or to a printer. 
Internally, XP (X printing extension) will translate the X calls to the 
appropriate language to be send to the printing system.
The same on windows, but we use windows/GDI calls instead.

I hope I answered your question.
Comment 29 David Joham CLA 2003-10-27 16:23:11 EST
 
Couldn't you just save the file the user is trying to print into /tmp and then call an 
external printing program? In the most rudementary example, I created a simple text file 
in vi and then did the following command from the console 
 
lpr <textfile.java> 
 
It printed just fine. Since one could expect that eclipse users would only be printing 
standard text, wouldn't this work? 
 
I'm sure with a little effort, you could extend this to work with any print system (kprinter 
in my particular case) 
 
David 
Comment 30 Alexandra Stehman CLA 2003-10-27 16:26:14 EST
Sure you could lpr text files.  But for those of us who are using UML tools such
as Borland's Togethersoft Plugin for Eclipse, there isn't any good way to do this.
Comment 31 Felipe Heidrich CLA 2003-10-27 16:43:16 EST
That is not what printing on SWT does. Still, one could easily write a eclipse 
plugin to print out files using external programs, but that is not a solution 
for SWT.
Comment 32 Daniel Le Berre CLA 2003-10-27 16:47:28 EST
And more generally, any plugin using GEF would have some problem to print.
(e.g. EclipseUML)

However, I miss the printing feature on GTK. It is IMHO undelievable that such a
feature is missing on a "supported" platform.
Comment 33 Jared Burns CLA 2003-10-27 17:21:50 EST
It's not a real solution, but if anyone's interested I should point out that you 
can use the External Tools support in Eclipse to print files using external 
programs. Just create a new Program launch config from the External Tools dialog 
(Run->External Tools->External Tools...) that launches your favorite printing 
utility and you can pass the selected resource as a parameter.
Comment 34 David Joham CLA 2003-10-27 18:11:02 EST
 
OK, just so that I understand properly, SWT wants to "paint" it's printed canvas the 
same way it draws it on the screen. Is that right? 
 
Putting aside religious wars about widgets, would it be possible to use Qt/KDE to 
implement a proper print solution for SWT? Take a look at: 
 
http://printing.kde.org/developer/tutorial/basic.php 
 
KPrinter inherits from QPaintDevice, such that you can draw on it as on a normal 
QWidget. The drawing primitives are then converted to PS code instead of shown on the 
screen. You should thus consider the KPrinter object as a usual drawing area.  
 
That would seem to behave in a manner consistant with what SWT expects. I'm not 
advocating a switch to Qt (although I would really love to have a Qt version of SWT) but I 
am curious if that widget set would solve this particular problem. 
 
David 
Comment 35 Felipe Heidrich CLA 2003-10-27 19:02:10 EST
"OK, just so that I understand properly, SWT wants to "paint" it's printed 
canvas the same way it draws it on the screen. Is that right? "
Right.

The solution you pointed out would be perfect for a Qt port, what doesn't 
exist. We would need to have a GTK equivalent to that.
We can't use Qt in the middle of our GTK port, there is technical reason for 
that as well as a legal one (I believe so).

thanks for information.
Comment 36 David J. Orme CLA 2003-10-27 22:33:06 EST
All of these comments are correct about what is needed.

There are links above to example Java code that does exactly what you want
(output Postscript based on graphics commands on a canvas), but for AWT.  Using
that code as a reference it should be straightforward, if a bit tedious, to
create a similar implementation for a SWT GC.

I have no time right now or I'd do it.  So I did the next best thing and
documented it so someone else can do it.

Good luck.
Comment 37 Felipe Heidrich CLA 2003-10-28 10:51:41 EST
David, thank you for the documentation. But just like you we don't have time 
to implement it in time for Eclipse 3.0.
Comment 38 Daniel Le Berre CLA 2003-10-28 11:10:43 EST
It is no longer a big issue since printing using external tools works perfectly.

(most people under linux can install a2ps to print java code, or text files).

It would be great to add a note about it on the GTK release notes.

Printing diagrams with GEF related plugins remains a problem.


Comment 39 David J. Orme CLA 2003-10-28 11:27:46 EST
Believe me, Felipe, I can appreciate not having enough time to do it yet. :-)

Actually, I was hoping someone else in the open source community would step
forward and do it.  Like I said, I don't think it would be that hard....  ;-)
Comment 40 Carolyn MacLeod CLA 2003-10-28 11:31:27 EST
The original problem with generating postscript was that we decided that SWT 
was not in the business of writing yet another postscript-generation package. 
We have some "generate-postscript-from-SWT-drawing-calls" code that was 
written a long time ago by a student. I can probably find it somewhere. At the 
time, it looked like XPrint was the correct way for SWT to go, however time 
has shown that XPrint is not well supported. So clearly, we either have to 
help support XPrint, or generate postscript. Or find a correctly-licensed 
postscript generating package that we can include in eclipse. None of which we 
have time for in the 3.0 time frame.

Thank-you to Jared for his external tools suggestion. I will make sure that it 
gets into the SWT FAQ and the GTK release notes.
Comment 41 David J. Orme CLA 2003-10-28 12:28:27 EST
I'm confused and frustrated.

Are you saying that the opinion of the SWT team is *still* that you're not in
the business of maintaining a SWT to Postscript library--even though this is the
platform-native way to print on Unixes?

If that is the case, can you *at least* reply to the lengthy comments that I
posted above about why I believe that this is the best choice for SWT?

If this is not the case, and you have been convinced that generating Postscript
is probably the best way to go on Unixes, please make this clear.

I just spent an hour locating PSGr (the most widely-used AWT-to-Postscript
library for Java) since it's no longer available at Sandia National Labs where
it was written and then looking at the code to see what it would take to do a
rewrite for SWT.  If the SWT team isn't going to support this effort then I'm
wasting my time.

<frustrated>Please at least be clear about what you will support!</frustrated>

:-}


Comment 42 Carolyn MacLeod CLA 2003-10-28 13:59:48 EST
Sorry, I thought I was clear. The answer is that we haven't decided yet. 
Someone needs to take the time to do the research, and there just hasn't been 
time for that in this round. Your arguments are very convincing, and my guess 
is that we will find that there are simply too many XPrint issues. If that is 
indeed the case, we will look at using a postscript-generation package. But 
the license will be very key. We would have to (a) like the package and 
believe that it will work for us, and (b) get a lawyer to read their license 
and allow its use in our code. Obviously an AWT package won't work unless it's 
rewritten. But even rewriting code is considered to be "using" it, and it is 
imperative that we do not introduce any "viral" licensing issues/problems into 
SWT (and hence, into all of eclipse). This is very very very important, and I 
urge you to read the PSGr license very very carefully before continuing along 
that path. (I haven't read it - it might be ok. The bottom line is that anyone 
who uses the source must not be forced to provide their source to their 
customers, and they must not be forced to give their product away free). If 
you are certain that the license will not be a problem, then I encourage you 
to submit a trail implementation of the SWT printing API on a PSGr rewrite. 
You can submit it to this bug report, or to the SWT newsgroup, or to the SWT 
mailing list. Your time so far has not been wasted - you have our attention 
<g>. I cannot promise more than that at this time, and I am very sorry for 
that. I *can* promise that if you submit a sample implementation, we will take 
it seriously. (And if you submit a complete implementation, we will take it 
very seriously <g>). Please see the FAQ section of this link for more info on 
the licensing issues: http://www.eclipse.org/legal/main.html
I can't stress that enough.
Comment 43 David J. Orme CLA 2003-10-28 14:14:35 EST
Okay; thanks for the clarification.

Comment 44 David Schweiger CLA 2003-10-28 20:25:40 EST
The mistake of using a own home grown postscript generator should be avoided.
Take a look at OO and esp. Mozilla. Lots of problems, many bugs, poor print
quality and a huge amount of code will make it a painfull full time job to get
such a code working and maintained. Just think about font handling (TTF/OTF
fonts, CID subsetting), Postscript level versions (not all printers support
Type42 fonts and Unix/VMS systems do not have ghostscript installed by default),
incompatibilites and printer firmware bugs. And you would have to support at
least CUPS. And then LPRng (because CUPS-haters will demand on it). And then all
the seperate platform specific spoolers on AIX, HPUX, Solaris, VMS etc.
There are no APIs available which will handle the details for you, except
gnome-print and XPrint (I am thinking here about the version from
http://xprint.mozdev.org/ or those available on Solaris/HPUX).

gnome-print may be an option if you do not want to care about memory/resource
usage, an extra API layer to wrap all GdkGC calls (and seperate
refcounts/objects), a dependicy on lots of gnome libraries and incompatibilities
to non-CUPS spooler systems.

The remaining option would be XPrint. The version from xprint.mozdev.org solves
the problems listed above in a quite simple and clean manner. What about trying
to consult the mailinglist [http://xprint.mozdev.org/list.html] and ask for help?
Comment 45 David Schweiger CLA 2003-10-28 20:28:41 EST
Carolyn MacLeod:
> and my guess 
> is that we will find that there are simply too many XPrint issues

Can you summarize the issues you are thinking about, please?
Comment 46 Felipe Heidrich CLA 2003-10-29 11:49:36 EST
David, although you think using Xprint is a simple and clean solution I can 
not see how it could be implement. Actually, we consider the possibility long 
ago (see comments #3 adn #4). The print implementation on motif open a Display 
and create a Drawable window on it. With this elemtents we can create a XGC 
anytime. But to create a GdkGC we need a GdkDrawable and I don't know how to 
come from a Display and a Drawable (X elements) to a GdkDrawable.

Comment 47 Jared Burns CLA 2003-11-21 13:31:59 EST
(changed summary to make searching for "linux print" turn up this report)
Comment 48 Grant Gayed CLA 2003-12-05 14:16:42 EST
*** Bug 48107 has been marked as a duplicate of this bug. ***
Comment 49 Miike CLA 2003-12-10 16:39:18 EST
> Thank-you to Jared for his external tools suggestion. 
> I will make sure that it gets into the SWT FAQ and the GTK release notes.

Could someone maybe post here how the "external tool" or plugin workaround
works ? There is no single word about printing in the GTK readme file, and
its realy annoying to be unable to print under linux.

I think its very sad that eclipse under windows can print but not under linux.
An open source, freeware project like eclipse should not have better M$ support
then linux support imo.

Thanks though and sorry for posting here.
Comment 50 Carolyn MacLeod CLA 2003-12-10 17:18:56 EST
Sorry - I added the following link to the SWT FAQ but forgot to mention it in 
this bug report.

http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/platform-swt-
home/faq.html#printOnX

I asked the owner of the GTk readme to update it, but I guess it wasn't done.
I will try to find the master copy and paste the link there.
Comment 51 Carolyn MacLeod CLA 2003-12-10 17:51:55 EST
OK. I looked for a GTk "readme" or "release notes" among the files owned by 
the SWT team, and I didn't find any. (This is undoubtably why the Gtk 
implementation owner couldn't update it for me). The only thing I can find 
that is even close is a file called "about.html" containing License, Binding, 
and Contribution info. This is not the place to put the "how to print" info.

So I looked at the bigger picture - eclipse itself - and I see that there is 
an eclipse/readme/readme_eclipse.html that contains release notes.  My best 
guess is that this is what you mean. At the top of this file is a notice that 
reads:

"Last revised May 22, 2003
[These release notes have yet to be updated for the 3.0 development stream.
What follows are the 2.1.0 release notes.]"

So I suspect that even if I could figure out who owns this file, it is 
probably "frozen" until the 3.0 release. I realize that that is not a very 
helpful thing for me to say. I hope that for now, the SWT FAQ is helpful for 
you.
Comment 52 DJ Houghton CLA 2004-02-29 19:26:28 EST
*** Bug 53367 has been marked as a duplicate of this bug. ***
Comment 53 christophe dufaza CLA 2004-04-15 19:49:28 EDT
One can find my (humble) overall feeling about the "Is un*x/gtk a supported
platform ?" issue in a message I just post to the eclipse.platform.swt newsgroup.
This comment is only about proposing a technical solution for the this topic.

I understand the SWT developers (according to Veronika Irvine) who stand : we
want a solution that supports the nice pattern we choose, that is printing must
be addressed the same way graphic windows are, by drawing to a graphic context
(GC) object representing a device.

[supplementary support, page handling for example, being the responsability of
the Printer object, but everyone agree this is not the tricky part]

But I disagree with the assertion which stands that this pattern implementation
for the GTK port MUST directly relies upon a  corresponding GTK native object.
Comment #17 From Felipe Heidrich :
but we prefer to have a GTK solution for printing. If GTK doesn't not have
support for printing we are afraid that there will be no print support for
SWT-GTK port.

This oriented this thread to look strictly at the native side, including
solutions that involve gnome-print and/or gimp-print. Less or more direct
postscript generation has also been introduced. Several times David J. Orme post
very constructive comments and ideas.

But it seems now the situation is frozen to the (ridiculous regarding a
"supported platform") external-tool/plugin workarounds.

I would like to propose a solution that could get some consensus. And actually
contribute a usable implementation for it. As details bellow will show, this
would obviously involve some support from the SWT team.

What do we want ?
A complete port of the SWT printing API for the GTK platform.
For a user point of view, this means :
- be able to print source code from the editor view in the Eclipse workbench.
- be able to print diagrams from some GEF based plugins (for exemple UML tools)
- in one word : be able to print on gtk whenever the print command is available
on windows
 
Constraints :
- Respect the paradigm : "we print by drawing to the SWT graphic context"
- Do not include neither an internal postscript generation package to SWT, nor
add another supplementary dependency (gnome/gimp-print library, an external
postscript generation package) to SWT

Given :
+ The JAVA Grahics2D object implements all the drawXXX we find in the SWT GC class
+ The JAVA Printing API (and JPS) reference implementation on the un*x platforms
provides streaming (to a file or a printer) a postscript representation of a
Graphics2D
+ As dealing with postscript is the natural way of printing on the un*x
platforms, we can assume even a non postscript printer will flawlessly work on
any un*x box (this worked just fine on my linux box)


AFAIK, the SWT printing API usage may be described as :

// init (swt) printer and gc
printer= new Printer(..);
GC gc= new GC(printer,...);

// print an N pages doc : iter N times 
printer.startPage();
gc.drawXXX(...);
printer.endPage();

// release printer
gc.release();
printer.release();


so there are two jobs :
- patch the GC implementation to draw on an embedded Graphics2D when initialized
with a printer SWT device as in "new GC(printer)"
- patch the Printer implementation to use JPS to print/stream the previous
Graphics2D object

This solution involves no external library (just uses some new features of the
JRE 1.3 and 1.4), and is intended to pass the assumed constraints.

What we would prefer to know _before_ we start code, and that may need some
help/support from the SWT core developers, relates to the GC/Printer objects we
introduce having no native GTK peer. 

Though this peer is not involved in the printing process itself, this may lead
to SWT encountering some inconsistent situations I can't figure out.  

For example, I do not know how to deal with the 
int handle
property of the Printer device. I'm in doubt about returning a value that may
confuse some SWT internal registry.

Other calls that cause me troubles, for the same reason, are  :
int internal_new_GC(GCData data)
void internal_dispose_GC(int handle, GCData data)


Please, Veronika, Felipe, 

1) don't say us that an implementation of the "print via drawing to a GC"
pattern that does not rely upon any GTK native peer will hurt you _per_se_

2) don't object we didn't plan on how to integrate the page/printer setup
windows ; JAVA printing API should again provide a good start for this (still
having no GTK peer for them I admit), though I didn't investigate deeper on this
point ; but imho being able to print on the default printer using default paper
size is better that not being able to print at all. 

3) say us you may accept to give some help/support in dealing with this
internal/handle issues that trouble me, and that certainly require a deeper
knowledge of SWT than I have (and that may take me a lot of time to learn just
by reading the source code)

Finally, though testing the implementation via an autonomous SWT application
like the snippet above is the way to go, it would be rewarding to be able to
test the consequences on the Eclipse IDE behavior. For this I need to know how
to (globally?) enable the print feature for the gtk port, which I didn't find
yet. For example, is anyone aware of the place (in the code or properties files)
where the print command is disabled for the gtk port of the Eclipse IDE workbench ?

I hope this post will help in solving an issue for which the current status may
not please un*x users, who aren't so few I want to believe.

I'm sure if we demonstrate a solution that works, while not offensing the
overall design, the GTK port of SWT will one day support printing.

Best regards,
duf.
Comment 54 Carolyn MacLeod CLA 2004-04-16 00:16:39 EDT
I can answer one of your questions. Printing is enabled or disabled in the IDE 
right in the SWT printing implementation itself. Look at the implementation of 
Printer.getPrinterList(). If this returns null, or an empty array of 
PrinterData, then the IDE disables the Print... menu item.
Comment 55 David J. Orme CLA 2004-04-16 10:12:20 EDT
Regarding comment #53, I would fully support this solution.

Comment 56 christophe dufaza CLA 2004-04-17 15:13:09 EDT
Created attachment 9621 [details]
Postscript output produced by a SWT Print snippet (GTK port)
Comment 57 christophe dufaza CLA 2004-04-17 15:15:04 EDT
My original Comment #53 post was a bit more rude than the intent ; and I
sincerely apologize to anyone who felt it offending.

But since this, I did some coding as a proof of concept step, and found this
very encouraging, though I agree we'd have to deal with a few not so obvious issues.

Here's the feedback. 

As this proposition relies upon the JAVA2 Printing API (and may be upon JPS),
I'll start with a few words on its overall usage pattern, for those who don't
have it in mind.

This API sounded me a candidate for our topic as it also involves a "print
(postscript) via drawing to some graphic context (GC)" paradigm.
I will abbreviate package names, actual ones being under (all available with
JAVA SDK 1.3/1.4) :
- java.awt.print 
- javax.print 
[note: though the API is obviously designed to support any MIME types and/or
formatting, using postscript is by far the safest way on any un*x platform] 

Basically, you print via setting up an awt.Printable, that is overriding a print
method  as :
public void print(java.awt.Graphics g, PageFormat pageFormat, int pageIndex) {
	// all the g.setXXX() and g.drawXXX() here
}

This is called by the print api when the job is sent to the selected print
service. This means it's this api reference implementation that will "prepare" a
graphic context (actually a Graphics2D object) that represent the target print
device.

This is the root for the main constraint : 
after a 
swt.GC gc= new GC(new swt.Printer())
call, all subsequent requests to the swt GC must be delegated to an abstract GC
that stack them (as we dont't have any real gtk device for this), in order to be
able to replay (the awt equivalent for) these requests against the awt.Graphics,
when it will come to actually print.

For this I investigate three ways :

A) setting up an awt.Component comp_to_print and perform the job via 
1) comp.to_print.getGraphics().drawXXX() while stacking
2) comp.to_print.paint(gc) for the actual print job
this implies having an _active_ AWT/Swing container to get a non null
comp.to_print.getGraphics(), which imho we can't stand with : constraining a SWT
application to instantiate AWT/Swing windows when it comes to print will
immediately/soon be a mess. I'm not sure it's even possible.

B) using an AWT BufferedImage img via :
1) img.getGraphics().drawXXX() while stacking
2) gc.drawImage(img) for the actual print job 
this sounds better as it seems to represent less work to get the feature done,
but introduces significant issues:
- I found both through personal experience and through web resources (forums and
bug databases) that (1.3 and 1.4) SUN reference implementations had a few bugs
and issues regarding streaming to postscript the results of some gc.drawImage()
calls.
- you loose all features of producing vectorial  postscript, and get all
drawbacks of using rasters; particulary, text scaling produces awful output. 

C) using the command pattern
- commands.add(new GCCommand()) when stacking, GCCommand having DrawText,
DrawLine, DrawRectangle, and so on, subclasses
- iter on commands.elementAt(k).process(gc) for actual print
this involves more work but sounds cleaner

I think (and experienced) options A and B are unusable. The options C) gave me
interesting results.

This way I get the SWT Print API snippet
[http://dev.eclipse.org/viewcvs/index.cgi/platform-swt-home/snippits/snippet132.html]
to work fine on my linux/gtk port ; I created an attachment with generated
postscript file, so you can compare with windoz output (which I can't do).
I also extend the snippet (as to my 2nd attachment) to check the behavior with a
multi pages print job. and that's fine to.

[note: I finally choose to print to postscript files, and to stream one A4 page
per (numbered) file, for easier testing reasons, but targeting a real non
postscript printer works exactly the same, and this is not only possible on a
un*x box]

Though I had implemented less that 1/4 of the gc.drawXXX (and gc.getXXX) calls
in my abstract GC facade (and the corresponding commands), I wanted to get an
idea about the consequences upon the eclipse IDE.

Thus, I recompile the required stuff to use these modified (and new) classes,
and  tried to print a (text) file from the workbench text editor (thanx to
Carolyn who said me it was just so straightforward) ...

well, eclipse does not crash, but the output files, though correct postscript
files, appear just as blank pages ;-(

from what I see in the log, this is due to most of the drawXXX calls to the SWT
gc doesn't appear within a start/end page sequence (I use this sequence to sync
the commands stack).
as I didn't do much testing with this, and haven't yet dive into the SWT
StyledText stuff, I have no precise clue about what really happens, even not
enough ideas to request precise help on this.

I think we thus have a few area :

- the facade + command related design pattern : it's the most usable I get, but
if anyone is aware of an easier way, welcome ;-)

- scaling/clipping/coordinate/fonts/color/metrics issues : I intent to use the
actual awt print device properties to provide all these swt.GC.getXXX() calls
based upon their awt.Graphics2D printer device equivalent. so far, I think it's
not obvious, but doable

- internal GTK (gdk) handles : the way I use (and not use) them does not
currently crash the soft, neither throw any exception, but I'm sure there are
(currently) hidden consequences(*). I would greatly appreciate any pointer to
technical notes introducing to the swt/gtk mapping (notably about the context,
data, and handle concepts).
(*) this is also somewhat involved with failing to correctly print the text
editor content, but as I said, I don't know much about this now

- investigating about swt StyledText stuff, in order to get working the
integration with the eclipse IDE workbench. we have source code and documented
API. I hope I'll soon have more details about this.

- as it should be easy to get this working on any platform (for example using a
ghostscript driver as the printer), may we design it in order to integrate other
ports of SWT ? 

My plans are to polish a bit my (very starting-point) code, to a somewhat clean
and easy-to-read-design form, and make it available here as an attachment. This
would make possible for interested peoples to help me debug/fix/extend/refactor
to quickly see if it may be a viable solution or not. Particulary I hope this
will help the eclipse/swt guys to point out how we should deal with internal
handles (for example, they may tell us an unused range, but that's surely not a
cents of what we need to know).

There are certainly many points I miss, due to my low level knowledge regarding
both SWT and GTK, and any comment or suggestion may improve my understanding of
the overall.

Best regards,
duf.
Comment 58 christophe dufaza CLA 2004-04-17 15:20:22 EDT
Created attachment 9622 [details]
SWT snippet patched to involve printing multi page documents
Comment 59 Felipe Heidrich CLA 2004-04-19 11:18:11 EDT
Christophe, unfortunately I won't be able to look at your code right now. 
Printing support for GTK is not in the Eclipse 3.0 plan and we (eclipse-
developers) have only two weeks for code freeze and I'm very busy with other 
stuff. I'm sorry but I will only be able to look at your code after Eclipse 
3.0. Car, would you have some time available (note: IMO, implementing GTK 
printing would take at least two weeks (working fast))?
Comment 60 christophe dufaza CLA 2004-04-20 05:51:12 EDT
Created attachment 9687 [details]
Archive that contains source files and ps exemples for SWT/GTK Print

Files that relate to Comment #57. Obsoletes attachments #56 and #58.

examples: 
* ./out.ps (output produced by Snippet1.java)
* ./single-snipper.ps and /multi-snipper.ps (output produced by Snippet2.java)

java source files:
* org/eclipse/swt/graphics and org/eclipse/swt/printing
Comment 61 christophe dufaza CLA 2004-05-27 07:24:52 EDT
I didn't have so much time to spend on this topic these last times, but
here are the changes (regarding Comment #60) :
1) better page geometry handling : seems near good
2  better font metrics handling : seems near good, but vertical measure appears
bugy when running the word wrap snippet 
3) source code is now very easy to read and understand (imho), and the Printer
API documentation is updated to point out GTK port specific behaviors when needed
4) i can confirm that printing via a StyleText widget works as well as the
snippets, that is less or more well depending on the exact content. But it's
still impossible to print from an Eclipse IDE workbench text editor : does it
actualy rely upon a StyledText widget ?-) 

To encourage feedback (ideas about Workbench/StyledText or geometry issues) and
contributions (features as drawXXX), without overloading this thread,
i invite volunteers or interested peoples to visit the (temporary) URL :
http://perso.wanadoo.fr/openborges/opensource.html#GTKPrinting
There you will find latest status about this try, and the related
sources and binary downloads.

Felipe (and others), I know you're still working hard on the 3.0 final release,
and won't bore you more. but if you can have a read ;-)

best regards,
duf. 
Comment 62 christophe dufaza CLA 2004-06-14 11:22:09 EDT
this week-end I had some time for a more serious debug session, and found that
my tests were actualy based upon a simple text widget and _not_ a StyledText,
which confused me.

to be short, I didn't get that pango layout work was done directly _inside_ the
StyledText (and related) objects, and did not rely "only" upon the GC
implementation.
so I have re-implemented the handling of layout, styles (colors, fonts) and  tab
expantion  for the case of printing (ie. when there is no gtk device to do the
equivalent pango on) in the StyledText stuff.
given this, and bug fixes regarding styles and geometry, integration with
workbench editors now works fine (you can print styled cleanly formatted source
code from Eclipse).

I'm now running Eclipse dayly with this patched swt.jar, to see if my stuff may
reveal side effects (it surely will, since the GC class is somewhat largely
modified). I particulary worry about memory leaks. 

I will try to make the source code (as a patch against the current CVS stream) 
and detailed status available this week (see URL in #Comment 61).
interested end-users/testers may also feel free to request me for a binary build
(a patched swt.jar).

I hope blocking issues are now behind us, and that remaining work to a public
usable implementation is just adding the (numerous) missing drawXXX calls.

best regards,
duf.
Comment 63 christophe dufaza CLA 2004-08-29 19:24:32 EDT
The work was stalling for now a couple of month, and no material was available.
I just put a release online. you can check current status (and download sources
and binaries, if you want to have a deeper look) at :
http://www.openborges.org/dev/swt-gtk-printing

(this URL updates and replaces the one in #comment 61)

regards,
duf.
Comment 64 christophe dufaza CLA 2004-09-01 11:10:04 EDT
i've been reported the url does not show on some releases of IE.
this should now be fixed for any xhtml enabled browser.

i apologize for any disappointment.

regards,
duf.
Comment 65 Felipe Heidrich CLA 2004-09-01 14:02:30 EDT
Gtk 2.8 plan includes printing:
http://www.gtk.org/plan/2.8/

Does anyone know anything about it ?
Comment 66 Andrea Aime CLA 2004-09-22 15:35:14 EDT
Yes, one thing. It's an eternity away... :-( 
 
"The timeframe for the 2.8 release is mid 2005." 
 
(which really means 2.8 will be available in the 
widespread Linux distributions in the late 2005) 
Comment 67 Steve Northover CLA 2004-11-04 10:36:52 EST
*** Bug 77695 has been marked as a duplicate of this bug. ***
Comment 68 Billy Biggs CLA 2004-12-10 09:13:16 EST
*** Bug 80683 has been marked as a duplicate of this bug. ***
Comment 69 Billy Biggs CLA 2005-05-19 14:38:28 EDT
*** Bug 95995 has been marked as a duplicate of this bug. ***
Comment 70 Toon Geens CLA 2005-08-17 12:50:38 EDT
GTK 2.8.0 has been released:
http://mail.gnome.org/archives/gnome-announce-list/2005-August/msg00054.html

Can this issue finally be solved ?
Comment 71 Billy Biggs CLA 2005-08-17 13:02:20 EDT
Printing was dropped from the GTK+ 2.8 plan a while back due to the cairo work.
 It's on Owen's list for 2.10 though, see yesterday's development meeting notes:

  http://www.gtk.org/plan/meetings/20050816.txt

We might be able to do something using the cairo code done for the advanced
graphics API: maybe there's a half-way solution since the GTK+ solution will
involve cairo.
Comment 72 arne anka CLA 2005-08-18 02:33:28 EDT
i can't really understand why nobody cares to implement at least a temporary solution to enable 
linux/gtk users to print!
it's nearly 3 years now the issue initially was posted and all we get is "still not in gtk" because 
of the gtk-guys having completely different priorities than users of eclipse (boy, i wish 
somebody ports eclipse to qt -- it would look far better than ugly gtk ;-).
chosing the gtk-filechoser was definitively no good choice and gtk-printing may be even worse 
-- so please somebody implement a temporary solution (no, external tools are no solution)
Comment 73 Havard Bjastad CLA 2005-08-18 02:57:07 EDT
I agree 100% with the latest comment:
 - It's incredible that a product today can reach version 3.1 without (even a
simple) printing solution
 - A QT-based eclipse would rock so much more than the current GTK version
 - The GTK file chooser is horrible, if doesn't even let you step into
dot-directories...
Comment 74 Peter Williams CLA 2005-08-18 03:18:21 EDT
I don't know why they want to do printing via the GUI interface at all.

Personally, I find a print out of the representation of a file in a GUI editor
to be fairly awful.  What I would like the print function to do is just sent the
text file that's in the editor buffer off to cups to be printed like any other
text file.
Comment 75 Peter Williams CLA 2005-08-18 03:22:55 EDT
I probably misworded my last comment.  I meant that I don't see why GTK should
be involved in printing the file.
Comment 76 Mike CLA 2005-08-18 07:43:10 EDT
I fully agree with the lates comments. It is bad for us (developers) that 
eclipse misses printing support on linux. But it is more worse for application 
vendors building their applications on top of eclipse without that standard 
feature. The only reason why printing still isn't supported can be that to less 
people use eclipse on different systems than windows. Just think about how long 
this bug report exists and it's status is still NEW.

The root of all evil is this damn SWT !!! Swing has much more features, it is 
almost platform independent and has at least a clear design. It is absurd that 
you must cope with platform problems in your platform indipendent (Java) 
application.
Comment 77 Hugo A. Garcia CLA 2005-08-18 10:48:56 EDT
I agree that we should not be so focus on having printing linked to GTK. There
is also a Motif version of Eclispe that runs very well and that too is NOT
printing. So what gives? There is no support for printing in Linux (period)

So... can we have some kind of simple hook to CUPS??

It would be simple JFace Dialog that would have as it model some object(s)
representing the CUPS system hooks. Now... I can figure out the GUI part and if
someone wants to figure out the CUPS hook part then I am more than willing to
pair up and do it. We can provide this solution as a separate plugin until
whatever happens here happens but at least we can print.

Comment 78 Hugo A. Garcia CLA 2005-08-18 11:24:46 EDT
(In reply to comment #77)
> I agree that we should not be so focus on having printing linked to GTK. There
> is also a Motif version of Eclispe that runs very well and that too is NOT
> printing. So what gives? There is no support for printing in Linux (period)
> 
> So... can we have some kind of simple hook to CUPS??
> 
> It would be simple JFace Dialog that would have as it model some object(s)
> representing the CUPS system hooks. Now... I can figure out the GUI part and if
> someone wants to figure out the CUPS hook part then I am more than willing to
> pair up and do it. We can provide this solution as a separate plugin until
> whatever happens here happens but at least we can print.

We could probrably use the JavaTM Print Service.

Comment 79 Dani Megert CLA 2005-08-19 09:34:58 EDT
This missing feature should be mentioned in the README.
Comment 80 Dani Megert CLA 2005-08-23 08:20:38 EDT
*** Bug 107715 has been marked as a duplicate of this bug. ***
Comment 81 Steve Northover CLA 2005-08-24 09:01:15 EDT
>There is also a Motif version of Eclispe that runs very well and that
>too is NOT printing. 

Printing is implemented for Motif using XPrint.
Comment 82 Steve Northover CLA 2005-08-24 09:03:48 EDT
Really, if GTK does not support printing, neither does SWT.  I realize that 
this is a big problem, but you'll need to take it up with the GTK folks.  GTK 
C programs can't print either.  I'm very sorry about this but there's not much 
I can do.
Comment 83 arne anka CLA 2005-08-24 11:06:03 EDT
well, it's a couple of years now gtk does not provide printing capabilities. so waiting for gtk to 
implement a crucial feature like printing was a bad bet.
i think we have to accept that the gtk guys do not care for others using their toolkit -- and to 
have an other solution than gtk may provide in a far, far future (mr spock? any informations 
about gtk implementing printing in your time?).
eclipse definitively _needs_ a solution to print on it's own. it's in no way acceptable that (as 
someone said before) eclipse reached version 3.1 without ability to print for a major platform.
as a conversion to better equipped toolkits is no option (despite of heavely improving the look 
of eclipse compared to ugly gtk ...) there has to be a printing solution independent of gtk.

btw (and very important to me): does "if GTK does not support printing, neither does SWT" 
mean, _no_ (literally _no_) gtlk-based swt-application will print? i consider switching a project 
to swt -- but if printing is impossible, it's completely meaningless and makes swt rather a joke 
than a useful tollkit ...
Comment 84 Marcus Fihlon CLA 2005-08-24 11:47:43 EDT
GTK was originally designed for THE GIMP, which is cross platform application
with perfect printing support. I know a lot of applications using GTK which are
able to print.

If I want print something with Eclipse (I use GNU/Linux with GNOME and Eclipse
GTK Port) I have to copy and paste it first into an editor (if you want have
something to lough about: yes, it is a GTK editor).

Thats not good and this is really a bug, not a missing feature only. It should
be resolved by yesterday!

Thats what I have to say.

Marcus
Comment 85 Steve Northover CLA 2005-08-24 11:56:12 EDT
Arne, there is no need to be negative and insulting.  If printing on Linux is 
a critical feature for your application, then you'll need to use a graphics 
library that supports it.  For example, since you are a Java programmer, you 
could use SWT for Motif or Swing/Java2D.  If you were a C programmer, you 
would not choose GTK (unless you were willing to wait for GTK to implement 
printing).

Here is our mandate:

"SWT is a widget toolkit for Java designed to provide efficient, portable 
access to the user-interface facilities of the operating systems on which it 
is implemented."

Marcus, this is just TTY printing, right?
Comment 86 Mark CLA 2005-08-24 12:20:09 EDT
I haven't said anything since originally posting this bug.  I can sense some
frustration building in the emails and will admit I feel a bit of it myself.

I don't know anything about GTK or SWT (I build webapps for Tomcat with
Eclipse), but I just did a quick google and found some things.  

First, a search for "gtk printing"
(http://www.google.com/search?hl=en&q=gtk+printing) shows this bug at about the
4th hit.  Boy, we're popular ;)

Second, there seems to be a package for printing on gtk
(http://gtklp.sourceforge.net/).  I don't know if anyone has looked into it.

Third, just to do a comparison for java GUI toolkits.  I googled "java swing
printing" and got this
(http://java.sun.com/developer/technicalArticles/Printing/SwingPrinting/).  It
says Swing has facilities for printing since 1999.  I have to ask why SWT hasn't
done the same?

Finally,  I appreciate the very large effort IBM (and other developers) have put
into Eclipse and I understand that priorties have to be made.  I want to thank
them for the work they have done.

I hope that the folks working on Eclipse won't drop this issue.  Rather, I would
hope that Steve's comment (posted earlier today): 

"Really, if GTK does not support printing, neither does SWT.  I realize that
this is a big problem, but you'll need to take it up with the GTK folks.  GTK C
programs can't print either.  I'm very sorry about this but there's not much I
can do." 

isn't the last word.  Printing in Eclipse on Linux is a big issue to many folks,
and could be a PR nightmare in more ways than just for Eclipse.
Comment 87 arne anka CLA 2005-08-24 12:25:42 EDT
there was not intention to be "negative and insulting"!
i'm still shocked by the fact, that printing has so low priority -- and as the whole thread shows 
i'm not the only one.
there is still no serious proposal how to solve this -- but only shrugging and refering to a years 
old problem of gtk. if you interpret that as "negative and insulting", well, i can't help.
Comment 88 Marcus Fihlon CLA 2005-08-24 12:35:12 EDT
(In reply to comment #85)

> Marcus, this is just TTY printing, right?

I don't know, but I think so that my GTK editor does it this way. But take a
look at GIMP -- it is based on GTK and has perfect print capabilities (on
Windows _and_ on Linux). But since I'm not a C programmer and use GIMP only for
my digital photos I don't know how they realized that.

Marcus
Comment 89 Jared Burns CLA 2005-08-24 13:32:11 EDT
A word on printing in Gimp. My understanding is that printing in Gimp is
provided by a third-party plugin (Gimp-Print). Gimp itself doesn't have printing
support (because GTK doesn't have it?).

The Gimp-Print Sourceforge page describes the project as "A very high quality
package of printer drivers for Ghostscript and CUPS. This project also maintains
the Print plug-in for the Gimp from the same code base"

http://gimp-print.sourceforge.net/
Comment 90 Billy Biggs CLA 2005-08-24 17:19:35 EDT
There is a fair bit of confusion in the last batch of comments.  Some brief
clarifications:

 - If you just want to print the file in the Eclipse editor, use
   Run > External Tools, add a Print program set to /usr/bin/lpr, and in the
   arguments use ${container_loc}/${resource_name}.  You can then use
   the External Tools run icon in the toolbar to print in Eclipse.

   This bug report is about printing complex documents (editors with syntax
   colouring, graphical editors, etc) which requires a full drawing API.

 - gimp-print is a gimp plug-in for printing images in gimp.  It does not
   print text or 2D shapes required by SWT.

 - CUPS is a backend for finding printers and printing files.  This would
   be useful for creating a print dialog, but does not provide a drawing API.

 - XPrint keeps coming up, but it is not compatible with GTK+, especially
   for printing text (which is rather important):
   http://www.redhat.com/archives/fedora-devel-list/2004-September/msg01132.html


I think there are three options:

  1. libgnomeprint, discussed in comment #15.  This is used by many GNOME
     applications, but does not match the GDK drawing API, and so the
     implementation is not straightforward.  This will also be deprecated
     when GTK+ implements printing.

  2. Write a PostScript output backend for GC and use the print dialog from
     libgnomeprint.

  3. Wait for GTK+ to provide a print dialog and use cairo for drawing.


Option 1 is painful, but may be worth it until GTK+ has a replacement.
libgnomeprint was not always stable, but is unlikely to break now.  It is
unfortunate that this does not match the long-term goal for GTK+ apps.
http://mail.gnome.org/archives/desktop-devel-list/2004-November/msg00716.html

Option 2 is painful: SWT would end up duplicating the code in libgnomeprint or
cairo, and dealing with printing pango fonts is difficult.  See comment #44 for
more reasons.

Option 3 is obviously best.  SWT has the cairo code, and only needs cairo to
finish the PostScript backend and GTK+ to include a standard print dialog.  This
is on the GTK+ schedule, and is intended to replace libgnomeprint.
Comment 91 Havard Bjastad CLA 2005-08-24 17:58:31 EDT
Billy, your comment seems to make a lot of sense, but leaves one question (at
least for me): Why isn't Swing printing a 4th option? While I appreciate the
desire to reimplement every Swing bit in SWT, Swing is already bundled with
every JDK, so utilizing it for printing might be an easy short-term solution. Or
am I completely missing something?
Comment 92 Peter Williams CLA 2005-08-24 18:56:44 EDT
What rubbish.  Lot's of GTK programs can print.  They just don't do it via GTK.

As I said before printing through the graphics interface is not the only way to
do it and for text files is probably not the best way to do it.  What's wrong
with the tried and true method of sending the text file to the printing system
and letting the priniting system take care of the details?
Comment 93 Billy Biggs CLA 2005-08-24 19:26:13 EDT
Peter -- see the first point in my last post.  You can print just fine using lpr in
Eclipse, and I describe how.  If that's all you want it already works fine.

If you want Eclipse to use lpr for the print button, please file a new enhancement
request against Platform > UI.  This bug is tracking the SWT Printer
implementation under GTK+.
Comment 94 Marcus Fihlon CLA 2005-08-25 03:42:18 EDT
(In reply to comment #90)

>  - If you just want to print the file in the Eclipse editor, use
>    Run > External Tools, add a Print program set to /usr/bin/lpr, and in the
>    arguments use ${container_loc}/${resource_name}.  You can then use
>    the External Tools run icon in the toolbar to print in Eclipse.

Good morning! Thanks a lot for this tip - I used gtklp instead of lpr. gtklp
displays a graphical print dialog where a lot of things can be donce (numbers of
copies, sorting, 2 and more pages on one, selecting the printer etc).

I'm happy now with this solution!

Have a nice day
Marcus
Comment 95 arne anka CLA 2005-10-08 17:10:25 EDT
it's annoying and appalling to see how ignorant these crucial issue is handled!
still the same old, stupid idea of "external tools" -- probably posed by people using eclipse 
under windows and thus never proving the stupidity of that proposal!
of all supported platforms windows is the only one with a proprietary solution for printing -- 
platforms providing an open printing startegy are disdainful ignored.
stop the meaningless waiting for a solution provided by the gtk-guys -- as long as the spend 
more time to produce unusable file-dialogs i wont exoect them to spend time to work on things 
not really necessary for gnome.

all platforms except windows provide support for postscript natively, and all platforms except 
windows print postscript natively.
a lot of applications utilize a printing strategy consisting of a) recieving postscript and b) sen 
ding the postscript to a printer/program/whatsoever specified by the user. mozilla does, 
firefox does, opera does, openoffice does -- a solution not patronizing the user works well for 
a world of software -- but is inacceptable to eclipse?
as swt needs platform-dependent libraries already and printing is implemented only for a few 
supported platforms there should be no hinder to implement for platforms other than windows 
(and macos maybe) a solution creating postscript on print request and send it to a printer/
program specified by the user in certain preferences page.
it's a solution platform and toolkit agnostic and used widely in a notably part of the world -- and 
thus working well. eclipse does not need to reinvent the wheel!
Comment 96 Arthur CLA 2005-11-06 15:02:31 EST
Cairo 1.0.2 has been released a month ago. "Currently supported output targets
include the X Window System, win32, and image buffers. Experimental backends
include OpenGL (through glitz), Quartz, XCB, PostScript and PDF file output."
The PostScript output seems to be usable.

What are the cairo (or updated gtk libraries) integration plans for eclipse?
Comment 97 Billy Biggs CLA 2005-11-06 20:02:21 EST
SWT's GC has a back-end for cairo in 3.1.  It is updated to the cairo 1.0
API in SWT 3.2, and the GTK+ team is working on the print dialog for
GTK+ 2.10.  See comment #90.
Comment 98 Kim Lux CLA 2005-11-26 14:58:56 EST
I'm shocked to find that Eclipse won't print under Linux. 

"If you want Eclipse to use lpr for the print button, please file a new
enhancement request against Platform > UI."

Did this ever happen ?

"This bug is tracking the SWT Printer implementation under GTK+."

Why is the focus of this discussion limited to such a narrow solution ?  Other GTK apps didn't wait.  I vote for a CUPS system.  What are the downsides to that ?  Doesn't kwrite use a CUPS implementation and doesn't it work OK ?

Comment 99 Kim Lux CLA 2005-11-26 15:15:56 EST
Created attachment 30663 [details]
Image of how I set up kwrite to do printing

My work around for this issue is to set kwrite up as an external tool print engine.  See attachment.  It works well.
Comment 100 arne anka CLA 2005-11-28 03:09:48 EST
well, even kwrite will print formatted text only. this is achieved by that stupid "external tools"-solution too. but it's simply unbearable to be unable to prinbt other things than plain text. i would like f ex to print uml-diagrams, "screenshots" fr4om the ve and much more.
hopefully, now cairo exists, the guys will fix this grave bug (but i'm still very sceptically -- they did not care to fix it all the years, why should they now)
Comment 101 Daniel Spiewak CLA 2006-01-05 18:10:56 EST
I have a create deal of respect for the work that christophe has put into his solution. (see comment 63 and several previous)  However, I'd like to point out for the record that SWT peering to Swing for printing is simply out of the question for a long term solution in the main SWT trunk.  I'm not saying that Christophe doesn't have a great hack to fix for individual applications, or even a patched SWT that can be used in Eclipse.  What I am saying is that the actual SWT implementation can't peer to Swing.  It would break every application that uses gcj for native compilation and uses SWT only because the native libs can be redistributed.  A lot of people are depending on SWT's independance from Swing.  Once you start tying the two together, you open the door to a world of pain (not to mention a PR nightmare from *both* the Swing bashers and the SWT bashers).

I realize this is a rather important issue which has been somewhat put off by the SWT team (with good reason).  I think that they've made it fairly clear as to how they want to procede (wait for GTK printing support).  If you guys really want this to make it into the SWT main jar, start jumping on the GTK team and flood their bugzilla.  I'm fairly certain that as soon as GTK starts offering printing support, it will be included in the next release of Eclipse GTK.
Comment 102 Stephan Michels CLA 2006-01-05 18:46:15 EST
Does an enhancement request in gnome's bugzilla exist? I can't find an entry 
for the missing printing dialog / printing opportunity in gtk.
Comment 103 Mathis Ahrens CLA 2006-01-18 18:34:58 EST
I did not find one either, so I created one:
http://bugzilla.gnome.org/show_bug.cgi?id=327605

I hope this helps communication.
(And BTW: Please stop being demanding, try to help gtk if you care)
Comment 104 Niclas Hedhman CLA 2006-02-06 00:09:21 EST
I can only note that the Plans for SWT 3.2 does not list "Printing on Linux" as an item. Is it at all on the radar?
Windows XP skinning and other eye-candy seems more important.

I am not an Eclipse fan in general (but now in need of the very interesting projects EMF/GEF/GMF), and this issue makes me laugh. A two-dollar company that doesn't provide printing in the most silly applications can be waved away, but this is possibly one of the largest accumulated Java efforts in the world. And all depending on a SWT flaw of massive scale.

well, well... GTK is listing printing to "possibly" be included in the 2.10 release, targeted for May 2006. Does that mean I can have it for Christmas? Which year?
Comment 105 Niclas Hedhman CLA 2006-02-06 00:13:11 EST
One more comment;

Shouldn't the obvious solution be to generate PDF or PS output instead??

How it gets to the printer is less of a concern, isn't it.
Comment 106 Steve Northover CLA 2006-02-06 10:43:28 EST
Niclas, please make the necessary modifications to both GTK and/or SWT and submit the patches.
Comment 107 Daniel Spiewak CLA 2006-02-06 11:57:25 EST
Niclas - read the comments above to see why this issue, though very annoying and a blocker for many people, can't really be fixed by SWT.  In other words, the fix is basically postponed until the GTK team adds printing support.  Vote on the bug there (I don't have a URL handy) to give them a kick in the pants.  That's about all we can do (other than write the GTK support as a patch and submit it).
Comment 108 Stephan Michels CLA 2006-02-07 02:00:47 EST
It seems there is some active development for GTK in th recent weeks.
http://www.0xdeadbeef.com/?p=161
http://blogs.gnome.org/view/alexl/2006/01/27/0
http://blogs.gnome.org/view/alexl/2006/02/03/0

It's funny to see that this happen after Mathis filed the gnome bug report. Maybe just a coincidence, maybe not.
Comment 109 Michael R Head CLA 2006-04-21 13:16:54 EDT
More good news. Printing support has landed in GTK's CVS HEAD.

http://blogs.gnome.org/view/alexl/2006/04/21/0
Comment 110 Daniel Spiewak CLA 2006-04-21 14:19:38 EDT
That's great news!  Can we expect this to be integrated into SWT in 4.0?
Comment 111 Steve Northover CLA 2006-04-21 15:29:15 EDT
We'll work to get it on the plan for the next release.
Comment 112 S Iyengar CLA 2006-05-09 07:18:49 EDT
(In reply to comment #111)
> We'll work to get it on the plan for the next release.
> 

Does that mean 3.2;-)?
Comment 113 Carolyn MacLeod CLA 2006-05-16 16:40:36 EDT
Taking ownership.
No, it will not be in 3.2...   ;)

Here's what I have done so far this afternoon to get eclipse up and running on the latest gtk (note: NOT from CVS... I just took the latest snapshots):

# as root...
cd /usr/local/src/
wget http://ftp.acc.umu.se/pub/gnome/sources/glib/2.11/glib-2.11.1.tar.gz
wget http://cairographics.org/snapshots/cairo-1.1.6.tar.gz
wget http://ftp.acc.umu.se/pub/gnome/sources/pango/1.13/pango-1.13.1.tar.gz
wget http://ftp.acc.umu.se/pub/gnome/sources/atk/1.11/atk-1.11.4.tar.gz
wget http://ftp.gnome.org/pub/gnome/sources/gtk+/2.9/gtk+-2.9.0.tar.gz
tar xvfz glib-2.11.1.tar.gz
tar xvfz cairo-1.1.6.tar.gz
tar xvfz pango-1.13.1.tar.gz
tar xvfz atk-1.11.4.tar.gz
tar xvfz gtk+-2.9.0.tar.gz

cd glib-2.11.1
./configure --prefix=/usr/local/gtk-2.9.0/ --enable-debug=yes
make
make install
export PKG_CONFIG_PATH=/usr/local/gtk-2.9.0/lib/pkgconfig/
export LD_LIBRARY_PATH=/usr/local/gtk-2.9.0/lib/

cd ../cairo-1.1.6
./configure --prefix=/usr/local/gtk-2.9.0/ --enable-debug=yes --enable-pdf=yes --enable-ps=yes
make
make install

cd ../pango-1.13.1
./configure --prefix=/usr/local/gtk-2.9.0/ --enable-debug=yes
make
make install

cd ../atk-1.11.4
./configure --prefix=/usr/local/gtk-2.9.0/ --enable-debug=yes
make
make install

cd ../gtk+-2.9.0
./configure --prefix=/usr/local/gtk-2.9.0/ --enable-debug=yes
make
make install
------------------------

Before starting eclipse, export the following:
setenv LD_LIBRARY_PATH /usr/local/gtk-2.9.0/lib/
setenv GTK_PATH /usr/lib/gtk-2.0/2.4.0/
setenv GTK_DATA_PREFIX /usr/
setenv PKG_CONFIG_PATH /usr/local/gtk-2.9.0/lib/pkgconfig/
------------------------

Now I am just starting to look at the API in file:///usr/local/gtk-2.9.0/share/gtk-doc/html/gtk/Printing.html

Any examples of the intended use of the API are welcome, or if anyone spots any potential problems in the snapshot versions I downloaded, please let me know before I hit them!  Thanks.  :)
Comment 114 Michael R Head CLA 2006-05-16 17:52:16 EDT
There will be a talk at GUADEC in June re: the GTK printing API...
http://guadec.org/node/219
Comment 115 Andrew Overholt CLA 2006-05-16 18:56:40 EDT
(In reply to comment #114)
> There will be a talk at GUADEC in June re: the GTK printing API...
> http://guadec.org/node/219

I'll be at GUADEC FWIW.  I'm sure we could get Alex to comment on an API, though.
Comment 116 Ismael Juma CLA 2006-05-16 19:29:44 EDT
(In reply to comment #113)
> or if anyone spots any
> potential problems in the snapshot versions I downloaded, please let me know
> before I hit them!  Thanks.  :)

Just a FIY, I quote from the gtk+ weekly meeting that took place today:

"mclasen - regarding printing, I hope we can land the last big missing pieces this week, or early next week"
Comment 117 Carolyn MacLeod CLA 2006-05-17 17:25:13 EDT
Created attachment 41817 [details]
Screen snap of print dialog

I have a print dialog.
I had to get the gtk+-2.9.1 snapshot that just went up today... guess I'm at the bleeding edge <g>. 2.9.1 is nice because it has a Printing demo in bin/gtk-demo.

Thanks for the warning in comment 116, Ismael - I will keep it in mind.
Comment 118 Carolyn MacLeod CLA 2006-07-17 17:16:42 EDT
Fixed > 20060717, and it will be in tomorrow's integration build.
You need GTK+ 2.10 to run it.

There are still a few problems, for which the following bugs have been opened:
http://bugzilla.gnome.org/show_bug.cgi?id=339323
http://bugzilla.gnome.org/show_bug.cgi?id=344519
http://bugzilla.gnome.org/show_bug.cgi?id=345590
http://bugzilla.gnome.org/show_bug.cgi?id=346245
http://bugzilla.gnome.org/show_bug.cgi?id=346252
http://bugzilla.gnome.org/show_bug.cgi?id=346903
https://bugs.eclipse.org/bugs/show_bug.cgi?id=150870
https://bugs.eclipse.org/bugs/show_bug.cgi?id=150873

It was a pleasure to work with Matthias Clasen at RedHat, who owns the GTK+ printing code - he was very responsive. Thanks!
Comment 119 Benjamin Pasero CLA 2006-07-19 02:34:36 EDT
That's great to hear! 

Is there any Api I can use to check wether printing is supported? E.g. a method that tells me wether the user is on GTK+ 2.10 or an older GTK?

Ben
Comment 120 Felipe Heidrich CLA 2006-07-19 11:40:16 EDT
(In reply to comment #119)

There is not, the workbench uses Printer#getPrinterList() to determine if the printer button is enable or not, something like:
printerButton.setEnable(Printer#getPrinterList() > 0);
Comment 121 Benjamin Pasero CLA 2006-07-19 15:58:21 EDT
Thanks for the info, that should do it for me as well :)

Ben
Comment 122 Carolyn MacLeod CLA 2007-04-16 16:40:05 EDT
*** Bug 154101 has been marked as a duplicate of this bug. ***