tags 549038 + patch
thanks

Hi,

On 21/05/10 17:43, Julien BLACHE wrote:
> Emilio Pozuelo Monfort <po...@debian.org> wrote:
>> I'm dropping python-gtkhtml2 now, so this is RC. I'll see if I can port it,
>> though if you can have a look at it that would be great.
> 
> Not going to happen, I'm afraid...

I've looked at it and here's a patch. You'll need to depend on python-webkit and
drop the python-gtkhtml2 dependency. I cannot run eikazo (it refuses to start
saying I have no scanners) so I've tested the Help directly with

$ python /usr/share/pyshared/Eikazo/Help.py

And it works fine.

Let me know if you find any problems with it.

Cheers,
Emilio
diff -ruNp eikazo-0.5.2/Eikazo/Help.py eikazo-0.5.2.new/Eikazo/Help.py
--- eikazo-0.5.2/Eikazo/Help.py	2006-08-08 14:38:39.000000000 +0200
+++ eikazo-0.5.2.new/Eikazo/Help.py	2010-05-21 18:21:07.000000000 +0200
@@ -18,16 +18,12 @@ Foundation, Inc., 59 Temple Place, Suite
 help widget and help window
 """
 
-# FIXME: Where is some documentation for gtkhtml2 ???
-# couldn't find anything, neither for the C libs nor for the Python wrapper
-# So the stuff here is based on the Python example and some trial and error...
-#
 # FIXME: a decent url parser should be used instead of the wuickly
 # hacked stuff.
 
 import os, sys, traceback
 import gtk
-import gtkhtml2 # FIXME: use try/except!!
+import webkit # FIXME: use try/except!!
 import I18n
 
 t = I18n.get_translation('eikazo')
@@ -42,78 +38,35 @@ class Help:
         self.window = None
     
     def show(self, content=None):
-        dir = os.path.split(__file__)[0]
+        dir = os.path.abspath(os.path.split(__file__)[0])
         self.dir = os.path.join(dir, 'doc')
         fname = os.path.join(self.dir, 'index.html')
+        fname = "file://" + fname # webkit expects an URI
         
         if not self.window:
             self.window = gtk.Window()
             self.window.set_title(_('Eikazo Help'))
-
-            self.doc = gtkhtml2.Document()
-            self.doc.clear()
-            
-            self.doc.connect('request_url', self.cb_request_url)
-            self.doc.connect('link_clicked', self.cb_link_clicked)
             
             self.widget = gtk.ScrolledWindow()
-            self.view = gtkhtml2.View()
+            self.view = webkit.WebView()
             self.widget.add(self.view)
             self.view.show()
             
-            # when is this callback called???
-            #self.view.connect('request_object', self.cb_request_object)
-
-            self.view.set_document(self.doc)
-
             self.window.add(self.widget)
             self.widget.show()
             self.window.connect("destroy", self.cb_destroy)
             self.window.set_default_size(600, 400)
             self.window.show_all()
         
-        self.doc.open_stream('text/html')
-        self.doc.write_stream(open(fname).read())
-        self.doc.close_stream()
+        self.view.load_uri(fname)
     
     def cb_destroy(self, w):
         self.window = None
-        del self.doc
         del self.widget
         del self.view
-        
-    def cb_request_url(self, doc, url, stream):
-        """ called for <img> tags and when a link to an anchor is clicked
-        """
-        stream.write(open(os.path.join(self.dir, url)).read())
-        
-    def cb_link_clicked(self, doc, link):
-        # contains the plain link as found in an <a href> tag.
-        # we may have a filename, an anchor or a filename and an anchor
-        link = link.split('#')
-        if link[0]:
-            try:
-                fname = os.path.join(self.dir, link[0])
-                text = open(fname).read()
-                self.doc.open_stream('text/html')
-                self.doc.write_stream(text)
-                self.doc.close_stream()
-            except:
-                # a missing file here is not important enough to crash the 
-                # whole application. Obly print the error message
-                err = sys.exc_info()
-                print str(err[0]), str(err[1])
-                traceback.print_tb(err[2])
-        if len(link) > 1:
-            self.view.jump_to_anchor(link[1])
-    
-    #def cb_request_object(self, doc, url, stream):
-    #    # no idea hwat this is good for...
-    #    pass
-        
     
 if __name__ == '__main__':
     h = Help()
     h.show()
     h.window.show_all()
-    gtk.main()
\ No hay ningún carácter de nueva línea al final del fichero
+    gtk.main()

Reply via email to