changeset 467341adb843 in /home/hg/repos/gajim
author: Yann Leboulanger asterix@lagaule.org branches: gajim_0.16 details:http://hg.gajim.org/gajim?cmd=changeset;node=467341adb843 description: keep image tags when we replace the temporary image by the downloaded image. Fixes #8182
diffstat:
src/htmltextview.py | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-)
diffs (61 lines):
diff -r d6d76868b184 -r 467341adb843 src/htmltextview.py --- a/src/htmltextview.py Wed Nov 04 21:54:24 2015 +0100 +++ b/src/htmltextview.py Sun Nov 15 14:28:31 2015 +0100 @@ -489,10 +489,10 @@ tag.title = title return tag
- def _update_img(self, (mem, alt), attrs, img_mark): + def _update_img(self, (mem, alt), attrs, img_mark, tags): '''Callback function called after the function helpers.download_image. ''' - self._process_img(attrs, (mem, alt, img_mark)) + self._process_img(attrs, (mem, alt, img_mark, tags))
def _process_img(self, attrs, loaded=None): '''Process a img tag. @@ -501,6 +501,7 @@ update = False pixbuf = None replace_mark = None + replace_tags = None
try: if attrs['src'].startswith('data:image/'): @@ -509,14 +510,14 @@ img = attrs['src'].split(',')[1] mem = base64.standard_b64decode(urllib2.unquote(img)) elif loaded is not None: - (mem, alt, replace_mark) = loaded + (mem, alt, replace_mark, replace_tags) = loaded update = True else: if self.conv_textview: img_mark = self.textbuf.create_mark(None, self.iter, True) gajim.thread_interface(helpers.download_image, [ self.conv_textview.account, attrs], self._update_img, - [attrs, img_mark]) + [attrs, img_mark, self._get_style_tags()]) alt = attrs.get('alt', '') if alt: alt += '\n' @@ -574,7 +575,10 @@ self.textbuf.delete(working_iter, next_iter) self.textbuf.delete_mark(replace_mark) if pixbuf is not None: - tags = self._get_style_tags() + if replace_mark: + tags = replace_tags + else: + tags = self._get_style_tags() if tags: tmpmark = self.textbuf.create_mark(None, working_iter, True) self.textbuf.insert_pixbuf(working_iter, pixbuf) @@ -1271,4 +1275,7 @@ w.set_default_size(400, 300) w.show_all() w.connect('destroy', lambda w: gtk.main_quit()) + gtk.gdk.threads_init() + gtk.gdk.threads_enter() gtk.main() + gtk.gdk.threads_leave()