Mercurial > pidgin
comparison src/dialogs.c @ 6695:0c5637b5462e
[gaim-migrate @ 7221]
This is contact support. Really.
It has a few bugs left in it, like sorting not working, and stuff like that,
but it's pretty solid for the most part.
I'm not in the mood to do a whole lot of typing, so just use and enjoy.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Tue, 02 Sep 2003 03:41:10 +0000 |
parents | b89d98f0bf79 |
children | d93c6a1fadf2 |
comparison
equal
deleted
inserted
replaced
6694:2d2f04c5c7d2 | 6695:0c5637b5462e |
---|---|
377 dialogwindows = g_list_prepend(dialogwindows, w->window); | 377 dialogwindows = g_list_prepend(dialogwindows, w->window); |
378 gtk_widget_show_all(w->window); | 378 gtk_widget_show_all(w->window); |
379 } | 379 } |
380 | 380 |
381 static void | 381 static void |
382 do_remove_chat(struct chat *chat) | 382 do_remove_chat(GaimBlistChat *chat) |
383 { | 383 { |
384 gaim_blist_remove_chat(chat); | 384 gaim_blist_remove_chat(chat); |
385 gaim_blist_save(); | 385 gaim_blist_save(); |
386 } | 386 } |
387 | 387 |
388 static void | 388 static void |
389 do_remove_buddy(struct buddy *b) | 389 do_remove_buddy(GaimBuddy *b) |
390 { | 390 { |
391 struct group *g; | 391 GaimGroup *g; |
392 GaimConversation *c; | 392 GaimConversation *c; |
393 gchar *name; | 393 gchar *name; |
394 GaimAccount *account; | 394 GaimAccount *account; |
395 | 395 |
396 if (!b) | 396 if (!b) |
412 gaim_conversation_update(c, GAIM_CONV_UPDATE_REMOVE); | 412 gaim_conversation_update(c, GAIM_CONV_UPDATE_REMOVE); |
413 | 413 |
414 g_free(name); | 414 g_free(name); |
415 } | 415 } |
416 | 416 |
417 void do_remove_group(struct group *g) | 417 void do_remove_group(GaimGroup *g) |
418 { | 418 { |
419 GaimBlistNode *b = ((GaimBlistNode*)g)->child; | 419 GaimBlistNode *cnode, *bnode; |
420 while (b) { | 420 cnode = ((GaimBlistNode*)g)->child; |
421 if(GAIM_BLIST_NODE_IS_BUDDY(b)) { | 421 while(cnode) { |
422 struct buddy *bd = (struct buddy *)b; | 422 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { |
423 GaimConversation *c = gaim_find_conversation_with_account(bd->name, bd->account); | 423 bnode = cnode->child; |
424 if (gaim_account_is_connected(bd->account)) { | 424 cnode = cnode->next; |
425 serv_remove_buddy(bd->account->gc, bd->name, g->name); | 425 while(bnode) { |
426 gaim_blist_remove_buddy(bd); | 426 GaimBuddy *b; |
427 | 427 if(GAIM_BLIST_NODE_IS_BUDDY(bnode)) { |
428 if (c != NULL) | 428 b = (GaimBuddy*)bnode; |
429 gaim_conversation_update(c, GAIM_CONV_UPDATE_REMOVE); | 429 bnode = bnode->next; |
430 GaimConversation *c = gaim_find_conversation_with_account(b->name, b->account); | |
431 if(gaim_account_is_connected(b->account)) { | |
432 serv_remove_buddy(b->account->gc, b->name, g->name); | |
433 gaim_blist_remove_buddy(b); | |
434 if(c) | |
435 gaim_conversation_update(c, | |
436 GAIM_CONV_UPDATE_REMOVE); | |
437 } | |
438 } else { | |
439 bnode = bnode->next; | |
440 } | |
430 } | 441 } |
431 } else if(GAIM_BLIST_NODE_IS_CHAT(b)) { | 442 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode)) { |
432 struct chat *chat = (struct chat *)b; | 443 GaimBlistChat *chat = (GaimBlistChat *)cnode; |
433 if (gaim_account_is_connected(chat->account)) { | 444 cnode = cnode->next; |
445 if(gaim_account_is_connected(chat->account)) | |
434 gaim_blist_remove_chat(chat); | 446 gaim_blist_remove_chat(chat); |
435 } | 447 } else { |
448 cnode = cnode->next; | |
436 } | 449 } |
437 b = b->next; | |
438 } | 450 } |
439 gaim_blist_remove_group(g); | 451 gaim_blist_remove_group(g); |
440 gaim_blist_save(); | 452 gaim_blist_save(); |
441 } | 453 } |
442 | 454 |
443 void show_confirm_del(struct buddy *b) | 455 void show_confirm_del(GaimBuddy *b) |
444 { | 456 { |
445 char *text; | 457 char *text; |
446 if (!b) | 458 if (!b) |
447 return; | 459 return; |
448 | 460 |
453 _("Cancel"), NULL); | 465 _("Cancel"), NULL); |
454 | 466 |
455 g_free(text); | 467 g_free(text); |
456 } | 468 } |
457 | 469 |
458 void show_confirm_del_chat(struct chat *chat) | 470 void show_confirm_del_blist_chat(GaimBlistChat *chat) |
459 { | 471 { |
460 char *name = gaim_chat_get_display_name(chat); | 472 char *name = gaim_blist_chat_get_display_name(chat); |
461 char *text = g_strdup_printf(_("You are about to remove the chat %s from your buddy list. Do you want to continue?"), name); | 473 char *text = g_strdup_printf(_("You are about to remove the chat %s from your buddy list. Do you want to continue?"), name); |
462 | 474 |
463 gaim_request_action(NULL, NULL, _("Remove Chat"), text, -1, chat, 2, | 475 gaim_request_action(NULL, NULL, _("Remove Chat"), text, -1, chat, 2, |
464 _("Remove Chat"), G_CALLBACK(do_remove_chat), | 476 _("Remove Chat"), G_CALLBACK(do_remove_chat), |
465 _("Cancel"), NULL); | 477 _("Cancel"), NULL); |
466 | 478 |
467 g_free(name); | 479 g_free(name); |
468 g_free(text); | 480 g_free(text); |
469 } | 481 } |
470 | 482 |
471 void show_confirm_del_group(struct group *g) | 483 void show_confirm_del_group(GaimGroup *g) |
472 { | 484 { |
473 char *text = g_strdup_printf(_("You are about to remove the group %s and all its members from your buddy list. Do you want to continue?"), | 485 char *text = g_strdup_printf(_("You are about to remove the group %s and all its members from your buddy list. Do you want to continue?"), |
474 g->name); | 486 g->name); |
475 | 487 |
476 gaim_request_action(NULL, NULL, _("Remove Group"), text, -1, g, 2, | 488 gaim_request_action(NULL, NULL, _("Remove Group"), text, -1, g, 2, |
775 | 787 |
776 void do_add_buddy(GtkWidget *w, int resp, struct addbuddy *a) | 788 void do_add_buddy(GtkWidget *w, int resp, struct addbuddy *a) |
777 { | 789 { |
778 const char *grp, *who, *whoalias; | 790 const char *grp, *who, *whoalias; |
779 GaimConversation *c; | 791 GaimConversation *c; |
780 struct buddy *b; | 792 GaimBuddy *b; |
781 struct group *g; | 793 GaimGroup *g; |
782 void *icon_data; | 794 void *icon_data; |
783 void *icon_data2; | 795 void *icon_data2; |
784 int icon_len; | 796 int icon_len; |
785 | 797 |
786 if (resp == GTK_RESPONSE_OK) { | 798 if (resp == GTK_RESPONSE_OK) { |
793 if (!(g = gaim_find_group(grp))) { | 805 if (!(g = gaim_find_group(grp))) { |
794 g = gaim_group_new(grp); | 806 g = gaim_group_new(grp); |
795 gaim_blist_add_group(g, NULL); | 807 gaim_blist_add_group(g, NULL); |
796 } | 808 } |
797 b = gaim_buddy_new(a->gc->account, who, whoalias); | 809 b = gaim_buddy_new(a->gc->account, who, whoalias); |
798 gaim_blist_add_buddy(b, g, NULL); | 810 gaim_blist_add_buddy(b, NULL, g, NULL); |
799 serv_add_buddy(a->gc, who); | 811 serv_add_buddy(a->gc, who); |
800 | 812 |
801 if (c != NULL) | 813 if (c != NULL) |
802 gaim_conversation_update(c, GAIM_CONV_UPDATE_ADD); | 814 gaim_conversation_update(c, GAIM_CONV_UPDATE_ADD); |
803 | 815 |
817 | 829 |
818 static GList *groups_tree() | 830 static GList *groups_tree() |
819 { | 831 { |
820 GList *tmp = NULL; | 832 GList *tmp = NULL; |
821 char *tmp2; | 833 char *tmp2; |
822 struct group *g; | 834 GaimGroup *g; |
823 | 835 |
824 GaimBlistNode *gnode = gaim_get_blist()->root; | 836 GaimBlistNode *gnode = gaim_get_blist()->root; |
825 | 837 |
826 if (!gnode) { | 838 if (!gnode) { |
827 tmp2 = g_strdup(_("Buddies")); | 839 tmp2 = g_strdup(_("Buddies")); |
828 tmp = g_list_append(tmp, tmp2); | 840 tmp = g_list_append(tmp, tmp2); |
829 } else { | 841 } else { |
830 while (gnode) { | 842 while (gnode) { |
831 if(GAIM_BLIST_NODE_IS_GROUP(gnode)) { | 843 if(GAIM_BLIST_NODE_IS_GROUP(gnode)) { |
832 g = (struct group *)gnode; | 844 g = (GaimGroup *)gnode; |
833 tmp2 = g->name; | 845 tmp2 = g->name; |
834 tmp = g_list_append(tmp, tmp2); | 846 tmp = g_list_append(tmp, tmp2); |
835 } | 847 } |
836 gnode = gnode->next; | 848 gnode = gnode->next; |
837 } | 849 } |
846 | 858 |
847 | 859 |
848 static void | 860 static void |
849 add_group_cb(GaimConnection *gc, const char *group_name) | 861 add_group_cb(GaimConnection *gc, const char *group_name) |
850 { | 862 { |
851 struct group *g; | 863 GaimGroup *g; |
852 | 864 |
853 g = gaim_group_new(group_name); | 865 g = gaim_group_new(group_name); |
854 gaim_blist_add_group(g, NULL); | 866 gaim_blist_add_group(g, NULL); |
855 gaim_blist_save(); | 867 gaim_blist_save(); |
856 } | 868 } |
992 static void do_add_chat(GtkWidget *w, struct addchat *ac) { | 1004 static void do_add_chat(GtkWidget *w, struct addchat *ac) { |
993 GHashTable *components = g_hash_table_new_full(g_str_hash, g_str_equal, | 1005 GHashTable *components = g_hash_table_new_full(g_str_hash, g_str_equal, |
994 g_free, g_free); | 1006 g_free, g_free); |
995 GList *tmp; | 1007 GList *tmp; |
996 | 1008 |
997 struct chat *chat; | 1009 GaimBlistChat *chat; |
998 struct group *group; | 1010 GaimGroup *group; |
999 const char *group_name; | 1011 const char *group_name; |
1000 | 1012 |
1001 for(tmp = ac->entries; tmp; tmp = tmp->next) { | 1013 for(tmp = ac->entries; tmp; tmp = tmp->next) { |
1002 if(g_object_get_data(tmp->data, "is_spin")) { | 1014 if(g_object_get_data(tmp->data, "is_spin")) { |
1003 g_hash_table_replace(components, | 1015 g_hash_table_replace(components, |
1009 g_strdup(g_object_get_data(tmp->data, "identifier")), | 1021 g_strdup(g_object_get_data(tmp->data, "identifier")), |
1010 g_strdup(gtk_entry_get_text(tmp->data))); | 1022 g_strdup(gtk_entry_get_text(tmp->data))); |
1011 } | 1023 } |
1012 } | 1024 } |
1013 | 1025 |
1014 chat = gaim_chat_new(ac->account, gtk_entry_get_text(GTK_ENTRY(ac->alias_entry)), components); | 1026 chat = gaim_blist_chat_new(ac->account, gtk_entry_get_text(GTK_ENTRY(ac->alias_entry)), components); |
1015 | 1027 |
1016 group_name = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(ac->group_combo)->entry)); | 1028 group_name = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(ac->group_combo)->entry)); |
1017 if (!(group = gaim_find_group(group_name))) { | 1029 if (!(group = gaim_find_group(group_name))) { |
1018 group = gaim_group_new(group_name); | 1030 group = gaim_group_new(group_name); |
1019 gaim_blist_add_group(group, NULL); | 1031 gaim_blist_add_group(group, NULL); |
1237 gtk_option_menu_remove_menu(GTK_OPTION_MENU(ac->account_menu)); | 1249 gtk_option_menu_remove_menu(GTK_OPTION_MENU(ac->account_menu)); |
1238 gtk_option_menu_set_menu(GTK_OPTION_MENU(ac->account_menu), menu); | 1250 gtk_option_menu_set_menu(GTK_OPTION_MENU(ac->account_menu), menu); |
1239 gtk_option_menu_set_history(GTK_OPTION_MENU(ac->account_menu), place); | 1251 gtk_option_menu_set_history(GTK_OPTION_MENU(ac->account_menu), place); |
1240 } | 1252 } |
1241 | 1253 |
1242 void show_add_chat(GaimAccount *account, struct group *group) { | 1254 void show_add_chat(GaimAccount *account, GaimGroup *group) { |
1243 struct addchat *ac = g_new0(struct addchat, 1); | 1255 struct addchat *ac = g_new0(struct addchat, 1); |
1244 struct gaim_gtk_buddy_list *gtkblist; | 1256 struct gaim_gtk_buddy_list *gtkblist; |
1245 GList *c; | 1257 GList *c; |
1246 GaimConnection *gc; | 1258 GaimConnection *gc; |
1247 | 1259 |
1253 GTK_ICON_SIZE_DIALOG); | 1265 GTK_ICON_SIZE_DIALOG); |
1254 | 1266 |
1255 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); | 1267 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); |
1256 | 1268 |
1257 if (account) { | 1269 if (account) { |
1258 ac->account = account; | 1270 ac->account = account; |
1259 } else { | 1271 } else { |
1260 /* Select an account with chat capabilities */ | 1272 /* Select an account with chat capabilities */ |
1261 for (c = gaim_connections_get_all(); c != NULL; c = c->next) { | 1273 for (c = gaim_connections_get_all(); c != NULL; c = c->next) { |
1262 gc = c->data; | 1274 gc = c->data; |
1263 | 1275 |
1264 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->join_chat) { | 1276 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->join_chat) { |
1265 ac->account = gc->account; | 1277 ac->account = gc->account; |
1266 break; | 1278 break; |
1267 } | 1279 } |
1268 } | 1280 } |
1269 } | 1281 } |
1270 | 1282 |
1271 if (!ac->account) { | 1283 if (!ac->account) { |
1272 gaim_notify_error(NULL, NULL, | 1284 gaim_notify_error(NULL, NULL, |
1273 _("You are not currently signed on with any " | 1285 _("You are not currently signed on with any " |
1274 "protocols that have the ability to chat."), NULL); | 1286 "protocols that have the ability to chat."), NULL); |
2961 | 2973 |
2962 return; | 2974 return; |
2963 } | 2975 } |
2964 | 2976 |
2965 static void | 2977 static void |
2966 alias_chat_cb(struct chat *chat, const char *new_alias) | 2978 alias_chat_cb(GaimBlistChat *chat, const char *new_alias) |
2967 { | 2979 { |
2968 gaim_blist_alias_chat(chat, new_alias); | 2980 gaim_blist_alias_chat(chat, new_alias); |
2969 gaim_blist_save(); | 2981 gaim_blist_save(); |
2970 } | 2982 } |
2971 | 2983 |
2972 void | 2984 void |
2973 alias_dialog_chat(struct chat *chat) | 2985 alias_dialog_blist_chat(GaimBlistChat *chat) |
2974 { | 2986 { |
2975 gaim_request_input(NULL, _("Alias Chat"), _("Alias chat"), | 2987 gaim_request_input(NULL, _("Alias Chat"), _("Alias chat"), |
2976 _("Please enter an aliased name for this chat."), | 2988 _("Please enter an aliased name for this chat."), |
2977 chat->alias, FALSE, FALSE, | 2989 chat->alias, FALSE, FALSE, |
2978 _("OK"), G_CALLBACK(alias_chat_cb), | 2990 _("OK"), G_CALLBACK(alias_chat_cb), |
2979 _("Cancel"), NULL, chat); | 2991 _("Cancel"), NULL, chat); |
2980 } | 2992 } |
2981 | 2993 |
2982 static void | 2994 static void |
2983 alias_buddy_cb(struct buddy *buddy, GaimRequestFields *fields) | 2995 alias_buddy_cb(GaimBuddy *buddy, GaimRequestFields *fields) |
2984 { | 2996 { |
2985 const char *alias; | 2997 const char *alias; |
2986 | 2998 |
2987 alias = gaim_request_fields_get_string(fields, "alias"); | 2999 alias = gaim_request_fields_get_string(fields, "alias"); |
2988 | 3000 |
2991 serv_alias_buddy(buddy); | 3003 serv_alias_buddy(buddy); |
2992 gaim_blist_save(); | 3004 gaim_blist_save(); |
2993 } | 3005 } |
2994 | 3006 |
2995 void | 3007 void |
2996 alias_dialog_bud(struct buddy *b) | 3008 alias_dialog_bud(GaimBuddy *b) |
2997 { | 3009 { |
2998 GaimRequestFields *fields; | 3010 GaimRequestFields *fields; |
2999 GaimRequestFieldGroup *group; | 3011 GaimRequestFieldGroup *group; |
3000 GaimRequestField *field; | 3012 GaimRequestField *field; |
3001 | 3013 |
3485 | 3497 |
3486 /*------------------------------------------------------------------------*/ | 3498 /*------------------------------------------------------------------------*/ |
3487 /* The dialog for renaming groups */ | 3499 /* The dialog for renaming groups */ |
3488 /*------------------------------------------------------------------------*/ | 3500 /*------------------------------------------------------------------------*/ |
3489 | 3501 |
3490 static void do_rename_group(struct group *g, const char *new_name) | 3502 static void do_rename_group(GaimGroup *g, const char *new_name) |
3491 { | 3503 { |
3492 gaim_blist_rename_group(g, new_name); | 3504 gaim_blist_rename_group(g, new_name); |
3493 gaim_blist_save(); | 3505 gaim_blist_save(); |
3494 } | 3506 } |
3495 | 3507 |
3496 void show_rename_group(GtkWidget *unused, struct group *g) | 3508 void show_rename_group(GtkWidget *unused, GaimGroup *g) |
3497 { | 3509 { |
3498 gaim_request_input(NULL, _("Rename Group"), _("New group name"), | 3510 gaim_request_input(NULL, _("Rename Group"), _("New group name"), |
3499 _("Please enter a new name for the selected group."), | 3511 _("Please enter a new name for the selected group."), |
3500 g->name, FALSE, FALSE, | 3512 g->name, FALSE, FALSE, |
3501 _("OK"), G_CALLBACK(do_rename_group), | 3513 _("OK"), G_CALLBACK(do_rename_group), |