Come and See

Decemberists: Yesterday evening, The Decemberists were in London, and made a wonderful concert at Shepherd Bush. I’ve fallen in love with the band after vieweing the video of their song Sixteen Military Wives and I started getting my hands on their whole discography (right now, only the singles are missing). They played mostly songs from their new album, The Crane Wife, which is really as good as it can get (so go out and buy it now).

gnome-utils: It seems that my plea for someone to work on GFloppy has been useful; right now, Paul Betts and Riccardo Setti are working on a replacement using HAL and libparted, and are also getting the ball rolling for adding formatting support directly in HAL. Guys, you rock!

GTK+: I’ve been working on fixing some bugs of the GtkRecentChooserMenu widget; specifically, bug #377164 and bug #405696. While I was at it, I finally closed the FIXME I left in code, for supporting both appending and prepending custom menu items in the recent files menu, and finally added a test case for the widget, so I can track regressions.

Recent files menu
Obligatory screenshot of the test application

FOSDEM ’07: Like last year, at the end of February I’ll be in Bruxelles, attending FOSDEM.

Well That Was Easy

After a bit more than six months of work, Clutter 0.2.0 is finally out!

We put a lot of effort in making the API a bit less rough around the edges, and adding new features at the same time. Like the new Behaviour objects which can be used to control multiple actors using a function of time; or the fixed point API, which should make Clutter work fast even on embedded devices; or the Pango integration, which should keep the texture memory usage low and give you all the features of pango. On top of that, there’s the new memory management semantic of the actors – now working like GTK+ widgets: now you just ave to add an actor to a group, and the group itself will be responsible of deallocating the memory when the group gets destroyed.

Along with the core library there’s a GStreamer integration library, which you can use to add audio and video support to a Clutter application; a Cairo integration library, for drawing directly on a Clutter texture actor; and, obviously, Perl and Python bindings, so that you don’t have to use C to use Clutter.

Clutter is still a work in progress, and we at OpenedHand hope to add even more new features in the 0.3 development cycle – some of them are already planned and in the works right now. What we need are application developers willing to use Clutter and telling us what we need to add to Clutter to make it rock even more.

John Saw That Number

Thanks to Ross and his mad python-fu skillz, now we have a working Python binding for gtkunique – for the brave souls which may want to use it.

The repositories locations have been changed, after the servers update at OpenedHand, so here’s where the fun is:

  trunk:  bzr branch http://folks.o-hand.com/~ebassi/bzr/gtkunique
  python: bzr branch http://folks.o-hand.com/~ebassi/bzr/pygtkunique
  perl:   bzr branch http://folks.o-hand.com/~ebassi/bzr/gtkunique-perl

Testing is greatly appreciated.

gtkunique future: GtkUnique is API frozen, and feature complete as far as I’m concerned (bug fixing and eventual feature requests notwithstanding). I’ve opened a bug for integration into GTK+: #378260. You can watch it and give your opinion there.

Boogie Woogie Bugle Boy

Lately there has been some activity in projects moving from EggRecent to GtkRecent. Obviously, this led to questions and bugs opened about the API.

One of the questions is: if I had a EggRecentModel singleton what should I use now?. Since EggRecent needed a EggRecentModel around for the entire lifetime of the recently used files list, you had to keep at least a singleton around; you also had to pass it to the objects (not widgets) displaying the list, because each istance of the objects would modify the list itself. GtkRecentManager does not need that, since the widgets usually use their own internal instance of the manager and they don’t change the list in any way. So you can create a new GtkRecentManager and keep it around as a singleton (remember to call g_object_unref() on it when finished, otherwise you’ll leak it):

GtkRecentManager *manager_singleton = gtk_recent_manager_new ();

and then pass it to the widgets:

GtkWidget *dialog =
  gtk_recent_chooser_dialog_new_with_manager ("Recent Documents"
                                              parent,
                                              manager_singleton,
                                              GTK_STOCK_CLOSE,  GTK_RESPONSE_CLOSE,
                                              GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                              NULL);

Nevertheless, you should really use gtk_recent_manager_get_default() which will do the right thing, and pass you a per-process instance and you won’t have to care about its memory management (no g_object_unref() when quitting). Also, using gtk_recent_manager_get_default() means that you don’t have to use the _with_manager variant of the widgets constructor, as they will use the per-process GtkRecentManager by default. Using your own GtkRecentManager makes sense only if you want to use the “filename” constructor-only property to specify your own storage file (and you should do that only if you know what you are doing):

GtkRecentManager *manager = gtk_recent_manager_get_default ();

  ...

GtkWidget *dialog =
  gtk_recent_chooser_dialog_new ("Recent Documents"
                                 parent,
                                 GTK_STOCK_CLOSE,  GTK_RESPONSE_CLOSE,
                                 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                 NULL);

Another question is the dreaded I want an inline list of recent files in the File menu; I’ll redirect you to the bug report linked for the rationales about why I think the inline list sucks, and should be removed from the UIs of GNOME applications in favour of the sub-menu. Anyhow, for those Unbelievers still using this Windows-cloned relic of the past, here’s a simple function for adding an inline list to an existing GtkUIManager instance; it’s part of a example of integration between GtkRecent and the UI manager I sent to the gtk-devel mailing list before GUADEC.

static void
add_inline_recent_items (guint         merge_id,
                         GtkUIManager *ui_manager)
{
  GtkActionGroup *action_group;
  GtkRecentManager *manager;
  GList *items, *l;
  guint i;

  action_group = gtk_action_group_new ("recent-info");
  gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);

  manager = gtk_recent_manager_get_default ();

  /* we don't care about sorting and filtering, but it can
   * be done using g_list_sort_with_data() and clamping the
   * resulting list to the desired length
   */
  gtk_recent_manager_set_limit (manager, 4);
  items = gtk_recent_manager_get_items (manager);

  /* no items: attach an insensitive place holder */
  if (!items)
    {
      GtkAction *action;

      action = g_object_new (GTK_TYPE_ACTION,
      			     "name", "recent-info-empty",
			     "label", "No recently used files",
			     "sensitive", FALSE,
			     NULL);
      gtk_action_group_add_action (action_group, action);
      g_object_unref (action);

      gtk_ui_manager_add_ui (ui_manager, merge_id,
  			     "/MenuBar/FileMenu/RecentFiles",
			     "recent-info-empty",
			     "recent-info-empty",
			     GTK_UI_MANAGER_MENUITEM,
			     FALSE);

      return;
    }

  for (i = 0, l = items;
       l != NULL;
       i += 1, l = l->next)
    {
      GtkRecentInfo *info = l->data;
      gchar *name = g_strdup_printf ("recent-info-%d-%lu",
      				     i,
				     (gulong) time (NULL));
      gchar *action_name = g_strdup (name);
      GtkAction *action;

      action = g_object_new (GTK_TYPE_ACTION,
      			     "name", action_name,
			     "label", gtk_recent_info_get_display_name (info),
			     "stock_id", NULL,
			     NULL);
      g_object_set_data_full (G_OBJECT (action), "gtk-recent-info",
                              gtk_recent_info_ref (info),
			      (GDestroyNotify) gtk_recent_info_unref);
      g_signal_connect (action, "activate",
                        G_CALLBACK (recent_activate_cb), NULL);
      gtk_action_group_add_action (action_group, action);
      g_object_unref (action);

      /* all you need is a UI definition with a "placeholder" element called
       * "RecentFiles" under a "menu" element called "FileMenu".
       */
      gtk_ui_manager_add_ui (ui_manager, merge_id,
  			     "/MenuBar/FileMenu/RecentFiles",
			     name,
			     action_name,
			     GTK_UI_MANAGER_MENUITEM,
			     FALSE);

      g_print ("* adding action `%s'\n", action_name);

      g_free (action_name);
      g_free (name);
    }

  /* unref the info objects so that they will be destroyed when
   * the actions to which they are bound are destroyed with the
   * UIManager instance
   */
  g_list_foreach (items, (GFunc) gtk_recent_info_unref, NULL);
  g_list_free (items);
}

This code should give you an idea on how to implement your own version. Making the menu reloading the inline list means removing the UI definitions using the merge_id integer and calling this function again inside a callback attached to the “changed” signal of a GtkRecentManager instance, and it is left as an exercise for the reader. ;-)

GtkRecent and GtkUIManager

I’m really sorry that the UIManager integration did not happen in time for 2.10; it means that some applications will have to implement it by themselves until GTK+ 2.12 is out with a common implementation. In the meantime, continue asking me or opening bugs in Bugzilla.

Update@2006-08-02T09:51+0100: the complete code now has the “reload-when-list-change” feature. Remember: you may cut and paste this code for a basic support of recent files inside an inline menu; there are at least another couple of ways to implement the same level of support, and mostly it depends on how you handle your own documents. I’d like for GTK+ or libgnome or GLib to have a “document” class abstracting most of this and other stuff, like Cocoa on OSX has the NSDocument class.

Update@2006-08-02T16:05+0100: another update – I’ve fixed a couple of leaks (a GtkAction is a GObject and not a GtkObject) and added the sorting function for the inlined list.

How Good It Can Be

Corey, why on earth should we switch from an entire set of system configuration tools written in Perl to another one written in Python? Just for the sake of Python? Just because there are more Python zealots^Whackers on GNOME than there are Perl ones?

I understand that Ubuntu loves Python, but please: rewriting every tool in Python just for the sake of it is totally useless. What Python gives us over Perl, for system configuration backends? (No, it’s not a rethorical question: I’m serious).

Gtk+ 2.9.0 released

Finally, the first development release of GTK+ (codenamed The Magic Project Ridley aka libgnome sucks release by a developer whose name won’t be disclosed in this blog) has been finally sealed by Matthias Clasen yesterday, after battling with make distcheck.

There is so much goodness in this release that I’ll just wait for Kris to make a blog about it, and link the NEWS file and let you see the enormous work that has been done in the past nine months. So, find the contributor nearest to you and hug him (or buy him a beer); to help this hugging (and beer buying) procedure, here’s a list:

Ævar Arnfjörð Bjarmason, Akkana Peck, Alexander Larsson, Alexander Nedotuskov, Alex Graveley, Anders Carlsson, Andrei Yurkevich, Andrew Conkling, Andrew S. Dixon, Arjan van de Ven, Arnaud Charlet, Bastien Nocera, Behdad Esfahbod, Benedikt Meurer, Benjamin Berg, Benjamin Otte, Benoît Carpentier, Bodo-Merle Sandor, Bogdan Nicula, Brad Taylor, Calum Benson, Carlos Garnacho Parro, Carl Worth, Chris Lahey, Chris Lord, Christian Kirbach, Christian Lohmaier, Christian Neumair, Christian Persch, Christian Stimming, Christophe Belle, Claudio Saavedra, Clytie Siddall, Colin Walters, Cory Dodt, Coverity, Crispin Flowerday, Damien Carbery, Damon Chaplin, Daniel Drake, Daniel Kasak, Dan Winship, Dave Andreoli, David Baron, David Trowbridge, Davyd Madeley, Denis Auroux, Dennis Cranston, Diego González, Dom Lachowicz, Donald Straney, Duncan Coutts, Ed Catmur, Elie De Brauwer, Emmanuel Rodriguez, Eric Cazeaux, Evert Verhellen, Francisco Javier F. Serrador, Frederic Croszat, Guilherme de S. Pastore, Guillaume Cottenceau, Gustavo Carneiro, Hamed Malek, Hans Breuer, Havoc Pennington, Hylke van der Schaaf, Ian McDonald, Itai Bar-Haim, Jaap A. Haitsma, James Su, Jean-Yves Lefort, Jens Granseuer, Jeremy Cook, Jody Goldberg, Joe Marcus Clarke, Joe Wreschnig, Johan Dahlin, John Cupitt, John Ehresman, John Finlay, John Palmieri, John Spray, Jonathan Blandford, Jorn Baayen, JP Rosevaar, Jürg Billeter, Kalle Vahlmann, Kathy Fernandez, Kazuki Iwamoto, Kean Johnston, Kjartan Maraas, Kristian Rietveld, Larry Ewing, Leena Gunda, Lillian Angel, Li Yuan, Lorenzo Gil Sanchez, Maciej Katafiasz, Magnus Bergmann, Markku Vire, Mark McLoughlin, Marko Anastasov, Mark Wielaard, Mart Raudsepp, Martyn Russell, Mathias Hasselmann, Matthijs Douze, Maxim Udushlivy, Michael Emmel, Michael Natterer, Milosz Derezynski, Morten Welinder, Murray Cumming, Nickolay V. Shmyrev, Nicolas Setton, Niklas Knutsson, Olexiy Avramchenko, Owen Taylor, Paolo Borelli, Paolo Maggi, Peter Breitenlohner, Peter Harvey, Peter Lund, Peter Zelezny, Philip Langdale, Raphael Slinckx, Ray Strode, Richard Hult, Robert Ögren, Rodney Dawes, Ross Burton, Ryan Lovett, Sadrul Habib Chowdhury, Sebastien Bacher, Søren Sandmann, Stanislav Brabec, Stefan Kost, Stephane Chauveau, Steve Chaplin, Steve Frécinaux, Sven Herzberg, Sven Neumann, Thomas Broyer, Thomas Fitzsimmons, Thomas Klausner, Thomas Leonard, Tim Evans, Tim Janik, Todd Berman, Tommi Komulainen, Torbjörn Andersson, Tor Lillqvist (and his Evil Twin), Torsten Schoenfeld, Tze’ela Hebron, Vincent Untz, Wolfgang Thaller, Wouter Bolsterlee, Yang Hong, Yevgen Muntyan, Yong Wang. And, obviously, our fearless maintainer Matthias Clasen.

Kudos to all of them.

FOSDEM 2006

Next week-end I’ll be in Brussels, at this year’s FOSDEM.

I wasn’t sure whether I’d be able to go or not – late flight booking and I had to check at two hostels before actually getting some place to sleep. I mostly plan to attend the GNOME track, especially Philip‘s talk on design patterns using GObject and Kristian‘s talk on Project Ridley; also, the X.org track and the embedded Linux track promise to be really interesting.