From e47feb3b0f7771dd7d2332c1dfb1aecabd1c77e5 Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Wed, 9 Apr 2014 13:04:37 -0300 Subject: [PATCH] Make webactivity and webkit1 implementations independient We can't import webkit and Webkit2 in the same process and that was introduced in 4ea52b3173e7d90f51800dfd12fb0424c877d4a6 Signed-off-by: Gonzalo Odiard --- src/sugar3/activity/webkit1.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/sugar3/activity/webkit1.py b/src/sugar3/activity/webkit1.py index 0560e899..f87dd777 100644 --- a/src/sugar3/activity/webkit1.py +++ b/src/sugar3/activity/webkit1.py @@ -36,7 +36,7 @@ import mimetypes from gi.repository import SugarExt from sugar3.activity import activity -from sugar3.activity.webactivity import FilePicker +from sugar3.graphics.objectchooser import ObjectChooser class LocalRequestHandler(BaseHTTPRequestHandler): @@ -98,6 +98,29 @@ class LocalHTTPServer(HTTPServer): self.server_port = port +class FilePicker(ObjectChooser): + def __init__(self, parent): + ObjectChooser.__init__(self, parent) + + def run(self): + jobject = None + _file = None + try: + result = ObjectChooser.run(self) + if result == Gtk.ResponseType.ACCEPT: + jobject = self.get_selected_object() + logging.debug('FilePicker.run: %r', jobject) + + if jobject and jobject.file_path: + _file = jobject.file_path + logging.debug('FilePicker.run: file=%r', _file) + finally: + if jobject is not None: + jobject.destroy() + + return _file + + class WebActivity(Gtk.Window): def __init__(self, handle): Gtk.Window.__init__(self)