Mercurial > pidgin
comparison console/gntblist.c @ 14694:8538993dbb00
[gaim-migrate @ 17446]
Patch #1571853 from Richard Nelson (wabz):
"This patch removes the contact and all buddies when
removing a contact, rather than just removing it from
the blist (and having all the buddies show up next time
gaim-text is opened)"
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 08 Oct 2006 04:21:20 +0000 |
parents | dbcdef1ab5af |
children | ef94c6b853ab |
comparison
equal
deleted
inserted
replaced
14693:ae0136b0a3ae | 14694:8538993dbb00 |
---|---|
29 #include <savedstatuses.h> | 29 #include <savedstatuses.h> |
30 #include <server.h> | 30 #include <server.h> |
31 #include <signal.h> | 31 #include <signal.h> |
32 #include <status.h> | 32 #include <status.h> |
33 #include <util.h> | 33 #include <util.h> |
34 #include "debug.h" | |
34 | 35 |
35 #include "gntgaim.h" | 36 #include "gntgaim.h" |
36 #include "gntbox.h" | 37 #include "gntbox.h" |
37 #include "gntcombobox.h" | 38 #include "gntcombobox.h" |
38 #include "gntentry.h" | 39 #include "gntentry.h" |
54 GntWidget *window; | 55 GntWidget *window; |
55 GntWidget *tree; | 56 GntWidget *tree; |
56 | 57 |
57 GntWidget *tooltip; | 58 GntWidget *tooltip; |
58 GaimBlistNode *tnode; /* Who is the tooltip being displayed for? */ | 59 GaimBlistNode *tnode; /* Who is the tooltip being displayed for? */ |
60 GaimBuddy *tagged; | |
59 | 61 |
60 GntWidget *context; | 62 GntWidget *context; |
61 GaimBlistNode *cnode; | 63 GaimBlistNode *cnode; |
62 | 64 |
63 /* XXX: I am KISSing */ | 65 /* XXX: I am KISSing */ |
338 gaim_request_field_group_add_field(group, field); | 340 gaim_request_field_group_add_field(group, field); |
339 | 341 |
340 field = gaim_request_field_string_new("alias", _("Alias"), alias, FALSE); | 342 field = gaim_request_field_string_new("alias", _("Alias"), alias, FALSE); |
341 gaim_request_field_group_add_field(group, field); | 343 gaim_request_field_group_add_field(group, field); |
342 | 344 |
343 field = gaim_request_field_string_new("group", _("Group"), grp->name, FALSE); | 345 field = gaim_request_field_string_new("group", _("Group"), grp ? grp->name : NULL, FALSE); |
344 gaim_request_field_group_add_field(group, field); | 346 gaim_request_field_group_add_field(group, field); |
345 | 347 |
346 gaim_request_fields(NULL, _("Add Chat"), NULL, | 348 gaim_request_fields(NULL, _("Add Chat"), NULL, |
347 _("You can edit more information from the context menu later."), | 349 _("You can edit more information from the context menu later."), |
348 fields, _("Add"), G_CALLBACK(add_chat_cb), _("Cancel"), NULL, NULL); | 350 fields, _("Add"), G_CALLBACK(add_chat_cb), _("Cancel"), NULL, NULL); |
717 } | 719 } |
718 | 720 |
719 static void | 721 static void |
720 gg_add_buddy(GaimGroup *grp, GaimBlistNode *selected) | 722 gg_add_buddy(GaimGroup *grp, GaimBlistNode *selected) |
721 { | 723 { |
722 gaim_blist_request_add_buddy(NULL, NULL, grp->name, NULL); | 724 gaim_blist_request_add_buddy(NULL, NULL, grp ? grp->name : NULL, NULL); |
723 } | 725 } |
724 | 726 |
725 static void | 727 static void |
726 gg_add_group(GaimGroup *grp, GaimBlistNode *selected) | 728 gg_add_group(GaimGroup *grp, GaimBlistNode *selected) |
727 { | 729 { |
812 else | 814 else |
813 return; | 815 return; |
814 } | 816 } |
815 | 817 |
816 remove_context_menu(ggblist); | 818 remove_context_menu(ggblist); |
819 } | |
820 | |
821 /* Xerox'd from gtkdialogs.c:gaim_gtkdialogs_remove_contact_cb */ | |
822 static void | |
823 remove_contact(GaimContact *contact) | |
824 { | |
825 GaimBlistNode *bnode, *cnode; | |
826 GaimGroup *group; | |
827 | |
828 cnode = (GaimBlistNode *)contact; | |
829 group = (GaimGroup*)cnode->parent; | |
830 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
831 GaimBuddy *buddy = (GaimBuddy*)bnode; | |
832 if (gaim_account_is_connected(buddy->account)) | |
833 gaim_account_remove_buddy(buddy->account, buddy, group); | |
834 } | |
835 gaim_blist_remove_contact(contact); | |
817 } | 836 } |
818 | 837 |
819 static void | 838 static void |
820 rename_blist_node(GaimBlistNode *node, const char *newname) | 839 rename_blist_node(GaimBlistNode *node, const char *newname) |
821 { | 840 { |
906 | 925 |
907 static void | 926 static void |
908 gg_blist_remove_node(GaimBlistNode *node) | 927 gg_blist_remove_node(GaimBlistNode *node) |
909 { | 928 { |
910 if (GAIM_BLIST_NODE_IS_CONTACT(node)) { | 929 if (GAIM_BLIST_NODE_IS_CONTACT(node)) { |
911 gaim_blist_remove_contact((GaimContact*)node); | 930 remove_contact((GaimContact*)node); |
912 } else if (GAIM_BLIST_NODE_IS_BUDDY(node)) { | 931 } else if (GAIM_BLIST_NODE_IS_BUDDY(node)) { |
913 GaimBuddy *buddy = (GaimBuddy*)node; | 932 GaimBuddy *buddy = (GaimBuddy*)node; |
914 GaimGroup *group = gaim_buddy_get_group(buddy); | 933 GaimGroup *group = gaim_buddy_get_group(buddy); |
915 gaim_account_remove_buddy(gaim_buddy_get_account(buddy), buddy, group); | 934 gaim_account_remove_buddy(gaim_buddy_get_account(buddy), buddy, group); |
916 gaim_blist_remove_buddy(buddy); | 935 gaim_blist_remove_buddy(buddy); |
926 { | 945 { |
927 char *primary; | 946 char *primary; |
928 const char *name, *sec = NULL; | 947 const char *name, *sec = NULL; |
929 | 948 |
930 /* XXX: could be a contact */ | 949 /* XXX: could be a contact */ |
931 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | 950 if (GAIM_BLIST_NODE_IS_CONTACT(node)) { |
932 name = gaim_contact_get_alias((GaimContact*)node); | 951 GaimContact *c = (GaimContact*)node; |
933 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | 952 name = gaim_contact_get_alias(c); |
953 if (c->totalsize > 1) | |
954 sec = _("Removing this contact will also remove all the buddies in the contact"); | |
955 } else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
934 name = gaim_buddy_get_name((GaimBuddy*)node); | 956 name = gaim_buddy_get_name((GaimBuddy*)node); |
935 else if (GAIM_BLIST_NODE_IS_CHAT(node)) | 957 else if (GAIM_BLIST_NODE_IS_CHAT(node)) |
936 name = gaim_chat_get_name((GaimChat*)node); | 958 name = gaim_chat_get_name((GaimChat*)node); |
937 else if (GAIM_BLIST_NODE_IS_GROUP(node)) | 959 else if (GAIM_BLIST_NODE_IS_GROUP(node)) |
938 { | 960 { |
952 _("Cancel"), NULL); | 974 _("Cancel"), NULL); |
953 g_free(primary); | 975 g_free(primary); |
954 } | 976 } |
955 | 977 |
956 static void | 978 static void |
979 gg_blist_tag_buddy(GaimBlistNode *node) | |
980 { | |
981 ggblist->tagged = (GaimBuddy *)node; | |
982 gaim_debug_info("blist", "Tagged buddy\n"); | |
983 } | |
984 | |
985 static void | |
986 gg_blist_place_tagged(GaimBlistNode *node) | |
987 { | |
988 if (GAIM_BLIST_NODE_IS_GROUP(node)) { | |
989 gaim_blist_add_buddy(ggblist->tagged, NULL, (GaimGroup *)node, NULL); | |
990 } else { | |
991 GaimContact *contact = (GaimContact *)node; | |
992 gaim_blist_add_buddy(ggblist->tagged, contact, | |
993 gaim_buddy_get_group(gaim_contact_get_priority_buddy(contact)), NULL); | |
994 } | |
995 ggblist->tagged = NULL; | |
996 gaim_debug_info("blist", "Placed buddy\n"); | |
997 } | |
998 | |
999 static void | |
957 draw_context_menu(GGBlist *ggblist) | 1000 draw_context_menu(GGBlist *ggblist) |
958 { | 1001 { |
959 GaimBlistNode *node = NULL; | 1002 GaimBlistNode *node = NULL; |
960 GntWidget *context = NULL, *window = NULL; | 1003 GntWidget *context = NULL, *window = NULL; |
961 GntTree *tree = NULL; | 1004 GntTree *tree = NULL; |
969 remove_context_menu(ggblist); | 1012 remove_context_menu(ggblist); |
970 } | 1013 } |
971 | 1014 |
972 node = gnt_tree_get_selection_data(tree); | 1015 node = gnt_tree_get_selection_data(tree); |
973 | 1016 |
974 if (node == NULL) | |
975 return; | |
976 if (ggblist->tooltip) | 1017 if (ggblist->tooltip) |
977 remove_tooltip(ggblist); | 1018 remove_tooltip(ggblist); |
978 | 1019 |
979 ggblist->cnode = node; | 1020 ggblist->cnode = node; |
980 ggblist->context = context = gnt_tree_new(); | 1021 ggblist->context = context = gnt_tree_new(); |
981 GNT_WIDGET_SET_FLAGS(context, GNT_WIDGET_NO_BORDER); | 1022 GNT_WIDGET_SET_FLAGS(context, GNT_WIDGET_NO_BORDER); |
982 gnt_widget_set_name(context, "context menu"); | 1023 gnt_widget_set_name(context, "context menu"); |
983 g_signal_connect(G_OBJECT(context), "activate", G_CALLBACK(context_menu_callback), ggblist); | 1024 g_signal_connect(G_OBJECT(context), "activate", G_CALLBACK(context_menu_callback), ggblist); |
984 | 1025 |
985 if (GAIM_BLIST_NODE_IS_CONTACT(node)) { | 1026 if (!node) { |
1027 create_group_menu(GNT_TREE(context), NULL); | |
1028 title = g_strdup(_("Buddy List")); | |
1029 } else if (GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
986 create_buddy_menu(GNT_TREE(context), | 1030 create_buddy_menu(GNT_TREE(context), |
987 gaim_contact_get_priority_buddy((GaimContact*)node)); | 1031 gaim_contact_get_priority_buddy((GaimContact*)node)); |
988 title = g_strdup(gaim_contact_get_alias((GaimContact*)node)); | 1032 title = g_strdup(gaim_contact_get_alias((GaimContact*)node)); |
989 } else if (GAIM_BLIST_NODE_IS_BUDDY(node)) { | 1033 } else if (GAIM_BLIST_NODE_IS_BUDDY(node)) { |
990 GaimBuddy *buddy = (GaimBuddy *)node; | 1034 GaimBuddy *buddy = (GaimBuddy *)node; |
1001 } | 1045 } |
1002 | 1046 |
1003 append_extended_menu(GNT_TREE(context), node); | 1047 append_extended_menu(GNT_TREE(context), node); |
1004 | 1048 |
1005 /* These are common for everything */ | 1049 /* These are common for everything */ |
1006 add_custom_action(GNT_TREE(context), _("Rename"), | 1050 if (node) { |
1007 GAIM_CALLBACK(gg_blist_rename_node_cb), node); | 1051 add_custom_action(GNT_TREE(context), _("Rename"), |
1008 add_custom_action(GNT_TREE(context), _("Remove"), | 1052 GAIM_CALLBACK(gg_blist_rename_node_cb), node); |
1009 GAIM_CALLBACK(gg_blist_remove_node_cb), node); | 1053 add_custom_action(GNT_TREE(context), _("Remove"), |
1054 GAIM_CALLBACK(gg_blist_remove_node_cb), node); | |
1055 if (ggblist->tagged && (GAIM_BLIST_NODE_IS_CONTACT(node) | |
1056 || GAIM_BLIST_NODE_IS_GROUP(node))) { | |
1057 add_custom_action(GNT_TREE(context), _("Place tagged"), | |
1058 GAIM_CALLBACK(gg_blist_place_tagged), node); | |
1059 } else if (GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
1060 add_custom_action(GNT_TREE(context), _("Tag"), | |
1061 GAIM_CALLBACK(gg_blist_tag_buddy), node); | |
1062 } | |
1063 } | |
1010 | 1064 |
1011 window = gnt_vbox_new(FALSE); | 1065 window = gnt_vbox_new(FALSE); |
1012 GNT_WIDGET_SET_FLAGS(window, GNT_WIDGET_TRANSIENT); | 1066 GNT_WIDGET_SET_FLAGS(window, GNT_WIDGET_TRANSIENT); |
1013 gnt_box_set_toplevel(GNT_BOX(window), TRUE); | 1067 gnt_box_set_toplevel(GNT_BOX(window), TRUE); |
1014 gnt_box_set_title(GNT_BOX(window), title); | 1068 gnt_box_set_title(GNT_BOX(window), title); |