multi-threading in a Pidgin plugin

Kevin Stange kstange at
Sat Sep 15 06:24:06 EDT 2012

On 09/15/2012 03:37 AM, Martin Stiborský wrote:
> Hello,
> I'm working on a plugin for Pidgin. This plugin adds few things into
> the UI of the Pidgin and one part is a GtkImage - for this widget, I
> need to download a image from network and display it.
> More specifically, the image is a avatar photo, stored on company
> intranet and when you select a buddy in a buddy list, the image
> change.
> I need to put this "fetch image" part to another thread I guess -
> because I don't want to block the UI.

Probably, your best bet is to look at the existing functions we use for
fetching things, however if this isn't happening over HTTP, this may not
work.  Even so, these functions may serve as inspiration for the ones
you need to write.  Take a look at our URI/URL functions in util.h:

> What is the best practices to do that in Pidgin and libpurple? I've
> read a few things about libpurple and thread, but because I'm quite
> new to C and multi-processing (posix threads...) at all, I'm confused.
> For example, in source codes in pidgin, I've found only one usage of
> "pthread_create", so I guess there is a another solution.

Pidgin and libpurple are not thread safe.  It's better for you to hook
your asynchronous code into the glib/GTK+ main loop and use signals and
callbacks to start and step through your request and then retrieve data
when it's ready.  See eventloop.h:

> Thanks guys, for any hint!


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the Devel mailing list