| 127 |
127 |
| 128 static void add_buddy(PurpleBuddy *buddy, FinchBlist *ggblist); |
128 static void add_buddy(PurpleBuddy *buddy, FinchBlist *ggblist); |
| 129 static void add_contact(PurpleContact *contact, FinchBlist *ggblist); |
129 static void add_contact(PurpleContact *contact, FinchBlist *ggblist); |
| 130 static void add_group(PurpleGroup *group, FinchBlist *ggblist); |
130 static void add_group(PurpleGroup *group, FinchBlist *ggblist); |
| 131 static void add_chat(PurpleChat *chat, FinchBlist *ggblist); |
131 static void add_chat(PurpleChat *chat, FinchBlist *ggblist); |
| 132 static void add_node(PurpleBlistNode *node, FinchBlist *ggblist); |
132 static void add_node(PurpleBListNode *node, FinchBlist *ggblist); |
| 133 static void node_update(PurpleBuddyList *list, PurpleBlistNode *node); |
133 static void node_update(PurpleBuddyList *list, PurpleBListNode *node); |
| 134 #if 0 |
134 #if 0 |
| 135 static gboolean is_contact_online(PurpleContact *contact); |
135 static gboolean is_contact_online(PurpleContact *contact); |
| 136 static gboolean is_group_online(PurpleGroup *group); |
136 static gboolean is_group_online(PurpleGroup *group); |
| 137 #endif |
137 #endif |
| 138 static void draw_tooltip(FinchBlist *ggblist); |
138 static void draw_tooltip(FinchBlist *ggblist); |
| 139 static void tooltip_for_buddy(PurpleBuddy *buddy, GString *str, gboolean full); |
139 static void tooltip_for_buddy(PurpleBuddy *buddy, GString *str, gboolean full); |
| 140 static gboolean remove_typing_cb(gpointer null); |
140 static gboolean remove_typing_cb(gpointer null); |
| 141 static void remove_peripherals(FinchBlist *ggblist); |
141 static void remove_peripherals(FinchBlist *ggblist); |
| 142 static const char * get_display_name(PurpleBlistNode *node); |
142 static const char * get_display_name(PurpleBListNode *node); |
| 143 static void savedstatus_changed(PurpleSavedStatus *now, PurpleSavedStatus *old); |
143 static void savedstatus_changed(PurpleSavedStatus *now, PurpleSavedStatus *old); |
| 144 static void blist_show(PurpleBuddyList *list); |
144 static void blist_show(PurpleBuddyList *list); |
| 145 static void update_node_display(PurpleBlistNode *buddy, FinchBlist *ggblist); |
145 static void update_node_display(PurpleBListNode *buddy, FinchBlist *ggblist); |
| 146 static void update_buddy_display(PurpleBuddy *buddy, FinchBlist *ggblist); |
146 static void update_buddy_display(PurpleBuddy *buddy, FinchBlist *ggblist); |
| 147 static gboolean account_autojoin_cb(PurpleConnection *pc, gpointer null); |
147 static gboolean account_autojoin_cb(PurpleConnection *pc, gpointer null); |
| 148 static void finch_request_add_buddy(PurpleAccount *account, const char *username, const char *grp, const char *alias); |
148 static void finch_request_add_buddy(PurpleAccount *account, const char *username, const char *grp, const char *alias); |
| 149 static void menu_group_set_cb(GntMenuItem *item, gpointer null); |
149 static void menu_group_set_cb(GntMenuItem *item, gpointer null); |
| 150 |
150 |
| 151 /* Sort functions */ |
151 /* Sort functions */ |
| 152 static int blist_node_compare_position(PurpleBlistNode *n1, PurpleBlistNode *n2); |
152 static int blist_node_compare_position(PurpleBListNode *n1, PurpleBListNode *n2); |
| 153 static int blist_node_compare_text(PurpleBlistNode *n1, PurpleBlistNode *n2); |
153 static int blist_node_compare_text(PurpleBListNode *n1, PurpleBListNode *n2); |
| 154 static int blist_node_compare_status(PurpleBlistNode *n1, PurpleBlistNode *n2); |
154 static int blist_node_compare_status(PurpleBListNode *n1, PurpleBListNode *n2); |
| 155 static int blist_node_compare_log(PurpleBlistNode *n1, PurpleBlistNode *n2); |
155 static int blist_node_compare_log(PurpleBListNode *n1, PurpleBListNode *n2); |
| 156 |
156 |
| 157 static int color_available; |
157 static int color_available; |
| 158 static int color_away; |
158 static int color_away; |
| 159 static int color_offline; |
159 static int color_offline; |
| 160 static int color_idle; |
160 static int color_idle; |
| 161 |
161 |
| 162 /** |
162 /** |
| 163 * Buddy List Manager functions. |
163 * Buddy List Manager functions. |
| 164 */ |
164 */ |
| 165 |
165 |
| 166 static gboolean default_can_add_node(PurpleBlistNode *node) |
166 static gboolean default_can_add_node(PurpleBListNode *node) |
| 167 { |
167 { |
| 168 gboolean offline = purple_prefs_get_bool(PREF_ROOT "/showoffline"); |
168 gboolean offline = purple_prefs_get_bool(PREF_ROOT "/showoffline"); |
| 169 |
169 |
| 170 if (PURPLE_IS_BUDDY(node)) { |
170 if (PURPLE_IS_BUDDY(node)) { |
| 171 PurpleBuddy *buddy = (PurpleBuddy*)node; |
171 PurpleBuddy *buddy = (PurpleBuddy*)node; |
| 181 if (fnode && fnode->signed_timer) |
181 if (fnode && fnode->signed_timer) |
| 182 return TRUE; /* Show if the buddy just signed off */ |
182 return TRUE; /* Show if the buddy just signed off */ |
| 183 if (purple_blist_node_get_bool(node, "show_offline")) |
183 if (purple_blist_node_get_bool(node, "show_offline")) |
| 184 return TRUE; |
184 return TRUE; |
| 185 } else if (PURPLE_IS_CONTACT(node)) { |
185 } else if (PURPLE_IS_CONTACT(node)) { |
| 186 PurpleBlistNode *nd; |
186 PurpleBListNode *nd; |
| 187 for (nd = purple_blist_node_get_first_child(node); |
187 for (nd = purple_blist_node_get_first_child(node); |
| 188 nd; nd = purple_blist_node_get_sibling_next(nd)) { |
188 nd; nd = purple_blist_node_get_sibling_next(nd)) { |
| 189 if (default_can_add_node(nd)) |
189 if (default_can_add_node(nd)) |
| 190 return TRUE; |
190 return TRUE; |
| 191 } |
191 } |
| 192 } else if (PURPLE_IS_CHAT(node)) { |
192 } else if (PURPLE_IS_CHAT(node)) { |
| 193 PurpleChat *chat = (PurpleChat*)node; |
193 PurpleChat *chat = (PurpleChat*)node; |
| 194 if (purple_account_is_connected(purple_chat_get_account(chat))) |
194 if (purple_account_is_connected(purple_chat_get_account(chat))) |
| 195 return TRUE; /* Show whenever the account is online */ |
195 return TRUE; /* Show whenever the account is online */ |
| 196 } else if (PURPLE_IS_GROUP(node)) { |
196 } else if (PURPLE_IS_GROUP(node)) { |
| 197 PurpleBlistNode *nd; |
197 PurpleBListNode *nd; |
| 198 gboolean empty = purple_prefs_get_bool(PREF_ROOT "/emptygroups"); |
198 gboolean empty = purple_prefs_get_bool(PREF_ROOT "/emptygroups"); |
| 199 if (empty) |
199 if (empty) |
| 200 return TRUE; /* If we want to see empty groups, we can show any group */ |
200 return TRUE; /* If we want to see empty groups, we can show any group */ |
| 201 |
201 |
| 202 for (nd = purple_blist_node_get_first_child(node); |
202 for (nd = purple_blist_node_get_first_child(node); |
| 402 * API addition would be necessary */ |
402 * API addition would be necessary */ |
| 403 #if 0 |
403 #if 0 |
| 404 if (!gnt_tree_get_expanded(GNT_TREE(ggblist->tree), node)) { |
404 if (!gnt_tree_get_expanded(GNT_TREE(ggblist->tree), node)) { |
| 405 for (node = purple_blist_node_get_first_child(node); node; |
405 for (node = purple_blist_node_get_first_child(node); node; |
| 406 node = purple_blist_node_get_sibling_next(node)) { |
406 node = purple_blist_node_get_sibling_next(node)) { |
| 407 PurpleBlistNode *pnode; |
407 PurpleBListNode *pnode; |
| 408 pnode = purple_contact_get_priority_buddy((PurpleContact*)node); |
408 pnode = purple_contact_get_priority_buddy((PurpleContact*)node); |
| 409 fnode = purple_blist_node_get_ui_data(node); |
409 fnode = purple_blist_node_get_ui_data(node); |
| 410 if (fnode && fnode->signed_timer) { |
410 if (fnode && fnode->signed_timer) { |
| 411 flag |= GNT_TEXT_FLAG_BLINK; |
411 flag |= GNT_TEXT_FLAG_BLINK; |
| 412 break; |
412 break; |
| 418 |
418 |
| 419 return flag; |
419 return flag; |
| 420 } |
420 } |
| 421 |
421 |
| 422 static void |
422 static void |
| 423 blist_update_row_flags(PurpleBlistNode *node) |
423 blist_update_row_flags(PurpleBListNode *node) |
| 424 { |
424 { |
| 425 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), node, get_blist_node_flag(node)); |
425 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), node, get_blist_node_flag(node)); |
| 426 gnt_tree_set_row_color(GNT_TREE(ggblist->tree), node, get_display_color(node)); |
426 gnt_tree_set_row_color(GNT_TREE(ggblist->tree), node, get_display_color(node)); |
| 427 } |
427 } |
| 428 |
428 |
| 429 #if 0 |
429 #if 0 |
| 430 static gboolean |
430 static gboolean |
| 431 is_contact_online(PurpleContact *contact) |
431 is_contact_online(PurpleContact *contact) |
| 432 { |
432 { |
| 433 PurpleBlistNode *node; |
433 PurpleBListNode *node; |
| 434 for (node = purple_blist_node_get_first_child(((PurpleBlistNode*)contact)); node; |
434 for (node = purple_blist_node_get_first_child(((PurpleBListNode*)contact)); node; |
| 435 node = purple_blist_node_get_sibling_next(node)) { |
435 node = purple_blist_node_get_sibling_next(node)) { |
| 436 FinchBlistNode *fnode = purple_blist_node_get_ui_data(node); |
436 FinchBlistNode *fnode = purple_blist_node_get_ui_data(node); |
| 437 if (PURPLE_IS_BUDDY_ONLINE((PurpleBuddy*)node) || |
437 if (PURPLE_IS_BUDDY_ONLINE((PurpleBuddy*)node) || |
| 438 (fnode && fnode->signed_timer)) |
438 (fnode && fnode->signed_timer)) |
| 439 return TRUE; |
439 return TRUE; |
| 553 node_remove(list, node); |
553 node_remove(list, node); |
| 554 } |
554 } |
| 555 |
555 |
| 556 if (PURPLE_IS_BUDDY(node)) { |
556 if (PURPLE_IS_BUDDY(node)) { |
| 557 PurpleBuddy *buddy = (PurpleBuddy*)node; |
557 PurpleBuddy *buddy = (PurpleBuddy*)node; |
| 558 add_node((PurpleBlistNode*)buddy, FINCH_GET_DATA(list)); |
558 add_node((PurpleBListNode*)buddy, FINCH_GET_DATA(list)); |
| 559 node_update(list, purple_blist_node_get_parent(node)); |
559 node_update(list, purple_blist_node_get_parent(node)); |
| 560 } else if (PURPLE_IS_CHAT(node)) { |
560 } else if (PURPLE_IS_CHAT(node)) { |
| 561 add_node(node, FINCH_GET_DATA(list)); |
561 add_node(node, FINCH_GET_DATA(list)); |
| 562 } else if (PURPLE_IS_CONTACT(node)) { |
562 } else if (PURPLE_IS_CONTACT(node)) { |
| 563 if (purple_blist_node_get_ui_data(node)== NULL) { |
563 if (purple_blist_node_get_ui_data(node)== NULL) { |
| 883 |
883 |
| 884 static void |
884 static void |
| 885 add_group(PurpleGroup *group, FinchBlist *ggblist) |
885 add_group(PurpleGroup *group, FinchBlist *ggblist) |
| 886 { |
886 { |
| 887 gpointer parent; |
887 gpointer parent; |
| 888 PurpleBlistNode *node = (PurpleBlistNode *)group; |
888 PurpleBListNode *node = (PurpleBListNode *)group; |
| 889 if (purple_blist_node_get_ui_data(node)) |
889 if (purple_blist_node_get_ui_data(node)) |
| 890 return; |
890 return; |
| 891 parent = ggblist->manager->find_parent((PurpleBlistNode*)group); |
891 parent = ggblist->manager->find_parent((PurpleBListNode*)group); |
| 892 create_finch_blist_node(node, gnt_tree_add_row_after(GNT_TREE(ggblist->tree), group, |
892 create_finch_blist_node(node, gnt_tree_add_row_after(GNT_TREE(ggblist->tree), group, |
| 893 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), |
893 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), |
| 894 parent, NULL)); |
894 parent, NULL)); |
| 895 gnt_tree_set_expanded(GNT_TREE(ggblist->tree), node, |
895 gnt_tree_set_expanded(GNT_TREE(ggblist->tree), node, |
| 896 !purple_blist_node_get_bool(node, "collapsed")); |
896 !purple_blist_node_get_bool(node, "collapsed")); |
| 897 } |
897 } |
| 898 |
898 |
| 899 static const char * |
899 static const char * |
| 900 get_display_name(PurpleBlistNode *node) |
900 get_display_name(PurpleBListNode *node) |
| 901 { |
901 { |
| 902 static char text[2096]; |
902 static char text[2096]; |
| 903 char status[8] = " "; |
903 char status[8] = " "; |
| 904 const char *name = NULL; |
904 const char *name = NULL; |
| 905 |
905 |
| 956 |
956 |
| 957 static void |
957 static void |
| 958 add_chat(PurpleChat *chat, FinchBlist *ggblist) |
958 add_chat(PurpleChat *chat, FinchBlist *ggblist) |
| 959 { |
959 { |
| 960 gpointer parent; |
960 gpointer parent; |
| 961 PurpleBlistNode *node = (PurpleBlistNode *)chat; |
961 PurpleBListNode *node = (PurpleBListNode *)chat; |
| 962 if (purple_blist_node_get_ui_data(node)) |
962 if (purple_blist_node_get_ui_data(node)) |
| 963 return; |
963 return; |
| 964 if (!purple_account_is_connected(purple_chat_get_account(chat))) |
964 if (!purple_account_is_connected(purple_chat_get_account(chat))) |
| 965 return; |
965 return; |
| 966 |
966 |
| 967 parent = ggblist->manager->find_parent((PurpleBlistNode*)chat); |
967 parent = ggblist->manager->find_parent((PurpleBListNode*)chat); |
| 968 |
968 |
| 969 create_finch_blist_node(node, gnt_tree_add_row_after(GNT_TREE(ggblist->tree), chat, |
969 create_finch_blist_node(node, gnt_tree_add_row_after(GNT_TREE(ggblist->tree), chat, |
| 970 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), |
970 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), |
| 971 parent, NULL)); |
971 parent, NULL)); |
| 972 } |
972 } |
| 973 |
973 |
| 974 static void |
974 static void |
| 975 add_contact(PurpleContact *contact, FinchBlist *ggblist) |
975 add_contact(PurpleContact *contact, FinchBlist *ggblist) |
| 976 { |
976 { |
| 977 gpointer parent; |
977 gpointer parent; |
| 978 PurpleBlistNode *node = (PurpleBlistNode*)contact; |
978 PurpleBListNode *node = (PurpleBListNode*)contact; |
| 979 const char *name; |
979 const char *name; |
| 980 |
980 |
| 981 if (purple_blist_node_get_ui_data(node)) |
981 if (purple_blist_node_get_ui_data(node)) |
| 982 return; |
982 return; |
| 983 |
983 |
| 984 name = get_display_name(node); |
984 name = get_display_name(node); |
| 985 if (name == NULL) |
985 if (name == NULL) |
| 986 return; |
986 return; |
| 987 |
987 |
| 988 parent = ggblist->manager->find_parent((PurpleBlistNode*)contact); |
988 parent = ggblist->manager->find_parent((PurpleBListNode*)contact); |
| 989 |
989 |
| 990 create_finch_blist_node(node, gnt_tree_add_row_after(GNT_TREE(ggblist->tree), contact, |
990 create_finch_blist_node(node, gnt_tree_add_row_after(GNT_TREE(ggblist->tree), contact, |
| 991 gnt_tree_create_row(GNT_TREE(ggblist->tree), name), |
991 gnt_tree_create_row(GNT_TREE(ggblist->tree), name), |
| 992 parent, NULL)); |
992 parent, NULL)); |
| 993 |
993 |
| 996 |
996 |
| 997 static void |
997 static void |
| 998 add_buddy(PurpleBuddy *buddy, FinchBlist *ggblist) |
998 add_buddy(PurpleBuddy *buddy, FinchBlist *ggblist) |
| 999 { |
999 { |
| 1000 gpointer parent; |
1000 gpointer parent; |
| 1001 PurpleBlistNode *node = (PurpleBlistNode *)buddy; |
1001 PurpleBListNode *node = (PurpleBListNode *)buddy; |
| 1002 PurpleContact *contact; |
1002 PurpleContact *contact; |
| 1003 |
1003 |
| 1004 if (purple_blist_node_get_ui_data(node)) |
1004 if (purple_blist_node_get_ui_data(node)) |
| 1005 return; |
1005 return; |
| 1006 |
1006 |
| 1007 contact = purple_buddy_get_contact(buddy); |
1007 contact = purple_buddy_get_contact(buddy); |
| 1008 parent = ggblist->manager->find_parent((PurpleBlistNode*)buddy); |
1008 parent = ggblist->manager->find_parent((PurpleBListNode*)buddy); |
| 1009 |
1009 |
| 1010 create_finch_blist_node(node, gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy, |
1010 create_finch_blist_node(node, gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy, |
| 1011 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), |
1011 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), |
| 1012 parent, NULL)); |
1012 parent, NULL)); |
| 1013 |
1013 |
| 1014 blist_update_row_flags((PurpleBlistNode*)buddy); |
1014 blist_update_row_flags((PurpleBListNode*)buddy); |
| 1015 if (buddy == purple_contact_get_priority_buddy(contact)) |
1015 if (buddy == purple_contact_get_priority_buddy(contact)) |
| 1016 blist_update_row_flags((PurpleBlistNode*)contact); |
1016 blist_update_row_flags((PurpleBListNode*)contact); |
| 1017 } |
1017 } |
| 1018 |
1018 |
| 1019 #if 0 |
1019 #if 0 |
| 1020 static void |
1020 static void |
| 1021 buddy_signed_on(PurpleBuddy *buddy, FinchBlist *ggblist) |
1021 buddy_signed_on(PurpleBuddy *buddy, FinchBlist *ggblist) |
| 1022 { |
1022 { |
| 1023 add_node((PurpleBlistNode*)buddy, ggblist); |
1023 add_node((PurpleBListNode*)buddy, ggblist); |
| 1024 } |
1024 } |
| 1025 |
1025 |
| 1026 static void |
1026 static void |
| 1027 buddy_signed_off(PurpleBuddy *buddy, FinchBlist *ggblist) |
1027 buddy_signed_off(PurpleBuddy *buddy, FinchBlist *ggblist) |
| 1028 { |
1028 { |
| 1029 node_remove(purple_get_blist(), (PurpleBlistNode*)buddy); |
1029 node_remove(purple_get_blist(), (PurpleBListNode*)buddy); |
| 1030 } |
1030 } |
| 1031 #endif |
1031 #endif |
| 1032 |
1032 |
| 1033 PurpleBlistUiOps *finch_blist_get_ui_ops() |
1033 PurpleBlistUiOps *finch_blist_get_ui_ops() |
| 1034 { |
1034 { |
| 1181 { |
1181 { |
| 1182 PurpleMenuAction *action = purple_menu_action_new(_("Auto-join"), NULL, chat, NULL); |
1182 PurpleMenuAction *action = purple_menu_action_new(_("Auto-join"), NULL, chat, NULL); |
| 1183 GntMenuItem *check = gnt_menuitem_check_new( |
1183 GntMenuItem *check = gnt_menuitem_check_new( |
| 1184 purple_menu_action_get_label(action)); |
1184 purple_menu_action_get_label(action)); |
| 1185 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(check), |
1185 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(check), |
| 1186 purple_blist_node_get_bool((PurpleBlistNode*)chat, "gnt-autojoin")); |
1186 purple_blist_node_get_bool((PurpleBListNode*)chat, "gnt-autojoin")); |
| 1187 gnt_menu_add_item(menu, check); |
1187 gnt_menu_add_item(menu, check); |
| 1188 gnt_menuitem_set_callback(check, autojoin_toggled, action); |
1188 gnt_menuitem_set_callback(check, autojoin_toggled, action); |
| 1189 g_signal_connect_swapped(G_OBJECT(menu), "destroy", |
1189 g_signal_connect_swapped(G_OBJECT(menu), "destroy", |
| 1190 G_CALLBACK(purple_menu_action_free), action); |
1190 G_CALLBACK(purple_menu_action_free), action); |
| 1191 |
1191 |
| 1192 add_custom_action(menu, _("Edit Settings"), (PurpleCallback)chat_components_edit, chat); |
1192 add_custom_action(menu, _("Edit Settings"), (PurpleCallback)chat_components_edit, chat); |
| 1193 } |
1193 } |
| 1194 |
1194 |
| 1195 static void |
1195 static void |
| 1196 finch_add_buddy(PurpleBlistNode *selected, PurpleGroup *grp) |
1196 finch_add_buddy(PurpleBListNode *selected, PurpleGroup *grp) |
| 1197 { |
1197 { |
| 1198 purple_blist_request_add_buddy(NULL, NULL, grp ? purple_group_get_name(grp) : NULL, NULL); |
1198 purple_blist_request_add_buddy(NULL, NULL, grp ? purple_group_get_name(grp) : NULL, NULL); |
| 1199 } |
1199 } |
| 1200 |
1200 |
| 1201 static void |
1201 static void |
| 1202 finch_add_group(PurpleBlistNode *selected, PurpleGroup *grp) |
1202 finch_add_group(PurpleBListNode *selected, PurpleGroup *grp) |
| 1203 { |
1203 { |
| 1204 purple_blist_request_add_group(); |
1204 purple_blist_request_add_group(); |
| 1205 } |
1205 } |
| 1206 |
1206 |
| 1207 static void |
1207 static void |
| 1208 finch_add_chat(PurpleBlistNode *selected, PurpleGroup *grp) |
1208 finch_add_chat(PurpleBListNode *selected, PurpleGroup *grp) |
| 1209 { |
1209 { |
| 1210 purple_blist_request_add_chat(NULL, grp, NULL, NULL); |
1210 purple_blist_request_add_chat(NULL, grp, NULL, NULL); |
| 1211 } |
1211 } |
| 1212 |
1212 |
| 1213 static void |
1213 static void |
| 1232 serv_get_info(conn, name); |
1232 serv_get_info(conn, name); |
| 1233 return uihandle; |
1233 return uihandle; |
| 1234 } |
1234 } |
| 1235 |
1235 |
| 1236 static void |
1236 static void |
| 1237 finch_blist_get_buddy_info_cb(PurpleBlistNode *selected, PurpleBuddy *buddy) |
1237 finch_blist_get_buddy_info_cb(PurpleBListNode *selected, PurpleBuddy *buddy) |
| 1238 { |
1238 { |
| 1239 finch_retrieve_user_info(purple_account_get_connection(purple_buddy_get_account(buddy)), purple_buddy_get_name(buddy)); |
1239 finch_retrieve_user_info(purple_account_get_connection(purple_buddy_get_account(buddy)), purple_buddy_get_name(buddy)); |
| 1240 } |
1240 } |
| 1241 |
1241 |
| 1242 static void |
1242 static void |
| 1243 finch_blist_menu_send_file_cb(PurpleBlistNode *selected, PurpleBuddy *buddy) |
1243 finch_blist_menu_send_file_cb(PurpleBListNode *selected, PurpleBuddy *buddy) |
| 1244 { |
1244 { |
| 1245 serv_send_file(purple_account_get_connection(purple_buddy_get_account(buddy)), purple_buddy_get_name(buddy), NULL); |
1245 serv_send_file(purple_account_get_connection(purple_buddy_get_account(buddy)), purple_buddy_get_name(buddy), NULL); |
| 1246 } |
1246 } |
| 1247 |
1247 |
| 1248 static void |
1248 static void |
| 1249 finch_blist_pounce_node_cb(PurpleBlistNode *selected, PurpleBlistNode *node) |
1249 finch_blist_pounce_node_cb(PurpleBListNode *selected, PurpleBListNode *node) |
| 1250 { |
1250 { |
| 1251 PurpleBuddy *b; |
1251 PurpleBuddy *b; |
| 1252 if (PURPLE_IS_CONTACT(node)) |
1252 if (PURPLE_IS_CONTACT(node)) |
| 1253 b = purple_contact_get_priority_buddy((PurpleContact *)node); |
1253 b = purple_contact_get_priority_buddy((PurpleContact *)node); |
| 1254 else |
1254 else |
| 1312 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), !permitted); |
1312 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), !permitted); |
| 1313 gnt_menuitem_set_callback(item, toggle_block_buddy, buddy); |
1313 gnt_menuitem_set_callback(item, toggle_block_buddy, buddy); |
| 1314 gnt_menu_add_item(menu, item); |
1314 gnt_menu_add_item(menu, item); |
| 1315 |
1315 |
| 1316 item = gnt_menuitem_check_new(_("Show when offline")); |
1316 item = gnt_menuitem_check_new(_("Show when offline")); |
| 1317 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), purple_blist_node_get_bool((PurpleBlistNode*)buddy, "show_offline")); |
1317 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), purple_blist_node_get_bool((PurpleBListNode*)buddy, "show_offline")); |
| 1318 gnt_menuitem_set_callback(item, toggle_show_offline, buddy); |
1318 gnt_menuitem_set_callback(item, toggle_show_offline, buddy); |
| 1319 gnt_menu_add_item(menu, item); |
1319 gnt_menu_add_item(menu, item); |
| 1320 |
1320 |
| 1321 /* Protocol actions */ |
1321 /* Protocol actions */ |
| 1322 append_proto_menu(menu, |
1322 append_proto_menu(menu, |
| 1323 purple_account_get_connection(purple_buddy_get_account(buddy)), |
1323 purple_account_get_connection(purple_buddy_get_account(buddy)), |
| 1324 (PurpleBlistNode*)buddy); |
1324 (PurpleBListNode*)buddy); |
| 1325 } |
1325 } |
| 1326 |
1326 |
| 1327 static void |
1327 static void |
| 1328 append_extended_menu(GntMenu *menu, PurpleBlistNode *node) |
1328 append_extended_menu(GntMenu *menu, PurpleBListNode *node) |
| 1329 { |
1329 { |
| 1330 GList *iter; |
1330 GList *iter; |
| 1331 |
1331 |
| 1332 for (iter = purple_blist_node_get_extended_menu(node); |
1332 for (iter = purple_blist_node_get_extended_menu(node); |
| 1333 iter; iter = g_list_delete_link(iter, iter)) |
1333 iter; iter = g_list_delete_link(iter, iter)) |
| 1338 |
1338 |
| 1339 /* Xerox'd from gtkdialogs.c:purple_gtkdialogs_remove_contact_cb */ |
1339 /* Xerox'd from gtkdialogs.c:purple_gtkdialogs_remove_contact_cb */ |
| 1340 static void |
1340 static void |
| 1341 remove_contact(PurpleContact *contact) |
1341 remove_contact(PurpleContact *contact) |
| 1342 { |
1342 { |
| 1343 PurpleBlistNode *bnode, *cnode; |
1343 PurpleBListNode *bnode, *cnode; |
| 1344 PurpleGroup *group; |
1344 PurpleGroup *group; |
| 1345 |
1345 |
| 1346 cnode = (PurpleBlistNode *)contact; |
1346 cnode = (PurpleBListNode *)contact; |
| 1347 group = (PurpleGroup*)purple_blist_node_get_parent(cnode); |
1347 group = (PurpleGroup*)purple_blist_node_get_parent(cnode); |
| 1348 for (bnode = purple_blist_node_get_first_child(cnode); bnode; bnode = purple_blist_node_get_sibling_next(bnode)) { |
1348 for (bnode = purple_blist_node_get_first_child(cnode); bnode; bnode = purple_blist_node_get_sibling_next(bnode)) { |
| 1349 PurpleBuddy *buddy = (PurpleBuddy*)bnode; |
1349 PurpleBuddy *buddy = (PurpleBuddy*)bnode; |
| 1350 PurpleAccount *account = purple_buddy_get_account(buddy); |
1350 PurpleAccount *account = purple_buddy_get_account(buddy); |
| 1351 if (purple_account_is_connected(account)) |
1351 if (purple_account_is_connected(account)) |
| 1570 |
1570 |
| 1571 if (PURPLE_IS_GROUP(target)) |
1571 if (PURPLE_IS_GROUP(target)) |
| 1572 tg = (PurpleGroup*)target; |
1572 tg = (PurpleGroup*)target; |
| 1573 else if (PURPLE_IS_BUDDY(target)) { |
1573 else if (PURPLE_IS_BUDDY(target)) { |
| 1574 tc = (PurpleContact*)purple_blist_node_get_parent(target); |
1574 tc = (PurpleContact*)purple_blist_node_get_parent(target); |
| 1575 tg = (PurpleGroup*)purple_blist_node_get_parent((PurpleBlistNode*)tc); |
1575 tg = (PurpleGroup*)purple_blist_node_get_parent((PurpleBListNode*)tc); |
| 1576 } else { |
1576 } else { |
| 1577 if (PURPLE_IS_CONTACT(target)) |
1577 if (PURPLE_IS_CONTACT(target)) |
| 1578 tc = (PurpleContact*)target; |
1578 tc = (PurpleContact*)target; |
| 1579 tg = (PurpleGroup*)purple_blist_node_get_parent(target); |
1579 tg = (PurpleGroup*)purple_blist_node_get_parent(target); |
| 1580 } |
1580 } |
| 1581 |
1581 |
| 1582 if (ggblist->tagged) { |
1582 if (ggblist->tagged) { |
| 1583 GList *list = ggblist->tagged; |
1583 GList *list = ggblist->tagged; |
| 1584 ggblist->tagged = NULL; |
1584 ggblist->tagged = NULL; |
| 1585 while (list) { |
1585 while (list) { |
| 1586 PurpleBlistNode *node = list->data; |
1586 PurpleBListNode *node = list->data; |
| 1587 list = g_list_delete_link(list, list); |
1587 list = g_list_delete_link(list, list); |
| 1588 |
1588 |
| 1589 if (PURPLE_IS_GROUP(node)) { |
1589 if (PURPLE_IS_GROUP(node)) { |
| 1590 update_node_display(node, ggblist); |
1590 update_node_display(node, ggblist); |
| 1591 /* Add the group after the current group */ |
1591 /* Add the group after the current group */ |
| 1592 purple_blist_add_group((PurpleGroup*)node, (PurpleBlistNode*)tg); |
1592 purple_blist_add_group((PurpleGroup*)node, (PurpleBListNode*)tg); |
| 1593 } else if (PURPLE_IS_CONTACT(node)) { |
1593 } else if (PURPLE_IS_CONTACT(node)) { |
| 1594 update_buddy_display(purple_contact_get_priority_buddy((PurpleContact*)node), ggblist); |
1594 update_buddy_display(purple_contact_get_priority_buddy((PurpleContact*)node), ggblist); |
| 1595 if (PURPLE_BLIST_NODE(tg) == target) { |
1595 if (PURPLE_BLIST_NODE(tg) == target) { |
| 1596 /* The target is a group, just add the contact to the group. */ |
1596 /* The target is a group, just add the contact to the group. */ |
| 1597 purple_blist_add_contact((PurpleContact*)node, tg, NULL); |
1597 purple_blist_add_contact((PurpleContact*)node, tg, NULL); |
| 1598 } else if (tc) { |
1598 } else if (tc) { |
| 1599 /* The target is either a buddy, or a contact. Merge with that contact. */ |
1599 /* The target is either a buddy, or a contact. Merge with that contact. */ |
| 1600 purple_blist_merge_contact((PurpleContact*)node, (PurpleBlistNode*)tc); |
1600 purple_blist_merge_contact((PurpleContact*)node, (PurpleBListNode*)tc); |
| 1601 } else { |
1601 } else { |
| 1602 /* The target is a chat. Add the contact to the group after this chat. */ |
1602 /* The target is a chat. Add the contact to the group after this chat. */ |
| 1603 purple_blist_add_contact((PurpleContact*)node, NULL, target); |
1603 purple_blist_add_contact((PurpleContact*)node, NULL, target); |
| 1604 } |
1604 } |
| 1605 } else if (PURPLE_IS_BUDDY(node)) { |
1605 } else if (PURPLE_IS_BUDDY(node)) { |
| 1894 /* Escape was pressed */ |
1894 /* Escape was pressed */ |
| 1895 if (gnt_tree_is_searching(GNT_TREE(ggblist->tree))) |
1895 if (gnt_tree_is_searching(GNT_TREE(ggblist->tree))) |
| 1896 gnt_bindable_perform_action_named(GNT_BINDABLE(ggblist->tree), "end-search", NULL); |
1896 gnt_bindable_perform_action_named(GNT_BINDABLE(ggblist->tree), "end-search", NULL); |
| 1897 remove_peripherals(ggblist); |
1897 remove_peripherals(ggblist); |
| 1898 } else if (strcmp(text, GNT_KEY_INS) == 0) { |
1898 } else if (strcmp(text, GNT_KEY_INS) == 0) { |
| 1899 PurpleBlistNode *node = gnt_tree_get_selection_data(GNT_TREE(ggblist->tree)); |
1899 PurpleBListNode *node = gnt_tree_get_selection_data(GNT_TREE(ggblist->tree)); |
| 1900 purple_blist_request_add_buddy(NULL, NULL, |
1900 purple_blist_request_add_buddy(NULL, NULL, |
| 1901 node && PURPLE_IS_GROUP(node) ? purple_group_get_name(PURPLE_GROUP(node)) : NULL, |
1901 node && PURPLE_IS_GROUP(node) ? purple_group_get_name(PURPLE_GROUP(node)) : NULL, |
| 1902 NULL); |
1902 NULL); |
| 1903 } else if (!gnt_tree_is_searching(GNT_TREE(ggblist->tree))) { |
1903 } else if (!gnt_tree_is_searching(GNT_TREE(ggblist->tree))) { |
| 1904 if (strcmp(text, "t") == 0) { |
1904 if (strcmp(text, "t") == 0) { |
| 1926 { |
1926 { |
| 1927 PurpleContact *contact; |
1927 PurpleContact *contact; |
| 1928 |
1928 |
| 1929 contact = purple_buddy_get_contact(buddy); |
1929 contact = purple_buddy_get_contact(buddy); |
| 1930 |
1930 |
| 1931 gnt_tree_change_text(GNT_TREE(ggblist->tree), buddy, 0, get_display_name((PurpleBlistNode*)buddy)); |
1931 gnt_tree_change_text(GNT_TREE(ggblist->tree), buddy, 0, get_display_name((PurpleBListNode*)buddy)); |
| 1932 gnt_tree_change_text(GNT_TREE(ggblist->tree), contact, 0, get_display_name((PurpleBlistNode*)contact)); |
1932 gnt_tree_change_text(GNT_TREE(ggblist->tree), contact, 0, get_display_name((PurpleBListNode*)contact)); |
| 1933 |
1933 |
| 1934 blist_update_row_flags((PurpleBlistNode *)buddy); |
1934 blist_update_row_flags((PurpleBListNode *)buddy); |
| 1935 if (buddy == purple_contact_get_priority_buddy(contact)) |
1935 if (buddy == purple_contact_get_priority_buddy(contact)) |
| 1936 blist_update_row_flags((PurpleBlistNode *)contact); |
1936 blist_update_row_flags((PurpleBListNode *)contact); |
| 1937 |
1937 |
| 1938 if (ggblist->tnode == (PurpleBlistNode*)buddy) |
1938 if (ggblist->tnode == (PurpleBListNode*)buddy) |
| 1939 draw_tooltip(ggblist); |
1939 draw_tooltip(ggblist); |
| 1940 } |
1940 } |
| 1941 |
1941 |
| 1942 static void |
1942 static void |
| 1943 buddy_status_changed(PurpleBuddy *buddy, PurpleStatus *old, PurpleStatus *now, FinchBlist *ggblist) |
1943 buddy_status_changed(PurpleBuddy *buddy, PurpleStatus *old, PurpleStatus *now, FinchBlist *ggblist) |
| 2338 g_signal_handlers_unblock_matched(ggblist->statustext, G_SIGNAL_MATCH_FUNC, |
2338 g_signal_handlers_unblock_matched(ggblist->statustext, G_SIGNAL_MATCH_FUNC, |
| 2339 0, 0, NULL, status_text_changed, NULL); |
2339 0, 0, NULL, status_text_changed, NULL); |
| 2340 } |
2340 } |
| 2341 |
2341 |
| 2342 static int |
2342 static int |
| 2343 blist_node_compare_position(PurpleBlistNode *n1, PurpleBlistNode *n2) |
2343 blist_node_compare_position(PurpleBListNode *n1, PurpleBListNode *n2) |
| 2344 { |
2344 { |
| 2345 while ((n1 = purple_blist_node_get_sibling_prev(n1)) != NULL) |
2345 while ((n1 = purple_blist_node_get_sibling_prev(n1)) != NULL) |
| 2346 if (n1 == n2) |
2346 if (n1 == n2) |
| 2347 return 1; |
2347 return 1; |
| 2348 return -1; |
2348 return -1; |
| 2349 } |
2349 } |
| 2350 |
2350 |
| 2351 static int |
2351 static int |
| 2352 blist_node_compare_text(PurpleBlistNode *n1, PurpleBlistNode *n2) |
2352 blist_node_compare_text(PurpleBListNode *n1, PurpleBListNode *n2) |
| 2353 { |
2353 { |
| 2354 const char *s1, *s2; |
2354 const char *s1, *s2; |
| 2355 char *us1, *us2; |
2355 char *us1, *us2; |
| 2356 int ret; |
2356 int ret; |
| 2357 |
2357 |