comparison pidgin/gtkconv.c @ 19417:f3f78f43b822

API to reattach a conversation to gtk UI. Use the new API to access message-history of a conversation.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 25 Aug 2007 05:09:56 +0000
parents cbc08c427db6
children e8bd9d92202e
comparison
equal deleted inserted replaced
19416:3489182dc187 19417:f3f78f43b822
2688 **************************************************************************/ 2688 **************************************************************************/
2689 void 2689 void
2690 pidgin_conv_present_conversation(PurpleConversation *conv) 2690 pidgin_conv_present_conversation(PurpleConversation *conv)
2691 { 2691 {
2692 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); 2692 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv);
2693 GdkModifierType state;
2693 2694
2694 if(gtkconv->win==hidden_convwin) { 2695 if(gtkconv->win==hidden_convwin) {
2695 pidgin_conv_window_remove_gtkconv(hidden_convwin, gtkconv); 2696 pidgin_conv_window_remove_gtkconv(hidden_convwin, gtkconv);
2696 pidgin_conv_placement_place(gtkconv); 2697 pidgin_conv_placement_place(gtkconv);
2697 } 2698 }
2698 2699
2699 pidgin_conv_switch_active_conversation(conv); 2700 pidgin_conv_switch_active_conversation(conv);
2700 pidgin_conv_window_switch_gtkconv(gtkconv->win, gtkconv); 2701 /* Switch the tab only if the user initiated the event by pressing
2702 * a button or hitting a key. */
2703 if (gtk_get_current_event_state(&state))
2704 pidgin_conv_window_switch_gtkconv(gtkconv->win, gtkconv);
2701 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); 2705 gtk_window_present(GTK_WINDOW(gtkconv->win->window));
2702 } 2706 }
2703 2707
2704 GList * 2708 GList *
2705 pidgin_conversations_find_unseen_list(PurpleConversationType type, 2709 pidgin_conversations_find_unseen_list(PurpleConversationType type,
2721 2725
2722 for (; l != NULL && (max_count == 0 || c < max_count); l = l->next) { 2726 for (; l != NULL && (max_count == 0 || c < max_count); l = l->next) {
2723 PurpleConversation *conv = (PurpleConversation*)l->data; 2727 PurpleConversation *conv = (PurpleConversation*)l->data;
2724 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); 2728 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv);
2725 2729
2726 if(gtkconv->active_conv != conv) 2730 if(gtkconv == NULL || gtkconv->active_conv != conv)
2727 continue; 2731 continue;
2728 2732
2729 if (gtkconv->unseen_state >= min_state 2733 if (gtkconv->unseen_state >= min_state
2730 && (!hidden_only || 2734 && (!hidden_only ||
2731 (hidden_only && gtkconv->win == hidden_convwin))) { 2735 (hidden_only && gtkconv->win == hidden_convwin))) {
7133 7137
7134 static void 7138 static void
7135 update_chat_topic(PurpleConversation *conv, const char *old, const char *new) 7139 update_chat_topic(PurpleConversation *conv, const char *old, const char *new)
7136 { 7140 {
7137 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC); 7141 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC);
7142 }
7143
7144 gboolean pidgin_conv_attach_to_conversation(PurpleConversation *conv)
7145 {
7146 GList *list;
7147
7148 if (PIDGIN_IS_PIDGIN_CONVERSATION(conv))
7149 return FALSE;
7150
7151 purple_conversation_set_ui_ops(conv, pidgin_conversations_get_conv_ui_ops());
7152 private_gtkconv_new(conv, FALSE);
7153
7154 list = purple_conversation_get_message_history(conv);
7155 list = g_list_last(list);
7156 while (list) {
7157 PurpleConvMessage *msg = list->data;
7158 pidgin_conv_write_conv(conv, msg->who, msg->who, msg->what, msg->flags, msg->when);
7159 list = list->prev;
7160 }
7161
7162 /* XXX: If this is a chat:
7163 * - populate the userlist
7164 * - set the topic
7165 */
7166
7167 return TRUE;
7138 } 7168 }
7139 7169
7140 void * 7170 void *
7141 pidgin_conversations_get_handle(void) 7171 pidgin_conversations_get_handle(void)
7142 { 7172 {