+- (void)contact: (XMPPContact*)contact
+ didSetAvatar: (OFString*)avatarFile
+{
+ of_log(@"Got an avatar from %@", contact.rosterItem.JID);
+ g_idle_add_block(^{
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeRowReference *ref;
+ OFString *bareJID = [contact.rosterItem.JID bareJID];
+ OFMapTable *contactRows = [_contactMap objectForKey: bareJID];
+ OFArray *groups = contact.rosterItem.groups;;
+
+ GdkPixbuf *avatar =
+ gdk_pixbuf_new_from_file([avatarFile UTF8String], NULL);
+
+ if (groups == nil)
+ groups = @[ @"General" ];
+
+ for (OFString *group in groups) {
+ ref = [contactRows valueForKey: group];
+ path = gtk_tree_row_reference_get_path(ref);
+ gtk_tree_model_get_iter(GTK_TREE_MODEL(_roster_model),
+ &iter, path);
+ gtk_tree_path_free(path);
+
+ gtk_tree_store_set(_roster_model, &iter,
+ 4, avatar, -1);
+ }
+ g_object_unref(G_OBJECT(avatar));
+ });
+}
+