comparison src/gtkconv.c @ 11869:3ba50c385299

[gaim-migrate @ 14160] This should make joining big channels a bit quicker/more efficient. It was really bad before, now it's just bad. My crude testing showed it shaved a few hundred thousand library calls of joining #gaim, so it can't be too bad. committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Fri, 28 Oct 2005 01:46:12 +0000
parents fa7b84231ece
children 34ea75bdd0c9
comparison
equal deleted inserted replaced
11868:4b71193448b3 11869:3ba50c385299
119 /* Prototypes. <-- because Paco-Paco hates this comment. */ 119 /* Prototypes. <-- because Paco-Paco hates this comment. */
120 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first); 120 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first);
121 static void gray_stuff_out(GaimGtkConversation *gtkconv); 121 static void gray_stuff_out(GaimGtkConversation *gtkconv);
122 static GList *generate_invite_user_names(GaimConnection *gc); 122 static GList *generate_invite_user_names(GaimConnection *gc);
123 static void add_chat_buddy_common(GaimConversation *conv, const char *name, 123 static void add_chat_buddy_common(GaimConversation *conv, const char *name,
124 const char *alias, const char *old_name); 124 GaimConvChatBuddyFlags flags, const char *alias, const char *old_name);
125 static gboolean tab_complete(GaimConversation *conv); 125 static gboolean tab_complete(GaimConversation *conv);
126 static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type); 126 static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type);
127 static void gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state); 127 static void gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state);
128 static void update_typing_icon(GaimGtkConversation *gtkconv); 128 static void update_typing_icon(GaimGtkConversation *gtkconv);
129 static char *item_factory_translate_func (const char *path, gpointer func_data); 129 static char *item_factory_translate_func (const char *path, gpointer func_data);
1356 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) 1356 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv)
1357 { 1357 {
1358 GaimConversation *conv = gtkconv->active_conv; 1358 GaimConversation *conv = gtkconv->active_conv;
1359 GaimGtkChatPane *gtkchat; 1359 GaimGtkChatPane *gtkchat;
1360 GaimConvChat *chat; 1360 GaimConvChat *chat;
1361 GaimConvChatBuddyFlags flags;
1361 GtkTreeIter iter; 1362 GtkTreeIter iter;
1362 GtkTreeModel *model; 1363 GtkTreeModel *model;
1363 GtkTreeSelection *sel; 1364 GtkTreeSelection *sel;
1364 char *name; 1365 char *name;
1365 char *alias; 1366 char *alias;
1372 1373
1373 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { 1374 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) {
1374 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1375 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter,
1375 CHAT_USERS_NAME_COLUMN, &name, 1376 CHAT_USERS_NAME_COLUMN, &name,
1376 CHAT_USERS_ALIAS_COLUMN, &alias, 1377 CHAT_USERS_ALIAS_COLUMN, &alias,
1378 CHAT_USERS_FLAGS_COLUMN, &flags,
1377 -1); 1379 -1);
1378 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); 1380 gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
1379 } 1381 }
1380 else 1382 else
1381 return; 1383 return;
1383 if (gaim_conv_chat_is_user_ignored(chat, name)) 1385 if (gaim_conv_chat_is_user_ignored(chat, name))
1384 gaim_conv_chat_unignore(chat, name); 1386 gaim_conv_chat_unignore(chat, name);
1385 else 1387 else
1386 gaim_conv_chat_ignore(chat, name); 1388 gaim_conv_chat_ignore(chat, name);
1387 1389
1388 add_chat_buddy_common(conv, name, alias, NULL); 1390 add_chat_buddy_common(conv, name, flags, alias, NULL);
1389 g_free(name); 1391 g_free(name);
1390 g_free(alias); 1392 g_free(alias);
1391 } 1393 }
1392 1394
1393 static void 1395 static void
2853 2855
2854 return scale; 2856 return scale;
2855 } 2857 }
2856 2858
2857 static void 2859 static void
2858 add_chat_buddy_common(GaimConversation *conv, const char *name, const char *alias, const char *old_name) 2860 add_chat_buddy_common(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags, const char *alias, const char *old_name)
2859 { 2861 {
2860 GaimGtkConversation *gtkconv; 2862 GaimGtkConversation *gtkconv;
2861 GaimGtkChatPane *gtkchat; 2863 GaimGtkChatPane *gtkchat;
2862 GaimConvChat *chat; 2864 GaimConvChat *chat;
2863 GaimConnection *gc; 2865 GaimConnection *gc;
2864 GaimPluginProtocolInfo *prpl_info; 2866 GaimPluginProtocolInfo *prpl_info;
2865 GaimConvChatBuddyFlags flags;
2866 GtkListStore *ls; 2867 GtkListStore *ls;
2867 GdkPixbuf *pixbuf; 2868 GdkPixbuf *pixbuf;
2868 GtkTreeIter iter; 2869 GtkTreeIter iter;
2869 gboolean is_me = FALSE; 2870 gboolean is_me = FALSE;
2870 gboolean is_buddy; 2871 gboolean is_buddy;
2880 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) 2881 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)))
2881 return; 2882 return;
2882 2883
2883 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); 2884 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)));
2884 2885
2885 flags = gaim_conv_chat_user_get_flags(chat, name);
2886 pixbuf = get_chat_buddy_status_icon(chat, name, flags); 2886 pixbuf = get_chat_buddy_status_icon(chat, name, flags);
2887 2887
2888 if (!strcmp(chat->nick, gaim_normalize(conv->account, old_name != NULL ? old_name : name))) 2888 if (!strcmp(chat->nick, gaim_normalize(conv->account, old_name != NULL ? old_name : name)))
2889 is_me = TRUE; 2889 is_me = TRUE;
2890 2890
4338 gtkconv_set_unseen(gtkconv, unseen); 4338 gtkconv_set_unseen(gtkconv, unseen);
4339 } 4339 }
4340 } 4340 }
4341 4341
4342 static void 4342 static void
4343 gaim_gtkconv_chat_add_users(GaimConversation *conv, GList *users, GList *aliases) 4343 gaim_gtkconv_chat_add_users(GaimConversation *conv, GList *users, GList *flags, GList *aliases)
4344 { 4344 {
4345 GaimConvChat *chat; 4345 GaimConvChat *chat;
4346 GaimGtkConversation *gtkconv; 4346 GaimGtkConversation *gtkconv;
4347 GaimGtkChatPane *gtkchat; 4347 GaimGtkChatPane *gtkchat;
4348 GList *l; 4348 GList *l;
4349 GList *ll; 4349 GList *ll;
4350 GList *lll;
4350 char tmp[BUF_LONG]; 4351 char tmp[BUF_LONG];
4351 int num_users; 4352 int num_users;
4352 4353
4353 chat = GAIM_CONV_CHAT(conv); 4354 chat = GAIM_CONV_CHAT(conv);
4354 gtkconv = GAIM_GTK_CONVERSATION(conv); 4355 gtkconv = GAIM_GTK_CONVERSATION(conv);
4362 num_users); 4363 num_users);
4363 4364
4364 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); 4365 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp);
4365 4366
4366 l = users; 4367 l = users;
4367 ll = aliases; 4368 ll = flags;
4368 while (l != NULL && ll != NULL) { 4369 lll = aliases;
4369 add_chat_buddy_common(conv, (const char *)l->data, (const char *)ll->data, NULL); 4370 while (l != NULL && ll != NULL && lll != NULL) {
4371 add_chat_buddy_common(conv, (const char *)l->data, GPOINTER_TO_INT(ll->data), (const char *)lll->data, NULL);
4370 l = l->next; 4372 l = l->next;
4371 ll = ll->next; 4373 ll = ll->next;
4374 lll = lll->next;
4372 } 4375 }
4373 } 4376 }
4374 4377
4375 static void 4378 static void
4376 gaim_gtkconv_chat_rename_user(GaimConversation *conv, const char *old_name, 4379 gaim_gtkconv_chat_rename_user(GaimConversation *conv, const char *old_name,
4377 const char *new_name, const char *new_alias) 4380 const char *new_name, const char *new_alias)
4378 { 4381 {
4379 GaimConvChat *chat; 4382 GaimConvChat *chat;
4380 GaimGtkConversation *gtkconv; 4383 GaimGtkConversation *gtkconv;
4381 GaimGtkChatPane *gtkchat; 4384 GaimGtkChatPane *gtkchat;
4385 GaimConvChatBuddyFlags flags;
4382 GtkTreeIter iter; 4386 GtkTreeIter iter;
4383 GtkTreeModel *model; 4387 GtkTreeModel *model;
4384 int f = 1; 4388 int f = 1;
4385 4389
4386 chat = GAIM_CONV_CHAT(conv); 4390 chat = GAIM_CONV_CHAT(conv);
4393 return; 4397 return;
4394 4398
4395 while (f != 0) { 4399 while (f != 0) {
4396 char *val; 4400 char *val;
4397 4401
4398 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); 4402 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1);
4399 4403
4400 if (!gaim_utf8_strcasecmp(old_name, val)) { 4404 if (!gaim_utf8_strcasecmp(old_name, val)) {
4401 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); 4405 gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
4402 g_free(val); 4406 g_free(val);
4403 break; 4407 break;
4411 if (!gaim_conv_chat_find_user(chat, old_name)) 4415 if (!gaim_conv_chat_find_user(chat, old_name))
4412 return; 4416 return;
4413 4417
4414 g_return_if_fail(new_alias != NULL); 4418 g_return_if_fail(new_alias != NULL);
4415 4419
4416 add_chat_buddy_common(conv, new_name, new_alias, old_name); 4420 add_chat_buddy_common(conv, new_name, flags, new_alias, old_name);
4417 } 4421 }
4418 4422
4419 static void 4423 static void
4420 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) 4424 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user)
4421 { 4425 {
4522 4526
4523 static void 4527 static void
4524 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) 4528 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user)
4525 { 4529 {
4526 GaimConvChat *chat; 4530 GaimConvChat *chat;
4531 GaimConvChatBuddyFlags flags;
4527 GaimGtkConversation *gtkconv; 4532 GaimGtkConversation *gtkconv;
4528 GaimGtkChatPane *gtkchat; 4533 GaimGtkChatPane *gtkchat;
4529 GtkTreeIter iter; 4534 GtkTreeIter iter;
4530 GtkTreeModel *model; 4535 GtkTreeModel *model;
4531 int f = 1; 4536 int f = 1;
4560 if (!gaim_conv_chat_find_user(chat, user)) 4565 if (!gaim_conv_chat_find_user(chat, user))
4561 return; 4566 return;
4562 4567
4563 g_return_if_fail(alias != NULL); 4568 g_return_if_fail(alias != NULL);
4564 4569
4565 add_chat_buddy_common(conv, user, alias, NULL); 4570 flags = gaim_conv_chat_user_get_flags(chat, user);
4571
4572 add_chat_buddy_common(conv, user, flags, alias, NULL);
4566 g_free(alias); 4573 g_free(alias);
4567 } 4574 }
4568 4575
4569 gboolean 4576 gboolean
4570 gaim_gtkconv_has_focus(GaimConversation *conv) 4577 gaim_gtkconv_has_focus(GaimConversation *conv)