src/gtkconv.c

changeset 6407
d67b6a6ba7d2
parent 6405
30166fa1b9a2
child 6433
de2056e0136a
--- a/src/gtkconv.c	Thu Aug 07 01:15:54 2003 +0000
+++ b/src/gtkconv.c	Thu Aug 07 20:47:29 2003 +0000
@@ -4623,6 +4623,37 @@
 }
 
 static void
+gaim_gtkconv_chat_add_users(GaimConversation *conv, GList *users)
+{
+	GaimChat *chat;
+	GaimGtkConversation *gtkconv;
+	GaimGtkChatPane *gtkchat;
+	GList *l;
+	char tmp[BUF_LONG];
+	int num_users;
+	int pos;
+
+	chat    = GAIM_CHAT(conv);
+	gtkconv = GAIM_GTK_CONVERSATION(conv);
+	gtkchat = gtkconv->u.chat;
+
+	num_users = g_list_length(gaim_chat_get_users(chat));
+
+	g_snprintf(tmp, sizeof(tmp),
+			   ngettext("%d person in room", "%d people in room",
+						num_users),
+			   num_users);
+
+	gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp);
+
+	for (l = users; l != NULL; l = l->next) {
+		pos = g_list_index(gaim_chat_get_users(chat), (char *)l->data);
+
+		add_chat_buddy_common(conv, (char *)l->data, pos);
+	}
+}
+
+static void
 gaim_gtkconv_chat_rename_user(GaimConversation *conv, const char *old_name,
 							  const char *new_name)
 {
@@ -4740,6 +4771,70 @@
 }
 
 static void
+gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users)
+{
+	GaimChat *chat;
+	GaimGtkConversation *gtkconv;
+	GaimGtkChatPane *gtkchat;
+	GtkTreeIter iter;
+	GtkTreeModel *model;
+	GList *names = NULL;
+	GList *l;
+	char tmp[BUF_LONG];
+	int num_users;
+	int f = 1;
+
+	chat    = GAIM_CHAT(conv);
+	gtkconv = GAIM_GTK_CONVERSATION(conv);
+	gtkchat = gtkconv->u.chat;
+
+	num_users = g_list_length(gaim_chat_get_users(chat)) -
+	            g_list_length(users);
+
+	for (l = users; l != NULL; l = l->next) {
+		for (names = gaim_chat_get_users(chat);
+			 names != NULL;
+			 names = names->next) {
+
+			char *u = (char *)names->data;
+
+			if (!gaim_utf8_strcasecmp(u, (char *)l->data)) {
+				model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list));
+
+				if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model),
+												   &iter))
+					break;
+
+				while (f != 0) {
+					char *val;
+
+					gtk_tree_model_get(GTK_TREE_MODEL(model), &iter,
+									   1, &val, -1);
+
+					if (!gaim_utf8_strcasecmp((char *)l->data, val))
+						gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
+
+					f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
+
+					g_free(val);
+				}
+
+				break;
+			}
+		}
+	}
+
+	if (names == NULL)
+		return;
+
+	g_snprintf(tmp, sizeof(tmp),
+			   ngettext("%d person in room", "%d people in room",
+						num_users), num_users);
+
+	gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp);
+}
+
+static void
 gaim_gtkconv_set_title(GaimConversation *conv, const char *title)
 {
 	GaimGtkConversation *gtkconv;
@@ -4892,8 +4987,10 @@
 	gaim_gtkconv_write_im,           /* write_im             */
 	gaim_gtkconv_write_conv,         /* write_conv           */
 	gaim_gtkconv_chat_add_user,      /* chat_add_user        */
+	gaim_gtkconv_chat_add_users,     /* chat_add_users       */
 	gaim_gtkconv_chat_rename_user,   /* chat_rename_user     */
 	gaim_gtkconv_chat_remove_user,   /* chat_remove_user     */
+	gaim_gtkconv_chat_remove_users,  /* chat_remove_users    */
 	gaim_gtkconv_set_title,          /* set_title            */
 	NULL,                            /* update_progress      */
 	gaim_gtkconv_updated             /* updated              */

mercurial