aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2009-10-26 19:59:09 +0800
committerXavier Claessens <xclaesse@gmail.com>2009-11-25 01:29:43 +0800
commit591c58b68cb39c62d22d76f394c30481b0821018 (patch)
tree0c31012d4d527189d29e35c86be66dd000886c47 /libempathy-gtk
parent954545eee55262449162dd8d0aa10ce6f9c8d036 (diff)
downloadgsoc2013-empathy-591c58b68cb39c62d22d76f394c30481b0821018.tar
gsoc2013-empathy-591c58b68cb39c62d22d76f394c30481b0821018.tar.gz
gsoc2013-empathy-591c58b68cb39c62d22d76f394c30481b0821018.tar.bz2
gsoc2013-empathy-591c58b68cb39c62d22d76f394c30481b0821018.tar.lz
gsoc2013-empathy-591c58b68cb39c62d22d76f394c30481b0821018.tar.xz
gsoc2013-empathy-591c58b68cb39c62d22d76f394c30481b0821018.tar.zst
gsoc2013-empathy-591c58b68cb39c62d22d76f394c30481b0821018.zip
Use new smiley parser in EmpathyChatTextView.
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-chat-text-view.c29
-rw-r--r--libempathy-gtk/empathy-smiley-manager.h4
2 files changed, 20 insertions, 13 deletions
diff --git a/libempathy-gtk/empathy-chat-text-view.c b/libempathy-gtk/empathy-chat-text-view.c
index de777f2fb..aa8676bfd 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 7d37c592a..9530fe85b 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,