Mercurial > pidgin.yaz
comparison finch/gntconv.c @ 22217:ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 26 Jan 2008 22:33:08 +0000 |
parents | 07c2b8fa7bb4 |
children | 797230b3e48e |
comparison
equal
deleted
inserted
replaced
22216:b99d6d21cd79 | 22217:ad357ca94de9 |
---|---|
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 = conv->ui_data; | 285 ggc = FINCH_GET_DATA(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(buddy->account, buddy->name); | 321 PurpleConversation *conv = find_conv_with_contact(buddy->account, buddy->name); |
322 if (conv == NULL) | 322 if (conv == NULL) |
323 return; | 323 return; |
324 generate_send_to_menu(conv->ui_data); | 324 generate_send_to_menu(FINCH_GET_DATA(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(cc->ui_data); | 336 generate_send_to_menu(FINCH_GET_DATA(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, |
608 } | 608 } |
609 | 609 |
610 static void | 610 static void |
611 finch_create_conversation(PurpleConversation *conv) | 611 finch_create_conversation(PurpleConversation *conv) |
612 { | 612 { |
613 FinchConv *ggc = conv->ui_data; | 613 FinchConv *ggc = FINCH_GET_DATA(conv); |
614 char *title; | 614 char *title; |
615 PurpleConversationType type; | 615 PurpleConversationType type; |
616 PurpleConversation *cc; | 616 PurpleConversation *cc; |
617 PurpleAccount *account; | 617 PurpleAccount *account; |
618 PurpleBlistNode *convnode = NULL; | 618 PurpleBlistNode *convnode = NULL; |
620 if (ggc) | 620 if (ggc) |
621 return; | 621 return; |
622 | 622 |
623 account = purple_conversation_get_account(conv); | 623 account = purple_conversation_get_account(conv); |
624 cc = find_conv_with_contact(account, purple_conversation_get_name(conv)); | 624 cc = find_conv_with_contact(account, purple_conversation_get_name(conv)); |
625 if (cc && cc->ui_data) | 625 if (cc && FINCH_GET_DATA(cc)) |
626 ggc = cc->ui_data; | 626 ggc = FINCH_GET_DATA(cc); |
627 else | 627 else |
628 ggc = g_new0(FinchConv, 1); | 628 ggc = g_new0(FinchConv, 1); |
629 | 629 |
630 /* Each conversation with the same person will have the same logging setting */ | 630 /* Each conversation with the same person will have the same logging setting */ |
631 if (ggc->list) { | 631 if (ggc->list) { |
633 purple_conversation_is_logging(ggc->list->data)); | 633 purple_conversation_is_logging(ggc->list->data)); |
634 } | 634 } |
635 | 635 |
636 ggc->list = g_list_prepend(ggc->list, conv); | 636 ggc->list = g_list_prepend(ggc->list, conv); |
637 ggc->active_conv = conv; | 637 ggc->active_conv = conv; |
638 conv->ui_data = ggc; | 638 FINCH_SET_DATA(conv, ggc); |
639 | 639 |
640 if (cc && cc->ui_data) { | 640 if (cc && FINCH_GET_DATA(cc)) { |
641 finch_conversation_set_active(conv); | 641 finch_conversation_set_active(conv); |
642 return; | 642 return; |
643 } | 643 } |
644 | 644 |
645 type = purple_conversation_get_type(conv); | 645 type = purple_conversation_get_type(conv); |
736 | 736 |
737 static void | 737 static void |
738 finch_destroy_conversation(PurpleConversation *conv) | 738 finch_destroy_conversation(PurpleConversation *conv) |
739 { | 739 { |
740 /* do stuff here */ | 740 /* do stuff here */ |
741 FinchConv *ggc = conv->ui_data; | 741 FinchConv *ggc = FINCH_GET_DATA(conv); |
742 ggc->list = g_list_remove(ggc->list, conv); | 742 ggc->list = g_list_remove(ggc->list, conv); |
743 if (ggc->list && conv == ggc->active_conv) | 743 if (ggc->list && conv == ggc->active_conv) |
744 ggc->active_conv = ggc->list->data; | 744 ggc->active_conv = ggc->list->data; |
745 | 745 |
746 if (ggc->list == NULL) { | 746 if (ggc->list == NULL) { |
753 | 753 |
754 static void | 754 static void |
755 finch_write_common(PurpleConversation *conv, const char *who, const char *message, | 755 finch_write_common(PurpleConversation *conv, const char *who, const char *message, |
756 PurpleMessageFlags flags, time_t mtime) | 756 PurpleMessageFlags flags, time_t mtime) |
757 { | 757 { |
758 FinchConv *ggconv = conv->ui_data; | 758 FinchConv *ggconv = FINCH_GET_DATA(conv); |
759 char *strip, *newline; | 759 char *strip, *newline; |
760 GntTextFormatFlags fl = 0; | 760 GntTextFormatFlags fl = 0; |
761 int pos; | 761 int pos; |
762 | 762 |
763 g_return_if_fail(ggconv != NULL); | 763 g_return_if_fail(ggconv != NULL); |
906 } | 906 } |
907 | 907 |
908 static void | 908 static void |
909 finch_chat_add_users(PurpleConversation *conv, GList *users, gboolean new_arrivals) | 909 finch_chat_add_users(PurpleConversation *conv, GList *users, gboolean new_arrivals) |
910 { | 910 { |
911 FinchConv *ggc = conv->ui_data; | 911 FinchConv *ggc = FINCH_GET_DATA(conv); |
912 GntEntry *entry = GNT_ENTRY(ggc->entry); | 912 GntEntry *entry = GNT_ENTRY(ggc->entry); |
913 | 913 |
914 if (!new_arrivals) | 914 if (!new_arrivals) |
915 { | 915 { |
916 /* Print the list of users in the room */ | 916 /* Print the list of users in the room */ |
945 | 945 |
946 static void | 946 static void |
947 finch_chat_rename_user(PurpleConversation *conv, const char *old, const char *new_n, const char *new_a) | 947 finch_chat_rename_user(PurpleConversation *conv, const char *old, const char *new_n, const char *new_a) |
948 { | 948 { |
949 /* Update the name for string completion */ | 949 /* Update the name for string completion */ |
950 FinchConv *ggc = conv->ui_data; | 950 FinchConv *ggc = FINCH_GET_DATA(conv); |
951 GntEntry *entry = GNT_ENTRY(ggc->entry); | 951 GntEntry *entry = GNT_ENTRY(ggc->entry); |
952 GntTree *tree = GNT_TREE(ggc->u.chat->userlist); | 952 GntTree *tree = GNT_TREE(ggc->u.chat->userlist); |
953 PurpleConvChatBuddy *cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), new_n); | 953 PurpleConvChatBuddy *cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), new_n); |
954 | 954 |
955 gnt_entry_remove_suggest(entry, old); | 955 gnt_entry_remove_suggest(entry, old); |
963 | 963 |
964 static void | 964 static void |
965 finch_chat_remove_users(PurpleConversation *conv, GList *list) | 965 finch_chat_remove_users(PurpleConversation *conv, GList *list) |
966 { | 966 { |
967 /* Remove the name from string completion */ | 967 /* Remove the name from string completion */ |
968 FinchConv *ggc = conv->ui_data; | 968 FinchConv *ggc = FINCH_GET_DATA(conv); |
969 GntEntry *entry = GNT_ENTRY(ggc->entry); | 969 GntEntry *entry = GNT_ENTRY(ggc->entry); |
970 for (; list; list = list->next) { | 970 for (; list; list = list->next) { |
971 GntTree *tree = GNT_TREE(ggc->u.chat->userlist); | 971 GntTree *tree = GNT_TREE(ggc->u.chat->userlist); |
972 gnt_entry_remove_suggest(entry, list->data); | 972 gnt_entry_remove_suggest(entry, list->data); |
973 gnt_tree_remove(tree, list->data); | 973 gnt_tree_remove(tree, list->data); |
976 | 976 |
977 static void | 977 static void |
978 finch_chat_update_user(PurpleConversation *conv, const char *user) | 978 finch_chat_update_user(PurpleConversation *conv, const char *user) |
979 { | 979 { |
980 PurpleConvChatBuddy *cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), user); | 980 PurpleConvChatBuddy *cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), user); |
981 FinchConv *ggc = conv->ui_data; | 981 FinchConv *ggc = FINCH_GET_DATA(conv); |
982 gnt_tree_change_text(GNT_TREE(ggc->u.chat->userlist), (gpointer)user, 0, chat_flag_text(cb->flags)); | 982 gnt_tree_change_text(GNT_TREE(ggc->u.chat->userlist), (gpointer)user, 0, chat_flag_text(cb->flags)); |
983 } | 983 } |
984 | 984 |
985 static void | 985 static void |
986 finch_conv_present(PurpleConversation *conv) | 986 finch_conv_present(PurpleConversation *conv) |
1085 /* Xerox */ | 1085 /* Xerox */ |
1086 static PurpleCmdRet | 1086 static PurpleCmdRet |
1087 clear_command_cb(PurpleConversation *conv, | 1087 clear_command_cb(PurpleConversation *conv, |
1088 const char *cmd, char **args, char **error, void *data) | 1088 const char *cmd, char **args, char **error, void *data) |
1089 { | 1089 { |
1090 FinchConv *ggconv = conv->ui_data; | 1090 FinchConv *ggconv = FINCH_GET_DATA(conv); |
1091 gnt_text_view_clear(GNT_TEXT_VIEW(ggconv->tv)); | 1091 gnt_text_view_clear(GNT_TEXT_VIEW(ggconv->tv)); |
1092 purple_conversation_clear_message_history(conv); | 1092 purple_conversation_clear_message_history(conv); |
1093 return PURPLE_CMD_STATUS_OK; | 1093 return PURPLE_CMD_STATUS_OK; |
1094 } | 1094 } |
1095 | 1095 |
1142 } | 1142 } |
1143 | 1143 |
1144 static PurpleCmdRet | 1144 static PurpleCmdRet |
1145 users_command_cb(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data) | 1145 users_command_cb(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data) |
1146 { | 1146 { |
1147 FinchConv *fc = conv->ui_data; | 1147 FinchConv *fc = FINCH_GET_DATA(conv); |
1148 FinchConvChat *ch; | 1148 FinchConvChat *ch; |
1149 if (!fc) | 1149 if (!fc) |
1150 return PURPLE_CMD_STATUS_FAILED; | 1150 return PURPLE_CMD_STATUS_FAILED; |
1151 | 1151 |
1152 ch = fc->u.chat; | 1152 ch = fc->u.chat; |
1246 purple_signals_disconnect_by_handle(finch_conv_get_handle()); | 1246 purple_signals_disconnect_by_handle(finch_conv_get_handle()); |
1247 } | 1247 } |
1248 | 1248 |
1249 void finch_conversation_set_active(PurpleConversation *conv) | 1249 void finch_conversation_set_active(PurpleConversation *conv) |
1250 { | 1250 { |
1251 FinchConv *ggconv = conv->ui_data; | 1251 FinchConv *ggconv = FINCH_GET_DATA(conv); |
1252 PurpleAccount *account; | 1252 PurpleAccount *account; |
1253 char *title; | 1253 char *title; |
1254 | 1254 |
1255 g_return_if_fail(ggconv); | 1255 g_return_if_fail(ggconv); |
1256 g_return_if_fail(g_list_find(ggconv->list, conv)); | 1256 g_return_if_fail(g_list_find(ggconv->list, conv)); |
1262 g_free(title); | 1262 g_free(title); |
1263 } | 1263 } |
1264 | 1264 |
1265 void finch_conversation_set_info_widget(PurpleConversation *conv, GntWidget *widget) | 1265 void finch_conversation_set_info_widget(PurpleConversation *conv, GntWidget *widget) |
1266 { | 1266 { |
1267 FinchConv *fc = conv->ui_data; | 1267 FinchConv *fc = FINCH_GET_DATA(conv); |
1268 int height, width; | 1268 int height, width; |
1269 | 1269 |
1270 gnt_box_remove_all(GNT_BOX(fc->info)); | 1270 gnt_box_remove_all(GNT_BOX(fc->info)); |
1271 | 1271 |
1272 if (widget) { | 1272 if (widget) { |