| 100 |
92 |
| 101 static GtkWidget *invite_dialog = NULL; |
93 static GtkWidget *invite_dialog = NULL; |
| 102 |
94 |
| 103 /* Prototypes. <-- because Paco-Paco hates this comment. */ |
95 /* Prototypes. <-- because Paco-Paco hates this comment. */ |
| 104 static void got_typing_keypress(PidginConversation *gtkconv, gboolean first); |
96 static void got_typing_keypress(PidginConversation *gtkconv, gboolean first); |
| 105 static void gray_stuff_out(PidginConversation *gtkconv); |
|
| 106 static void add_chat_user_common(PurpleChatConversation *chat, PurpleChatUser *cb, const char *old_name); |
97 static void add_chat_user_common(PurpleChatConversation *chat, PurpleChatUser *cb, const char *old_name); |
| 107 static void pidgin_conv_updated(PurpleConversation *conv, PurpleConversationUpdateType type); |
98 static void pidgin_conv_updated(PurpleConversation *conv, PurpleConversationUpdateType type); |
| 108 static void conv_set_unseen(PurpleConversation *gtkconv, PidginUnseenState state); |
|
| 109 static void gtkconv_set_unseen(PidginConversation *gtkconv, PidginUnseenState state); |
|
| 110 static void update_typing_icon(PidginConversation *gtkconv); |
99 static void update_typing_icon(PidginConversation *gtkconv); |
| 111 gboolean pidgin_conv_has_focus(PurpleConversation *conv); |
100 gboolean pidgin_conv_has_focus(PurpleConversation *conv); |
| 112 static void pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields); |
101 static void pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields); |
| 113 |
102 |
| 114 static void pidgin_conv_placement_place(PidginConversation *conv); |
103 static void pidgin_conv_placement_place(PidginConversation *conv); |
| 1195 |
1166 |
| 1196 gtkconv->active_conv = conv; |
1167 gtkconv->active_conv = conv; |
| 1197 |
1168 |
| 1198 purple_signal_emit(pidgin_conversations_get_handle(), "conversation-switched", conv); |
1169 purple_signal_emit(pidgin_conversations_get_handle(), "conversation-switched", conv); |
| 1199 |
1170 |
| 1200 gray_stuff_out(gtkconv); |
|
| 1201 update_typing_icon(gtkconv); |
1171 update_typing_icon(gtkconv); |
| 1202 g_object_set_data(G_OBJECT(gtkconv->entry), "transient_buddy", NULL); |
1172 g_object_set_data(G_OBJECT(gtkconv->entry), "transient_buddy", NULL); |
| 1203 } |
|
| 1204 |
|
| 1205 void |
|
| 1206 pidgin_conv_present_conversation(PurpleConversation *conv) |
|
| 1207 { |
|
| 1208 #if 0 |
|
| 1209 PidginConversation *gtkconv; |
|
| 1210 GdkModifierType state; |
|
| 1211 |
|
| 1212 pidgin_conv_attach_to_conversation(conv); |
|
| 1213 gtkconv = PIDGIN_CONVERSATION(conv); |
|
| 1214 |
|
| 1215 pidgin_conv_switch_active_conversation(conv); |
|
| 1216 /* Switch the tab only if the user initiated the event by pressing |
|
| 1217 * a button or hitting a key. */ |
|
| 1218 if (gtk_get_current_event_state(&state)) |
|
| 1219 pidgin_conv_window_switch_gtkconv(gtkconv->win, gtkconv); |
|
| 1220 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); |
|
| 1221 #endif |
|
| 1222 } |
|
| 1223 |
|
| 1224 static GList * |
|
| 1225 pidgin_conversations_get_unseen(GList *l, |
|
| 1226 PidginUnseenState min_state, |
|
| 1227 guint max_count) |
|
| 1228 { |
|
| 1229 GList *r = NULL; |
|
| 1230 guint c = 0; |
|
| 1231 |
|
| 1232 for (; l != NULL && (max_count == 0 || c < max_count); l = l->next) { |
|
| 1233 PurpleConversation *conv = (PurpleConversation*)l->data; |
|
| 1234 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); |
|
| 1235 |
|
| 1236 if(gtkconv == NULL || gtkconv->active_conv != conv) { |
|
| 1237 continue; |
|
| 1238 } |
|
| 1239 |
|
| 1240 if (gtkconv->unseen_state >= min_state) { |
|
| 1241 r = g_list_prepend(r, conv); |
|
| 1242 c++; |
|
| 1243 } |
|
| 1244 } |
|
| 1245 |
|
| 1246 return r; |
|
| 1247 } |
|
| 1248 |
|
| 1249 GList * |
|
| 1250 pidgin_conversations_get_unseen_all(PidginUnseenState min_state, |
|
| 1251 guint max_count) |
|
| 1252 { |
|
| 1253 PurpleConversationManager *manager; |
|
| 1254 GList *list, *ret = NULL; |
|
| 1255 |
|
| 1256 manager = purple_conversation_manager_get_default(); |
|
| 1257 list = purple_conversation_manager_get_all(manager); |
|
| 1258 |
|
| 1259 ret = pidgin_conversations_get_unseen(list, min_state, max_count); |
|
| 1260 g_list_free(list); |
|
| 1261 |
|
| 1262 return ret; |
|
| 1263 } |
1173 } |
| 1264 |
1174 |
| 1265 static GtkActionEntry menu_entries[] = |
1175 static GtkActionEntry menu_entries[] = |
| 1266 /* TODO: fill out tooltips... */ |
1176 /* TODO: fill out tooltips... */ |
| 1267 { |
1177 { |
| 2432 } |
2319 } |
| 2433 |
2320 |
| 2434 return FALSE; |
2321 return FALSE; |
| 2435 } |
2322 } |
| 2436 |
2323 |
| 2437 /* |
|
| 2438 * Makes sure all the menu items and all the buttons are hidden/shown and |
|
| 2439 * sensitive/insensitive. This is called after changing tabs and when an |
|
| 2440 * account signs on or off. |
|
| 2441 */ |
|
| 2442 static void |
|
| 2443 gray_stuff_out(PidginConversation *gtkconv) |
|
| 2444 { |
|
| 2445 /* This will be replaced by managing an action group in the new conversation |
|
| 2446 * window. |
|
| 2447 */ |
|
| 2448 #if 0 |
|
| 2449 PidginConvWindow *win; |
|
| 2450 PurpleConversation *conv = gtkconv->active_conv; |
|
| 2451 PurpleConnection *gc; |
|
| 2452 PurpleProtocol *protocol = NULL; |
|
| 2453 PurpleAccount *account; |
|
| 2454 |
|
| 2455 win = pidgin_conv_get_window(gtkconv); |
|
| 2456 gc = purple_conversation_get_connection(conv); |
|
| 2457 account = purple_conversation_get_account(conv); |
|
| 2458 |
|
| 2459 if (gc != NULL) |
|
| 2460 protocol = purple_connection_get_protocol(gc); |
|
| 2461 |
|
| 2462 /* |
|
| 2463 * Handle hiding and showing stuff based on what type of conv this is. |
|
| 2464 * Stuff that Purple IMs support in general should be shown for IM |
|
| 2465 * conversations. Stuff that Purple chats support in general should be |
|
| 2466 * shown for chat conversations. It doesn't matter whether the protocol |
|
| 2467 * supports it or not--that only affects if the button or menu item |
|
| 2468 * is sensitive or not. |
|
| 2469 */ |
|
| 2470 if (PURPLE_IS_IM_CONVERSATION(conv)) { |
|
| 2471 /* Show stuff that applies to IMs, hide stuff that applies to chats */ |
|
| 2472 |
|
| 2473 /* Deal with menu items */ |
|
| 2474 gtk_action_set_visible(win->menu->view_log, TRUE); |
|
| 2475 gtk_action_set_visible(win->menu->send_file, TRUE); |
|
| 2476 gtk_action_set_visible(win->menu->get_info, TRUE); |
|
| 2477 gtk_action_set_visible(win->menu->invite, FALSE); |
|
| 2478 gtk_action_set_visible(win->menu->alias, TRUE); |
|
| 2479 if (purple_account_privacy_check(account, purple_conversation_get_name(conv))) { |
|
| 2480 gtk_action_set_visible(win->menu->unblock, FALSE); |
|
| 2481 gtk_action_set_visible(win->menu->block, TRUE); |
|
| 2482 } else { |
|
| 2483 gtk_action_set_visible(win->menu->block, FALSE); |
|
| 2484 gtk_action_set_visible(win->menu->unblock, TRUE); |
|
| 2485 } |
|
| 2486 |
|
| 2487 if (purple_blist_find_buddy(account, purple_conversation_get_name(conv)) == NULL) { |
|
| 2488 gtk_action_set_visible(win->menu->add, TRUE); |
|
| 2489 gtk_action_set_visible(win->menu->remove, FALSE); |
|
| 2490 } else { |
|
| 2491 gtk_action_set_visible(win->menu->remove, TRUE); |
|
| 2492 gtk_action_set_visible(win->menu->add, FALSE); |
|
| 2493 } |
|
| 2494 |
|
| 2495 gtk_action_set_visible(win->menu->insert_link, TRUE); |
|
| 2496 gtk_action_set_visible(win->menu->insert_image, TRUE); |
|
| 2497 } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) { |
|
| 2498 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ |
|
| 2499 |
|
| 2500 /* Deal with menu items */ |
|
| 2501 gtk_action_set_visible(win->menu->view_log, TRUE); |
|
| 2502 gtk_action_set_visible(win->menu->send_file, FALSE); |
|
| 2503 gtk_action_set_visible(win->menu->get_info, FALSE); |
|
| 2504 gtk_action_set_visible(win->menu->invite, TRUE); |
|
| 2505 gtk_action_set_visible(win->menu->alias, TRUE); |
|
| 2506 gtk_action_set_visible(win->menu->block, FALSE); |
|
| 2507 gtk_action_set_visible(win->menu->unblock, FALSE); |
|
| 2508 |
|
| 2509 if ((account == NULL) || purple_blist_find_chat(account, purple_conversation_get_name(conv)) == NULL) { |
|
| 2510 /* If the chat is NOT in the buddy list */ |
|
| 2511 gtk_action_set_visible(win->menu->add, TRUE); |
|
| 2512 gtk_action_set_visible(win->menu->remove, FALSE); |
|
| 2513 } else { |
|
| 2514 /* If the chat IS in the buddy list */ |
|
| 2515 gtk_action_set_visible(win->menu->add, FALSE); |
|
| 2516 gtk_action_set_visible(win->menu->remove, TRUE); |
|
| 2517 } |
|
| 2518 |
|
| 2519 gtk_action_set_visible(win->menu->insert_link, TRUE); |
|
| 2520 gtk_action_set_visible(win->menu->insert_image, TRUE); |
|
| 2521 } |
|
| 2522 |
|
| 2523 /* |
|
| 2524 * Handle graying stuff out based on whether an account is connected |
|
| 2525 * and what features that account supports. |
|
| 2526 */ |
|
| 2527 if ((gc != NULL) && |
|
| 2528 (!PURPLE_IS_CHAT_CONVERSATION(conv) || |
|
| 2529 !purple_chat_conversation_has_left(PURPLE_CHAT_CONVERSATION(conv)) )) |
|
| 2530 { |
|
| 2531 PurpleConnectionFlags features = purple_conversation_get_features(conv); |
|
| 2532 /* Account is online */ |
|
| 2533 |
|
| 2534 /* Deal with menu items */ |
|
| 2535 gtk_action_set_sensitive(win->menu->view_log, TRUE); |
|
| 2536 gtk_action_set_sensitive(win->menu->get_info, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER, get_info))); |
|
| 2537 gtk_action_set_sensitive(win->menu->invite, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT, invite))); |
|
| 2538 gtk_action_set_sensitive(win->menu->insert_link, (features & PURPLE_CONNECTION_FLAG_HTML)); |
|
| 2539 gtk_action_set_sensitive(win->menu->insert_image, !(features & PURPLE_CONNECTION_FLAG_NO_IMAGES)); |
|
| 2540 |
|
| 2541 if (PURPLE_IS_IM_CONVERSATION(conv)) |
|
| 2542 { |
|
| 2543 gboolean can_send_file = FALSE; |
|
| 2544 const gchar *name = purple_conversation_get_name(conv); |
|
| 2545 |
|
| 2546 if (PURPLE_IS_PROTOCOL_XFER(protocol) && |
|
| 2547 purple_protocol_xfer_can_receive(PURPLE_PROTOCOL_XFER(protocol), gc, name) |
|
| 2548 ) { |
|
| 2549 can_send_file = TRUE; |
|
| 2550 } |
|
| 2551 |
|
| 2552 gtk_action_set_sensitive(win->menu->add, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER, add_buddy))); |
|
| 2553 gtk_action_set_sensitive(win->menu->remove, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER, remove_buddy))); |
|
| 2554 gtk_action_set_sensitive(win->menu->send_file, can_send_file); |
|
| 2555 gtk_action_set_sensitive(win->menu->alias, |
|
| 2556 (account != NULL) && |
|
| 2557 (purple_blist_find_buddy(account, purple_conversation_get_name(conv)) != NULL)); |
|
| 2558 } |
|
| 2559 else if (PURPLE_IS_CHAT_CONVERSATION(conv)) |
|
| 2560 { |
|
| 2561 gtk_action_set_sensitive(win->menu->add, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT, join))); |
|
| 2562 gtk_action_set_sensitive(win->menu->remove, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT, join))); |
|
| 2563 gtk_action_set_sensitive(win->menu->alias, |
|
| 2564 (account != NULL) && |
|
| 2565 (purple_blist_find_chat(account, purple_conversation_get_name(conv)) != NULL)); |
|
| 2566 } |
|
| 2567 |
|
| 2568 } else { |
|
| 2569 /* Account is offline */ |
|
| 2570 /* Or it's a chat that we've left. */ |
|
| 2571 |
|
| 2572 /* Then deal with menu items */ |
|
| 2573 gtk_action_set_sensitive(win->menu->view_log, TRUE); |
|
| 2574 gtk_action_set_sensitive(win->menu->send_file, FALSE); |
|
| 2575 gtk_action_set_sensitive(win->menu->get_info, FALSE); |
|
| 2576 gtk_action_set_sensitive(win->menu->invite, FALSE); |
|
| 2577 gtk_action_set_sensitive(win->menu->alias, FALSE); |
|
| 2578 gtk_action_set_sensitive(win->menu->add, FALSE); |
|
| 2579 gtk_action_set_sensitive(win->menu->remove, FALSE); |
|
| 2580 gtk_action_set_sensitive(win->menu->insert_link, TRUE); |
|
| 2581 gtk_action_set_sensitive(win->menu->insert_image, FALSE); |
|
| 2582 } |
|
| 2583 #endif |
|
| 2584 } |
|
| 2585 |
|
| 2586 static void |
2324 static void |
| 2587 pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields) |
2325 pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields) |
| 2588 { |
2326 { |
| 2589 PidginConversation *gtkconv; |
2327 PidginConversation *gtkconv; |
| 2590 PidginConversationWindow *convwin; |
2328 PidginConversationWindow *convwin; |
| 2751 } |
2469 } |
| 2752 |
2470 |
| 2753 pidgin_conv_update_fields(conv, flags); |
2471 pidgin_conv_update_fields(conv, flags); |
| 2754 } |
2472 } |
| 2755 |
2473 |
| 2756 static void |
|
| 2757 wrote_msg_update_unseen_cb(PurpleConversation *conv, PurpleMessage *msg, |
|
| 2758 gpointer _unused) |
|
| 2759 { |
|
| 2760 PurpleMessageFlags flags; |
|
| 2761 if (conv == NULL) |
|
| 2762 return; |
|
| 2763 flags = purple_message_get_flags(msg); |
|
| 2764 if (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)) { |
|
| 2765 PidginUnseenState unseen = PIDGIN_UNSEEN_NONE; |
|
| 2766 |
|
| 2767 if ((flags & PURPLE_MESSAGE_NICK) == PURPLE_MESSAGE_NICK) |
|
| 2768 unseen = PIDGIN_UNSEEN_NICK; |
|
| 2769 else if (((flags & PURPLE_MESSAGE_SYSTEM) == PURPLE_MESSAGE_SYSTEM) || |
|
| 2770 ((flags & PURPLE_MESSAGE_ERROR) == PURPLE_MESSAGE_ERROR)) |
|
| 2771 unseen = PIDGIN_UNSEEN_EVENT; |
|
| 2772 else if ((flags & PURPLE_MESSAGE_NO_LOG) == PURPLE_MESSAGE_NO_LOG) |
|
| 2773 unseen = PIDGIN_UNSEEN_NO_LOG; |
|
| 2774 else |
|
| 2775 unseen = PIDGIN_UNSEEN_TEXT; |
|
| 2776 |
|
| 2777 conv_set_unseen(conv, unseen); |
|
| 2778 } |
|
| 2779 } |
|
| 2780 |
|
| 2781 static PurpleConversationUiOps conversation_ui_ops = |
2474 static PurpleConversationUiOps conversation_ui_ops = |
| 2782 { |
2475 { |
| 2783 pidgin_conv_new, |
2476 .create_conversation = pidgin_conv_new, |
| 2784 pidgin_conv_destroy, /* destroy_conversation */ |
2477 .destroy_conversation = pidgin_conv_destroy, |
| 2785 NULL, /* write_chat */ |
2478 .write_conv = pidgin_conv_write_conv, |
| 2786 NULL, /* write_im */ |
2479 .chat_add_users = pidgin_conv_chat_add_users, |
| 2787 pidgin_conv_write_conv, /* write_conv */ |
2480 .chat_rename_user = pidgin_conv_chat_rename_user, |
| 2788 pidgin_conv_chat_add_users, /* chat_add_users */ |
2481 .chat_remove_users = pidgin_conv_chat_remove_users, |
| 2789 pidgin_conv_chat_rename_user, /* chat_rename_user */ |
2482 .chat_update_user = pidgin_conv_chat_update_user, |
| 2790 pidgin_conv_chat_remove_users, /* chat_remove_users */ |
2483 .has_focus = pidgin_conv_has_focus, |
| 2791 pidgin_conv_chat_update_user, /* chat_update_user */ |
|
| 2792 pidgin_conv_present_conversation, /* present */ |
|
| 2793 pidgin_conv_has_focus, /* has_focus */ |
|
| 2794 NULL, /* send_confirm */ |
|
| 2795 NULL, |
|
| 2796 NULL, |
|
| 2797 NULL, |
|
| 2798 NULL |
|
| 2799 }; |
2484 }; |
| 2800 |
2485 |
| 2801 PurpleConversationUiOps * |
2486 PurpleConversationUiOps * |
| 2802 pidgin_conversations_get_conv_ui_ops(void) |
2487 pidgin_conversations_get_conv_ui_ops(void) |
| 2803 { |
2488 { |
| 3271 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/conversations/font_face", ""); |
2926 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/conversations/font_face", ""); |
| 3272 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/font_size", 3); |
2927 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/font_size", 3); |
| 3273 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/scrollback_lines", 4000); |
2928 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/scrollback_lines", 4000); |
| 3274 |
2929 |
| 3275 /* Conversations -> Chat */ |
2930 /* Conversations -> Chat */ |
| 3276 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/conversations/chat"); |
2931 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat"); |
| 3277 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/chat/entry_height", 54); |
|
| 3278 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/chat/userlist_width", 80); |
|
| 3279 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/chat/x", 0); |
|
| 3280 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/chat/y", 0); |
|
| 3281 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/chat/width", 340); |
|
| 3282 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/chat/height", 390); |
|
| 3283 |
2932 |
| 3284 /* Conversations -> IM */ |
2933 /* Conversations -> IM */ |
| 3285 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/conversations/im"); |
2934 purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/im"); |
| 3286 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/im/x", 0); |
|
| 3287 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/im/y", 0); |
|
| 3288 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/im/width", 340); |
|
| 3289 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/im/height", 390); |
|
| 3290 |
|
| 3291 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/im/entry_height", 54); |
|
| 3292 |
2935 |
| 3293 /* Connect callbacks. */ |
2936 /* Connect callbacks. */ |
| 3294 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar", |
2937 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar", |
| 3295 show_formatting_toolbar_pref_cb, NULL); |
2938 show_formatting_toolbar_pref_cb, NULL); |
| 3296 |
2939 |
| 3352 handle, G_CALLBACK(writing_msg), NULL); |
2995 handle, G_CALLBACK(writing_msg), NULL); |
| 3353 purple_signal_connect(purple_conversations_get_handle(), "writing-chat-msg", |
2996 purple_signal_connect(purple_conversations_get_handle(), "writing-chat-msg", |
| 3354 handle, G_CALLBACK(writing_msg), NULL); |
2997 handle, G_CALLBACK(writing_msg), NULL); |
| 3355 purple_signal_connect(purple_conversations_get_handle(), "received-im-msg", |
2998 purple_signal_connect(purple_conversations_get_handle(), "received-im-msg", |
| 3356 handle, G_CALLBACK(received_im_msg_cb), NULL); |
2999 handle, G_CALLBACK(received_im_msg_cb), NULL); |
| 3357 purple_signal_connect(purple_conversations_get_handle(), "cleared-message-history", |
|
| 3358 handle, G_CALLBACK(clear_conversation_scrollback_cb), NULL); |
|
| 3359 |
3000 |
| 3360 purple_conversations_set_ui_ops(&conversation_ui_ops); |
3001 purple_conversations_set_ui_ops(&conversation_ui_ops); |
| 3361 |
3002 |
| 3362 /* Callbacks to update a conversation */ |
3003 /* Callbacks to update a conversation */ |
| 3363 purple_signal_connect(blist_handle, "buddy-signed-on", |
3004 purple_signal_connect(blist_handle, "buddy-signed-on", |
| 3385 purple_signal_connect(purple_conversations_get_handle(), "chat-topic-changed", handle, |
3026 purple_signal_connect(purple_conversations_get_handle(), "chat-topic-changed", handle, |
| 3386 G_CALLBACK(update_chat_topic), NULL); |
3027 G_CALLBACK(update_chat_topic), NULL); |
| 3387 purple_signal_connect_priority(purple_conversations_get_handle(), "conversation-updated", handle, |
3028 purple_signal_connect_priority(purple_conversations_get_handle(), "conversation-updated", handle, |
| 3388 G_CALLBACK(pidgin_conv_updated), NULL, |
3029 G_CALLBACK(pidgin_conv_updated), NULL, |
| 3389 PURPLE_SIGNAL_PRIORITY_LOWEST); |
3030 PURPLE_SIGNAL_PRIORITY_LOWEST); |
| 3390 purple_signal_connect(purple_conversations_get_handle(), "wrote-im-msg", handle, |
|
| 3391 G_CALLBACK(wrote_msg_update_unseen_cb), NULL); |
|
| 3392 purple_signal_connect(purple_conversations_get_handle(), "wrote-chat-msg", handle, |
|
| 3393 G_CALLBACK(wrote_msg_update_unseen_cb), NULL); |
|
| 3394 } |
3031 } |
| 3395 |
3032 |
| 3396 void |
3033 void |
| 3397 pidgin_conversations_uninit(void) |
3034 pidgin_conversations_uninit(void) |
| 3398 { |
3035 { |
| 3399 purple_prefs_disconnect_by_handle(pidgin_conversations_get_handle()); |
3036 purple_prefs_disconnect_by_handle(pidgin_conversations_get_handle()); |
| 3400 purple_signals_disconnect_by_handle(pidgin_conversations_get_handle()); |
3037 purple_signals_disconnect_by_handle(pidgin_conversations_get_handle()); |
| 3401 purple_signals_unregister_by_instance(pidgin_conversations_get_handle()); |
3038 purple_signals_unregister_by_instance(pidgin_conversations_get_handle()); |
| 3402 } |
3039 } |
| 3403 |
3040 |
| 3404 |
|
| 3405 |
|
| 3406 |
|
| 3407 |
|
| 3408 |
|
| 3409 |
|
| 3410 |
|
| 3411 |
|
| 3412 |
|
| 3413 |
|
| 3414 |
|
| 3415 |
|
| 3416 |
|
| 3417 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, |
|
| 3418 * and touch each others' private members all day long */ |
|
| 3419 |
|
| 3420 /* pidgin |
|
| 3421 * |
|
| 3422 * Pidgin is the legal property of its developers, whose names are too numerous |
|
| 3423 * to list here. Please refer to the COPYRIGHT file distributed with this |
|
| 3424 * source distribution. |
|
| 3425 * |
|
| 3426 * This program is free software; you can redistribute it and/or modify |
|
| 3427 * it under the terms of the GNU General Public License as published by |
|
| 3428 * the Free Software Foundation; either version 2 of the License, or |
|
| 3429 * (at your option) any later version. |
|
| 3430 * |
|
| 3431 * This program is distributed in the hope that it will be useful, |
|
| 3432 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 3433 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 3434 * GNU General Public License for more details. |
|
| 3435 * |
|
| 3436 * You should have received a copy of the GNU General Public License |
|
| 3437 * along with this program; if not, write to the Free Software |
|
| 3438 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
| 3439 * |
|
| 3440 */ |
|
| 3441 |
|
| 3442 #include <gdk/gdkkeysyms.h> |
|
| 3443 |
|
| 3444 #include <purple.h> |
|
| 3445 |
|
| 3446 #include "gtkblist.h" |
|
| 3447 #include "gtkconv.h" |
|
| 3448 #include "gtkdialogs.h" |
|
| 3449 #include "gtkprivacy.h" |
|
| 3450 #include "gtkutils.h" |
|
| 3451 |
|
| 3452 /************************************************************************** |
|
| 3453 * Callbacks |
|
| 3454 **************************************************************************/ |
|
| 3455 |
|
| 3456 static void |
|
| 3457 conv_set_unseen(PurpleConversation *conv, PidginUnseenState state) |
|
| 3458 { |
|
| 3459 int unseen_count = 0; |
|
| 3460 PidginUnseenState unseen_state = PIDGIN_UNSEEN_NONE; |
|
| 3461 |
|
| 3462 if(g_object_get_data(G_OBJECT(conv), "unseen-count")) |
|
| 3463 unseen_count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "unseen-count")); |
|
| 3464 |
|
| 3465 if(g_object_get_data(G_OBJECT(conv), "unseen-state")) |
|
| 3466 unseen_state = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "unseen-state")); |
|
| 3467 |
|
| 3468 if (state == PIDGIN_UNSEEN_NONE) |
|
| 3469 { |
|
| 3470 unseen_count = 0; |
|
| 3471 unseen_state = PIDGIN_UNSEEN_NONE; |
|
| 3472 } |
|
| 3473 else |
|
| 3474 { |
|
| 3475 if (state >= PIDGIN_UNSEEN_TEXT) |
|
| 3476 unseen_count++; |
|
| 3477 |
|
| 3478 if (state > unseen_state) |
|
| 3479 unseen_state = state; |
|
| 3480 } |
|
| 3481 |
|
| 3482 g_object_set_data(G_OBJECT(conv), "unseen-count", GINT_TO_POINTER(unseen_count)); |
|
| 3483 g_object_set_data(G_OBJECT(conv), "unseen-state", GINT_TO_POINTER(unseen_state)); |
|
| 3484 |
|
| 3485 purple_conversation_update(conv, PURPLE_CONVERSATION_UPDATE_UNSEEN); |
|
| 3486 } |
|
| 3487 |
|
| 3488 static void |
|
| 3489 gtkconv_set_unseen(PidginConversation *gtkconv, PidginUnseenState state) |
|
| 3490 { |
|
| 3491 if (state == PIDGIN_UNSEEN_NONE) |
|
| 3492 { |
|
| 3493 gtkconv->unseen_count = 0; |
|
| 3494 gtkconv->unseen_state = PIDGIN_UNSEEN_NONE; |
|
| 3495 } |
|
| 3496 else |
|
| 3497 { |
|
| 3498 if (state >= PIDGIN_UNSEEN_TEXT) |
|
| 3499 gtkconv->unseen_count++; |
|
| 3500 |
|
| 3501 if (state > gtkconv->unseen_state) |
|
| 3502 gtkconv->unseen_state = state; |
|
| 3503 } |
|
| 3504 |
|
| 3505 g_object_set_data(G_OBJECT(gtkconv->active_conv), "unseen-count", GINT_TO_POINTER(gtkconv->unseen_count)); |
|
| 3506 g_object_set_data(G_OBJECT(gtkconv->active_conv), "unseen-state", GINT_TO_POINTER(gtkconv->unseen_state)); |
|
| 3507 |
|
| 3508 purple_conversation_update(gtkconv->active_conv, PURPLE_CONVERSATION_UPDATE_UNSEEN); |
|
| 3509 } |
|
| 3510 |
|
| 3511 /************************************************************************** |
3041 /************************************************************************** |
| 3512 * GTK window ops |
3042 * GTK window ops |
| 3513 **************************************************************************/ |
3043 **************************************************************************/ |
| 3514 static void |
3044 static void |
| 3515 pidgin_conv_placement_place(PidginConversation *conv) { |
3045 pidgin_conv_placement_place(PidginConversation *conv) { |