Mercurial > pidgin
diff src/gtkconv.c @ 12618:204bd8fac61f
[gaim-migrate @ 14954]
SF Patch #1355796 from Sadrul
This fixes the custom smiley bug where your text gets smilies from the other party in the conversation.
This is a bit of a hack, but it fix things until such time as the smiley tree stuff can be reworked.
" From the kwiki:
If someone uses an MSN smiley, it shows up when I type
the textual representation of it. For example, someone
set a smiley (a rainbow flashy question mark) for ? and
it showed up (on my side, I have no idea about theirs)
for every ? I typed. /luke as I understand this report,
the problem is that the custom smiley should be
restricted to exactly one conversation but is in fact
spanning the account/
* (sadrul) It appears what happens is, the custom
smiley is added to the smiley-tree for that
conversation-imhtml. So whenever any new message is
going to be added to the imhtml, it looks up the
smiley-tree first, and since the "?" (or anything else)
matches the smiley, it converts it to the smiley. At
first glance, it seems the fix would be non-trivial. It
will probably be necessary to distinguish between
custom-smileys (and also messages added to the imhtml)
of the sender and the receiver.
==== end ====
What this patch does is, it temporarily replaces the
smiley-tree for the conversation-imhtml with the
smiley-tree of the conversation-entrybox. I think this
will work because the smiley-trees of both these
imhtml-s are initially the same. When a custom smiley
is received, it is added the smiley-tree of the
conversation-imhtml. So temporarily restoring the
smiley-tree with the original smiley-tree (that in
conv-entrybox) should fix the problem."
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Thu, 22 Dec 2005 04:07:21 +0000 |
parents | eee2042ad4f4 |
children | 851b0bd7eb52 |
line wrap: on
line diff
--- a/src/gtkconv.c Thu Dec 22 04:07:00 2005 +0000 +++ b/src/gtkconv.c Thu Dec 22 04:07:21 2005 +0000 @@ -4473,6 +4473,20 @@ * escaped entities making the string longer */ int tag_start_offset = alias ? (strlen(alias_escaped) - strlen(alias)) : 0; int tag_end_offset = 0; + GtkSmileyTree *tree = NULL; + GHashTable *smiley_data = NULL; + + if (flags & GAIM_MESSAGE_SEND) + { + /* Temporarily revert to the original smiley-data to avoid showing up + * custom smileys of the buddy when sending message + */ + tree = GTK_IMHTML(gtkconv->imhtml)->default_smilies; + GTK_IMHTML(gtkconv->imhtml)->default_smilies = + GTK_IMHTML(gtkconv->entry)->default_smilies; + smiley_data = GTK_IMHTML(gtkconv->imhtml)->smiley_data; + GTK_IMHTML(gtkconv->imhtml)->smiley_data = GTK_IMHTML(gtkconv->entry)->smiley_data; + } if (flags & GAIM_MESSAGE_WHISPER) { str = g_malloc(1024); @@ -4616,6 +4630,13 @@ gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), with_font_tag, gtk_font_options | gtk_font_options_all); + if (flags & GAIM_MESSAGE_SEND) + { + /* Restore the smiley-data */ + GTK_IMHTML(gtkconv->imhtml)->default_smilies = tree; + GTK_IMHTML(gtkconv->imhtml)->smiley_data = smiley_data; + } + g_free(with_font_tag); g_free(new_message); } @@ -4959,35 +4980,12 @@ } static gboolean -gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile) -{ - GaimGtkConversation *gtkconv; +add_custom_smiley_for_imhtml(GtkIMHtml *imhtml, const char *sml, const char *smile) +{ GtkIMHtmlSmiley *smiley; GdkPixbufLoader *loader; - struct smiley_list *list; - const char *sml = NULL, *conv_sml; - - if (!conv || !smile || !*smile) { - return FALSE; - } - - /* If smileys are off, return false */ - if (gaim_gtkthemes_smileys_disabled()) - return FALSE; - - /* If possible add this smiley to the current theme. - * The addition is only temporary: custom smilies aren't saved to disk. */ - conv_sml = gaim_account_get_protocol_name(conv->account); - gtkconv = GAIM_GTK_CONVERSATION(conv); - - for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { - if (!strcmp(list->sml, conv_sml)) { - sml = list->sml; - break; - } - } - - smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); + + smiley = gtk_imhtml_smiley_get(imhtml, sml, smile); if (smiley) { @@ -4999,6 +4997,7 @@ * the smiley we are about to receive */ g_object_unref(G_OBJECT(smiley->icon)); + /* XXX: Is it necessary to _unref the loader first? */ smiley->loader = gdk_pixbuf_loader_new(); smiley->icon = NULL; @@ -5022,7 +5021,44 @@ g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); - gtk_imhtml_associate_smiley(GTK_IMHTML(gtkconv->imhtml), sml, smiley); + gtk_imhtml_associate_smiley(imhtml, sml, smiley); + + return TRUE; +} + +static gboolean +gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile, gboolean remote) +{ + GaimGtkConversation *gtkconv; + struct smiley_list *list; + const char *sml = NULL, *conv_sml; + + if (!conv || !smile || !*smile) { + return FALSE; + } + + /* If smileys are off, return false */ + if (gaim_gtkthemes_smileys_disabled()) + return FALSE; + + /* If possible add this smiley to the current theme. + * The addition is only temporary: custom smilies aren't saved to disk. */ + conv_sml = gaim_account_get_protocol_name(conv->account); + gtkconv = GAIM_GTK_CONVERSATION(conv); + + for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { + if (!strcmp(list->sml, conv_sml)) { + sml = list->sml; + break; + } + } + + if (!add_custom_smiley_for_imhtml(GTK_IMHTML(gtkconv->imhtml), sml, smile)) + return FALSE; + + if (!remote) /* If it's a local custom smiley, then add it for the entry */ + if (!add_custom_smiley_for_imhtml(GTK_IMHTML(gtkconv->entry), sml, smile)) + return FALSE; return TRUE; }