Hi
I really appreciate the latex feature. Math characters are impossible to obtain
on a keyboard. However, it isn't theme aware, that is the background will always
be white even if you set another color in your theme. Same for the text.
I have managed to improve this and wrote a small patch. It is attached to this
email. May someone have a look to it? If it is correct, it may be interesting to
push it. It is built against the current mercurial repo.
Regards
Jonathan
diff -r 278bcb0fc71b src/common/latex.py
--- a/src/common/latex.py Wed Sep 16 16:14:03 2009 +0200
+++ b/src/common/latex.py Thu Sep 17 12:06:05 2009 +0200
@@ -28,6 +28,7 @@
##
import os
+import gtk
import random
from tempfile import gettempdir
from subprocess import Popen, PIPE
@@ -109,11 +110,29 @@
'command': .join(argv),
'error': helpers.decode_string(str(e))}
+def gdkcolor_to_rgb (gdkcolor):
+ return [c / 65535. for c in (gdkcolor.red, gdkcolor.green, gdkcolor.blue)]
+
+def format_rgb (r, g, b):
+ colorstr = rgb
+ for color in (r, g, b):
+ colorstr += + str (color)
+ return colorstr
+
+def format_gdkcolor (gdkcolor):
+ return format_rgb (*gdkcolor_to_rgb (gdkcolor))
def latex_to_image(str_):
result = None
exitcode = 0
+ # get style colors and create string for dvipng
+ dummy = gtk.Invisible()
+ dummy.ensure_style()
+ style = dummy.get_style()
+ bg_str = format_gdkcolor(style.base[gtk.STATE_NORMAL])
+ fg_str = format_gdkcolor(style.text[gtk.STATE_NORMAL])
+
# filter latex code with bad commands
if check_blacklist(str_):
# we triggered the blacklist, immediately return None
@@ -131,7 +150,7 @@
if exitcode == 0:
# convert dvi to png
latex_png_dpi = gajim.config.get('latex_png_dpi')
- exitcode = try_run(['dvipng', '-bg', 'rgb 1.0 1.0 1.0', '-T',
+ exitcode = try_run(['dvipng', '-bg', bg_str, '-fg', fg_str, '-T',
'tight', '-D', latex_png_dpi, tmpfile + '.dvi', '-o',
tmpfile + '.png'])
___
Gajim-devel mailing list
Gajim-devel@gajim.org
http://lists.gajim.org/cgi-bin/listinfo/gajim-devel