Mercurial > pidgin.yaz
comparison console/gntblist.c @ 14385:d1e4e986bbd1
[gaim-migrate @ 17091]
Update the contact when the status of the priority buddy changes.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Thu, 31 Aug 2006 02:59:59 +0000 |
parents | 4a901f5d1312 |
children | f4af666fafe3 |
comparison
equal
deleted
inserted
replaced
14384:4a901f5d1312 | 14385:d1e4e986bbd1 |
---|---|
121 node_update(GaimBuddyList *list, GaimBlistNode *node) | 121 node_update(GaimBuddyList *list, GaimBlistNode *node) |
122 { | 122 { |
123 if (list->ui_data == NULL) | 123 if (list->ui_data == NULL) |
124 return; | 124 return; |
125 | 125 |
126 if (node->ui_data != NULL) | 126 if (node->ui_data != NULL) { |
127 { | |
128 gnt_tree_change_text(GNT_TREE(ggblist->tree), node, | 127 gnt_tree_change_text(GNT_TREE(ggblist->tree), node, |
129 0, get_display_name(node)); | 128 0, get_display_name(node)); |
130 } | 129 } |
131 | 130 |
132 if (GAIM_BLIST_NODE_IS_BUDDY(node)) | 131 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { |
133 { | |
134 GaimBuddy *buddy = (GaimBuddy*)node; | 132 GaimBuddy *buddy = (GaimBuddy*)node; |
135 if (gaim_presence_is_online(gaim_buddy_get_presence(buddy))) | 133 if (gaim_presence_is_online(gaim_buddy_get_presence(buddy))) |
136 add_node((GaimBlistNode*)buddy, list->ui_data); | 134 add_node((GaimBlistNode*)buddy, list->ui_data); |
137 else | 135 else |
138 node_remove(gaim_get_blist(), node); | 136 node_remove(gaim_get_blist(), node); |
139 } | 137 |
140 else if (GAIM_BLIST_NODE_IS_CHAT(node)) | 138 node_update(list, node->parent); |
141 { | 139 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) { |
142 add_chat((GaimChat *)node, list->ui_data); | 140 add_chat((GaimChat *)node, list->ui_data); |
143 } | 141 } |
144 } | 142 } |
145 | 143 |
146 static void | 144 static void |
314 static GaimBlistUiOps blist_ui_ops = | 312 static GaimBlistUiOps blist_ui_ops = |
315 { | 313 { |
316 new_list, | 314 new_list, |
317 new_node, | 315 new_node, |
318 NULL, | 316 NULL, |
319 node_update, /* This doesn't do crap */ | 317 node_update, |
320 node_remove, | 318 node_remove, |
321 NULL, | 319 NULL, |
322 NULL, | 320 NULL, |
323 .request_add_buddy = gg_request_add_buddy, | 321 .request_add_buddy = gg_request_add_buddy, |
324 .request_add_chat = gg_request_add_chat, | 322 .request_add_chat = gg_request_add_chat, |
424 static void | 422 static void |
425 add_contact(GaimContact *contact, GGBlist *ggblist) | 423 add_contact(GaimContact *contact, GGBlist *ggblist) |
426 { | 424 { |
427 GaimGroup *group; | 425 GaimGroup *group; |
428 GaimBlistNode *node = (GaimBlistNode*)contact; | 426 GaimBlistNode *node = (GaimBlistNode*)contact; |
429 GaimBuddy *buddy; | |
430 | 427 |
431 if (node->ui_data) | 428 if (node->ui_data) |
432 return; | 429 return; |
433 | 430 |
434 group = (GaimGroup*)node->parent; | 431 group = (GaimGroup*)node->parent; |
437 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), contact, | 434 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), contact, |
438 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), | 435 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), |
439 group, NULL); | 436 group, NULL); |
440 | 437 |
441 gnt_tree_set_expanded(GNT_TREE(ggblist->tree), contact, FALSE); | 438 gnt_tree_set_expanded(GNT_TREE(ggblist->tree), contact, FALSE); |
442 | |
443 buddy = gaim_contact_get_priority_buddy(contact); | |
444 if (gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) | |
445 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), contact, GNT_TEXT_FLAG_DIM); | |
446 else | |
447 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), contact, 0); | |
448 } | 439 } |
449 | 440 |
450 static void | 441 static void |
451 add_buddy(GaimBuddy *buddy, GGBlist *ggblist) | 442 add_buddy(GaimBuddy *buddy, GGBlist *ggblist) |
452 { | 443 { |
460 | 451 |
461 gnt_tree_remove(GNT_TREE(ggblist->tree), buddy); | 452 gnt_tree_remove(GNT_TREE(ggblist->tree), buddy); |
462 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy, | 453 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy, |
463 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), | 454 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), |
464 contact, NULL); | 455 contact, NULL); |
465 if (gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) | 456 if (gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) { |
466 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, GNT_TEXT_FLAG_DIM); | 457 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, GNT_TEXT_FLAG_DIM); |
467 else | 458 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), contact, GNT_TEXT_FLAG_DIM); |
459 } else { | |
468 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, 0); | 460 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, 0); |
461 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), contact, 0); | |
462 } | |
469 } | 463 } |
470 | 464 |
471 #if 0 | 465 #if 0 |
472 static void | 466 static void |
473 buddy_signed_on(GaimBuddy *buddy, GGBlist *ggblist) | 467 buddy_signed_on(GaimBuddy *buddy, GGBlist *ggblist) |
527 { | 521 { |
528 GList *list; | 522 GList *list; |
529 if (action == NULL) | 523 if (action == NULL) |
530 return; | 524 return; |
531 | 525 |
532 gnt_tree_add_row_after(tree, action, | 526 gnt_tree_add_row_last(tree, action, |
533 gnt_tree_create_row(tree, action->label), parent, NULL); | 527 gnt_tree_create_row(tree, action->label), parent); |
534 for (list = action->children; list; list = list->next) | 528 for (list = action->children; list; list = list->next) |
535 gnt_append_menu_action(tree, list->data, action); | 529 gnt_append_menu_action(tree, list->data, action); |
536 } | 530 } |
537 | 531 |
538 static void | 532 static void |
903 ggblist->context = context = gnt_tree_new(); | 897 ggblist->context = context = gnt_tree_new(); |
904 GNT_WIDGET_SET_FLAGS(context, GNT_WIDGET_NO_BORDER); | 898 GNT_WIDGET_SET_FLAGS(context, GNT_WIDGET_NO_BORDER); |
905 gnt_widget_set_name(context, "context menu"); | 899 gnt_widget_set_name(context, "context menu"); |
906 g_signal_connect(G_OBJECT(context), "activate", G_CALLBACK(context_menu_callback), ggblist); | 900 g_signal_connect(G_OBJECT(context), "activate", G_CALLBACK(context_menu_callback), ggblist); |
907 | 901 |
908 /* XXX: For now, for a contact, the context menu for the priority buddy will popup */ | 902 if (GAIM_BLIST_NODE_IS_CONTACT(node)) { |
909 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | 903 create_buddy_menu(GNT_TREE(context), |
910 node = (GaimBlistNode*)gaim_contact_get_priority_buddy((GaimContact*)node); | 904 gaim_contact_get_priority_buddy((GaimContact*)node)); |
911 | 905 title = g_strdup(gaim_contact_get_alias((GaimContact*)node)); |
912 if (GAIM_BLIST_NODE_IS_BUDDY(node)) | 906 } else if (GAIM_BLIST_NODE_IS_BUDDY(node)) { |
913 { | |
914 GaimBuddy *buddy = (GaimBuddy *)node; | 907 GaimBuddy *buddy = (GaimBuddy *)node; |
915 create_buddy_menu(GNT_TREE(context), buddy); | 908 create_buddy_menu(GNT_TREE(context), buddy); |
916 title = g_strdup(gaim_buddy_get_name(buddy)); | 909 title = g_strdup(gaim_buddy_get_name(buddy)); |
917 } | 910 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) { |
918 else if (GAIM_BLIST_NODE_IS_CHAT(node)) | |
919 { | |
920 GaimChat *chat = (GaimChat*)node; | 911 GaimChat *chat = (GaimChat*)node; |
921 create_chat_menu(GNT_TREE(context), chat); | 912 create_chat_menu(GNT_TREE(context), chat); |
922 title = g_strdup(gaim_chat_get_name(chat)); | 913 title = g_strdup(gaim_chat_get_name(chat)); |
923 } | 914 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { |
924 else if (GAIM_BLIST_NODE_IS_GROUP(node)) | |
925 { | |
926 GaimGroup *group = (GaimGroup *)node; | 915 GaimGroup *group = (GaimGroup *)node; |
927 create_group_menu(GNT_TREE(context), group); | 916 create_group_menu(GNT_TREE(context), group); |
928 title = g_strdup(group->name); | 917 title = g_strdup(group->name); |
929 } | 918 } |
930 | 919 |
1036 tooltip_for_buddy(pr, str); | 1025 tooltip_for_buddy(pr, str); |
1037 for (node = node->child; node; node = node->next) { | 1026 for (node = node->child; node; node = node->next) { |
1038 if (node == (GaimBlistNode*)pr || !GAIM_BUDDY_IS_ONLINE((GaimBuddy*)node)) | 1027 if (node == (GaimBlistNode*)pr || !GAIM_BUDDY_IS_ONLINE((GaimBuddy*)node)) |
1039 continue; | 1028 continue; |
1040 str = g_string_append(str, "\n----------\n"); | 1029 str = g_string_append(str, "\n----------\n"); |
1030 g_string_append_printf(str, _("Nickname: %s\n"), gaim_buddy_get_name((GaimBuddy*)node)); | |
1041 tooltip_for_buddy((GaimBuddy*)node, str); | 1031 tooltip_for_buddy((GaimBuddy*)node, str); |
1042 } | 1032 } |
1043 } else if (GAIM_BLIST_NODE_IS_BUDDY(node)) { | 1033 } else if (GAIM_BLIST_NODE_IS_BUDDY(node)) { |
1044 GaimBuddy *buddy = (GaimBuddy *)node; | 1034 GaimBuddy *buddy = (GaimBuddy *)node; |
1045 tooltip_for_buddy(buddy, str); | 1035 tooltip_for_buddy(buddy, str); |
1134 } | 1124 } |
1135 | 1125 |
1136 static void | 1126 static void |
1137 update_buddy_display(GaimBuddy *buddy, GGBlist *ggblist) | 1127 update_buddy_display(GaimBuddy *buddy, GGBlist *ggblist) |
1138 { | 1128 { |
1129 GaimContact *contact; | |
1130 | |
1131 contact = gaim_buddy_get_contact(buddy); | |
1132 | |
1139 gnt_tree_change_text(GNT_TREE(ggblist->tree), buddy, 0, get_display_name((GaimBlistNode*)buddy)); | 1133 gnt_tree_change_text(GNT_TREE(ggblist->tree), buddy, 0, get_display_name((GaimBlistNode*)buddy)); |
1134 gnt_tree_change_text(GNT_TREE(ggblist->tree), contact, 0, get_display_name((GaimBlistNode*)contact)); | |
1135 | |
1140 if (ggblist->tnode == (GaimBlistNode*)buddy) | 1136 if (ggblist->tnode == (GaimBlistNode*)buddy) |
1141 draw_tooltip(ggblist); | 1137 draw_tooltip(ggblist); |
1142 | 1138 |
1143 if (gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) | 1139 if (gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) { |
1144 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, GNT_TEXT_FLAG_DIM); | 1140 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, GNT_TEXT_FLAG_DIM); |
1145 else | 1141 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), contact, GNT_TEXT_FLAG_DIM); |
1142 } else { | |
1146 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, 0); | 1143 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, 0); |
1144 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), contact, 0); | |
1145 } | |
1147 } | 1146 } |
1148 | 1147 |
1149 static void | 1148 static void |
1150 buddy_status_changed(GaimBuddy *buddy, GaimStatus *old, GaimStatus *now, GGBlist *ggblist) | 1149 buddy_status_changed(GaimBuddy *buddy, GaimStatus *old, GaimStatus *now, GGBlist *ggblist) |
1151 { | 1150 { |
1442 case GAIM_BLIST_CHAT_NODE: | 1441 case GAIM_BLIST_CHAT_NODE: |
1443 s1 = gaim_chat_get_name((GaimChat*)n1); | 1442 s1 = gaim_chat_get_name((GaimChat*)n1); |
1444 s2 = gaim_chat_get_name((GaimChat*)n2); | 1443 s2 = gaim_chat_get_name((GaimChat*)n2); |
1445 break; | 1444 break; |
1446 case GAIM_BLIST_BUDDY_NODE: | 1445 case GAIM_BLIST_BUDDY_NODE: |
1447 s1 = gaim_buddy_get_alias((GaimBuddy*)n1); | 1446 /* XXX: reordering existing rows don't do well in GntTree */ |
1448 s2 = gaim_buddy_get_alias((GaimBuddy*)n2); | 1447 return gaim_presence_compare(gaim_buddy_get_presence((GaimBuddy*)n1), |
1448 gaim_buddy_get_presence((GaimBuddy*)n2)); | |
1449 break; | |
1450 case GAIM_BLIST_CONTACT_NODE: | |
1451 s1 = gaim_contact_get_alias((GaimContact*)n1); | |
1452 s2 = gaim_contact_get_alias((GaimContact*)n2); | |
1449 break; | 1453 break; |
1450 default: | 1454 default: |
1451 return -1; | 1455 return -1; |
1452 } | 1456 } |
1453 | 1457 |