From: Mark D. <the...@us...> - 2002-10-06 05:01:52
|
Update of /cvsroot/gaim/gaim/src In directory usw-pr-cvs1:/tmp/cvs-serv9466/src Modified Files: conversation.c gaim.h ui.h Log Message: 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"... :-) Index: conversation.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/conversation.c,v retrieving revision 1.383 retrieving revision 1.384 diff -u -d -r1.383 -r1.384 --- conversation.c 30 Sep 2002 01:05:14 -0000 1.383 +++ conversation.c 6 Oct 2002 05:01:49 -0000 1.384 @@ -284,6 +284,8 @@ g_list_free(c->send_history); if (c->typing_timeout) gtk_timeout_remove(c->typing_timeout); + if (c->type_again_timeout) + gtk_timeout_remove(c->type_again_timeout); g_string_free(c->history, TRUE); g_free(c); } @@ -535,7 +537,8 @@ if (!c->is_chat) { GSList *cn = connections; - serv_send_typing(c->gc, c->name, FALSE); + if (!(misc_options & OPT_MISC_STEALTH_TYPING)) + serv_send_typing(c->gc, c->name, NOT_TYPING); while (cn) { struct gaim_connection *gc = cn->data; cn = cn->next; @@ -820,6 +823,16 @@ gtk_notebook_next_page(notebook); } +gboolean send_typed(gpointer data) +{ + struct conversation *c = (struct conversation*)data; + if (c && c->gc && c->name) { + c->type_again = 1; + serv_send_typing(c->gc, c->name, TYPED); + } + return FALSE; +} + gboolean keypress_callback(GtkWidget *entry, GdkEventKey * event, struct conversation *c) { int pos; @@ -1066,23 +1079,34 @@ if (c && (!(misc_options & OPT_MISC_STEALTH_TYPING)) && !c->is_chat) { char *txt = gtk_editable_get_chars(GTK_EDITABLE(c->entry), 0, -1); - if (gdk_keyval_to_unicode(event->keyval) && + if (gdk_keyval_to_unicode(event->keyval) && (strlen(txt) == 0 || (c->type_again != 0 && time(NULL) > c->type_again))) { - int timeout = serv_send_typing(c->gc, c->name, TRUE); + int timeout = serv_send_typing(c->gc, c->name, TYPING); if (timeout) c->type_again = time(NULL) + timeout; else c->type_again = 0; + + if (c && c->type_again_timeout) + gtk_timeout_remove(c->type_again_timeout); + /* send TYPED after 5 seconds of not typing */ + c->type_again_timeout = gtk_timeout_add(5000, send_typed, (gpointer)c); } else if (strlen(txt) == 1) { if ((GTK_OLD_EDITABLE(c->entry)->current_pos == 1 && event->keyval == GDK_BackSpace) || - (GTK_OLD_EDITABLE(c->entry)->current_pos == 0 && event->keyval == GDK_Delete)) - serv_send_typing(c->gc, c->name, FALSE); + (GTK_OLD_EDITABLE(c->entry)->current_pos == 0 && event->keyval == GDK_Delete)) { + if (c && c->type_again_timeout) + gtk_timeout_remove(c->type_again_timeout); + serv_send_typing(c->gc, c->name, NOT_TYPING); + } } else if (GTK_OLD_EDITABLE(c->entry)->selection_start_pos == 0) { if (GTK_OLD_EDITABLE(c->entry)->selection_end_pos == strlen(txt) && strlen(txt) > 0 && - (event->keyval == GDK_BackSpace || event->keyval == GDK_Delete)) - serv_send_typing(c->gc, c->name, FALSE); + (event->keyval == GDK_BackSpace || event->keyval == GDK_Delete)) { + if (c && c->type_again_timeout) + gtk_timeout_remove(c->type_again_timeout); + serv_send_typing(c->gc, c->name, NOT_TYPING); + } } g_free(txt); } Index: gaim.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/gaim.h,v retrieving revision 1.339 retrieving revision 1.340 diff -u -d -r1.339 -r1.340 --- gaim.h 26 Sep 2002 15:23:33 -0000 1.339 +++ gaim.h 6 Oct 2002 05:01:49 -0000 1.340 @@ -117,6 +117,10 @@ #define PERMIT_SOME 3 #define DENY_SOME 4 +#define NOT_TYPING 0 +#define TYPING 1 +#define TYPED 2 + #define WFLAG_SEND 0x01 #define WFLAG_RECV 0x02 #define WFLAG_AUTO 0x04 Index: ui.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/ui.h,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- ui.h 29 Sep 2002 04:48:40 -0000 1.60 +++ ui.h 6 Oct 2002 05:01:49 -0000 1.61 @@ -148,6 +148,7 @@ gint unseen; guint typing_timeout; time_t type_again; + guint type_again_timeout; /* stuff used just for chat */ GList *in_room; |