X-Git-Url: http://cgit.babelmonkeys.de/?p=jubjub.git;a=blobdiff_plain;f=src%2Fgui%2Fgtk%2FJubGtkRosterUI.m;fp=src%2Fgui%2Fgtk%2FJubGtkRosterUI.m;h=227837dae7f63a979c634ea90a964656361017ca;hp=a742ba33b3bb2e8e37fa6d6cf3b4208227985364;hb=51295ea2536067f9aaf8bddafa25840235109801;hpb=ac24f40fcae2a1e7fc44d36e5f8448ec1cbe4120 diff --git a/src/gui/gtk/JubGtkRosterUI.m b/src/gui/gtk/JubGtkRosterUI.m index a742ba3..227837d 100644 --- a/src/gui/gtk/JubGtkRosterUI.m +++ b/src/gui/gtk/JubGtkRosterUI.m @@ -156,114 +156,109 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model, - (void)Jub_addRosterItem: (XMPPRosterItem*)item group: (OFString*)group { - g_idle_add_block(^{ - GtkTreeIter group_iter, contact_iter; - GtkTreeRowReference *group_ref, *contact_ref; - GtkTreePath *group_path, *contact_path; - OFString *bareJID = [item.JID bareJID]; - OFMapTable *contactRows; - - if (!(contactRows = [_contactMap objectForKey: bareJID])) { - contactRows = [OFMapTable - mapTableWithKeyFunctions: keyFunctions - valueFunctions: rowRefFunctions]; - - [_contactMap setObject: contactRows - forKey: bareJID]; - } - - group_ref = [_groupMap valueForKey: group]; - - if (!group_ref) { - // Create new group row - gtk_tree_store_append(_roster_model, &group_iter, NULL); - gtk_tree_store_set(_roster_model, &group_iter, - 0, [group UTF8String], -1); - - group_path = gtk_tree_model_get_path(GTK_TREE_MODEL( - _roster_model), &group_iter); - - group_ref = gtk_tree_row_reference_new(GTK_TREE_MODEL( - _roster_model), group_path); + GtkTreeIter group_iter, contact_iter; + GtkTreeRowReference *group_ref, *contact_ref; + GtkTreePath *group_path, *contact_path; + OFString *bareJID = [item.JID bareJID]; + OFMapTable *contactRows; + + if (!(contactRows = [_contactMap objectForKey: bareJID])) { + contactRows = [OFMapTable + mapTableWithKeyFunctions: keyFunctions + valueFunctions: rowRefFunctions]; + + [_contactMap setObject: contactRows + forKey: bareJID]; + } - [_groupMap setValue: group_ref - forKey: group]; - } else { - // Get iter for existing group row - group_path = gtk_tree_row_reference_get_path(group_ref); + group_ref = [_groupMap valueForKey: group]; - gtk_tree_model_get_iter(GTK_TREE_MODEL(_roster_model), - &group_iter, group_path); - } - gtk_tree_path_free(group_path); - - // Create new contact row - gtk_tree_store_append(_roster_model, &contact_iter, - &group_iter); - if (item.name) - gtk_tree_store_set(_roster_model, &contact_iter, - 0, [item.name UTF8String], - 1, [bareJID UTF8String], - 2, "unavailable", -1); - else if (item.JID.node) - gtk_tree_store_set(_roster_model, &contact_iter, - 0, [item.JID.node UTF8String], - 1, [bareJID UTF8String], - 2, "unavailable", -1); - else - gtk_tree_store_set(_roster_model, &contact_iter, - 0, [item.JID.domain UTF8String], - 1, [bareJID UTF8String], - 2, "unavailable", -1); + if (!group_ref) { + // Create new group row + gtk_tree_store_append(_roster_model, &group_iter, NULL); + gtk_tree_store_set(_roster_model, &group_iter, + 0, [group UTF8String], -1); - contact_path = gtk_tree_model_get_path(GTK_TREE_MODEL( - _roster_model), &contact_iter); + group_path = gtk_tree_model_get_path(GTK_TREE_MODEL( + _roster_model), &group_iter); - contact_ref = gtk_tree_row_reference_new(GTK_TREE_MODEL( - _roster_model), contact_path); + group_ref = gtk_tree_row_reference_new(GTK_TREE_MODEL( + _roster_model), group_path); - gtk_tree_path_free(contact_path); + [_groupMap setValue: group_ref + forKey: group]; + } else { + // Get iter for existing group row + group_path = gtk_tree_row_reference_get_path(group_ref); - [contactRows setValue: contact_ref - forKey: group]; - }); + gtk_tree_model_get_iter(GTK_TREE_MODEL(_roster_model), + &group_iter, group_path); + } + gtk_tree_path_free(group_path); + + // Create new contact row + gtk_tree_store_append(_roster_model, &contact_iter, &group_iter); + if (item.name) + gtk_tree_store_set(_roster_model, &contact_iter, + 0, [item.name UTF8String], + 1, [bareJID UTF8String], + 2, "unavailable", -1); + else if (item.JID.node) + gtk_tree_store_set(_roster_model, &contact_iter, + 0, [item.JID.node UTF8String], + 1, [bareJID UTF8String], + 2, "unavailable", -1); + else + gtk_tree_store_set(_roster_model, &contact_iter, + 0, [item.JID.domain UTF8String], + 1, [bareJID UTF8String], + 2, "unavailable", -1); + + contact_path = gtk_tree_model_get_path(GTK_TREE_MODEL(_roster_model), + &contact_iter); + + contact_ref = gtk_tree_row_reference_new(GTK_TREE_MODEL(_roster_model), + contact_path); + + gtk_tree_path_free(contact_path); + + [contactRows setValue: contact_ref + forKey: group]; } - (void)Jub_removeRosterItem: (XMPPRosterItem*)item group: (OFString*)group { - g_idle_add_block(^{ - GtkTreeIter contact_iter, group_iter; - GtkTreePath *contact_path, *group_path; - GtkTreeRowReference *contact_ref, *group_ref; - OFString *bareJID = [item.JID bareJID]; - OFMapTable *contactRows = [_contactMap objectForKey: bareJID]; - - contact_ref = [contactRows valueForKey: group]; - contact_path = gtk_tree_row_reference_get_path(contact_ref); - gtk_tree_model_get_iter(GTK_TREE_MODEL(_roster_model), - &contact_iter, contact_path); - gtk_tree_path_free(contact_path); - - gtk_tree_store_remove(_roster_model, &contact_iter); - - group_ref = [_groupMap valueForKey: group]; - group_path = gtk_tree_row_reference_get_path(group_ref); - gtk_tree_model_get_iter(GTK_TREE_MODEL(_roster_model), - &group_iter, group_path); - - if (!gtk_tree_model_iter_has_child(GTK_TREE_MODEL( - _roster_model), &group_iter)) { - gtk_tree_store_remove(_roster_model, &group_iter); - [_groupMap removeValueForKey: group]; - } + GtkTreeIter contact_iter, group_iter; + GtkTreePath *contact_path, *group_path; + GtkTreeRowReference *contact_ref, *group_ref; + OFString *bareJID = [item.JID bareJID]; + OFMapTable *contactRows = [_contactMap objectForKey: bareJID]; + + contact_ref = [contactRows valueForKey: group]; + contact_path = gtk_tree_row_reference_get_path(contact_ref); + gtk_tree_model_get_iter(GTK_TREE_MODEL(_roster_model), &contact_iter, + contact_path); + gtk_tree_path_free(contact_path); + + gtk_tree_store_remove(_roster_model, &contact_iter); + + group_ref = [_groupMap valueForKey: group]; + group_path = gtk_tree_row_reference_get_path(group_ref); + gtk_tree_model_get_iter(GTK_TREE_MODEL(_roster_model), &group_iter, + group_path); + + if (!gtk_tree_model_iter_has_child(GTK_TREE_MODEL(_roster_model), + &group_iter)) { + gtk_tree_store_remove(_roster_model, &group_iter); + [_groupMap removeValueForKey: group]; + } - gtk_tree_path_free(group_path); + gtk_tree_path_free(group_path); - [contactRows removeValueForKey: group]; - if([contactRows count] == 0) - [_contactMap removeObjectForKey: bareJID]; - }); + [contactRows removeValueForKey: group]; + if([contactRows count] == 0) + [_contactMap removeObjectForKey: bareJID]; } - (void)contactManager: (XMPPContactManager*)manager @@ -276,8 +271,10 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model, groups = @[ @"General" ]; for (OFString *group in groups) - [self Jub_addRosterItem: rosterItem - group: group]; + [self performSelectorOnGLibThread: @selector( + Jub_addRosterItem:group:) + withObject: rosterItem + withObject: group]; } - (void)contactManager: (XMPPContactManager*)manager @@ -290,8 +287,10 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model, groups = @[ @"General" ]; for (OFString *group in groups) - [self Jub_removeRosterItem: rosterItem - group: group]; + [self performSelectorOnGLibThread: @selector( + Jub_removeRosterItem:group:) + withObject: rosterItem + withObject: group]; } - (void)contact: (XMPPContact*)contact @@ -305,8 +304,10 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model, groups = @[ @"General" ]; for (OFString *group in groups) - [self Jub_removeRosterItem: oldItem - group: group]; + [self performSelectorOnGLibThread: @selector( + Jub_removeRosterItem:group:) + withObject: oldItem + withObject: group]; // Add contact to new set of groups groups = rosterItem.groups; @@ -315,8 +316,10 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model, groups = @[ @"General" ]; for (OFString *group in groups) - [self Jub_addRosterItem: rosterItem - group: group]; + [self performSelectorOnGLibThread: @selector( + Jub_addRosterItem:group:) + withObject: rosterItem + withObject: group]; } - (void)contact: (XMPPContact*)contact