Mercurial > pidgin
changeset 14550:c4e0ce19c5e1
[gaim-migrate @ 17273]
Patch #1558308 "gntgaim - Add buddy typing notification" from Richard Nelson (wabz)
"This patch adds/removes to/from the conversation window
title when a buddy starts/stops typing."
Pretty cool!
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Thu, 14 Sep 2006 01:37:32 +0000 |
parents | e63769f7aaed |
children | 3a35a71210fd |
files | console/gntconv.c |
diffstat | 1 files changed, 48 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/console/gntconv.c Thu Sep 14 00:56:36 2006 +0000 +++ b/console/gntconv.c Thu Sep 14 01:37:32 2006 +0000 @@ -194,6 +194,46 @@ return ret; } +static char * +get_conversation_title(GaimConversation *conv, GaimAccount *account) +{ + return g_strdup_printf(_("%s (%s -- %s)"), gaim_conversation_get_title(conv), + gaim_account_get_username(account), gaim_account_get_protocol_name(account)); +} + +static void +update_buddy_typing(GaimAccount *account, const char *who, gpointer null) +{ + GaimConversation *conv; + GGConv *ggc; + GaimConvIm *im = NULL; + char *title, *old_title; + + conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, who, account); + im = GAIM_CONV_IM(conv); + + if (!conv) + return; + + if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { + old_title = get_conversation_title(conv, account); + title = g_strdup_printf(_("%s [%s]"), old_title, + gnt_ascii_only() ? "T" : "\342\243\277"); + g_free(old_title); + } else + title = get_conversation_title(conv, account); + ggc = conv->ui_data; + gnt_screen_rename_widget(ggc->window, title); + g_free(title); +} + +static gpointer +gg_conv_get_handle() +{ + static int handle; + return &handle; +} + static void gg_create_conversation(GaimConversation *conv) { @@ -223,9 +263,8 @@ account = gaim_conversation_get_account(conv); type = gaim_conversation_get_type(conv); - title = g_strdup_printf(_("%s (%s -- %s)"), gaim_conversation_get_title(conv), - gaim_account_get_username(account), gaim_account_get_protocol_name(account)); - + title = get_conversation_title(conv, account); + ggc->window = gnt_box_new(FALSE, TRUE); gnt_box_set_title(GNT_BOX(ggc->window), title); gnt_box_set_toplevel(GNT_BOX(ggc->window), TRUE); @@ -255,6 +294,11 @@ g_signal_connect(G_OBJECT(ggc->tv), "size_changed", G_CALLBACK(size_changed_cb), NULL); g_signal_connect(G_OBJECT(ggc->window), "position_set", G_CALLBACK(save_position_cb), NULL); + gaim_signal_connect(gaim_conversations_get_handle(), "buddy-typing", gg_conv_get_handle(), + GAIM_CALLBACK(update_buddy_typing), NULL); + gaim_signal_connect(gaim_conversations_get_handle(), "buddy-typing-stopped", gg_conv_get_handle(), + GAIM_CALLBACK(update_buddy_typing), NULL); + g_free(title); } @@ -648,8 +692,7 @@ ggconv->active_conv = conv; account = gaim_conversation_get_account(conv); - title = g_strdup_printf(_("%s (%s -- %s)"), gaim_conversation_get_title(conv), - gaim_account_get_username(account), gaim_account_get_protocol_name(account)); + title = get_conversation_title(conv, account); gnt_screen_rename_widget(ggconv->window, title); g_free(title); }