# Path: pytrainer/lib/fileUtils.py
# class fileUtils:
#     def __init__(self, filename, data):
#         self.filename = filename
#         self.data = data
# 
#     def run(self):
#         logging.debug('>>')
#         if self.data is not None:
#             logging.debug("Writing in %s " % self.filename) 
#             out = open(self.filename, 'w')
#             out.write(self.data)
#             out.close()
#         else:
#             logging.error("Nothing to write in %s" % self.filename)
#         logging.debug('<<')


from pytrainer.lib.fileUtils import fileUtils
from gi.repository import Gtk
from gi.repository import WebKit2
import gi
import logging
		self.pack_box()
		logging.debug("<<")

	def pack_box(self):
		logging.debug(">>")
		scrolled_window = Gtk.ScrolledWindow()
		scrolled_window.add(self.wkview)
		self.box.pack_start(scrolled_window, True, True, 0)
		self.box.show_all()
		logging.debug("<<")

	def display_map(self, htmlfile=None):
		logging.debug(">>")
		if htmlfile is None:
			htmlfile = self.createErrorHtml()
		self.wkview.load_uri("file://%s" % (htmlfile))
		#self.box.show_all()
		logging.debug("<<")

	def createErrorHtml(self):
		logging.debug(">>")
		htmlfile = "%s/error.html" % (self.pytrainer_main.profile.tmpdir)
		content = '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<body>
No HTML file supplied to display
</body>
</html>
		'''

# Path: pytrainer/lib/fileUtils.py
# class fileUtils:
#     def __init__(self, filename, data):
#         self.filename = filename
#         self.data = data
# 
#     def run(self):
#         logging.debug('>>')
#         if self.data is not None:
#             logging.debug("Writing in %s " % self.filename) 
#             out = open(self.filename, 'w')
#             out.write(self.data)
#             out.close()
#         else:
#             logging.error("Nothing to write in %s" % self.filename)
#         logging.debug('<<')


# Path: pytrainer/extensions/mapviewer.py
from pytrainer.lib.fileUtils import fileUtils
from gi.repository import Gtk
from gi.repository import WebKit2
import gi
import logging

		self.pack_box()
		logging.debug("<<")

	def pack_box(self):
		logging.debug(">>")
		scrolled_window = Gtk.ScrolledWindow()
		scrolled_window.add(self.wkview)
		self.box.pack_start(scrolled_window, True, True, 0)
		self.box.show_all()
		logging.debug("<<")

	def display_map(self, htmlfile=None):
		logging.debug(">>")
		if htmlfile is None:
			htmlfile = self.createErrorHtml()
		self.wkview.load_uri("file://%s" % (htmlfile))
		#self.box.show_all()
		logging.debug("<<")

	def createErrorHtml(self):
		logging.debug(">>")
		htmlfile = "%s/error.html" % (self.pytrainer_main.profile.tmpdir)
		content = '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<body>
No HTML file supplied to display
</body>
</html>
		'''

		file = fileUtils(htmlfile,content)