Saturday, February 11, 2006

Before I can claim victory with menus, there remains some non-trivial work related to supporting standard dialogs. By this, I mean the dialogs that are needed to support print, page setup, and file selection ("save as" and "open") functionality.

Let's begin by discussing the layout of these dialogs. On the Macintosh, these dialogs are all provided by Cocoa in AppKit. I imagine that in .Net on Windows, a similar level of support holds true. Gtk+ provides a very simple file selection dialog (GtkFileSelection), but, unfortunately, print and page setup are missing, requiring the end user to come up with his or her own solution. This is a horrible state of affairs, and somewhat of a disappointment -- how could the Gtk+ community pursue projects like mono (bringing .NET APIs to Gtk+), and still not take care of this core issue?

Focusing in on the print/page setup dialog problem, a google search indicates that various people are working on a solution. I even worked on the problem way back in 1999 for Netscape/Mozilla (see http://lxr.mozilla.org/seamonkey/source/widget/src/gtk2/nsPrintdGTK.c). In the end, the project (e.g., Mozilla, Open Office, GIMP) is almost always forced to come up with its own solution (see the following Figure) to the problem, or steal something from someone else (I'm using "steal" in the Open Source sense of the word, of course).



Even support for Page Setup and Print is far from consistent among applications. Look at the GIMP print dialog, for example:



Here, GIMP doesn't implement a Page Setup dialog, but, instead, it rolls that functionality into the print dialog. While powerful, it is inconsistent in the sense that learning this dialog does nothing to help a user, say, learn how to perform a page setup/print sequence in Open Office.

On top of the above problems, there is also the issue of how to communicate with the printer. The strategy that I employed back in the day at Netscape made use of Postscript and lpr(1), which, for decades, was the method for printing. Nowadays, there are architectures like CUPS (which is compatible with lpr, according to the man pages). I'm sure that over the years, there has been more than one attempt to take a stab in the open source community of coming up with a generic printing architecture that serves the needs of everyone. Perhaps CUPS is it for configuration (i.e., page setup), and lpr is the way you perform the actual print.

Interestingly, CUPS is the engine that sits behind printer configuration on MacOS X, making the decision to base a cross-platform architecture on CUPS/lpr a near slam dunk (well, except on Windows of course). This is even more true with the realization that CUPS is also available on Windows (but "available" doesn't mean "present", so sadly, one cannot rely upon it).

So, this is what we have to work with:

MacOS X/Cocoa Print Setup UI: Native
MacOS X/Cocoa Print Setup Engine: Native with CUPS backend
MacOS X/Cocoa Print UI: Native
MacOS X/Cocoa Print Engine: CUPS/lpr

Windows/.NET Print Setup UI: Native
Windows/.NET Print Setup Engine: Native
Windows/.NET Print UI: Native (perhaps CUPS if installed by the user)
Windows/.NET Print Engine: Native

Linux/Gtk+ Print Setup UI: Undefined/Varies by application
Linux/Gtk+ Print Setup Engine: CUPS
Linux/Gtk+ Print UI: Undefined/Varies by application
Linux/Gtk+ Print Engine: CUPS/lpr

After getting CUPS configured here at home (to support a crufty old HP LaserJet 4MP that I have connected to the parallel port of a Fedora Core 4 server, which is acting as a print server) and configuring a separate Linux laptop and MacOS X to use the printer to convince myself it works, I decided that, yes, CUPS needs to be a part of whatever solution I put together on Linux under Gtk+.

Just for posterity, here is the cupsd.conf file on the print server:

LogLevel info
Port 631
<Location />
Order Deny, Allow
Deny From All
Allow From 127.0.0.1
Allow From 192.168.1.*
</Location>
BrowseAddress 192.168.1.255

<Location /printers/HPLaser>
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
Allow From 192.168.1.*
AuthType None
</Location>

And printers.conf:

# Printer configuration file for CUPS v1.1.23
# Written by cupsd on Sat 11 Feb 2006 04:13:22 PM PST
<DefaultPrinter HPLaser>
Info
Location
DeviceURI parallel:/dev/lp0
State Idle
Accepting Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
</Printer>

0 Comments:

Post a Comment

<< Home