Mercurial > pidgin.yaz
comparison src/conversation.c @ 3612:abb114442532
[gaim-migrate @ 3726]
Definitely better typing notification by Faceprint.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Wed, 09 Oct 2002 05:45:19 +0000 |
parents | bc87186a7478 |
children | 468dc12b5ee8 |
comparison
equal
deleted
inserted
replaced
3611:a99f6f97a3f9 | 3612:abb114442532 |
---|---|
820 if (currpage + 1 == g_list_length(notebook->children)) | 820 if (currpage + 1 == g_list_length(notebook->children)) |
821 gtk_notebook_set_page(notebook, 0); | 821 gtk_notebook_set_page(notebook, 0); |
822 else | 822 else |
823 gtk_notebook_next_page(notebook); | 823 gtk_notebook_next_page(notebook); |
824 } | 824 } |
825 | |
826 #define SEND_TYPED_TIMEOUT 5000 | |
825 | 827 |
826 gboolean send_typed(gpointer data) | 828 gboolean send_typed(gpointer data) |
827 { | 829 { |
828 struct conversation *c = (struct conversation*)data; | 830 struct conversation *c = (struct conversation*)data; |
829 if (c && c->gc && c->name) { | 831 if (c && c->gc && c->name) { |
1077 gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event"); | 1079 gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event"); |
1078 } | 1080 } |
1079 | 1081 |
1080 if (c && (!(misc_options & OPT_MISC_STEALTH_TYPING)) && !c->is_chat) { | 1082 if (c && (!(misc_options & OPT_MISC_STEALTH_TYPING)) && !c->is_chat) { |
1081 char *txt = gtk_editable_get_chars(GTK_EDITABLE(c->entry), 0, -1); | 1083 char *txt = gtk_editable_get_chars(GTK_EDITABLE(c->entry), 0, -1); |
1082 if (gdk_keyval_to_unicode(event->keyval) && | 1084 if (strlen(txt) == 1 && ((GTK_OLD_EDITABLE(c->entry)->current_pos == 1 && event->keyval == GDK_BackSpace) || |
1083 (strlen(txt) == 0 || (c->type_again != 0 && time(NULL) > c->type_again))) { | 1085 (GTK_OLD_EDITABLE(c->entry)->current_pos == 0 && event->keyval == GDK_Delete))) { |
1084 int timeout = serv_send_typing(c->gc, c->name, TYPING); | |
1085 if (timeout) | |
1086 c->type_again = time(NULL) + timeout; | |
1087 else | |
1088 c->type_again = 0; | |
1089 | |
1090 if (c && c->type_again_timeout) | 1086 if (c && c->type_again_timeout) |
1091 gtk_timeout_remove(c->type_again_timeout); | 1087 gtk_timeout_remove(c->type_again_timeout); |
1092 /* send TYPED after 5 seconds of not typing */ | 1088 serv_send_typing(c->gc, c->name, NOT_TYPING); |
1093 c->type_again_timeout = gtk_timeout_add(5000, send_typed, (gpointer)c); | 1089 } else if (GTK_OLD_EDITABLE(c->entry)->selection_start_pos == 0 && (GTK_OLD_EDITABLE(c->entry)->selection_end_pos == strlen(txt) && |
1094 } | 1090 strlen(txt) > 0 && (event->keyval == GDK_BackSpace || event->keyval == GDK_Delete))) { |
1095 else if (strlen(txt) == 1) { | 1091 if (c && c->type_again_timeout) |
1096 if ((GTK_OLD_EDITABLE(c->entry)->current_pos == 1 && event->keyval == GDK_BackSpace) || | 1092 gtk_timeout_remove(c->type_again_timeout); |
1097 (GTK_OLD_EDITABLE(c->entry)->current_pos == 0 && event->keyval == GDK_Delete)) { | 1093 serv_send_typing(c->gc, c->name, NOT_TYPING); |
1098 if (c && c->type_again_timeout) | 1094 } |
1099 gtk_timeout_remove(c->type_again_timeout); | 1095 else if (gdk_keyval_to_unicode(event->keyval) || event->keyval == GDK_BackSpace || event->keyval == GDK_Delete) { |
1100 serv_send_typing(c->gc, c->name, NOT_TYPING); | 1096 if (strlen(txt) == 0 || (c->type_again != 0 && time(NULL) > c->type_again)) { |
1097 int timeout = serv_send_typing(c->gc, c->name, TYPING); | |
1098 if (timeout) | |
1099 c->type_again = time(NULL) + timeout; | |
1100 else | |
1101 c->type_again = 0; | |
1101 } | 1102 } |
1102 } else if (GTK_OLD_EDITABLE(c->entry)->selection_start_pos == 0) { | 1103 if (c->type_again_timeout) |
1103 if (GTK_OLD_EDITABLE(c->entry)->selection_end_pos == strlen(txt) && | 1104 gtk_timeout_remove(c->type_again_timeout); |
1104 strlen(txt) > 0 && | 1105 c->type_again_timeout = gtk_timeout_add(SEND_TYPED_TIMEOUT, send_typed, (gpointer)c); |
1105 (event->keyval == GDK_BackSpace || event->keyval == GDK_Delete)) { | |
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 } | |
1110 } | 1106 } |
1111 g_free(txt); | 1107 g_free(txt); |
1112 } | 1108 } |
1113 return FALSE; | 1109 return FALSE; |
1114 } | 1110 } |