8 December 2004

  • Post author:
  • Post category:Uncategorized

Mataró

I’ve been in Mataró (about an hour from Barcelona) now since Sunday, and it’s quite a nice place. It is a bit cooler than Perth due to it being the middle of Winter here, but the way most of the locals are rugged up you’d think it was a lot colder. It’s great to catch up with everyone, and a number of pygtk developers will be turning up over the next few days for the BOF on the weekend.

Gnome Foundation Elections

Congratulations to the new board members. It is a little disappointing that only about 56% of members voted though. Once the membership committee has the anonymous voting stuff set up, it might be worth doing the preferential voting referrendum.

jhbuild

I’ve been working on some preliminary documentation for JHBuild, which is available here. It should be useful for new users and people looking at writing new module sets for it. It has a fairly complete command reference and config file reference, so it is probably useful for current users too. It would be good to add some information about setting up a tinderbox like the one Luis set up for Gnome.

Nautilus Extensions

  • Post author:
  • Post category:Uncategorized

One of the changes in the Gnome 2.9 development series is the removal of most of the Bonobo code from Nautilus, which results in a speed boost due to lower complexity and less IPC overhead. This had the effect of breaking existing bonobo based context menus, property pages and views. The first two can be converted to the Nautilus extension interface, but the second has no equivalent in the new code (partly because Nautilus is concentrating on being a file manager these days rather than a universal component shell like it was in the early days).

Two of the casualties of the change were gnome-control-center‘s font and theme code, and nautilus-media. Since I wrote the font browser code in gnome-control-center, I updated it to work again. It isn’t clear whether nautilus-media will be updated, since the view was a major component of it, and most of the remaining functionality is provided by totem.

Context Menus

If you are looking at updating a Nautilus context menu to use the new extension interface, fontilus-context-menu.c is a pretty good example to model your code on.

One of the big differences is the way Nautilus extensions are loaded compared to the old context menu API. With the old API, you would provide a Bonobo component and set a number of properties in the bonobo-activation server file listing a menu label, the list of mime types the context menu applies to, what URI schemes it supports and whether it supports multiple files. Nautilus could then do a single bonobo-activation query to find out what context menu items correspond to the current selection, and add them to the menu. If the user selected one of the items, the corresponding component would be activated, and an event sent to its Bonobo::EventListener interface.

In contrast, Nautilus extensions are initialised on Nautilus startup. They indicate that they provide context menu items by implementing the NautilusMenuProvider interface. When the user brings up the context menu, the get_file_items method will be called on all extensions that implement that interface. A list of NautilusFileInfo objects is passed in, and the method returns a list of NautilusMenuItem objects. Also, Nautilus extensions are run in-process while Bonobo components could be written for in-process or out of process use.

One of the benefits of this system is the added control of when to display a menu item, and what to use as the label. If you want to only display your context menu item when 42 text/html files and one image/png file are selected you can. However it does mean that each new extension causes some code to be run before popping up a context menu. I have no idea how this compares time wise to the time taken for the previous bonobo-activation query though.

Property Pages

The interface for property pages is quite similar to the context menu interface. As with context menus, you have an imperative NautilusPropertyPageProvider::get_pages interface rather than a declaritive interface based on activation properties. This has the benefit that you can simply not provide the page when the properties in question are not available for the file (with the old setup, you’d end up providing a properties page stating that there is nothing to display).

The other interesting parts of the extension interface is the NautilusInfoProvider interface that lets you attach extra information to files, such as extra emblems or custom attributes, and NautilusColumnProvider, which lets you provide additional columns for the list view that map to custom file attributes. One example of this is nautilus-vcs, which can show revision numbers for files in CVS working copies and adds emblems indicating the file state.

Of course, there are downsides to the extension interface too — since extensions are always in process, they can crash Nautilus or leak memory. However, it was already possible for Bonobo based extensions to do this if they were designed as in-process components and badly written …

Another issue is that language bindings might find it more difficult to support the extension interface where the language runtime would have to cooperate with Nautilus, compared to out of process Bonobo components where they have more control. I guess we’ll see what happens.

1 November 2004

Libtool

When looking into the libtool problem I mentioned earlier, I decided to take a look at the libtool-2.0 betas. Overall, it looks pretty good. I’ve updated the gnome-common autogen.sh script to support it. So if a package uses the LT_INIT macro, it will call libtoolize for you.

One of the new features in these versions of libtool is that if you have a AC_CONFIG_MACRO_DIR(directory) call in your configure.ac file, it will copy the libtool M4 macros to that directory. If you then call aclocal with the correct -I flag, autoconf will use that version of the macro.

This means that you will get consistent versions of ltmain.sh and libtool.m4, which is a lot more reliable. With the old setup, the version of ltmain.sh you got would depend on $PATH while the version of libtool.m4 would depend on the aclocal search path. With the new setup, it just depends on $PATH.

The only problem is that aclocal doesn’t automatically check the macro dir for macros. This is pretty easy to work around. Just pass the appropriate -I flag to aclocal in autogen.sh, and make sure ACLOCAL_AMFLAGS gets set appropriately in your Makefile.am‘s. This second part can be done from the configure.in file like so:

AC_CONFIG_MACRO_DIR([m4])
...
# make sure $ACLOCAL_FLAGS are used during a rebuild.
AC_SUBST([ACLOCAL_AMFLAGS], ["-I $ac_macro_dir \${ACLOCAL_FLAGS}"])

(the above will also pass $ACLOCAL_FLAGS to aclocal on a rebuild, which is expected when building most Gnome packages).

I also updated the gnome-common autogen.sh script to check for AC_CONFIG_MACRO_DIR, and call aclocal correctly, so a package maintainer doesn’t need to do anything special.

This system could benefit some of the other Gnome related build tools like intltool and gtk-doc — I recently got CC’d on an intltool bug that seemed to be caused by mismatched macros and support files, so people are tripping over the problem. It should be pretty trivial to modify intltoolize to check for AC_CONFIG_MACRO_DIR, and copy over the macro file if it finds it. This wouldn’t affect its behaviour on existing packages, but would be more reliable on packages that have been updated to use the macro.

Bazaar

I did some initial Fedora Core 2 packages for Bazaar (a new GNU Arch command line tool sponsored by Canonical). It is only an i386 build, but I’ll add an x86-64 build once I have FC2 or FC3 set up on my desktop (so far I’ve only got round to installing Ubuntu/AMD64 on it).

At the moment baz is quite similar to tla, but there are some promising interface ideas that should make it a lot nicer to use. If you’ve avoided Arch due to tla‘s complexity, baz might be worth trying when it develops further.

Libtool Problem (continued)

Shortly after posting the last entry about the libtool problem I sent a message to the bug-libtool list, Scott helped to track down the problem.

With the help of the test script I wrote, he managed to track down the change on the libtool-2.0 branch that fixed the problem. Applying this same change to a 1.5.x release fixed the problem. He has uploaded a new Debian package with the change, and I’ve altered the jhbuild bootstrap module set to include the patch too. The copy of the patch included with JHBuild can be found here. Hopefully it will also be in a future 1.5.x release (assuming that there are any more).

Scott pointed out another case where people might run into the problem is when building binary packages for software. A packager usually builds the new version of the software into a temporary prefix (often by setting the $DESTDIR environment variable when calling make install). If the package includes a library with some applications that link to the library and there is an old version of the package installed on the system, libtool could end up linking with the library in /usr/lib, which could result in a build failure if some new APIs were added. The patch should fix this particular case too.

So if you release tarballs that make use of libtool, applying this patch may help out the people maintaining binary packages of the software for a distro too (assuming that they haven’t gone the scorched earth route and deleted all the .la files …).

25 October 2004

  • Post author:
  • Post category:Uncategorized

Drive Mount Applet

The new drive mount applet is now checked into the HEAD branch of gnome-applets, so will be in Gnome 2.10. There are a few things left to do, such as making it possible to open the file manager as well as unmounting/ejecting it. I did up a screenshot showing what it looks like as an applet.

Libtool

Finally managed to reproduce a particular libtool bug that people have reported on and off. It does show why some people decide that .la files are evil, since it doesn’t occur when people delete those files …

A reduced test case can be found here. The problem occurs when you have multiple copies of a library in your linker library search path with associated .la files. In the test case, there are the following libraries:

  • libfoo.so and libfoo.la in the directory /A. This is the library we want to link to.
  • libfoo.so and libfoo.la in the directory /B. We don’t want to link to this one, because it is old.
  • libbar.so and libbar.la in the directory /B.

Let’s say I then try to link an app that needs libbar and the new version of libfoo, and happen to use the following link line:

libtool --mode=link gcc -o main main.c -lbar -L/A -L/B -lfoo

In the absense of libtool, this would result in us linking against /B/libbar.so and /A/libfoo.so (since /A comes before /B in the search path).

However, libtool ends up doing something quite different. When it sees -lbar, it notices that there is a libbar.la in /B, expands that argument to the full path name of the actual library (/B/libbar.so), and prepends /B to the library search path. This means that when it gets round to processing -lfoo, it finds /B/libfoo.la instead of /A/libfoo.la, and links to the wrong library.

If this sounds like an obscure bug, note that it also happens if we replace /B with /usr/lib. In this case, we don’t even need the -L/usr/lib argument. So the following command results in linking with /usr/lib/libfoo.so instead of /A/libfoo.so:

libtool --mode=link gcc -o main main.c -lbar -L/A -lfoo

This sort of situation is quite common when trying to build some software into a separate prefix that is also provided by the OS, when you are relying on a few libraries installed in /usr/lib with .la files.

After putting together the test case I tested it out in the latest development release (1.9f), and it appears that the problem has been fixed. Given that the libtool developers are so close to a 2.0 release, I don’t know whether they would bother putting out another 1.5.x release to fix the problem.

So if you do run into the problem, some possible solutions are:

  1. Upgrade to libtool-1.9f. I’m not sure how good an idea this is if you are producing tarballs, since they will be packaged with the development release too.
  2. Remove all the .la files in /usr/lib. Some distributors seem to take this route (eg. Ximian/Novell and Red Hat).