Mercurial > pidgin.yaz
comparison pidgin/gtkconv.c @ 21300:abbf74f4732b
propagate from branch 'im.pidgin.pidgin' (head e3fd21e6dabb99e5604e8337380353fcbe1a7279)
to branch 'im.pidgin.elb.make' (head 7422b9a549f752c05cc75f0c8e56fdd2bced034a)
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Sat, 10 Nov 2007 16:17:54 +0000 |
parents | 6de09629f091 |
children | 5cca0d7d9081 |
comparison
equal
deleted
inserted
replaced
21132:f2dcad9572b2 | 21300:abbf74f4732b |
---|---|
1028 for (c = buf ; *c ; c++) | 1028 for (c = buf ; *c ; c++) |
1029 { | 1029 { |
1030 if (*c == '/' || *c == '\\') | 1030 if (*c == '/' || *c == '\\') |
1031 *c = ' '; | 1031 *c = ' '; |
1032 } | 1032 } |
1033 purple_request_file(PIDGIN_CONVERSATION(conv), _("Save Conversation"), | 1033 purple_request_file_with_hint(PIDGIN_CONVERSATION(conv), _("Save Conversation"), |
1034 buf, | 1034 buf, |
1035 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, | 1035 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, |
1036 NULL, NULL, conv, | 1036 NULL, NULL, conv, |
1037 conv); | 1037 PURPLE_REQUEST_UI_HINT_BLIST, conv); |
1038 | 1038 |
1039 g_free(buf); | 1039 g_free(buf); |
1040 } | 1040 } |
1041 | 1041 |
1042 static void | 1042 static void |
1080 for (cur = buddies; cur != NULL; cur = cur->next) | 1080 for (cur = buddies; cur != NULL; cur = cur->next) |
1081 { | 1081 { |
1082 PurpleBlistNode *node = cur->data; | 1082 PurpleBlistNode *node = cur->data; |
1083 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) | 1083 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
1084 { | 1084 { |
1085 pidgin_log_show_contact((PurpleContact *)node->parent); | 1085 pidgin_log_show_contact_with_parent(GTK_WINDOW(win->window), (PurpleContact *)node->parent); |
1086 g_slist_free(buddies); | 1086 g_slist_free(buddies); |
1087 gdk_window_set_cursor(gtkblist->window->window, NULL); | 1087 gdk_window_set_cursor(gtkblist->window->window, NULL); |
1088 gdk_window_set_cursor(win->window->window, NULL); | 1088 gdk_window_set_cursor(win->window->window, NULL); |
1089 return; | 1089 return; |
1090 } | 1090 } |
1091 } | 1091 } |
1092 g_slist_free(buddies); | 1092 g_slist_free(buddies); |
1093 | 1093 |
1094 pidgin_log_show(type, name, account); | 1094 pidgin_log_show_with_parent(GTK_WINDOW(win->window), type, name, account); |
1095 | 1095 |
1096 gdk_window_set_cursor(gtkblist->window->window, NULL); | 1096 gdk_window_set_cursor(gtkblist->window->window, NULL); |
1097 gdk_window_set_cursor(win->window->window, NULL); | 1097 gdk_window_set_cursor(win->window->window, NULL); |
1098 } | 1098 } |
1099 | 1099 |
1235 PidginWindow *win = data; | 1235 PidginWindow *win = data; |
1236 PurpleConversation *conv; | 1236 PurpleConversation *conv; |
1237 | 1237 |
1238 conv = pidgin_conv_window_get_active_gtkconv(win)->active_conv; | 1238 conv = pidgin_conv_window_get_active_gtkconv(win)->active_conv; |
1239 | 1239 |
1240 pidgin_pounce_editor_show(purple_conversation_get_account(conv), | 1240 pidgin_pounce_editor_show_with_parent(GTK_WINDOW(win->window), purple_conversation_get_account(conv), |
1241 purple_conversation_get_name(conv), NULL); | 1241 purple_conversation_get_name(conv), NULL); |
1242 } | 1242 } |
1243 | 1243 |
1244 static void | 1244 static void |
1245 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) | 1245 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
2717 | 2717 |
2718 ext = purple_buddy_icon_get_extension(purple_conv_im_get_icon(PURPLE_CONV_IM(conv))); | 2718 ext = purple_buddy_icon_get_extension(purple_conv_im_get_icon(PURPLE_CONV_IM(conv))); |
2719 | 2719 |
2720 buf = g_strdup_printf("%s.%s", purple_normalize(conv->account, conv->name), ext); | 2720 buf = g_strdup_printf("%s.%s", purple_normalize(conv->account, conv->name), ext); |
2721 | 2721 |
2722 purple_request_file(gtkconv, _("Save Icon"), buf, TRUE, | 2722 purple_request_file_with_hint(gtkconv, _("Save Icon"), buf, TRUE, |
2723 G_CALLBACK(saveicon_writefile_cb), NULL, | 2723 G_CALLBACK(saveicon_writefile_cb), NULL, |
2724 conv->account, NULL, conv, | 2724 conv->account, NULL, conv, |
2725 gtkconv); | 2725 PURPLE_REQUEST_UI_HINT_BLIST, gtkconv); |
2726 | 2726 |
2727 g_free(buf); | 2727 g_free(buf); |
2728 } | 2728 } |
2729 | 2729 |
2730 static void | 2730 static void |
7421 update_chat_topic(PurpleConversation *conv, const char *old, const char *new) | 7421 update_chat_topic(PurpleConversation *conv, const char *old, const char *new) |
7422 { | 7422 { |
7423 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC); | 7423 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC); |
7424 } | 7424 } |
7425 | 7425 |
7426 /* Message history stuff */ | |
7427 | |
7428 /* Compare two PurpleConvMessage's, according to time in ascending order. */ | |
7429 static int | |
7430 message_compare(gconstpointer p1, gconstpointer p2) | |
7431 { | |
7432 const PurpleConvMessage *m1 = p1, *m2 = p2; | |
7433 return (m1->when > m2->when); | |
7434 } | |
7435 | |
7436 /* Adds some message history to the gtkconv. This happens in a idle-callback. */ | |
7426 static gboolean | 7437 static gboolean |
7427 add_message_history_to_gtkconv(gpointer data) | 7438 add_message_history_to_gtkconv(gpointer data) |
7428 { | 7439 { |
7429 PidginConversation *gtkconv = data; | 7440 PidginConversation *gtkconv = data; |
7430 int count = 0; | 7441 int count = 0; |
7431 int timer = gtkconv->attach.timer; | 7442 int timer = gtkconv->attach.timer; |
7432 time_t when = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(gtkconv->entry), "attach-start-time")); | 7443 time_t when = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(gtkconv->entry), "attach-start-time")); |
7444 gboolean im = (gtkconv->active_conv->type == PURPLE_CONV_TYPE_IM); | |
7433 | 7445 |
7434 gtkconv->attach.timer = 0; | 7446 gtkconv->attach.timer = 0; |
7435 while (gtkconv->attach.current && count < 100) { /* XXX: 100 is a random value here */ | 7447 while (gtkconv->attach.current && count < 100) { /* XXX: 100 is a random value here */ |
7436 PurpleConvMessage *msg = gtkconv->attach.current->data; | 7448 PurpleConvMessage *msg = gtkconv->attach.current->data; |
7437 if (when && when < msg->when) { | 7449 if (!im && when && when < msg->when) { |
7438 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR><HR>", 0); | 7450 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR><HR>", 0); |
7439 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL); | 7451 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL); |
7440 } | 7452 } |
7441 pidgin_conv_write_conv(gtkconv->active_conv, msg->who, msg->who, msg->what, msg->flags, msg->when); | 7453 pidgin_conv_write_conv(msg->conv, msg->who, msg->alias, msg->what, msg->flags, msg->when); |
7442 gtkconv->attach.current = gtkconv->attach.current->prev; | 7454 if (im) { |
7455 gtkconv->attach.current = g_list_delete_link(gtkconv->attach.current, gtkconv->attach.current); | |
7456 } else { | |
7457 gtkconv->attach.current = gtkconv->attach.current->prev; | |
7458 } | |
7443 count++; | 7459 count++; |
7444 } | 7460 } |
7445 gtkconv->attach.timer = timer; | 7461 gtkconv->attach.timer = timer; |
7446 if (gtkconv->attach.current) | 7462 if (gtkconv->attach.current) |
7447 return TRUE; | 7463 return TRUE; |
7448 | 7464 |
7465 g_source_remove(gtkconv->attach.timer); | |
7466 gtkconv->attach.timer = 0; | |
7467 if (im) { | |
7468 /* Print any message that was sent while the old history was being added back. */ | |
7469 GList *msgs = NULL; | |
7470 GList *iter = gtkconv->convs; | |
7471 for (; iter; iter = iter->next) { | |
7472 PurpleConversation *conv = iter->data; | |
7473 GList *history = purple_conversation_get_message_history(conv); | |
7474 for (; history; history = history->next) { | |
7475 PurpleConvMessage *msg = history->data; | |
7476 if (msg->when > when) | |
7477 msgs = g_list_prepend(msgs, msg); | |
7478 } | |
7479 } | |
7480 msgs = g_list_sort(msgs, message_compare); | |
7481 for (; msgs; msgs = g_list_delete_link(msgs, msgs)) { | |
7482 PurpleConvMessage *msg = msgs->data; | |
7483 pidgin_conv_write_conv(msg->conv, msg->who, msg->alias, msg->what, msg->flags, msg->when); | |
7484 } | |
7485 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR><HR>", 0); | |
7486 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL); | |
7487 } | |
7488 | |
7449 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL); | 7489 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL); |
7450 purple_signal_emit(pidgin_conversations_get_handle(), | 7490 purple_signal_emit(pidgin_conversations_get_handle(), |
7451 "conversation-displayed", gtkconv); | 7491 "conversation-displayed", gtkconv); |
7452 g_source_remove(gtkconv->attach.timer); | |
7453 gtkconv->attach.timer = 0; | |
7454 return FALSE; | 7492 return FALSE; |
7455 } | 7493 } |
7456 | 7494 |
7457 gboolean pidgin_conv_attach_to_conversation(PurpleConversation *conv) | 7495 static void |
7458 { | 7496 pidgin_conv_attach(PurpleConversation *conv) |
7459 GList *list; | 7497 { |
7460 PidginConversation *gtkconv; | |
7461 int timer; | 7498 int timer; |
7462 | |
7463 if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) | |
7464 return FALSE; | |
7465 | |
7466 purple_conversation_set_data(conv, "unseen-count", NULL); | 7499 purple_conversation_set_data(conv, "unseen-count", NULL); |
7467 purple_conversation_set_data(conv, "unseen-state", NULL); | 7500 purple_conversation_set_data(conv, "unseen-state", NULL); |
7468 purple_conversation_set_ui_ops(conv, pidgin_conversations_get_conv_ui_ops()); | 7501 purple_conversation_set_ui_ops(conv, pidgin_conversations_get_conv_ui_ops()); |
7469 private_gtkconv_new(conv, FALSE); | 7502 private_gtkconv_new(conv, FALSE); |
7503 timer = GPOINTER_TO_INT(purple_conversation_get_data(conv, "close-timer")); | |
7504 if (timer) | |
7505 purple_timeout_remove(timer); | |
7506 } | |
7507 | |
7508 gboolean pidgin_conv_attach_to_conversation(PurpleConversation *conv) | |
7509 { | |
7510 GList *list; | |
7511 PidginConversation *gtkconv; | |
7512 | |
7513 if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) | |
7514 return FALSE; | |
7515 | |
7516 pidgin_conv_attach(conv); | |
7470 gtkconv = PIDGIN_CONVERSATION(conv); | 7517 gtkconv = PIDGIN_CONVERSATION(conv); |
7471 | 7518 |
7472 list = purple_conversation_get_message_history(conv); | 7519 list = purple_conversation_get_message_history(conv); |
7473 if (list) { | 7520 if (list) { |
7521 switch (purple_conversation_get_type(conv)) { | |
7522 case PURPLE_CONV_TYPE_IM: | |
7523 { | |
7524 GList *convs; | |
7525 list = g_list_copy(list); | |
7526 for (convs = purple_get_ims(); convs; convs = convs->next) | |
7527 if (convs->data != conv && | |
7528 pidgin_conv_find_gtkconv(convs->data) == gtkconv) { | |
7529 pidgin_conv_attach(convs->data); | |
7530 list = g_list_concat(list, g_list_copy(purple_conversation_get_message_history(convs->data))); | |
7531 } | |
7532 list = g_list_sort(list, message_compare); | |
7533 gtkconv->attach.current = list; | |
7534 list = g_list_last(list); | |
7535 break; | |
7536 } | |
7537 case PURPLE_CONV_TYPE_CHAT: | |
7538 gtkconv->attach.current = g_list_last(list); | |
7539 break; | |
7540 default: | |
7541 g_return_val_if_reached(TRUE); | |
7542 } | |
7474 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", | 7543 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", |
7475 GINT_TO_POINTER(((PurpleConvMessage*)(list->data))->when)); | 7544 GINT_TO_POINTER(((PurpleConvMessage*)(list->data))->when)); |
7476 gtkconv->attach.current = g_list_last(list); | |
7477 gtkconv->attach.timer = g_idle_add(add_message_history_to_gtkconv, gtkconv); | 7545 gtkconv->attach.timer = g_idle_add(add_message_history_to_gtkconv, gtkconv); |
7478 } else { | 7546 } else { |
7479 purple_signal_emit(pidgin_conversations_get_handle(), | 7547 purple_signal_emit(pidgin_conversations_get_handle(), |
7480 "conversation-displayed", gtkconv); | 7548 "conversation-displayed", gtkconv); |
7481 } | 7549 } |
7483 if (conv->type == PURPLE_CONV_TYPE_CHAT) { | 7551 if (conv->type == PURPLE_CONV_TYPE_CHAT) { |
7484 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC); | 7552 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC); |
7485 pidgin_conv_chat_add_users(conv, PURPLE_CONV_CHAT(conv)->in_room, TRUE); | 7553 pidgin_conv_chat_add_users(conv, PURPLE_CONV_CHAT(conv)->in_room, TRUE); |
7486 } | 7554 } |
7487 | 7555 |
7488 timer = GPOINTER_TO_INT(purple_conversation_get_data(conv, "close-timer")); | |
7489 if (timer) | |
7490 purple_timeout_remove(timer); | |
7491 return TRUE; | 7556 return TRUE; |
7492 } | 7557 } |
7493 | 7558 |
7494 void * | 7559 void * |
7495 pidgin_conversations_get_handle(void) | 7560 pidgin_conversations_get_handle(void) |
9856 } | 9921 } |
9857 | 9922 |
9858 return colors; | 9923 return colors; |
9859 } | 9924 } |
9860 | 9925 |
9926 |