blob: 19d2dc9ca380bad259ada206b6679557c3818184 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
try:
import webkit
except ImportError:
import os, sys
sys.path.append(os.path.join(os.environ['SUGAR_BUNDLE_PATH'], 'epubview', 'modules'))
import webkit
import gtk
class _WebView(webkit.WebView):
def __init__(self):
webkit.WebView.__init__(self)
def get_page_height(self):
#TODO: Need to check status of page load
js = 'oldtitle=document.title;document.title=document.body.clientHeight;'
self.execute_script(js)
ret = self.get_main_frame().get_title()
js = 'document.title=oldtitle;'
self.execute_script(js)
return int(ret)
def add_bottom_padding(self, incr):
js = ('var newdiv = document.createElement("div");newdiv.style.height = "%dpx";document.body.appendChild(newdiv);' % incr)
self.execute_script(js)
|