-->
Previous Table of Contents Next


Using LessTif

Everyone wants to use the Motif libraries until they find out that they’re an added-cost feature for Linux. Unfortunately, the Motif library is commercial software, which means you have to pay extra to get either the Motif library source code or a set of binaries for your platforms. Add to this hassle the frustrating nature of the complex Motif license for software developers, where it’s almost impossible to tell if you can actually distribute your applications, and you’re ready to scream.

However, we’ve run across a great programming effort called LessTif, which is gaining more Motif functionality each day. While it’s not in completed form, we thought you might want to take a look at it, so we included it in the second CD-ROM’ s programming/lesstif directory.

LessTif is a workalike clone of the Motif libraries. That is, it is a set of programming libraries that look and act like the Motif libraries (Xm and Mrm). Under the hood, the code is entirely different. From a programmer’s perspective, though, LessTif has the same API as the Motif libraries and supports a number of Motif widgets, supporting more Motif widgets with each release. It uses public header files with the same name as their Motif counterparts.

For your programs, LessTif should allow your Motif programs to be recompiled under LessTif with no source code changes—at least in theory. We’ve had to make a few changes to get around the fact that LessTif is incomplete as we write this. Luckily, because LessTif is undergoing what looks like constant development, the problems we face today should gradually go away.

Distributed under the GNU license, you can use LessTif in free applications. You’ll probably want to check the GNU licenses before using LessTif for commercial software.

Installing LessTif

LessTif comes in source code format. All you need to do is run xmkmf and then make in the standard way to build X programs:


     xmkmf

     make

If you run into any problems, there’s a file named INSTALL with the distribution.

Problems with LessTif

The developers of LessTif clearly let you know that LessTif is not a complete Motif clone by any means. This is only natural at this early stage in LessTif’s development. Even so, there’s quite a few things present in LessTif that will appeal to Motif programmers.

LessTif, as incomplete free software, is not without its problems, as you’d expect. But each version gets better and better.

Editres Support

Editres is an X application and protocol that allows programs compiled with the X Toolkit (Xt) Intrinsics library to export information on widget attributes to an outside program, namely, editres itself.

With editres, for example, you can change the font, colors, and text displayed with any widget, presuming an application supports the editres protocol. To do this, an application must set up an event-handling function and pass the special editres library call, _XEditResCheckMessages, as the handler. For example, the following code sets this up for a Motif application:


     #include <X11/Xmu/Editres.h>



     Widget     toplevel;

     void     _XEditResCheckMessages();



     /* ... */



     XtAddEventHandler(toplevel,

       (EventMask) 0,

       True,

       _XEditResCheckMessages,

       NULL);

With this set up, your Motif application will properly respond to the editres protocol.

The reason we mention this is that LessTif calls XtAddEventHandler automatically from the Vendor shell widget. Thus, all LessTif programs will support editres. But there’s a slight problem with this. _XEditResCheckMessages resides in the X miscellaneous utilities library (libXmu.a) and you must be sure to link this in.

To link with LessTif, you need to link in at least the following libraries, as shown in the following command:


     cc -o foo foo.c -lXm -lXmu -lXt -lX11

We mention this because you’re probably not linking in the Xmu library now. It’s nice that LessTif supports editres from the start, but you need to remember to link in the Xmu library.

All in all, for free software, it’s hard to complain about LessTif. LessTif isn’t ready for prime-time usage yet, but it has made great strides in recent months. You’ll probably want to track its progress and conduct some tests before using it. Better yet, you may want to volunteer to help the effort.

Finding out More about LessTif

You can look up the LessTif home page on the World Wide Web by accessing http://www.hungry.com/products/lesstif/. You can also use FTP to acquire the latest version of LessTif, at machine ftp.hungry.com in the pub/hungry/lesstif directory.


Previous Table of Contents Next