Mercurial > pidgin.yaz
changeset 3768:f53370197bb9
[gaim-migrate @ 3907]
Tri-state typing notification (typing, typed, and no longer typing) by
Nathan D. Walp
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sun, 20 Oct 2002 19:38:36 +0000 |
parents | 65e9ea5934c8 |
children | 303e40b66b96 |
files | src/conversation.c src/core.h src/protocols/jabber/jabber.c src/protocols/msn/msn.c src/protocols/oscar/oscar.c src/protocols/yahoo/yahoo.c src/server.c src/ui.h |
diffstat | 8 files changed, 67 insertions(+), 98 deletions(-) [+] |
line wrap: on
line diff
--- a/src/conversation.c Sun Oct 20 19:08:21 2002 +0000 +++ b/src/conversation.c Sun Oct 20 19:38:36 2002 +0000 @@ -2068,19 +2068,16 @@ if (!flags & WFLAG_NOLOG && ((c->is_chat && (chat_options & OPT_CHAT_POPUP)) || (!c->is_chat && (im_options & OPT_IM_POPUP)))) gdk_window_show(c->window->window); - if (flags & WFLAG_RECV) - reset_typing(g_strdup(c->name)); /* tab highlighting */ if (c->is_chat && !(chat_options & OPT_CHAT_ONE_WINDOW)) /* if chat but not tabbed chat */ return; - if (!c->is_chat && !(im_options & OPT_IM_ONE_WINDOW)) /* if convo but not tabbed convo */ - return; if (!(flags & WFLAG_RECV) && !(flags & WFLAG_SYSTEM)) return; if ((c->unseen == 2) || ((c->unseen == 1) && !(flags & WFLAG_NICK))) return; + if (c->is_chat) { int offs; if ((convo_options & OPT_CONVO_COMBINE) && (im_options & OPT_IM_ONE_WINDOW)) @@ -2095,41 +2092,15 @@ g_list_index(conversations, c)) unhighlight = 1; } - if ((c->unseen != -1) && unhighlight) /* If there's no typing message - and we're on the same tab, don't bother - changing the color. */ - return; - - { - GtkNotebook *notebook = GTK_NOTEBOOK(c->is_chat ? chat_notebook : convo_notebook); - int offs = ((convo_options & OPT_CONVO_COMBINE) && - (im_options & OPT_IM_ONE_WINDOW) && c->is_chat) ? - g_list_length(conversations) : 0; - GList *ws = (c->is_chat ? chats : conversations); - GtkWidget *label = gtk_notebook_get_tab_label(notebook, - gtk_notebook_get_nth_page(notebook, - offs + g_list_index(ws, c))); - GtkStyle *style; - style = gtk_style_new(); - if (!GTK_WIDGET_REALIZED(label)) - gtk_widget_realize(label); - gtk_style_set_font(style, gdk_font_ref(gtk_style_get_font(label->style))); - if (!unhighlight && flags & WFLAG_NICK) { - style->fg[0].red = 0x0000; - style->fg[0].green = 0x0000; - style->fg[0].blue = 0xcccc; - c->unseen = 2; - } else if (!unhighlight) { - style->fg[0].red = 0xcccc; - style->fg[0].green = 0x0000; - style->fg[0].blue = 0x0000; - c->unseen = 1; - } else { - c->unseen = 0; - } - gtk_widget_set_style(label, style); - gtk_style_unref(style); + + if (!unhighlight && flags & WFLAG_NICK) { + c->unseen = 2; + } else if (!unhighlight) { + c->unseen = 1; + } else { + c->unseen = 0; } + update_convo_status(c, FALSE); } void update_progress(struct conversation *c, float percent) { @@ -2682,10 +2653,10 @@ gtk_imhtml_to_bottom(c->text); } -void show_typing(struct conversation *c) { - - if (c->is_chat) /* We shouldn't be getting typing notifications from chats. */ +void update_convo_status(struct conversation *c, int typing_state) { + if(!c) return; + debug_printf("update_convo_status called for %s\n", c->name); if (im_options & OPT_IM_ONE_WINDOW) { /* We'll make the tab green */ GtkStyle *style; GtkNotebook *notebook = GTK_NOTEBOOK(c->is_chat ? chat_notebook : convo_notebook); @@ -2700,26 +2671,54 @@ if (!GTK_WIDGET_REALIZED(label)) gtk_widget_realize(label); gtk_style_set_font(style, gdk_font_ref(gtk_style_get_font(label->style))); - style->fg[0].red = 0x0000; - style->fg[0].green = 0x9999; - style->fg[0].blue = 0x0000; + if(typing_state == TYPING) { + style->fg[0].red = 0x0000; + style->fg[0].green = 0x9999; + style->fg[0].blue = 0x0000; + } else if(typing_state == TYPED) { + style->fg[0].red = 0xfffff; + style->fg[0].green = 0xbbbb; + style->fg[0].blue = 0x2222; + } else if(c->unseen == 2) { + style->fg[0].red = 0x0000; + style->fg[0].green = 0x0000; + style->fg[0].blue = 0xcccc; + } else if(c->unseen == 1) { + style->fg[0].red = 0xcccc; + style->fg[0].green = 0x0000; + style->fg[0].blue = 0x0000; + } gtk_widget_set_style(label, style); debug_printf("setting style\n"); gtk_style_unref(style); - c->unseen = -1; } else { GtkWindow *win = (GtkWindow *)c->window; - char *buf; - if (strstr(win->title, " [TYPING]")) - return; - buf = g_malloc(strlen(win->title) + strlen(" [TYPING]") + 1); - g_snprintf(buf, - strlen(win->title) + strlen(" [TYPING]") + 1, "%s [TYPING]", - win->title); + char *buf, *buf2; + int len; + if(strstr(win->title, _(" [TYPING]"))) { + debug_printf("title had TYPING in it\n"); + len = strlen(win->title) - strlen(_(" [TYPING]")); + } else if(strstr(win->title, _(" [TYPED]"))) { + debug_printf("title had TYPED in it\n"); + len = strlen(win->title) - strlen(_(" [TYPED]")); + } else { + debug_printf("title was free of typing information\n"); + len = strlen(win->title); + } + buf = g_malloc(len+1); + g_snprintf(buf, len+1, win->title); + if(typing_state == TYPING) { + buf2 = g_strconcat(buf,_(" [TYPING]")); + g_free(buf); + buf = buf2; + } else if(typing_state == TYPED) { + buf2 = g_strconcat(buf,_(" [TYPED]")); + g_free(buf); + buf = buf2; + } gtk_window_set_title(win, buf); g_free(buf); } - } /* This returns a boolean, so that it can timeout */ @@ -2729,40 +2728,10 @@ g_free(name); return FALSE; } - /* Reset the title (if necessary) */ - if (c->is_chat) { - g_free(name); - c->typing_timeout = 0; - return FALSE; - } - if (!(im_options & OPT_IM_ONE_WINDOW)) { - GtkWindow *win = (GtkWindow*)c->window; - char *new_title; - if (strstr(win->title, " [TYPING]")) { - new_title = g_malloc(strlen(win->title) - strlen("[TYPING]")); - g_snprintf(new_title, strlen(win->title) - strlen("[TYPING]"), win->title); - gtk_window_set_title(win, new_title); - g_free(new_title); - - } - } else if (c->unseen == -1) { - GtkNotebook *notebook = GTK_NOTEBOOK(convo_notebook); - int offs = ((convo_options & OPT_CONVO_COMBINE) && - (im_options & OPT_IM_ONE_WINDOW) && c->is_chat) ? - g_list_length(conversations) : 0; - GList *ws = (conversations); - GtkWidget *label = gtk_notebook_get_tab_label(notebook, - gtk_notebook_get_nth_page(notebook, - offs + g_list_index(ws, c))); - GtkStyle *style; - style = gtk_style_new(); - if (!GTK_WIDGET_REALIZED(label)) - gtk_widget_realize(label); - gtk_style_set_font(style, gdk_font_ref(gtk_style_get_font(label->style))); - c->unseen = 0; - gtk_widget_set_style(label, style); - gtk_style_unref(style); - } + + /* Reset the title (if necessary) */ + update_convo_status(c, FALSE); + g_free(name); c->typing_timeout = 0; return FALSE;
--- a/src/core.h Sun Oct 20 19:08:21 2002 +0000 +++ b/src/core.h Sun Oct 20 19:38:36 2002 +0000 @@ -233,7 +233,7 @@ /* Functions in server.c */ extern void serv_got_update(struct gaim_connection *, char *, int, int, time_t, time_t, int, guint); extern void serv_got_im(struct gaim_connection *, char *, char *, guint32, time_t, gint); -extern void serv_got_typing(struct gaim_connection *, char *, int); +extern void serv_got_typing(struct gaim_connection *, char *, int, int); extern void serv_got_typing_stopped(struct gaim_connection *, char *); extern void serv_got_eviled(struct gaim_connection *, char *, int); extern void serv_got_chat_invite(struct gaim_connection *, char *, char *, char *, GList *);
--- a/src/protocols/jabber/jabber.c Sun Oct 20 19:08:21 2002 +0000 +++ b/src/protocols/jabber/jabber.c Sun Oct 20 19:38:36 2002 +0000 @@ -1348,7 +1348,7 @@ /* a non-message message! */ from = g_strdup_printf("%s@%s", p->from->user, p->from->server); if(typing) - serv_got_typing(GJ_GC(gjc), from, 0); + serv_got_typing(GJ_GC(gjc), from, 0, TYPING); else serv_got_typing_stopped(GJ_GC(gjc), from); g_free(from);
--- a/src/protocols/msn/msn.c Sun Oct 20 19:08:21 2002 +0000 +++ b/src/protocols/msn/msn.c Sun Oct 20 19:38:36 2002 +0000 @@ -656,7 +656,7 @@ if (!g_strncasecmp(content, "Content-Type: text/x-msmsgscontrol\r\n", strlen( "Content-Type: text/x-msmsgscontrol\r\n"))) { if (strstr(content,"TypingUser: ") && !ms->chat) { - serv_got_typing(ms->gc, ms->msguser, MSN_TYPING_RECV_TIMEOUT); + serv_got_typing(ms->gc, ms->msguser, MSN_TYPING_RECV_TIMEOUT, TYPING); return; }
--- a/src/protocols/oscar/oscar.c Sun Oct 20 19:08:21 2002 +0000 +++ b/src/protocols/oscar/oscar.c Sun Oct 20 19:38:36 2002 +0000 @@ -2384,11 +2384,11 @@ } break; case 0x0001: { /* Paused typing */ - serv_got_typing_stopped(gc, sn); + serv_got_typing(gc, sn, 0, TYPED); } break; case 0x0002: { /* Typing */ - serv_got_typing(gc, sn, 0); + serv_got_typing(gc, sn, 0, TYPING); } break; default: { @@ -4323,7 +4323,7 @@ if (typing) { /* I had to leave this. It's just too funny. It reminds me of my sister. */ debug_printf("ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); - serv_got_typing(gc,sn,0); + serv_got_typing(gc,sn,0, TYPING); } else serv_got_typing_stopped(gc,sn); return 1;
--- a/src/protocols/yahoo/yahoo.c Sun Oct 20 19:08:21 2002 +0000 +++ b/src/protocols/yahoo/yahoo.c Sun Oct 20 19:38:36 2002 +0000 @@ -538,7 +538,7 @@ if (!g_strncasecmp(msg, "TYPING", strlen("TYPING"))) { if (*stat == '1') - serv_got_typing(gc, from, 0); + serv_got_typing(gc, from, 0, TYPING); else serv_got_typing_stopped(gc, from); } else if (!g_strncasecmp(msg, "GAME", strlen("GAME"))) {
--- a/src/server.c Sun Oct 20 19:08:21 2002 +0000 +++ b/src/server.c Sun Oct 20 19:38:36 2002 +0000 @@ -856,11 +856,11 @@ do_error_dialog(buf2, NULL, GAIM_INFO); } -void serv_got_typing(struct gaim_connection *gc, char *name, int timeout) { +void serv_got_typing(struct gaim_connection *gc, char *name, int timeout, int state) { struct conversation *cnv = find_conversation(name); if (cnv) { set_convo_gc(cnv, gc); - show_typing(cnv); + update_convo_status(cnv, state); } else return; plugin_event(event_got_typing, gc, name); do_pounce(gc, name, OPT_POUNCE_TYPING); @@ -877,7 +877,7 @@ if (c && c->typing_timeout) { gtk_timeout_remove (c->typing_timeout); } - reset_typing(g_strdup(name)); + update_convo_status(c, NOT_TYPING); } static void close_invite(GtkWidget *w, GtkWidget *w2)
--- a/src/ui.h Sun Oct 20 19:08:21 2002 +0000 +++ b/src/ui.h Sun Oct 20 19:38:36 2002 +0000 @@ -419,7 +419,7 @@ extern void set_hide_icons(); extern void set_convo_titles(); extern void update_progress(struct conversation *, float); -extern void show_typing(struct conversation *); +extern void update_convo_status(struct conversation *, int); extern gboolean reset_typing(char *); extern void set_anim();