Finding redundant GObject classes in Empathy

As part of a bugfix I did today ((Thanks, as always, to my employer, Collabora, for letting me work on Empathy)), I made a commit to remove a redundant class from Empathy, which made me wonder if there were any other redundant classes in Empathy. A quick grep of G_DEFINE_ told me there are some 116 classes in Empathy, so I wasn’t going to check them all by hand.

Instead I put together this script, which I share with you in case it’s useful, which basically checks for all classes defined with G_DEFINE_TYPE and then looks to see if anything with that namespace is used in another file. It generates false positives for classes that aren’t used outside the file they’re defined in, or classes that have different namespaces to the classname, but it produces a much more manageable list.

I did consider looking for unused symbols, but couldn’t work out an easy way to do it properly. Empathy’s compile process is split into two archive libraries (libempathy.a and libempathy-gtk.a) and several binaries (empathy, empathy-call, empathy-accounts, etc.), so I couldn’t think of a way to ask the linker to find any unused symbols. I put together this second script, which will build a list of symbols in archives and look for those symbols copied into the binaries, which gets some of the way there, but will miss any unused symbols defined in the binaries’ sources (src/).

Desktop Summit Code of Conduct?

In light of OSCON adopting a code of conduct and anti-harassment policy, I was wondering, and even asked today, if the Desktop Summit has adopted an anti-harassment policy. Unfortunately I’m not going to make it to the Desktop Summit this year, but I searched a bit and all I could find was Dave Neary promising that Desktop Summit would adopt one [1, 2].

Can anyone tell me if the Desktop Summit has adopted a code of conduct? and if so, where I can find it? or if not, why the heck not?

Update: I have been contacted by an organiser to say that a draft attendees code of conduct has been written and will be published before the conference. Thanks for getting in touch so promptly 🙂

Update 2: the policy has now been published.

Empathy and GNOME Online Accounts

Today at the IM, Contacts and Social hackfest we talked about supporting chat accounts in GNOME Online Accounts.

I did some work exposing accounts from GNOME Online Accounts to Telepathy (Bug #652543). It still needs a little bit of work, but from Empathy it looks like this ((ignore the other Google Talk entry, that’s my non-GOA chat account)):

Empathy Accounts

With this work Empathy will prompt for the account password when there is a GOA account. Guillaume is currently working on extending Empathy’s authentication handler to authenticate automatically using the credentials from GOA (#652546).

Bastien is extending GOA to include a Chat account type so that you can control whether to enable chat from Online Accounts (#652574).

heading to IM, Contacts and Social hackfest

I am currently sat in Dubai airport on my way to the IM, Contacts and Social hackfest in at Collabora’s office in (real) Cambridge. Hopefully this week will get some cool progress made it integrating Telepathy and Folks into GNOME 3.

My attendance is sponsored by my employer, Collabora.


In recognition of the occasion, I actually started running GNOME 3. I’m enjoying it, except for missing Cantarell ((maybe I’m just missing a package, I’m running the gnome3-team ppa on Ubuntu natty)) and this focus follows mouse bug. I am looking forward to the reappearance of the world clocks.

Also it seems you can no longer make the screen lock on suspend, which feels like a big deal, because I’m the kind of person to leave a sleeping laptop lying around. If no one already has a good solution to this, I might write a fix using a gnome-shell extension.


It used to be that you could set different timeouts for screen blanking vs. screen locking. I’ve lived without this feature in recent years by remembering to press the lock-screen button on my keyboard, but I had this strange idea on the plane that screen locking can also be tied-in with IM presence.

At the moment the screen blanks after the idle time, which is equivalent to the away status in Telepathy (the computer is idle, save some power, also if the user has sound turned off, she won’t see your text). Whereas I wanted the screen to lock automatically after an extended period of being away, the xa status in Telepathy?

For the moment (it may change this week) Empathy is responsible for setting the presence in Mission Control, setting away in response to gnome-session and setting xa itself. Either the session could add a concept of extended away, which I could wire up to lock the screen. Or I could listen to the presence change from Mission Control. This could always be another shell extension.

Help! Links in GtkCellRenderers

I’m hoping that someone already has a solution to this, but I couldn’t find one via Google Code Search.

What I want is a GtkCellRenderer that can render markup which contains links, exactly like a modern GtkLabel can. If it can also render small 16px inline images, that would be pretty awesome bonus.

Before I write it myself, does anyone already have one of these (with a GPL-compatible license)?

Quick Tip: gtk_show_uri(): Operation Not Supported

Writing this down because it took me way too long to realise what I was missing.

If you’re getting the error “Operation Not Supported” when calling gtk_show_uri() or g_app_info_launch_default_for_uri(), then you’re most likely missing gvfs, which contains the extension points for all non-file:// URI schemas.

Now here’s the bit I forgot… gvfs has to be installed in the same prefix as glib. So if it works for your system GLib, but not for the one you built in some prefix, you probably forgot to build and install gvfs in that prefix.


The biographies of the advisory group for the Ada Initiative was recently announced and I’m extremely proud to say that I’m a part of it.

In other news, I merged support for contact blocking in Empathy 2.33.2, which will be in the Empathy 2.34 release (the gtk2 branch of Empathy), for Telepathy connection managers that support blocking (at least Google Talk). Hopefully my talented GOPW intern Chandi will find time to forward port that work to master (i.e. Empathy 3.x) before I do, so everyone else can enjoy it too.

Thanks to the hard work of other Collaborans (Emilio and Sjoerd), Empathy 2.33.2 also has experimental support for Call, the new VoIP API in Telepathy that supports a lot more than the older StreamedMedia API.

LD_PRELOAD GObject lifetime debugging tool

For years and years I’ve dreamt of a tool that would show me what GObjects are currently alive, and let me have a look at information about them. Today, while trying to debug a particularly horrid reference leak (program wedged under refdbg, and without being able to script SIGTRAP I’ve never found this method useful), I actually started writing the tool.

The tool uses LD_PRELOAD to replace g_object_new() — it should really replace g_object_newv() and g_object_new_valist() also, but I didn’t need those — to install a weak reference on the created objects to track their lifetime.

The result of which is something like this:

[danni@adelie src]$ \
 ++ Created object 0x9912530, GabbleGatewayPlugin
 ++ Created object 0x990c460, GabblePluginLoader
 ++ Created object 0x9917ab8, GabbleJabberProtocol
 ++ Created object 0x99172f0, GabbleConnectionManager

You can then list the currently living objects and their reference counts by sending SIGUSR1.

[danni@adelie src]$ killall -USR1 telepathy-gabble
Living Objects:
 - 0x9b47038, GabblePresence: 1 refs
 - 0x990c460, GabblePluginLoader: 2 refs
 - 0x9918ae0, GabbleRosterChannel: 1 refs
 - 0x991cb38, GabbleIMChannel: 1 refs

This by itself was useful in showing which object wasn’t finalized but should have been (and why my object in question also hadn’t finalized), but didn’t show me who was still holding the reference.

My hunch was that the problem was a reference cycle between two objects, so I hacked a bit of code into my tool to list the “connection” property on all objects that had it. [In Telepathy Connection Managers, objects are typically meant to let this go when connections become disconnected.]

  while (g_hash_table_iter_next (&iter, (gpointer) &obj, NULL))
      GObjectClass *klass;
      GObject *conn;

      g_print (" - %p, %s: %u refs\n",
          obj, G_OBJECT_TYPE_NAME (obj), obj->ref_count);

      klass = G_OBJECT_GET_CLASS (obj);
      if (g_object_class_find_property (klass, "connection") != NULL)
          g_object_get (obj,
              "connection", &conn,
          g_print ("\t + connection = %p\n", conn);
          if (conn != NULL)
            g_object_unref (conn);

This showed me which object was still holding a ref it should have let go. [Now I just need to work out why, the code in question is in an abstract base class, for which 5 of 6 concrete classes work correctly.]

If you’re interested, the code is in Git.

The tool could still benefit from a lot of work. For instance, the filtering is pretty basic at the moment and it should support all the ways to create GObjects. Originally I had envisioned this tool as a GUI window that popped up, so that you could click on an object and view all of its properties, connected signals, etc. That would be pretty neat actually.

Update: cassidy has already contributed by adding a listing of the objects remaining when a program exits and thus found a leak in Empathy. Awesome!

Creative Commons Attribution-ShareAlike 2.5 Australia
This work by Danielle Madeley is licensed under a Creative Commons Attribution-ShareAlike 2.5 Australia.