| 324 static PurpleCmdRet |
324 static PurpleCmdRet |
| 325 clear_command_cb(PurpleConversation *conv, |
325 clear_command_cb(PurpleConversation *conv, |
| 326 const char *cmd, char **args, char **error, void *data) |
326 const char *cmd, char **args, char **error, void *data) |
| 327 { |
327 { |
| 328 clear_conversation_scrollback(conv); |
328 clear_conversation_scrollback(conv); |
| |
329 purple_conversation_clear_message_history(conv); |
| 329 return PURPLE_CMD_STATUS_OK; |
330 return PURPLE_CMD_STATUS_OK; |
| 330 } |
331 } |
| 331 |
332 |
| 332 static PurpleCmdRet |
333 static PurpleCmdRet |
| 333 clearall_command_cb(PurpleConversation *conv, |
334 clearall_command_cb(PurpleConversation *conv, |
| 1297 |
1298 |
| 1298 add_remove_cb(NULL, PIDGIN_CONVERSATION(conv)); |
1299 add_remove_cb(NULL, PIDGIN_CONVERSATION(conv)); |
| 1299 } |
1300 } |
| 1300 |
1301 |
| 1301 static void |
1302 static void |
| |
1303 menu_hide_conv_cb(gpointer data, guint action, GtkWidget *widget) |
| |
1304 { |
| |
1305 PidginWindow *win = data; |
| |
1306 PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win); |
| |
1307 purple_conversation_set_ui_ops(conv, NULL); |
| |
1308 } |
| |
1309 |
| |
1310 static void |
| 1302 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
1311 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
| 1303 { |
1312 { |
| 1304 PidginWindow *win = data; |
1313 PidginWindow *win = data; |
| 1305 |
1314 |
| 1306 close_conv_cb(NULL, NULL, PIDGIN_CONVERSATION(pidgin_conv_window_get_active_conversation(win))); |
1315 close_conv_cb(NULL, NULL, PIDGIN_CONVERSATION(pidgin_conv_window_get_active_conversation(win))); |
| 2695 **************************************************************************/ |
2704 **************************************************************************/ |
| 2696 void |
2705 void |
| 2697 pidgin_conv_present_conversation(PurpleConversation *conv) |
2706 pidgin_conv_present_conversation(PurpleConversation *conv) |
| 2698 { |
2707 { |
| 2699 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); |
2708 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); |
| |
2709 GdkModifierType state; |
| 2700 |
2710 |
| 2701 if(gtkconv->win==hidden_convwin) { |
2711 if(gtkconv->win==hidden_convwin) { |
| 2702 pidgin_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
2712 pidgin_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
| 2703 pidgin_conv_placement_place(gtkconv); |
2713 pidgin_conv_placement_place(gtkconv); |
| 2704 } |
2714 } |
| 2705 |
2715 |
| 2706 pidgin_conv_switch_active_conversation(conv); |
2716 pidgin_conv_switch_active_conversation(conv); |
| 2707 pidgin_conv_window_switch_gtkconv(gtkconv->win, gtkconv); |
2717 /* Switch the tab only if the user initiated the event by pressing |
| |
2718 * a button or hitting a key. */ |
| |
2719 if (gtk_get_current_event_state(&state)) |
| |
2720 pidgin_conv_window_switch_gtkconv(gtkconv->win, gtkconv); |
| 2708 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); |
2721 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); |
| 2709 } |
2722 } |
| 2710 |
2723 |
| 2711 GList * |
2724 GList * |
| 2712 pidgin_conversations_find_unseen_list(PurpleConversationType type, |
2725 pidgin_conversations_find_unseen_list(PurpleConversationType type, |
| 2728 |
2741 |
| 2729 for (; l != NULL && (max_count == 0 || c < max_count); l = l->next) { |
2742 for (; l != NULL && (max_count == 0 || c < max_count); l = l->next) { |
| 2730 PurpleConversation *conv = (PurpleConversation*)l->data; |
2743 PurpleConversation *conv = (PurpleConversation*)l->data; |
| 2731 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); |
2744 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); |
| 2732 |
2745 |
| 2733 if(gtkconv->active_conv != conv) |
2746 if(gtkconv == NULL || gtkconv->active_conv != conv) |
| 2734 continue; |
2747 continue; |
| 2735 |
2748 |
| 2736 if (gtkconv->unseen_state >= min_state |
2749 if (gtkconv->unseen_state >= min_state |
| 2737 && (!hidden_only || |
2750 && (!hidden_only || |
| 2738 (hidden_only && gtkconv->win == hidden_convwin))) { |
2751 (hidden_only && gtkconv->win == hidden_convwin))) { |
| 2842 "<StockItem>", PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE }, |
2855 "<StockItem>", PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE }, |
| 2843 |
2856 |
| 2844 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>", NULL }, |
2857 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>", NULL }, |
| 2845 |
2858 |
| 2846 |
2859 |
| |
2860 { N_("/Conversation/_Hide"), NULL, menu_hide_conv_cb, 0, |
| |
2861 "<StockItem>", NULL}, |
| 2847 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, |
2862 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, |
| 2848 "<StockItem>", GTK_STOCK_CLOSE }, |
2863 "<StockItem>", GTK_STOCK_CLOSE }, |
| 2849 |
2864 |
| 2850 /* Options */ |
2865 /* Options */ |
| 2851 { N_("/_Options"), NULL, NULL, 0, "<Branch>", NULL }, |
2866 { N_("/_Options"), NULL, NULL, 0, "<Branch>", NULL }, |
| 5008 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
5023 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
| 5009 |
5024 |
| 5010 gtkconv->send_history = g_list_first(gtkconv->send_history); |
5025 gtkconv->send_history = g_list_first(gtkconv->send_history); |
| 5011 g_list_foreach(gtkconv->send_history, (GFunc)g_free, NULL); |
5026 g_list_foreach(gtkconv->send_history, (GFunc)g_free, NULL); |
| 5012 g_list_free(gtkconv->send_history); |
5027 g_list_free(gtkconv->send_history); |
| |
5028 |
| |
5029 if (gtkconv->attach.timer) { |
| |
5030 g_source_remove(gtkconv->attach.timer); |
| |
5031 } |
| 5013 |
5032 |
| 5014 if (tooltip.gtkconv == gtkconv) |
5033 if (tooltip.gtkconv == gtkconv) |
| 5015 reset_tooltip(); |
5034 reset_tooltip(); |
| 5016 |
5035 |
| 5017 g_free(gtkconv); |
5036 g_free(gtkconv); |
| 5225 |
5244 |
| 5226 g_return_if_fail(conv != NULL); |
5245 g_return_if_fail(conv != NULL); |
| 5227 gtkconv = PIDGIN_CONVERSATION(conv); |
5246 gtkconv = PIDGIN_CONVERSATION(conv); |
| 5228 g_return_if_fail(gtkconv != NULL); |
5247 g_return_if_fail(gtkconv != NULL); |
| 5229 |
5248 |
| |
5249 if (gtkconv->attach.timer) { |
| |
5250 /* We are currently in the process of filling up the buffer with the message |
| |
5251 * history of the conversation. So we do not need to add the message here. |
| |
5252 * Instead, this message will be added to the message-list, which in turn will |
| |
5253 * be processed and displayed by the attach-callback. |
| |
5254 */ |
| |
5255 return; |
| |
5256 } |
| |
5257 |
| 5230 if (conv != gtkconv->active_conv) |
5258 if (conv != gtkconv->active_conv) |
| 5231 { |
5259 { |
| 5232 if (flags & PURPLE_MESSAGE_ACTIVE_ONLY) |
5260 if (flags & PURPLE_MESSAGE_ACTIVE_ONLY) |
| 5233 { |
5261 { |
| 5234 /* Unless this had PURPLE_MESSAGE_NO_LOG, this message |
5262 /* Unless this had PURPLE_MESSAGE_NO_LOG, this message |
| 7157 |
7185 |
| 7158 static void |
7186 static void |
| 7159 update_chat_topic(PurpleConversation *conv, const char *old, const char *new) |
7187 update_chat_topic(PurpleConversation *conv, const char *old, const char *new) |
| 7160 { |
7188 { |
| 7161 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC); |
7189 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC); |
| |
7190 } |
| |
7191 |
| |
7192 static gboolean |
| |
7193 add_message_history_to_gtkconv(gpointer data) |
| |
7194 { |
| |
7195 PidginConversation *gtkconv = data; |
| |
7196 int count = 0; |
| |
7197 int timer = gtkconv->attach.timer; |
| |
7198 gtkconv->attach.timer = 0; |
| |
7199 while (gtkconv->attach.current && count < 100) { /* XXX: 100 is a random value here */ |
| |
7200 PurpleConvMessage *msg = gtkconv->attach.current->data; |
| |
7201 pidgin_conv_write_conv(gtkconv->active_conv, msg->who, msg->who, msg->what, msg->flags, msg->when); |
| |
7202 gtkconv->attach.current = gtkconv->attach.current->prev; |
| |
7203 count++; |
| |
7204 } |
| |
7205 gtkconv->attach.timer = timer; |
| |
7206 if (gtkconv->attach.current) |
| |
7207 return TRUE; |
| |
7208 |
| |
7209 g_source_remove(gtkconv->attach.timer); |
| |
7210 gtkconv->attach.timer = 0; |
| |
7211 return FALSE; |
| |
7212 } |
| |
7213 |
| |
7214 gboolean pidgin_conv_attach_to_conversation(PurpleConversation *conv) |
| |
7215 { |
| |
7216 GList *list; |
| |
7217 PidginConversation *gtkconv; |
| |
7218 |
| |
7219 if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) |
| |
7220 return FALSE; |
| |
7221 |
| |
7222 purple_conversation_set_ui_ops(conv, pidgin_conversations_get_conv_ui_ops()); |
| |
7223 private_gtkconv_new(conv, FALSE); |
| |
7224 gtkconv = PIDGIN_CONVERSATION(conv); |
| |
7225 |
| |
7226 list = purple_conversation_get_message_history(conv); |
| |
7227 if (list) { |
| |
7228 list = g_list_last(list); |
| |
7229 gtkconv->attach.current = list; |
| |
7230 gtkconv->attach.timer = g_idle_add(add_message_history_to_gtkconv, gtkconv); |
| |
7231 } |
| |
7232 |
| |
7233 /* XXX: If this is a chat: |
| |
7234 * - populate the userlist |
| |
7235 * - set the topic |
| |
7236 */ |
| |
7237 |
| |
7238 return TRUE; |
| 7162 } |
7239 } |
| 7163 |
7240 |
| 7164 void * |
7241 void * |
| 7165 pidgin_conversations_get_handle(void) |
7242 pidgin_conversations_get_handle(void) |
| 7166 { |
7243 { |