diff --git a/src/common/gajim.py b/src/common/gajim.py
index 5ce13a6523680830dcec121085687928191a768f..e5a61147089bb22be2ceffc80c125b68838db010 100644
--- a/src/common/gajim.py
+++ b/src/common/gajim.py
@@ -176,6 +176,65 @@ else:
 	if system('gpg -h >/dev/null 2>&1'):
 		HAVE_GPG = False
 
+import os
+import random
+from tempfile import gettempdir
+from subprocess import Popen
+
+def check_for_latex_support():
+	'''check is latex is available and if it can create a picture.'''
+
+	exitcode = 0
+	random.seed()
+	tmpfile = os.path.join(gettempdir(), "gajimtex_" + \
+		random.randint(0,100).__str__())
+
+	# build latex string
+	texstr = '\\documentclass[12pt]{article}\\usepackage[dvips]{graphicx}'
+	texstr += '\\usepackage{amsmath}\\usepackage{amssymb}\\pagestyle{empty}'
+	texstr += '\\begin{document}\\begin{large}\\begin{gather*}test'
+	texstr += '\\end{gather*}\\end{large}\\end{document}'
+
+	file_ = open(os.path.join(tmpfile + ".tex"), "w+")
+	file_.write(texstr)
+	file_.flush()
+	file_.close()
+	try:
+		if os.name == 'nt':
+			# CREATE_NO_WINDOW
+			p = Popen(['latex', '--interaction=nonstopmode', tmpfile + '.tex'],
+				creationflags=0x08000000, cwd=gettempdir())
+		else:
+			p = Popen(['latex', '--interaction=nonstopmode', tmpfile + '.tex'],
+				cwd=gettempdir())
+		exitcode = p.wait()
+	except Exception:
+		exitcode = 1
+	if exitcode == 0:
+		try:
+			if os.name == 'nt':
+				# CREATE_NO_WINDOW
+				p = Popen(['dvipng', '-bg', 'white', '-T', 'tight',
+					tmpfile + '.dvi', '-o', tmpfile + '.png'],
+					creationflags=0x08000000, cwd=gettempdir())
+			else:
+				p = Popen(['dvipng', '-bg', 'white', '-T', 'tight',
+					tmpfile + '.dvi', '-o', tmpfile + '.png'], cwd=gettempdir())
+			exitcode = p.wait()
+		except Exception:
+			exitcode = 1
+	extensions = ['.tex', '.log', '.aux', '.dvi', '.png']
+	for ext in extensions:
+		try:
+			os.remove(tmpfile + ext)
+		except Exception:
+			pass
+	if exitcode == 0:
+		return True
+	return False
+
+HAVE_LATEX = check_for_latex_support()
+
 gajim_identity = {'type': 'pc', 'category': 'client', 'name': 'Gajim'}
 gajim_common_features = [xmpp.NS_BYTESTREAM, xmpp.NS_SI, xmpp.NS_FILE,
 	xmpp.NS_MUC, xmpp.NS_MUC_USER, xmpp.NS_MUC_ADMIN, xmpp.NS_MUC_OWNER,
diff --git a/src/conversation_textview.py b/src/conversation_textview.py
index e03ba25d4e5f3ea0cdcb26bc4c51e17d30f7eb50..227d7ff0e9f9652388f647c28ed90ce068d3cef8 100644
--- a/src/conversation_textview.py
+++ b/src/conversation_textview.py
@@ -1141,7 +1141,8 @@ class ConversationTextview:
 			else:
 				if not show_ascii_formatting_chars:
 					special_text = special_text[1:-1] # remove _ _
-		elif special_text.startswith('$$') and special_text.endswith('$$'):
+		elif gajim.HAVE_LATEX and special_text.startswith('$$') and \
+		special_text.endswith('$$'):
 			try:
 				imagepath = self.latex_to_image(special_text)
 			except LatexError, e:
diff --git a/src/features_window.py b/src/features_window.py
index 45ee72fdb40f55e4aef16af63a1e488a043764db..390b20bd8403e5152e70dc5248935683ccffb743 100644
--- a/src/features_window.py
+++ b/src/features_window.py
@@ -31,10 +31,6 @@ import gtkgui_helpers
 from common import gajim
 from common import helpers
 
-import random
-from tempfile import gettempdir
-from subprocess import Popen
-
 class FeaturesWindow:
 	'''Class for features window'''
 
@@ -255,56 +251,7 @@ class FeaturesWindow:
 		return sleepy.SUPPORTED
 
 	def latex_available(self):
-		'''check is latex is available and if it can create a picture.'''
-
-		exitcode = 0
-		random.seed()
-		tmpfile = os.path.join(gettempdir(), "gajimtex_" + \
-			random.randint(0,100).__str__())
-
-		# build latex string
-		texstr = '\\documentclass[12pt]{article}\\usepackage[dvips]{graphicx}'
-		texstr += '\\usepackage{amsmath}\\usepackage{amssymb}\\pagestyle{empty}'
-		texstr += '\\begin{document}\\begin{large}\\begin{gather*}test'
-		texstr += '\\end{gather*}\\end{large}\\end{document}'
-
-		file_ = open(os.path.join(tmpfile + ".tex"), "w+")
-		file_.write(texstr)
-		file_.flush()
-		file_.close()
-		try:
-			if os.name == 'nt':
-				# CREATE_NO_WINDOW
-				p = Popen(['latex', '--interaction=nonstopmode', tmpfile + '.tex'],
-					creationflags=0x08000000, cwd=gettempdir())
-			else:
-				p = Popen(['latex', '--interaction=nonstopmode', tmpfile + '.tex'],
-					cwd=gettempdir())
-			exitcode = p.wait()
-		except Exception:
-			exitcode = 1
-		if exitcode == 0:
-			try:
-				if os.name == 'nt':
-					# CREATE_NO_WINDOW
-					p = Popen(['dvipng', '-bg', 'white', '-T', 'tight',
-						tmpfile + '.dvi', '-o', tmpfile + '.png'],
-						creationflags=0x08000000, cwd=gettempdir())
-				else:
-					p = Popen(['dvipng', '-bg', 'white', '-T', 'tight',
-						tmpfile + '.dvi', '-o', tmpfile + '.png'], cwd=gettempdir())
-				exitcode = p.wait()
-			except Exception:
-				exitcode = 1
-		extensions = ['.tex', '.log', '.aux', '.dvi', '.png']
-		for ext in extensions:
-			try:
-				os.remove(tmpfile + ext)
-			except Exception:
-				pass
-		if exitcode == 0:
-			return True
-		return False
+		return gajim.HAVE_LATEX
 
 	def pycrypto_available(self):
 		return gajim.HAVE_PYCRYPTO