comparison src/conversation.c @ 3596:bb966d68f9e3

[gaim-migrate @ 3698] I like typing notifcation. I think I'll marry it. Also, if I'm going to go around mentioning gaim on resumes, I can't very well tell people to look for "KingAnt"... :-) committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 06 Oct 2002 05:01:50 +0000
parents bdd0bebd2d04
children bc87186a7478
comparison
equal deleted inserted replaced
3595:1e60a05c7482 3596:bb966d68f9e3
282 c->send_history = c->send_history->next; 282 c->send_history = c->send_history->next;
283 } 283 }
284 g_list_free(c->send_history); 284 g_list_free(c->send_history);
285 if (c->typing_timeout) 285 if (c->typing_timeout)
286 gtk_timeout_remove(c->typing_timeout); 286 gtk_timeout_remove(c->typing_timeout);
287 if (c->type_again_timeout)
288 gtk_timeout_remove(c->type_again_timeout);
287 g_string_free(c->history, TRUE); 289 g_string_free(c->history, TRUE);
288 g_free(c); 290 g_free(c);
289 } 291 }
290 292
291 void update_log_convs() 293 void update_log_convs()
533 if (convo_options & OPT_CONVO_CHECK_SPELLING) 535 if (convo_options & OPT_CONVO_CHECK_SPELLING)
534 gtkspell_detach(GTK_TEXT(c->entry)); 536 gtkspell_detach(GTK_TEXT(c->entry));
535 537
536 if (!c->is_chat) { 538 if (!c->is_chat) {
537 GSList *cn = connections; 539 GSList *cn = connections;
538 serv_send_typing(c->gc, c->name, FALSE); 540 if (!(misc_options & OPT_MISC_STEALTH_TYPING))
541 serv_send_typing(c->gc, c->name, NOT_TYPING);
539 while (cn) { 542 while (cn) {
540 struct gaim_connection *gc = cn->data; 543 struct gaim_connection *gc = cn->data;
541 cn = cn->next; 544 cn = cn->next;
542 if (gc->prpl->convo_closed) 545 if (gc->prpl->convo_closed)
543 gc->prpl->convo_closed(gc, c->name); 546 gc->prpl->convo_closed(gc, c->name);
816 /* go to next page */ 819 /* go to next page */
817 if (currpage + 1 == g_list_length(notebook->children)) 820 if (currpage + 1 == g_list_length(notebook->children))
818 gtk_notebook_set_page(notebook, 0); 821 gtk_notebook_set_page(notebook, 0);
819 else 822 else
820 gtk_notebook_next_page(notebook); 823 gtk_notebook_next_page(notebook);
824 }
825
826 gboolean send_typed(gpointer data)
827 {
828 struct conversation *c = (struct conversation*)data;
829 if (c && c->gc && c->name) {
830 c->type_again = 1;
831 serv_send_typing(c->gc, c->name, TYPED);
832 }
833 return FALSE;
821 } 834 }
822 835
823 gboolean keypress_callback(GtkWidget *entry, GdkEventKey * event, struct conversation *c) 836 gboolean keypress_callback(GtkWidget *entry, GdkEventKey * event, struct conversation *c)
824 { 837 {
825 int pos; 838 int pos;
1064 gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event"); 1077 gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event");
1065 } 1078 }
1066 1079
1067 if (c && (!(misc_options & OPT_MISC_STEALTH_TYPING)) && !c->is_chat) { 1080 if (c && (!(misc_options & OPT_MISC_STEALTH_TYPING)) && !c->is_chat) {
1068 char *txt = gtk_editable_get_chars(GTK_EDITABLE(c->entry), 0, -1); 1081 char *txt = gtk_editable_get_chars(GTK_EDITABLE(c->entry), 0, -1);
1069 if (gdk_keyval_to_unicode(event->keyval) && 1082 if (gdk_keyval_to_unicode(event->keyval) &&
1070 (strlen(txt) == 0 || (c->type_again != 0 && time(NULL) > c->type_again))) { 1083 (strlen(txt) == 0 || (c->type_again != 0 && time(NULL) > c->type_again))) {
1071 int timeout = serv_send_typing(c->gc, c->name, TRUE); 1084 int timeout = serv_send_typing(c->gc, c->name, TYPING);
1072 if (timeout) 1085 if (timeout)
1073 c->type_again = time(NULL) + timeout; 1086 c->type_again = time(NULL) + timeout;
1074 else 1087 else
1075 c->type_again = 0; 1088 c->type_again = 0;
1089
1090 if (c && c->type_again_timeout)
1091 gtk_timeout_remove(c->type_again_timeout);
1092 /* send TYPED after 5 seconds of not typing */
1093 c->type_again_timeout = gtk_timeout_add(5000, send_typed, (gpointer)c);
1076 } 1094 }
1077 else if (strlen(txt) == 1) { 1095 else if (strlen(txt) == 1) {
1078 if ((GTK_OLD_EDITABLE(c->entry)->current_pos == 1 && event->keyval == GDK_BackSpace) || 1096 if ((GTK_OLD_EDITABLE(c->entry)->current_pos == 1 && event->keyval == GDK_BackSpace) ||
1079 (GTK_OLD_EDITABLE(c->entry)->current_pos == 0 && event->keyval == GDK_Delete)) 1097 (GTK_OLD_EDITABLE(c->entry)->current_pos == 0 && event->keyval == GDK_Delete)) {
1080 serv_send_typing(c->gc, c->name, FALSE); 1098 if (c && c->type_again_timeout)
1099 gtk_timeout_remove(c->type_again_timeout);
1100 serv_send_typing(c->gc, c->name, NOT_TYPING);
1101 }
1081 } else if (GTK_OLD_EDITABLE(c->entry)->selection_start_pos == 0) { 1102 } else if (GTK_OLD_EDITABLE(c->entry)->selection_start_pos == 0) {
1082 if (GTK_OLD_EDITABLE(c->entry)->selection_end_pos == strlen(txt) && 1103 if (GTK_OLD_EDITABLE(c->entry)->selection_end_pos == strlen(txt) &&
1083 strlen(txt) > 0 && 1104 strlen(txt) > 0 &&
1084 (event->keyval == GDK_BackSpace || event->keyval == GDK_Delete)) 1105 (event->keyval == GDK_BackSpace || event->keyval == GDK_Delete)) {
1085 serv_send_typing(c->gc, c->name, FALSE); 1106 if (c && c->type_again_timeout)
1107 gtk_timeout_remove(c->type_again_timeout);
1108 serv_send_typing(c->gc, c->name, NOT_TYPING);
1109 }
1086 } 1110 }
1087 g_free(txt); 1111 g_free(txt);
1088 } 1112 }
1089 return FALSE; 1113 return FALSE;
1090 } 1114 }