Mercurial > pidgin.yaz
comparison finch/gntconv.c @ 32432:49a33bd1baf1
Use the new accessor functions.
FINCH_GET_DATA() and FINCH_CONV() were both used to do the same thing
for a PurpleConversation, so standardize on FINCH_CONV().
author | andrew.victor@mxit.com |
---|---|
date | Fri, 26 Aug 2011 21:09:27 +0000 |
parents | 62b11ad353eb |
children | c39583aad67c |
comparison
equal
deleted
inserted
replaced
32431:c0a423e7fea4 | 32432:49a33bd1baf1 |
---|---|
280 | 280 |
281 if (!conv) | 281 if (!conv) |
282 return; | 282 return; |
283 | 283 |
284 im = PURPLE_CONV_IM(conv); | 284 im = PURPLE_CONV_IM(conv); |
285 ggc = FINCH_GET_DATA(conv); | 285 ggc = FINCH_CONV(conv); |
286 | 286 |
287 if (purple_conv_im_get_typing_state(im) == PURPLE_TYPING) { | 287 if (purple_conv_im_get_typing_state(im) == PURPLE_TYPING) { |
288 int scroll; | 288 int scroll; |
289 str = get_conversation_title(conv, account); | 289 str = get_conversation_title(conv, account); |
290 title = g_strdup_printf(_("%s [%s]"), str, | 290 title = g_strdup_printf(_("%s [%s]"), str, |
319 buddy_signed_on_off(PurpleBuddy *buddy, gpointer null) | 319 buddy_signed_on_off(PurpleBuddy *buddy, gpointer null) |
320 { | 320 { |
321 PurpleConversation *conv = find_conv_with_contact(purple_buddy_get_account(buddy), purple_buddy_get_name(buddy)); | 321 PurpleConversation *conv = find_conv_with_contact(purple_buddy_get_account(buddy), purple_buddy_get_name(buddy)); |
322 if (conv == NULL) | 322 if (conv == NULL) |
323 return; | 323 return; |
324 generate_send_to_menu(FINCH_GET_DATA(conv)); | 324 generate_send_to_menu(FINCH_CONV(conv)); |
325 } | 325 } |
326 | 326 |
327 static void | 327 static void |
328 account_signed_on_off(PurpleConnection *gc, gpointer null) | 328 account_signed_on_off(PurpleConnection *gc, gpointer null) |
329 { | 329 { |
331 while (list) { | 331 while (list) { |
332 PurpleConversation *conv = list->data; | 332 PurpleConversation *conv = list->data; |
333 PurpleConversation *cc = find_conv_with_contact( | 333 PurpleConversation *cc = find_conv_with_contact( |
334 purple_conversation_get_account(conv), purple_conversation_get_name(conv)); | 334 purple_conversation_get_account(conv), purple_conversation_get_name(conv)); |
335 if (cc) | 335 if (cc) |
336 generate_send_to_menu(FINCH_GET_DATA(cc)); | 336 generate_send_to_menu(FINCH_CONV(cc)); |
337 list = list->next; | 337 list = list->next; |
338 } | 338 } |
339 | 339 |
340 if (PURPLE_CONNECTION_IS_CONNECTED(gc)) { | 340 if (PURPLE_CONNECTION_IS_CONNECTED(gc)) { |
341 /* We just signed on. Let's see if there's any chat that we have open, | 341 /* We just signed on. Let's see if there's any chat that we have open, |
396 } | 396 } |
397 | 397 |
398 static void | 398 static void |
399 cleared_message_history_cb(PurpleConversation *conv, gpointer data) | 399 cleared_message_history_cb(PurpleConversation *conv, gpointer data) |
400 { | 400 { |
401 FinchConv *ggc = FINCH_GET_DATA(conv); | 401 FinchConv *ggc = FINCH_CONV(conv); |
402 if (ggc) | 402 if (ggc) |
403 gnt_text_view_clear(GNT_TEXT_VIEW(ggc->tv)); | 403 gnt_text_view_clear(GNT_TEXT_VIEW(ggc->tv)); |
404 } | 404 } |
405 | 405 |
406 static void | 406 static void |
747 } | 747 } |
748 | 748 |
749 static void | 749 static void |
750 finch_create_conversation(PurpleConversation *conv) | 750 finch_create_conversation(PurpleConversation *conv) |
751 { | 751 { |
752 FinchConv *ggc = FINCH_GET_DATA(conv); | 752 FinchConv *ggc = FINCH_CONV(conv); |
753 char *title; | 753 char *title; |
754 PurpleConversationType type; | 754 PurpleConversationType type; |
755 PurpleConversation *cc; | 755 PurpleConversation *cc; |
756 PurpleAccount *account; | 756 PurpleAccount *account; |
757 PurpleBlistNode *convnode = NULL; | 757 PurpleBlistNode *convnode = NULL; |
761 return; | 761 return; |
762 } | 762 } |
763 | 763 |
764 account = purple_conversation_get_account(conv); | 764 account = purple_conversation_get_account(conv); |
765 cc = find_conv_with_contact(account, purple_conversation_get_name(conv)); | 765 cc = find_conv_with_contact(account, purple_conversation_get_name(conv)); |
766 if (cc && FINCH_GET_DATA(cc)) | 766 if (cc && FINCH_CONV(cc)) |
767 ggc = FINCH_GET_DATA(cc); | 767 ggc = FINCH_CONV(cc); |
768 else | 768 else |
769 ggc = g_new0(FinchConv, 1); | 769 ggc = g_new0(FinchConv, 1); |
770 | 770 |
771 /* Each conversation with the same person will have the same logging setting */ | 771 /* Each conversation with the same person will have the same logging setting */ |
772 if (ggc->list) { | 772 if (ggc->list) { |
774 purple_conversation_is_logging(ggc->list->data)); | 774 purple_conversation_is_logging(ggc->list->data)); |
775 } | 775 } |
776 | 776 |
777 ggc->list = g_list_prepend(ggc->list, conv); | 777 ggc->list = g_list_prepend(ggc->list, conv); |
778 ggc->active_conv = conv; | 778 ggc->active_conv = conv; |
779 FINCH_SET_DATA(conv, ggc); | 779 purple_conversation_set_ui_data(conv, ggc); |
780 | 780 |
781 if (cc && FINCH_GET_DATA(cc) && cc != conv) { | 781 if (cc && FINCH_CONV(cc) && cc != conv) { |
782 finch_conversation_set_active(conv); | 782 finch_conversation_set_active(conv); |
783 return; | 783 return; |
784 } | 784 } |
785 | 785 |
786 type = purple_conversation_get_type(conv); | 786 type = purple_conversation_get_type(conv); |
883 | 883 |
884 static void | 884 static void |
885 finch_destroy_conversation(PurpleConversation *conv) | 885 finch_destroy_conversation(PurpleConversation *conv) |
886 { | 886 { |
887 /* do stuff here */ | 887 /* do stuff here */ |
888 FinchConv *ggc = FINCH_GET_DATA(conv); | 888 FinchConv *ggc = FINCH_CONV(conv); |
889 ggc->list = g_list_remove(ggc->list, conv); | 889 ggc->list = g_list_remove(ggc->list, conv); |
890 if (ggc->list && conv == ggc->active_conv) { | 890 if (ggc->list && conv == ggc->active_conv) { |
891 ggc->active_conv = ggc->list->data; | 891 ggc->active_conv = ggc->list->data; |
892 gg_setup_commands(ggc, TRUE); | 892 gg_setup_commands(ggc, TRUE); |
893 } | 893 } |
903 | 903 |
904 static void | 904 static void |
905 finch_write_common(PurpleConversation *conv, const char *who, const char *message, | 905 finch_write_common(PurpleConversation *conv, const char *who, const char *message, |
906 PurpleMessageFlags flags, time_t mtime) | 906 PurpleMessageFlags flags, time_t mtime) |
907 { | 907 { |
908 FinchConv *ggconv = FINCH_GET_DATA(conv); | 908 FinchConv *ggconv = FINCH_CONV(conv); |
909 char *strip, *newline; | 909 char *strip, *newline; |
910 GntTextFormatFlags fl = 0; | 910 GntTextFormatFlags fl = 0; |
911 int pos; | 911 int pos; |
912 | 912 |
913 g_return_if_fail(ggconv != NULL); | 913 g_return_if_fail(ggconv != NULL); |
1067 } | 1067 } |
1068 | 1068 |
1069 static void | 1069 static void |
1070 finch_chat_add_users(PurpleConversation *conv, GList *users, gboolean new_arrivals) | 1070 finch_chat_add_users(PurpleConversation *conv, GList *users, gboolean new_arrivals) |
1071 { | 1071 { |
1072 FinchConv *ggc = FINCH_GET_DATA(conv); | 1072 FinchConv *ggc = FINCH_CONV(conv); |
1073 GntEntry *entry = GNT_ENTRY(ggc->entry); | 1073 GntEntry *entry = GNT_ENTRY(ggc->entry); |
1074 | 1074 |
1075 if (!new_arrivals) | 1075 if (!new_arrivals) |
1076 { | 1076 { |
1077 /* Print the list of users in the room */ | 1077 /* Print the list of users in the room */ |
1109 | 1109 |
1110 static void | 1110 static void |
1111 finch_chat_rename_user(PurpleConversation *conv, const char *old, const char *new_n, const char *new_a) | 1111 finch_chat_rename_user(PurpleConversation *conv, const char *old, const char *new_n, const char *new_a) |
1112 { | 1112 { |
1113 /* Update the name for string completion */ | 1113 /* Update the name for string completion */ |
1114 FinchConv *ggc = FINCH_GET_DATA(conv); | 1114 FinchConv *ggc = FINCH_CONV(conv); |
1115 GntEntry *entry = GNT_ENTRY(ggc->entry); | 1115 GntEntry *entry = GNT_ENTRY(ggc->entry); |
1116 GntTree *tree = GNT_TREE(ggc->u.chat->userlist); | 1116 GntTree *tree = GNT_TREE(ggc->u.chat->userlist); |
1117 PurpleConvChatBuddy *cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), new_n); | 1117 PurpleConvChatBuddy *cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), new_n); |
1118 | 1118 |
1119 gnt_entry_remove_suggest(entry, old); | 1119 gnt_entry_remove_suggest(entry, old); |
1127 | 1127 |
1128 static void | 1128 static void |
1129 finch_chat_remove_users(PurpleConversation *conv, GList *list) | 1129 finch_chat_remove_users(PurpleConversation *conv, GList *list) |
1130 { | 1130 { |
1131 /* Remove the name from string completion */ | 1131 /* Remove the name from string completion */ |
1132 FinchConv *ggc = FINCH_GET_DATA(conv); | 1132 FinchConv *ggc = FINCH_CONV(conv); |
1133 GntEntry *entry = GNT_ENTRY(ggc->entry); | 1133 GntEntry *entry = GNT_ENTRY(ggc->entry); |
1134 for (; list; list = list->next) { | 1134 for (; list; list = list->next) { |
1135 GntTree *tree = GNT_TREE(ggc->u.chat->userlist); | 1135 GntTree *tree = GNT_TREE(ggc->u.chat->userlist); |
1136 gnt_entry_remove_suggest(entry, list->data); | 1136 gnt_entry_remove_suggest(entry, list->data); |
1137 gnt_tree_remove(tree, list->data); | 1137 gnt_tree_remove(tree, list->data); |
1140 | 1140 |
1141 static void | 1141 static void |
1142 finch_chat_update_user(PurpleConversation *conv, const char *user) | 1142 finch_chat_update_user(PurpleConversation *conv, const char *user) |
1143 { | 1143 { |
1144 PurpleConvChatBuddy *cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), user); | 1144 PurpleConvChatBuddy *cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), user); |
1145 FinchConv *ggc = FINCH_GET_DATA(conv); | 1145 FinchConv *ggc = FINCH_CONV(conv); |
1146 gnt_tree_change_text(GNT_TREE(ggc->u.chat->userlist), (gpointer)user, 0, chat_flag_text(cb->flags)); | 1146 gnt_tree_change_text(GNT_TREE(ggc->u.chat->userlist), (gpointer)user, 0, chat_flag_text(cb->flags)); |
1147 } | 1147 } |
1148 | 1148 |
1149 static void | 1149 static void |
1150 finch_conv_present(PurpleConversation *conv) | 1150 finch_conv_present(PurpleConversation *conv) |
1366 } | 1366 } |
1367 | 1367 |
1368 static PurpleCmdRet | 1368 static PurpleCmdRet |
1369 users_command_cb(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data) | 1369 users_command_cb(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data) |
1370 { | 1370 { |
1371 FinchConv *fc = FINCH_GET_DATA(conv); | 1371 FinchConv *fc = FINCH_CONV(conv); |
1372 FinchConvChat *ch; | 1372 FinchConvChat *ch; |
1373 if (!fc) | 1373 if (!fc) |
1374 return PURPLE_CMD_RET_FAILED; | 1374 return PURPLE_CMD_RET_FAILED; |
1375 | 1375 |
1376 ch = fc->u.chat; | 1376 ch = fc->u.chat; |
1492 purple_signals_disconnect_by_handle(finch_conv_get_handle()); | 1492 purple_signals_disconnect_by_handle(finch_conv_get_handle()); |
1493 } | 1493 } |
1494 | 1494 |
1495 void finch_conversation_set_active(PurpleConversation *conv) | 1495 void finch_conversation_set_active(PurpleConversation *conv) |
1496 { | 1496 { |
1497 FinchConv *ggconv = FINCH_GET_DATA(conv); | 1497 FinchConv *ggconv = FINCH_CONV(conv); |
1498 PurpleAccount *account; | 1498 PurpleAccount *account; |
1499 char *title; | 1499 char *title; |
1500 | 1500 |
1501 g_return_if_fail(ggconv); | 1501 g_return_if_fail(ggconv); |
1502 g_return_if_fail(g_list_find(ggconv->list, conv)); | 1502 g_return_if_fail(g_list_find(ggconv->list, conv)); |
1511 g_free(title); | 1511 g_free(title); |
1512 } | 1512 } |
1513 | 1513 |
1514 void finch_conversation_set_info_widget(PurpleConversation *conv, GntWidget *widget) | 1514 void finch_conversation_set_info_widget(PurpleConversation *conv, GntWidget *widget) |
1515 { | 1515 { |
1516 FinchConv *fc = FINCH_GET_DATA(conv); | 1516 FinchConv *fc = FINCH_CONV(conv); |
1517 int height, width; | 1517 int height, width; |
1518 | 1518 |
1519 gnt_box_remove_all(GNT_BOX(fc->info)); | 1519 gnt_box_remove_all(GNT_BOX(fc->info)); |
1520 | 1520 |
1521 if (widget) { | 1521 if (widget) { |