Mercurial > pidgin
changeset 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 | 3489182dc187 |
children | b33c2b085e78 |
files | pidgin/gtkconv.c pidgin/gtkconv.h |
diffstat | 2 files changed, 34 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/gtkconv.c Sat Aug 25 04:57:55 2007 +0000 +++ b/pidgin/gtkconv.c Sat Aug 25 05:09:56 2007 +0000 @@ -2690,6 +2690,7 @@ pidgin_conv_present_conversation(PurpleConversation *conv) { PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); + GdkModifierType state; if(gtkconv->win==hidden_convwin) { pidgin_conv_window_remove_gtkconv(hidden_convwin, gtkconv); @@ -2697,7 +2698,10 @@ } pidgin_conv_switch_active_conversation(conv); - pidgin_conv_window_switch_gtkconv(gtkconv->win, gtkconv); + /* Switch the tab only if the user initiated the event by pressing + * a button or hitting a key. */ + if (gtk_get_current_event_state(&state)) + pidgin_conv_window_switch_gtkconv(gtkconv->win, gtkconv); gtk_window_present(GTK_WINDOW(gtkconv->win->window)); } @@ -2723,7 +2727,7 @@ PurpleConversation *conv = (PurpleConversation*)l->data; PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); - if(gtkconv->active_conv != conv) + if(gtkconv == NULL || gtkconv->active_conv != conv) continue; if (gtkconv->unseen_state >= min_state @@ -7137,6 +7141,32 @@ pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC); } +gboolean pidgin_conv_attach_to_conversation(PurpleConversation *conv) +{ + GList *list; + + if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) + return FALSE; + + purple_conversation_set_ui_ops(conv, pidgin_conversations_get_conv_ui_ops()); + private_gtkconv_new(conv, FALSE); + + list = purple_conversation_get_message_history(conv); + list = g_list_last(list); + while (list) { + PurpleConvMessage *msg = list->data; + pidgin_conv_write_conv(conv, msg->who, msg->who, msg->what, msg->flags, msg->when); + list = list->prev; + } + + /* XXX: If this is a chat: + * - populate the userlist + * - set the topic + */ + + return TRUE; +} + void * pidgin_conversations_get_handle(void) {
--- a/pidgin/gtkconv.h Sat Aug 25 04:57:55 2007 +0000 +++ b/pidgin/gtkconv.h Sat Aug 25 05:09:56 2007 +0000 @@ -238,6 +238,8 @@ */ void pidgin_conv_present_conversation(PurpleConversation *conv); +gboolean pidgin_conv_attach_to_conversation(PurpleConversation *conv); + PidginWindow *pidgin_conv_get_window(PidginConversation *gtkconv); GdkPixbuf *pidgin_conv_get_tab_icon(PurpleConversation *conv, gboolean small_icon); void pidgin_conv_new(PurpleConversation *conv);