Mercurial > pidgin
comparison console/gntconv.c @ 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 | 553bbd68387e |
children | 81650a27f253 |
comparison
equal
deleted
inserted
replaced
14549:e63769f7aaed | 14550:c4e0ce19c5e1 |
---|---|
192 break; | 192 break; |
193 } | 193 } |
194 return ret; | 194 return ret; |
195 } | 195 } |
196 | 196 |
197 static char * | |
198 get_conversation_title(GaimConversation *conv, GaimAccount *account) | |
199 { | |
200 return g_strdup_printf(_("%s (%s -- %s)"), gaim_conversation_get_title(conv), | |
201 gaim_account_get_username(account), gaim_account_get_protocol_name(account)); | |
202 } | |
203 | |
204 static void | |
205 update_buddy_typing(GaimAccount *account, const char *who, gpointer null) | |
206 { | |
207 GaimConversation *conv; | |
208 GGConv *ggc; | |
209 GaimConvIm *im = NULL; | |
210 char *title, *old_title; | |
211 | |
212 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, who, account); | |
213 im = GAIM_CONV_IM(conv); | |
214 | |
215 if (!conv) | |
216 return; | |
217 | |
218 if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { | |
219 old_title = get_conversation_title(conv, account); | |
220 title = g_strdup_printf(_("%s [%s]"), old_title, | |
221 gnt_ascii_only() ? "T" : "\342\243\277"); | |
222 g_free(old_title); | |
223 } else | |
224 title = get_conversation_title(conv, account); | |
225 ggc = conv->ui_data; | |
226 gnt_screen_rename_widget(ggc->window, title); | |
227 g_free(title); | |
228 } | |
229 | |
230 static gpointer | |
231 gg_conv_get_handle() | |
232 { | |
233 static int handle; | |
234 return &handle; | |
235 } | |
236 | |
197 static void | 237 static void |
198 gg_create_conversation(GaimConversation *conv) | 238 gg_create_conversation(GaimConversation *conv) |
199 { | 239 { |
200 GGConv *ggc = conv->ui_data; | 240 GGConv *ggc = conv->ui_data; |
201 char *title; | 241 char *title; |
221 return; | 261 return; |
222 } | 262 } |
223 | 263 |
224 account = gaim_conversation_get_account(conv); | 264 account = gaim_conversation_get_account(conv); |
225 type = gaim_conversation_get_type(conv); | 265 type = gaim_conversation_get_type(conv); |
226 title = g_strdup_printf(_("%s (%s -- %s)"), gaim_conversation_get_title(conv), | 266 title = get_conversation_title(conv, account); |
227 gaim_account_get_username(account), gaim_account_get_protocol_name(account)); | 267 |
228 | |
229 ggc->window = gnt_box_new(FALSE, TRUE); | 268 ggc->window = gnt_box_new(FALSE, TRUE); |
230 gnt_box_set_title(GNT_BOX(ggc->window), title); | 269 gnt_box_set_title(GNT_BOX(ggc->window), title); |
231 gnt_box_set_toplevel(GNT_BOX(ggc->window), TRUE); | 270 gnt_box_set_toplevel(GNT_BOX(ggc->window), TRUE); |
232 gnt_box_set_pad(GNT_BOX(ggc->window), 0); | 271 gnt_box_set_pad(GNT_BOX(ggc->window), 0); |
233 gnt_widget_set_name(ggc->window, "conversation-window"); | 272 gnt_widget_set_name(ggc->window, "conversation-window"); |
252 gaim_prefs_get_int(PREF_ROOT "/position/y")); | 291 gaim_prefs_get_int(PREF_ROOT "/position/y")); |
253 gnt_widget_show(ggc->window); | 292 gnt_widget_show(ggc->window); |
254 | 293 |
255 g_signal_connect(G_OBJECT(ggc->tv), "size_changed", G_CALLBACK(size_changed_cb), NULL); | 294 g_signal_connect(G_OBJECT(ggc->tv), "size_changed", G_CALLBACK(size_changed_cb), NULL); |
256 g_signal_connect(G_OBJECT(ggc->window), "position_set", G_CALLBACK(save_position_cb), NULL); | 295 g_signal_connect(G_OBJECT(ggc->window), "position_set", G_CALLBACK(save_position_cb), NULL); |
296 | |
297 gaim_signal_connect(gaim_conversations_get_handle(), "buddy-typing", gg_conv_get_handle(), | |
298 GAIM_CALLBACK(update_buddy_typing), NULL); | |
299 gaim_signal_connect(gaim_conversations_get_handle(), "buddy-typing-stopped", gg_conv_get_handle(), | |
300 GAIM_CALLBACK(update_buddy_typing), NULL); | |
257 | 301 |
258 g_free(title); | 302 g_free(title); |
259 } | 303 } |
260 | 304 |
261 static void | 305 static void |
646 g_return_if_fail(ggconv); | 690 g_return_if_fail(ggconv); |
647 g_return_if_fail(g_list_find(ggconv->list, conv)); | 691 g_return_if_fail(g_list_find(ggconv->list, conv)); |
648 | 692 |
649 ggconv->active_conv = conv; | 693 ggconv->active_conv = conv; |
650 account = gaim_conversation_get_account(conv); | 694 account = gaim_conversation_get_account(conv); |
651 title = g_strdup_printf(_("%s (%s -- %s)"), gaim_conversation_get_title(conv), | 695 title = get_conversation_title(conv, account); |
652 gaim_account_get_username(account), gaim_account_get_protocol_name(account)); | |
653 gnt_screen_rename_widget(ggconv->window, title); | 696 gnt_screen_rename_widget(ggconv->window, title); |
654 g_free(title); | 697 g_free(title); |
655 } | 698 } |
656 | 699 |