From: Xavier Claessens Date: Mon, 26 Oct 2009 11:59:09 +0000 (+0100) Subject: Use new smiley parser in EmpathyChatTextView. X-Git-Url: https://git.0d.be/?p=empathy.git;a=commitdiff_plain;h=591c58b68cb39c62d22d76f394c30481b0821018 Use new smiley parser in EmpathyChatTextView. --- diff --git a/libempathy-gtk/empathy-chat-text-view.c b/libempathy-gtk/empathy-chat-text-view.c index de777f2f..aa8676bf 100644 --- a/libempathy-gtk/empathy-chat-text-view.c +++ b/libempathy-gtk/empathy-chat-text-view.c @@ -1262,7 +1262,8 @@ chat_text_view_insert_text_with_emoticons (EmpathyChatTextView *view, { EmpathyChatTextViewPriv *priv = GET_PRIV (view); gboolean use_smileys = FALSE; - GSList *smileys, *l; + GSList *hits, *l; + gint last = 0; empathy_conf_get_bool (empathy_conf_get (), EMPATHY_PREFS_CHAT_SHOW_SMILEYS, @@ -1273,19 +1274,25 @@ chat_text_view_insert_text_with_emoticons (EmpathyChatTextView *view, return; } - smileys = empathy_smiley_manager_parse (priv->smiley_manager, str); - for (l = smileys; l; l = l->next) { - EmpathySmiley *smiley; + hits = empathy_smiley_manager_parse_len (priv->smiley_manager, str, -1); + for (l = hits; l; l = l->next) { + EmpathySmileyHit *hit = l->data; - smiley = l->data; - if (smiley->pixbuf) { - gtk_text_buffer_insert_pixbuf (priv->buffer, iter, smiley->pixbuf); - } else { - gtk_text_buffer_insert (priv->buffer, iter, smiley->str, -1); + if (hit->start > last) { + /* Append the text between last smiley (or the + * start of the message) and this smiley */ + gtk_text_buffer_insert (priv->buffer, iter, str + last, + hit->start - last); } - empathy_smiley_free (smiley); + gtk_text_buffer_insert_pixbuf (priv->buffer, iter, hit->pixbuf); + + last = hit->end; + + empathy_smiley_hit_free (hit); } - g_slist_free (smileys); + g_slist_free (hits); + + gtk_text_buffer_insert (priv->buffer, iter, str + last, -1); } void diff --git a/libempathy-gtk/empathy-smiley-manager.h b/libempathy-gtk/empathy-smiley-manager.h index 7d37c592..9530fe85 100644 --- a/libempathy-gtk/empathy-smiley-manager.h +++ b/libempathy-gtk/empathy-smiley-manager.h @@ -56,8 +56,8 @@ typedef struct { typedef struct { GdkPixbuf *pixbuf; const gchar *path; - gint start; - gint end; + gint start; + gint end; } EmpathySmileyHit; typedef void (*EmpathySmileyMenuFunc) (EmpathySmileyManager *manager,