[Sugar-devel] [PATCH 2/2] Removing mozilla xpcom and hulahop, adding WebKit
Simon Schampijer
simon at schampijer.de
Fri Nov 25 04:13:37 EST 2011
Hi Manuel,
thanks for the patch!
as we already have a non-working HEAD with the last commit I would
suggest to do the following:
- make one commit that only replaces the sugar with sugar3
- make an initial commit that switches from xulrunner to webkit, having
a simple webview coming up, uncommenting the stuff that breaks
- then remove one by one the functionality: copy, download, upload...(as
you did in the woring branch)
It is only sligtly different from your patch, but might be a bit
clearer. You have a few stuff removed (like filepicker) but it is then
still used in browse.py. And there are large parts uncommented, I would
prefer to just uncomment the breakers and then replace functionality by
functionality. Hope that makese sense. Please let me know if you have
other ideas or think this approach is too complicated etc, I am open for
discussion.
Thanks,
Simon
On 22/11/11 22:42, Manuel Quiñones wrote:
> Changed sugar imports to sugar3. The activity launches now in that
> sugar branch.
>
> This commit breaks a lot of Browse functionality. This is marked in
> the code with a FIXME keyword. In places where the old code seems
> relevant as reference, it was kept as comment. When no relevant, it
> was deleted. Old or unused code was also removed.
>
> Original work was done by Daniel Drake.
>
> Signed-off-by: Manuel Quiñones<manuq at laptop.org>
> ---
> browser.py | 249 ++++---------------------
> downloadmanager.py | 505 ++++++++++-----------------------------------------
> edittoolbar.py | 60 +++----
> filepicker.py | 166 -----------------
> globalhistory.py | 80 --------
> linkbutton.py | 7 +-
> palettes.py | 83 ++++-----
> places.py | 2 +-
> progresslistener.py | 103 -----------
> promptservice.py | 67 -------
> securitydialogs.py | 51 -----
> sessionhistory.py | 8 -
> sessionstore.py | 32 ++--
> viewtoolbar.py | 3 +-
> webactivity.py | 70 +++----
> webtoolbar.py | 29 ++--
> widgets.py | 2 +-
> 17 files changed, 268 insertions(+), 1249 deletions(-)
> delete mode 100644 filepicker.py
> delete mode 100644 globalhistory.py
> delete mode 100644 progresslistener.py
> delete mode 100644 promptservice.py
> delete mode 100644 securitydialogs.py
>
> diff --git a/browser.py b/browser.py
> index f2c4cc5..0aa38ed 100644
> --- a/browser.py
> +++ b/browser.py
> @@ -17,87 +17,26 @@
> # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
>
> import os
> -import time
> from gettext import gettext as _
>
> from gi.repository import GObject
> from gi.repository import Gtk
> +from gi.repository import Gdk
> from gi.repository import Pango
> -import hulahop
> -import xpcom
> -from xpcom.nsError import *
> -from xpcom import components
> -from xpcom.components import interfaces
> -from hulahop.webview import WebView
> -
> -from sugar import env
> -from sugar.activity import activity
> -from sugar.graphics import style
> -from sugar.graphics.icon import Icon
> +from gi.repository import WebKit
> +
> +from sugar3 import env
> +from sugar3.activity import activity
> +from sugar3.graphics import style
> +from sugar3.graphics.icon import Icon
>
> import sessionstore
> -from palettes import ContentInvoker
> from sessionhistory import HistoryListener
> -from progresslistener import ProgressListener
> from widgets import BrowserNotebook
>
> -_ZOOM_AMOUNT = 0.1
> _LIBRARY_PATH = '/usr/share/library-common/index.html'
>
>
> -class SaveListener(object):
> - _com_interfaces_ = interfaces.nsIWebProgressListener
> -
> - def __init__(self, user_data, callback):
> - self._user_data = user_data
> - self._callback = callback
> -
> - def onStateChange(self, webProgress, request, stateFlags, status):
> - listener_class = interfaces.nsIWebProgressListener
> - if (stateFlags& listener_class.STATE_IS_REQUEST and
> - stateFlags& listener_class.STATE_STOP):
> - self._callback(self._user_data)
> -
> - # Contrary to the documentation, STATE_IS_REQUEST is _not_ always set
> - # if STATE_IS_DOCUMENT is set.
> - if (stateFlags& listener_class.STATE_IS_DOCUMENT and
> - stateFlags& listener_class.STATE_STOP):
> - self._callback(self._user_data)
> -
> - def onProgressChange(self, progress, request, curSelfProgress,
> - maxSelfProgress, curTotalProgress, maxTotalProgress):
> - pass
> -
> - def onLocationChange(self, progress, request, location):
> - pass
> -
> - def onStatusChange(self, progress, request, status, message):
> - pass
> -
> - def onSecurityChange(self, progress, request, state):
> - pass
> -
> -
> -class CommandListener(object):
> -
> - _com_interfaces_ = interfaces.nsIDOMEventListener
> -
> - def __init__(self, window):
> - self._window = window
> -
> - def handleEvent(self, event):
> - if not event.isTrusted:
> - return
> -
> - uri = event.originalTarget.ownerDocument.documentURI
> - if not uri.startswith('about:neterror?e=nssBadCert'):
> - return
> -
> - cls = components.classes['@sugarlabs.org/add-cert-exception;1']
> - cert_exception = cls.createInstance(interfaces.hulahopAddCertException)
> - cert_exception.showDialog(self._window)
> -
> -
> class TabbedView(BrowserNotebook):
> __gtype_name__ = 'TabbedView'
>
> @@ -107,8 +46,6 @@ class TabbedView(BrowserNotebook):
> ([])),
> }
>
> - _com_interfaces_ = interfaces.nsIWindowCreator
> -
> AGENT_SHEET = os.path.join(activity.get_bundle_path(),
> 'agent-stylesheet.css')
> USER_SHEET = os.path.join(env.get_profile_path(), 'gecko',
> @@ -120,36 +57,11 @@ class TabbedView(BrowserNotebook):
> self.props.show_border = False
> self.props.scrollable = True
>
> - io_service_class = components.classes[ \
> - "@mozilla.org/network/io-service;1"]
> - io_service = io_service_class.getService(interfaces.nsIIOService)
> -
> - # Use xpcom to turn off "offline mode" detection, which disables
> - # access to localhost for no good reason. (Trac #6250.)
> - io_service2 = io_service_class.getService(interfaces.nsIIOService2)
> - io_service2.manageOfflineStatus = False
> -
> - cls = components.classes['@mozilla.org/content/style-sheet-service;1']
> - style_sheet_service = cls.getService(interfaces.nsIStyleSheetService)
> -
> - if os.path.exists(TabbedView.AGENT_SHEET):
> - agent_sheet_uri = io_service.newURI('file:///' +
> - TabbedView.AGENT_SHEET,
> - None, None)
> - style_sheet_service.loadAndRegisterSheet(agent_sheet_uri,
> - interfaces.nsIStyleSheetService.AGENT_SHEET)
> -
> - if os.path.exists(TabbedView.USER_SHEET):
> - url = 'file:///' + TabbedView.USER_SHEET
> - user_sheet_uri = io_service.newURI(url, None, None)
> - style_sheet_service.loadAndRegisterSheet(user_sheet_uri,
> - interfaces.nsIStyleSheetService.USER_SHEET)
> -
> - cls = components.classes['@mozilla.org/embedcomp/window-watcher;1']
> - window_watcher = cls.getService(interfaces.nsIWindowWatcher)
> - window_creator = xpcom.server.WrapObject(self,
> - interfaces.nsIWindowCreator)
> - window_watcher.setWindowCreator(window_creator)
> + # FIXME xpcom was removed
> + # # Use xpcom to turn off "offline mode" detection, which disables
> + # # access to localhost for no good reason. (Trac #6250.)
> + # io_service2 = io_service_class.getService(interfaces.nsIIOService2)
> + # io_service2.manageOfflineStatus = False
>
> self.connect('size-allocate', self.__size_allocate_cb)
> self.connect('page-added', self.__page_added_cb)
> @@ -159,29 +71,6 @@ class TabbedView(BrowserNotebook):
> self._update_closing_buttons()
> self._update_tab_sizes()
>
> - def createChromeWindow(self, parent, flags):
> - if flags& interfaces.nsIWebBrowserChrome.CHROME_OPENAS_CHROME:
> - dialog = PopupDialog()
> - dialog.view.is_chrome = True
> -
> - parent_dom_window = parent.webBrowser.contentDOMWindow
> - parent_view = hulahop.get_view_for_window(parent_dom_window)
> - if parent_view:
> - dialog.set_transient_for(parent_view.get_toplevel())
> -
> - browser = dialog.view.browser
> -
> - item = browser.queryInterface(interfaces.nsIDocShellTreeItem)
> - item.itemType = interfaces.nsIDocShellTreeItem.typeChromeWrapper
> -
> - return browser.containerWindow
> - else:
> - browser = Browser()
> - browser.connect('new-tab', self.__new_tab_cb)
> - self._append_tab(browser)
> -
> - return browser.browser.containerWindow
> -
> def __size_allocate_cb(self, widget, allocation):
> self._update_tab_sizes()
>
> @@ -242,7 +131,8 @@ class TabbedView(BrowserNotebook):
>
> n_pages = self.get_n_pages()
> canvas_size = self.get_allocation()
> - overlap_size = self.style_get_property('tab-overlap') * n_pages - 1
> + # overlap_size = self.style_get_property('tab-overlap') * n_pages - 1
> + overlap_size = 0 # FIXME
> allowed_size = canvas_size.width - overlap_size
>
> tab_new_size = int(allowed_size * 1.0 / (n_pages + 1))
> @@ -310,14 +200,6 @@ class TabbedView(BrowserNotebook):
> sessionstore.set_session(browser, tab_session)
>
>
> -Gtk.rc_parse_string('''
> - style "browse-tab-close" {
> - xthickness = 0
> - ythickness = 0
> - }
> - widget "*browse-tab-close" style "browse-tab-close"''')
> -
> -
> class TabLabel(Gtk.HBox):
> __gtype_name__ = 'TabLabel'
>
> @@ -331,7 +213,9 @@ class TabLabel(Gtk.HBox):
> GObject.GObject.__init__(self)
>
> self._browser = browser
> - self._browser.connect('is-setup', self.__browser_is_setup_cb)
> +
> + # FIXME is-setup was a signal emited in old code
> + # self._browser.connect('is-setup', self.__browser_is_setup_cb)
>
> self._label = Gtk.Label(label=_('Untitled'))
> self._label.set_ellipsize(Pango.EllipsizeMode.END)
> @@ -367,16 +251,17 @@ class TabLabel(Gtk.HBox):
> self.emit('tab-close', self._browser)
>
> def __browser_is_setup_cb(self, browser):
> - browser.progress.connect('notify::location',
> - self.__location_changed_cb)
> + # FIXME progress bar removed for now
> + # browser.progress.connect('notify::location',
> + # self.__location_changed_cb)
> browser.connect('notify::title', self.__title_changed_cb)
>
> - def __location_changed_cb(self, progress_listener, pspec):
> - url = self._browser.get_url_from_nsiuri(progress_listener.location)
> - if url == 'about:blank':
> - self._label.set_text(_('Loading...'))
> - else:
> - self._label.set_text(url)
> + # def __location_changed_cb(self, progress_listener, pspec):
> + # url = self._browser.get_url_from_nsiuri(progress_listener.location)
> + # if url == 'about:blank':
> + # self._label.set_text(_('Loading...'))
> + # else:
> + # self._label.set_text(url)
>
> def __title_changed_cb(self, browser, pspec):
> if browser.props.title == "":
> @@ -385,7 +270,7 @@ class TabLabel(Gtk.HBox):
> self._label.set_text(browser.props.title)
>
>
> -class Browser(WebView):
> +class Browser(WebKit.WebView):
> __gtype_name__ = 'Browser'
>
> __gsignals__ = {
> @@ -398,41 +283,20 @@ class Browser(WebView):
> }
>
> def __init__(self):
> - WebView.__init__(self)
> + WebKit.WebView.__init__(self)
>
> self.history = HistoryListener()
> - self.progress = ProgressListener()
> -
> - cls = components.classes["@mozilla.org/typeaheadfind;1"]
> - self.typeahead = cls.createInstance(interfaces.nsITypeAheadFind)
> -
> - def do_setup(self):
> - WebView.do_setup(self)
> - listener = xpcom.server.WrapObject(ContentInvoker(self),
> - interfaces.nsIDOMEventListener)
> - self.window_root.addEventListener('click', listener, False)
> -
> - listener = xpcom.server.WrapObject(CommandListener(self.dom_window),
> - interfaces.nsIDOMEventListener)
> - self.window_root.addEventListener('command', listener, False)
> -
> - self.progress.setup(self)
> -
> - self.history.setup(self.web_navigation)
> -
> - self.typeahead.init(self.doc_shell)
> -
> - self.emit('is-setup')
>
> def get_url_from_nsiuri(self, uri):
> """
> get a nsIURI object and return a string with the url
> """
> - if uri == None:
> - return ''
> - cls = components.classes['@mozilla.org/intl/texttosuburi;1']
> - texttosuburi = cls.getService(interfaces.nsITextToSubURI)
> - return texttosuburi.unEscapeURIForUI(uri.originCharset, uri.spec)
> + return '' # FIXME
> + # if uri == None:
> + # return ''
> + # cls = components.classes['@mozilla.org/intl/texttosuburi;1']
> + # texttosuburi = cls.getService(interfaces.nsITextToSubURI)
> + # return texttosuburi.unEscapeURIForUI(uri.originCharset, uri.spec)
>
> def get_session(self):
> return sessionstore.get_session(self)
> @@ -440,50 +304,11 @@ class Browser(WebView):
> def set_session(self, data):
> return sessionstore.set_session(self, data)
>
> - def get_source(self, async_cb, async_err_cb):
> - cls = components.classes[ \
> - '@mozilla.org/embedding/browser/nsWebBrowserPersist;1']
> - persist = cls.createInstance(interfaces.nsIWebBrowserPersist)
> - # get the source from the cache
> - persist.persistFlags = \
> - interfaces.nsIWebBrowserPersist.PERSIST_FLAGS_FROM_CACHE
> -
> - temp_path = os.path.join(activity.get_activity_root(), 'instance')
> - file_path = os.path.join(temp_path, '%i' % time.time())
> - cls = components.classes["@mozilla.org/file/local;1"]
> - local_file = cls.createInstance(interfaces.nsILocalFile)
> - local_file.initWithPath(file_path)
> -
> - progresslistener = SaveListener(file_path, async_cb)
> - persist.progressListener = xpcom.server.WrapObject(
> - progresslistener, interfaces.nsIWebProgressListener)
> -
> - uri = self.web_navigation.currentURI
> - persist.saveURI(uri, self.doc_shell, None, None, None, local_file)
> -
> - def zoom_in(self):
> - contentViewer = self.doc_shell.queryInterface( \
> - interfaces.nsIDocShell).contentViewer
> - if contentViewer is not None:
> - markupDocumentViewer = contentViewer.queryInterface( \
> - interfaces.nsIMarkupDocumentViewer)
> - markupDocumentViewer.fullZoom += _ZOOM_AMOUNT
> -
> - def zoom_out(self):
> - contentViewer = self.doc_shell.queryInterface( \
> - interfaces.nsIDocShell).contentViewer
> - if contentViewer is not None:
> - markupDocumentViewer = contentViewer.queryInterface( \
> - interfaces.nsIMarkupDocumentViewer)
> - markupDocumentViewer.fullZoom -= _ZOOM_AMOUNT
> -
> def get_history_index(self):
> - return self.web_navigation.sessionHistory.index
> + return 0 # FIXME
>
> def set_history_index(self, index):
> - if index == -1:
> - return
> - self.web_navigation.gotoIndex(index)
> + pass # FIXME
>
> def open_new_tab(self, url):
> self.emit('new-tab', url)
> @@ -499,7 +324,7 @@ class PopupDialog(Gtk.Window):
> self.set_default_size(Gdk.Screen.width() - border * 2,
> Gdk.Screen.height() - border * 2)
>
> - self.view = WebView()
> + self.view = WebKit.WebView()
> self.view.connect('notify::visibility', self.__notify_visibility_cb)
> self.add(self.view)
> self.view.realize()
> diff --git a/downloadmanager.py b/downloadmanager.py
> index 0a8d2b2..835d198 100644
> --- a/downloadmanager.py
> +++ b/downloadmanager.py
> @@ -17,25 +17,9 @@
>
> import os
> import logging
> -from gettext import gettext as _
> import time
> -import tempfile
> -
> -from gi.repository import Gtk
> -import hulahop
> -import xpcom
> -from xpcom.nsError import *
> -from xpcom import components
> -from xpcom.components import interfaces
> -from xpcom.server.factory import Factory
> -
> -from sugar.datastore import datastore
> -from sugar import profile
> -from sugar import mime
> -from sugar.graphics.alert import Alert, TimeoutAlert
> -from sugar.graphics.icon import Icon
> -from sugar.graphics import style
> -from sugar.activity import activity
> +
> +from sugar3.activity import activity
> # #3903 - this constant can be removed and assumed to be 1 when dbus-python
> # 0.82.3 is the only version used
> import dbus
> @@ -69,11 +53,12 @@ def num_downloads():
>
>
> def remove_all_downloads():
> - for download in _active_downloads:
> - download.cancelable.cancel(NS_ERROR_FAILURE)
> - if download.dl_jobject is not None:
> - datastore.delete(download.dl_jobject.object_id)
> - download.cleanup()
> + pass # FIXME
> + # for download in _active_downloads:
> + # download.cancelable.cancel(NS_ERROR_FAILURE)
> + # if download.dl_jobject is not None:
> + # datastore.delete(download.dl_jobject.object_id)
> + # download.cleanup()
>
> def remove_old_parts():
> temp_path = os.path.join(activity.get_activity_root(), 'instance')
> @@ -85,387 +70,95 @@ def remove_old_parts():
> logging.debug('removing %s' % file_full_path)
> os.remove(file_full_path)
>
> -class HelperAppLauncherDialog:
> - _com_interfaces_ = interfaces.nsIHelperAppLauncherDialog
> -
> - def promptForSaveToFile(self, launcher, window_context,
> - default_file, suggested_file_extension,
> - force_prompt=False):
> - file_class = components.classes['@mozilla.org/file/local;1']
> - dest_file = file_class.createInstance(interfaces.nsILocalFile)
> -
> - if default_file:
> - default_file = default_file.encode('utf-8', 'replace')
> - base_name, extension = os.path.splitext(default_file)
> - else:
> - base_name = ''
> - if suggested_file_extension:
> - extension = '.' + suggested_file_extension
> - else:
> - extension = ''
> -
> - temp_path = os.path.join(activity.get_activity_root(), 'instance')
> - if not os.path.exists(temp_path):
> - os.makedirs(temp_path)
> - fd, file_path = tempfile.mkstemp(dir=temp_path, prefix=base_name,
> - suffix=extension)
> - os.close(fd)
> - os.chmod(file_path, 0644)
> - dest_file.initWithPath(file_path)
> -
> - interface_id = interfaces.nsIInterfaceRequestor
> - requestor = window_context.queryInterface(interface_id)
> - dom_window = requestor.getInterface(interfaces.nsIDOMWindow)
> - _dest_to_window[file_path] = dom_window
> -
> - return dest_file
> -
> - def show(self, launcher, context, reason):
> - launcher.saveToDisk(None, False)
> - return NS_OK
> -
> -
> -components.registrar.registerFactory('{64355793-988d-40a5-ba8e-fcde78cac631}',
> - 'Sugar Download Manager',
> - '@mozilla.org/helperapplauncherdialog;1',
> - Factory(HelperAppLauncherDialog))
> -
> -
> -class Download:
> - _com_interfaces_ = interfaces.nsITransfer
> -
> - def init(self, source, target, display_name, mime_info, start_time,
> - temp_file, cancelable):
> - self._source = source
> - self._mime_type = mime_info.MIMEType
> - self._temp_file = temp_file
> - self._target_file = target.queryInterface(interfaces.nsIFileURL).file
> - self._display_name = display_name
> - self.cancelable = cancelable
> - self.datastore_deleted_handler = None
> -
> - self.dl_jobject = None
> - self._object_id = None
> - self._last_update_time = 0
> - self._last_update_percent = 0
> - self._stop_alert = None
> -
> - file_path = self._target_file.path.encode('utf-8', 'replace')
> - dom_window = _dest_to_window[file_path]
> - del _dest_to_window[file_path]
> -
> - view = hulahop.get_view_for_window(dom_window)
> - logging.debug('Download.init dom_window: %r', dom_window)
> - self._activity = view.get_toplevel()
> -
> - return NS_OK
> -
> - def onStatusChange(self, web_progress, request, status, message):
> - logging.info('Download.onStatusChange(%r, %r, %r, %r)',
> - web_progress, request, status, message)
> -
> - def onStateChange(self, web_progress, request, state_flags, status):
> - if state_flags& interfaces.nsIWebProgressListener.STATE_START:
> - self._create_journal_object()
> - self._object_id = self.dl_jobject.object_id
> -
> - alert = TimeoutAlert(9)
> - alert.props.title = _('Download started')
> - alert.props.msg = self._get_file_name()
> - self._activity.add_alert(alert)
> - alert.connect('response', self.__start_response_cb)
> - alert.show()
> - global _active_downloads
> - _active_downloads.append(self)
> -
> - elif state_flags& interfaces.nsIWebProgressListener.STATE_STOP:
> - if NS_FAILED(status):
> - # download cancelled
> - self.cleanup()
> - return
> -
> - self._stop_alert = Alert()
> - self._stop_alert.props.title = _('Download completed')
> - self._stop_alert.props.msg = self._get_file_name()
> - open_icon = Icon(icon_name='zoom-activity')
> - self._stop_alert.add_button(Gtk.ResponseType.APPLY,
> - _('Show in Journal'), open_icon)
> - open_icon.show()
> - ok_icon = Icon(icon_name='dialog-ok')
> - self._stop_alert.add_button(Gtk.ResponseType.OK, _('Ok'), ok_icon)
> - ok_icon.show()
> - self._activity.add_alert(self._stop_alert)
> - self._stop_alert.connect('response', self.__stop_response_cb)
> - self._stop_alert.show()
> -
> - self.dl_jobject.metadata['title'] = self._get_file_name()
> - self.dl_jobject.metadata['description'] = _('From: %s') \
> - % self._source.spec
> - self.dl_jobject.metadata['progress'] = '100'
> - self.dl_jobject.file_path = self._target_file.path
> -
> - if self._mime_type in ['application/octet-stream',
> - 'application/x-zip']:
> - sniffed_mime_type = mime.get_for_file(self._target_file.path)
> - self.dl_jobject.metadata['mime_type'] = sniffed_mime_type
> -
> - if self._check_image_mime_type():
> - self.dl_jobject.metadata['preview'] = self._get_preview_image()
> -
> - datastore.write(self.dl_jobject,
> - transfer_ownership=True,
> - reply_handler=self._internal_save_cb,
> - error_handler=self._internal_save_error_cb,
> - timeout=360 * DBUS_PYTHON_TIMEOUT_UNITS_PER_SECOND)
> -
> - def _check_image_mime_type(self):
> - for pixbuf_format in GdkPixbuf.Pixbuf.get_formats():
> - if self._mime_type in pixbuf_format['mime_types']:
> - return True
> - return False
> -
> - def _get_preview_image(self):
> - preview_width, preview_height = style.zoom(300), style.zoom(225)
> -
> - pixbuf = GdkPixbuf.Pixbuf.new_from_file(self._target_file.path)
> - width, height = pixbuf.get_width(), pixbuf.get_height()
> -
> - scale = 1
> - if (width> preview_width) or (height> preview_height):
> - scale_x = preview_width / float(width)
> - scale_y = preview_height / float(height)
> - scale = min(scale_x, scale_y)
> -
> - pixbuf2 = GdkPixbuf.Pixbuf(GdkPixbuf.Colorspace.RGB, \
> - pixbuf.get_has_alpha(), \
> - pixbuf.get_bits_per_sample(), \
> - preview_width, preview_height)
> - pixbuf2.fill(style.COLOR_WHITE.get_int())
> -
> - margin_x = int((preview_width - (width * scale)) / 2)
> - margin_y = int((preview_height - (height * scale)) / 2)
> -
> - pixbuf.scale(pixbuf2, margin_x, margin_y, \
> - preview_width - (margin_x * 2), \
> - preview_height - (margin_y * 2), \
> - margin_x, margin_y, scale, scale, \
> - GdkPixbuf.InterpType.BILINEAR)
> -
> - preview_data = []
> -
> - def save_func(buf, data):
> - data.append(buf)
> -
> - pixbuf2.save_to_callback(save_func, 'png', user_data=preview_data)
> - preview_data = ''.join(preview_data)
> - return dbus.ByteArray(preview_data)
> -
> - def __start_response_cb(self, alert, response_id):
> - global _active_downloads
> - if response_id is Gtk.ResponseType.CANCEL:
> - logging.debug('Download Canceled')
> - logging.debug('target_path=%r', self._target_file.path)
> - self.cancelable.cancel(NS_ERROR_FAILURE)
> - try:
> - datastore.delete(self._object_id)
> - except Exception:
> - logging.exception('Object has been deleted already')
> - self.cleanup()
> - if self._stop_alert is not None:
> - self._activity.remove_alert(self._stop_alert)
> -
> - self._activity.remove_alert(alert)
> -
> - def __stop_response_cb(self, alert, response_id):
> - global _active_downloads
> - if response_id is Gtk.ResponseType.APPLY:
> - logging.debug('Start application with downloaded object')
> - activity.show_object_in_journal(self._object_id)
> - self._activity.remove_alert(alert)
> -
> - def cleanup(self):
> - global _active_downloads
> - if self in _active_downloads:
> - _active_downloads.remove(self)
> -
> - if self.datastore_deleted_handler is not None:
> - self.datastore_deleted_handler.remove()
> - self.datastore_deleted_handler = None
> -
> - if os.path.isfile(self._target_file.path):
> - os.remove(self._target_file.path)
> - if os.path.isfile(self._target_file.path + '.part'):
> - os.remove(self._target_file.path + '.part')
> -
> - if self.dl_jobject is not None:
> - self.dl_jobject.destroy()
> - self.dl_jobject = None
> -
> - def _internal_save_cb(self):
> - self.cleanup()
> -
> - def _internal_save_error_cb(self, err):
> - logging.error('Error saving activity object to datastore: %s', err)
> - self.cleanup()
> -
> - def onProgressChange64(self, web_progress, request, cur_self_progress,
> - max_self_progress, cur_total_progress,
> - max_total_progress):
> - percent = (cur_self_progress * 100) / max_self_progress
> -
> - if (time.time() - self._last_update_time)< _MIN_TIME_UPDATE and \
> - (percent - self._last_update_percent)< _MIN_PERCENT_UPDATE:
> - return
> -
> - self._last_update_time = time.time()
> - self._last_update_percent = percent
> -
> - if percent< 100:
> - self.dl_jobject.metadata['progress'] = str(percent)
> - datastore.write(self.dl_jobject)
> -
> - def _get_file_name(self):
> - if self._display_name:
> - return self._display_name
> - elif self._source.scheme == 'data':
> - return 'Data URI'
> - else:
> - uri = self._source
> - if uri == None:
> - return ''
> - cls = components.classes['@mozilla.org/intl/texttosuburi;1']
> - texttosuburi = cls.getService(interfaces.nsITextToSubURI)
> - path = texttosuburi.unEscapeURIForUI(uri.originCharset, uri.spec)
> - location, file_name = os.path.split(path)
> - return file_name
> -
> - def _create_journal_object(self):
> - self.dl_jobject = datastore.create()
> - self.dl_jobject.metadata['title'] = \
> - _('Downloading %(file)s from \n%(source)s.') % \
> - {'file': self._get_file_name(), 'source': self._source.spec}
> -
> - self.dl_jobject.metadata['progress'] = '0'
> - self.dl_jobject.metadata['keep'] = '0'
> - self.dl_jobject.metadata['buddies'] = ''
> - self.dl_jobject.metadata['preview'] = ''
> - self.dl_jobject.metadata['icon-color'] = \
> - profile.get_color().to_string()
> - self.dl_jobject.metadata['mime_type'] = self._mime_type
> - self.dl_jobject.file_path = ''
> - datastore.write(self.dl_jobject)
> -
> - bus = dbus.SessionBus()
> - obj = bus.get_object(DS_DBUS_SERVICE, DS_DBUS_PATH)
> - datastore_dbus = dbus.Interface(obj, DS_DBUS_INTERFACE)
> - self.datastore_deleted_handler = datastore_dbus.connect_to_signal(
> - 'Deleted', self.__datastore_deleted_cb,
> - arg0=self.dl_jobject.object_id)
> -
> - def __datastore_deleted_cb(self, uid):
> - logging.debug('Downloaded entry has been deleted from the data'
> - ' store: %r', uid)
> - global _active_downloads
> - if self in _active_downloads:
> - # TODO: Use NS_BINDING_ABORTED instead of NS_ERROR_FAILURE.
> - self.cancelable.cancel(NS_ERROR_FAILURE)
> - self.cleanup()
> -
> -
> -components.registrar.registerFactory('{23c51569-e9a1-4a92-adeb-3723db82ef7c}',
> - 'Sugar Download',
> - '@mozilla.org/transfer;1',
> - Factory(Download))
> -
> -
> def save_link(url, text, owner_document):
> - # Inspired on Firefox' browser/base/content/nsContextMenu.js:saveLink()
> -
> - cls = components.classes["@mozilla.org/network/io-service;1"]
> - io_service = cls.getService(interfaces.nsIIOService)
> - uri = io_service.newURI(url, None, None)
> - channel = io_service.newChannelFromURI(uri)
> -
> - auth_prompt_callback = xpcom.server.WrapObject(
> - _AuthPromptCallback(owner_document.defaultView),
> - interfaces.nsIInterfaceRequestor)
> - channel.notificationCallbacks = auth_prompt_callback
> -
> - channel.loadFlags = channel.loadFlags | \
> - interfaces.nsIRequest.LOAD_BYPASS_CACHE | \
> - interfaces.nsIChannel.LOAD_CALL_CONTENT_SNIFFERS
> -
> - # HACK: when we QI for nsIHttpChannel on objects that implement
> - # just nsIChannel, pyxpcom gets confused trac #1029
> - if uri.scheme == 'http':
> - if _implements_interface(channel, interfaces.nsIHttpChannel):
> - channel.referrer = io_service.newURI(owner_document.documentURI,
> - None, None)
> -
> - # kick off the channel with our proxy object as the listener
> - listener = xpcom.server.WrapObject(
> - _SaveLinkProgressListener(owner_document),
> - interfaces.nsIStreamListener)
> - channel.asyncOpen(listener, None)
> -
> -
> -def _implements_interface(obj, interface):
> - try:
> - obj.QueryInterface(interface)
> - return True
> - except xpcom.Exception, e:
> - if e.errno == NS_NOINTERFACE:
> - return False
> - else:
> - raise
> -
> -
> -class _AuthPromptCallback(object):
> - _com_interfaces_ = interfaces.nsIInterfaceRequestor
> -
> - def __init__(self, dom_window):
> - self._dom_window = dom_window
> -
> - def getInterface(self, uuid):
> - if uuid in [interfaces.nsIAuthPrompt, interfaces.nsIAuthPrompt2]:
> - cls = components.classes["@mozilla.org/embedcomp/window-watcher;1"]
> - window_watcher = cls.getService(interfaces.nsIPromptFactory)
> - return window_watcher.getPrompt(self._dom_window, uuid)
> - return None
> -
> -
> -class _SaveLinkProgressListener(object):
> - _com_interfaces_ = interfaces.nsIStreamListener
> -
> - """ an object to proxy the data through to
> - nsIExternalHelperAppService.doContent, which will wait for the appropriate
> - MIME-type headers and then prompt the user with a file picker
> - """
> -
> - def __init__(self, owner_document):
> - self._owner_document = owner_document
> - self._external_listener = None
> -
> - def onStartRequest(self, request, context):
> - if request.status != NS_OK:
> - logging.error("Error downloading link")
> - return
> -
> - class_name = '@mozilla.org/uriloader/external-helper-app-service;1'
> - cls = components.classes[class_name]
> - interface_id = interfaces.nsIExternalHelperAppService
> - external_helper = cls.getService(interface_id)
> -
> - channel = request.QueryInterface(interfaces.nsIChannel)
> -
> - self._external_listener = \
> - external_helper.doContent(channel.contentType, request,
> - self._owner_document.defaultView, True)
> - self._external_listener.onStartRequest(request, context)
> -
> - def onStopRequest(self, request, context, statusCode):
> - self._external_listener.onStopRequest(request, context, statusCode)
> -
> - def onDataAvailable(self, request, context, inputStream, offset, count):
> - self._external_listener.onDataAvailable(request, context, inputStream,
> - offset, count)
> + pass # FIXME
> + # # Inspired on Firefox' browser/base/content/nsContextMenu.js:saveLink()
> +
> + # cls = components.classes["@mozilla.org/network/io-service;1"]
> + # io_service = cls.getService(interfaces.nsIIOService)
> + # uri = io_service.newURI(url, None, None)
> + # channel = io_service.newChannelFromURI(uri)
> +
> + # auth_prompt_callback = xpcom.server.WrapObject(
> + # _AuthPromptCallback(owner_document.defaultView),
> + # interfaces.nsIInterfaceRequestor)
> + # channel.notificationCallbacks = auth_prompt_callback
> +
> + # channel.loadFlags = channel.loadFlags | \
> + # interfaces.nsIRequest.LOAD_BYPASS_CACHE | \
> + # interfaces.nsIChannel.LOAD_CALL_CONTENT_SNIFFERS
> +
> + # # HACK: when we QI for nsIHttpChannel on objects that implement
> + # # just nsIChannel, pyxpcom gets confused trac #1029
> + # if uri.scheme == 'http':
> + # if _implements_interface(channel, interfaces.nsIHttpChannel):
> + # channel.referrer = io_service.newURI(owner_document.documentURI,
> + # None, None)
> +
> + # # kick off the channel with our proxy object as the listener
> + # listener = xpcom.server.WrapObject(
> + # _SaveLinkProgressListener(owner_document),
> + # interfaces.nsIStreamListener)
> + # channel.asyncOpen(listener, None)
> +
> +
> +# def _implements_interface(obj, interface):
> +# try:
> +# obj.QueryInterface(interface)
> +# return True
> +# except xpcom.Exception, e:
> +# if e.errno == NS_NOINTERFACE:
> +# return False
> +# else:
> +# raise
> +
> +
> +# class _AuthPromptCallback(object):
> +# _com_interfaces_ = interfaces.nsIInterfaceRequestor
> +
> +# def __init__(self, dom_window):
> +# self._dom_window = dom_window
> +
> +# def getInterface(self, uuid):
> +# if uuid in [interfaces.nsIAuthPrompt, interfaces.nsIAuthPrompt2]:
> +# cls = components.classes["@mozilla.org/embedcomp/window-watcher;1"]
> +# window_watcher = cls.getService(interfaces.nsIPromptFactory)
> +# return window_watcher.getPrompt(self._dom_window, uuid)
> +# return None
> +
> +
> +# class _SaveLinkProgressListener(object):
> +# _com_interfaces_ = interfaces.nsIStreamListener
> +
> +# """ an object to proxy the data through to
> +# nsIExternalHelperAppService.doContent, which will wait for the appropriate
> +# MIME-type headers and then prompt the user with a file picker
> +# """
> +
> +# def __init__(self, owner_document):
> +# self._owner_document = owner_document
> +# self._external_listener = None
> +
> +# def onStartRequest(self, request, context):
> +# if request.status != NS_OK:
> +# logging.error("Error downloading link")
> +# return
> +
> +# class_name = '@mozilla.org/uriloader/external-helper-app-service;1'
> +# cls = components.classes[class_name]
> +# interface_id = interfaces.nsIExternalHelperAppService
> +# external_helper = cls.getService(interface_id)
> +
> +# channel = request.QueryInterface(interfaces.nsIChannel)
> +
> +# self._external_listener = \
> +# external_helper.doContent(channel.contentType, request,
> +# self._owner_document.defaultView, True)
> +# self._external_listener.onStartRequest(request, context)
> +
> +# def onStopRequest(self, request, context, statusCode):
> +# self._external_listener.onStopRequest(request, context, statusCode)
> +
> +# def onDataAvailable(self, request, context, inputStream, offset, count):
> +# self._external_listener.onDataAvailable(request, context, inputStream,
> +# offset, count)
> diff --git a/edittoolbar.py b/edittoolbar.py
> index d5f0286..9e4024b 100644
> --- a/edittoolbar.py
> +++ b/edittoolbar.py
> @@ -16,20 +16,16 @@
> # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
>
> from gi.repository import Gtk
> +from gi.repository import Gdk
> from gettext import gettext as _
>
> -from xpcom.components import interfaces
> -
> -from sugar.activity import activity
> -from sugar.graphics import iconentry
> -from sugar.graphics.toolbutton import ToolButton
> -from sugar.graphics import style
> +from sugar3.activity import activity
> +from sugar3.graphics import iconentry
> +from sugar3.graphics.toolbutton import ToolButton
> +from sugar3.graphics import style
>
>
> class EditToolbar(activity.EditToolbar):
> -
> - _com_interfaces_ = interfaces.nsIObserver
> -
> def __init__(self, act):
> activity.EditToolbar.__init__(self)
>
> @@ -102,46 +98,36 @@ class EditToolbar(activity.EditToolbar):
> self._next.show()
>
> def __undo_cb(self, button):
> - command_manager = self._get_command_manager()
> - command_manager.doCommand('cmd_undo', None, None)
> + pass # FIXME
>
> def __redo_cb(self, button):
> - command_manager = self._get_command_manager()
> - command_manager.doCommand('cmd_redo', None, None)
> + pass # FIXME
>
> def __copy_cb(self, button):
> - command_manager = self._get_command_manager()
> - command_manager.doCommand('cmd_copy', None, None)
> + pass # FIXME
>
> def __paste_cb(self, button):
> - command_manager = self._get_command_manager()
> - command_manager.doCommand('cmd_paste', None, None)
> -
> - def _get_command_manager(self):
> - tabbed_view = self._activity.get_canvas()
> - web_browser = tabbed_view.props.current_browser.browser
> - interface_id = interfaces.nsIInterfaceRequestor
> - requestor = web_browser.queryInterface(interface_id)
> - return requestor.getInterface(interfaces.nsICommandManager)
> + pass # FIXME
>
> def __search_entry_activate_cb(self, entry):
> tabbed_view = self._activity.get_canvas()
> tabbed_view.props.current_browser.typeahead.findAgain(False, False)
>
> def __search_entry_changed_cb(self, entry):
> - tabbed_view = self._activity.get_canvas()
> - found = tabbed_view.props.current_browser.typeahead.find( \
> - entry.props.text, False)
> - if found == interfaces.nsITypeAheadFind.FIND_NOTFOUND:
> - self._prev.props.sensitive = False
> - self._next.props.sensitive = False
> - entry.modify_text(Gtk.StateType.NORMAL,
> - style.COLOR_BUTTON_GREY.get_gdk_color())
> - else:
> - self._prev.props.sensitive = True
> - self._next.props.sensitive = True
> - entry.modify_text(Gtk.StateType.NORMAL,
> - style.COLOR_BLACK.get_gdk_color())
> + pass # FIXME
> + # tabbed_view = self._activity.get_canvas()
> + # found = tabbed_view.props.current_browser.typeahead.find( \
> + # entry.props.text, False)
> + # if found == interfaces.nsITypeAheadFind.FIND_NOTFOUND:
> + # self._prev.props.sensitive = False
> + # self._next.props.sensitive = False
> + # entry.modify_text(Gtk.StateType.NORMAL,
> + # style.COLOR_BUTTON_GREY.get_gdk_color())
> + # else:
> + # self._prev.props.sensitive = True
> + # self._next.props.sensitive = True
> + # entry.modify_text(Gtk.StateType.NORMAL,
> + # style.COLOR_BLACK.get_gdk_color())
>
> def __find_previous_cb(self, button):
> tabbed_view = self._activity.get_canvas()
> diff --git a/filepicker.py b/filepicker.py
> deleted file mode 100644
> index a06e879..0000000
> --- a/filepicker.py
> +++ /dev/null
> @@ -1,166 +0,0 @@
> -# Copyright (C) 2007, One Laptop Per Child
> -#
> -# This program is free software; you can redistribute it and/or modify
> -# it under the terms of the GNU General Public License as published by
> -# the Free Software Foundation; either version 2 of the License, or
> -# (at your option) any later version.
> -#
> -# This program is distributed in the hope that it will be useful,
> -# but WITHOUT ANY WARRANTY; without even the implied warranty of
> -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> -# GNU General Public License for more details.
> -#
> -# You should have received a copy of the GNU General Public License
> -# along with this program; if not, write to the Free Software
> -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> -
> -import logging
> -import os
> -import tempfile
> -import shutil
> -
> -from gi.repository import Gtk
> -import hulahop
> -
> -import xpcom
> -from xpcom import components
> -from xpcom.components import interfaces
> -from xpcom.server.factory import Factory
> -
> -from sugar.graphics.objectchooser import ObjectChooser
> -from sugar.activity.activity import get_activity_root
> -
> -
> -_temp_dirs_to_clean = []
> -
> -
> -def cleanup_temp_files():
> - while _temp_dirs_to_clean:
> - temp_dir = _temp_dirs_to_clean.pop()
> - if os.path.isdir(temp_dir):
> - shutil.rmtree(temp_dir, ignore_errors=True)
> - else:
> - logging.debug('filepicker.cleanup_temp_files: no file %r',
> - temp_dir)
> -
> -
> -class FilePicker:
> - _com_interfaces_ = interfaces.nsIFilePicker
> -
> - cid = '{57901c41-06cb-4b9e-8258-37323327b583}'
> - description = 'Sugar File Picker'
> -
> - def __init__(self):
> - self._title = None
> - self._parent = None
> - self._file = None
> -
> - def appendFilter(self, title, filter):
> - logging.warning('FilePicker.appendFilter: UNIMPLEMENTED')
> -
> - def appendFilters(self, filterMask):
> - logging.warning('FilePicker.appendFilters: UNIMPLEMENTED')
> -
> - def init(self, parent, title, mode):
> - self._title = title
> - self._file = None
> - self._parent = hulahop.get_view_for_window(parent).get_toplevel()
> -
> - if mode != interfaces.nsIFilePicker.modeOpen:
> - raise xpcom.COMException(NS_ERROR_NOT_IMPLEMENTED)
> -
> - def show(self):
> - chooser = ObjectChooser(parent=self._parent)
> - jobject = None
> - try:
> - result = chooser.run()
> - if result == Gtk.ResponseType.ACCEPT:
> - jobject = chooser.get_selected_object()
> - logging.debug('FilePicker.show: %r', jobject)
> -
> - if jobject and jobject.file_path:
> - tmp_dir = tempfile.mkdtemp(prefix='', \
> - dir=os.path.join(get_activity_root(), 'tmp'))
> - self._file = os.path.join(tmp_dir,
> - _basename_strip(jobject))
> -
> - os.rename(jobject.file_path, self._file)
> -
> - global _temp_dirs_to_clean
> - _temp_dirs_to_clean.append(tmp_dir)
> -
> - logging.debug('FilePicker.show: file=%r', self._file)
> - finally:
> - if jobject is not None:
> - jobject.destroy()
> - chooser.destroy()
> - del chooser
> -
> - if self._file:
> - return interfaces.nsIFilePicker.returnOK
> - else:
> - return interfaces.nsIFilePicker.returnCancel
> -
> - def set_defaultExtension(self, default_extension):
> - logging.warning('FilePicker.set_defaultExtension: UNIMPLEMENTED')
> -
> - def get_defaultExtension(self):
> - logging.warning('FilePicker.get_defaultExtension: UNIMPLEMENTED')
> - return None
> -
> - def set_defaultString(self, default_string):
> - logging.warning('FilePicker.set_defaultString: UNIMPLEMENTED')
> -
> - def get_defaultString(self):
> - logging.warning('FilePicker.get_defaultString: UNIMPLEMENTED')
> - return None
> -
> - def set_displayDirectory(self, display_directory):
> - logging.warning('FilePicker.set_displayDirectory: UNIMPLEMENTED')
> -
> - def get_displayDirectory(self):
> - logging.warning('FilePicker.get_displayDirectory: UNIMPLEMENTED')
> - return None
> -
> - def set_filterIndex(self, filter_index):
> - logging.warning('FilePicker.set_filterIndex: UNIMPLEMENTED')
> -
> - def get_filterIndex(self):
> - logging.warning('FilePicker.get_filterIndex: UNIMPLEMENTED')
> - return None
> -
> - def get_file(self):
> - logging.debug('FilePicker.get_file: %r', self._file)
> - if self._file:
> - cls = components.classes["@mozilla.org/file/local;1"]
> - local_file = cls.createInstance(interfaces.nsILocalFile)
> - local_file.initWithPath(self._file)
> - return local_file
> - else:
> - return None
> -
> - def get_Files(self):
> - logging.warning('FilePicker.get_Files: UNIMPLEMENTED')
> - return None
> -
> - def get_FileURL(self):
> - logging.warning('FilePicker.get_FileURL: UNIMPLEMENTED')
> - return None
> -
> -
> -components.registrar.registerFactory(FilePicker.cid,
> - FilePicker.description,
> - '@mozilla.org/filepicker;1',
> - Factory(FilePicker))
> -
> -
> -def _basename_strip(jobject):
> - name = jobject.metadata.get('title', 'untitled')
> - name = name.replace(os.sep, ' ').strip()
> -
> - root_, mime_extension = os.path.splitext(jobject.file_path)
> -
> - if not name.endswith(mime_extension):
> - name += mime_extension
> -
> - return name
> diff --git a/globalhistory.py b/globalhistory.py
> deleted file mode 100644
> index 1ec0a72..0000000
> --- a/globalhistory.py
> +++ /dev/null
> @@ -1,80 +0,0 @@
> -# Copyright (C) 2008, Red Hat, Inc.
> -#
> -# This program is free software; you can redistribute it and/or modify
> -# it under the terms of the GNU General Public License as published by
> -# the Free Software Foundation; either version 2 of the License, or
> -# (at your option) any later version.
> -#
> -# This program is distributed in the hope that it will be useful,
> -# but WITHOUT ANY WARRANTY; without even the implied warranty of
> -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> -# GNU General Public License for more details.
> -#
> -# You should have received a copy of the GNU General Public License
> -# along with this program; if not, write to the Free Software
> -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> -
> -from datetime import datetime
> -
> -from xpcom import components
> -from xpcom.components import interfaces
> -from xpcom.server.factory import Factory
> -
> -import places
> -
> -
> -class GlobalHistory:
> - _com_interfaces_ = interfaces.nsIGlobalHistory, \
> - interfaces.nsIGlobalHistory2, \
> - interfaces.nsIGlobalHistory3
> -
> - cid = '{2a53cf28-c48e-4a01-ba18-3d3fef3e2985}'
> - description = 'Sugar Global History'
> -
> - def __init__(self):
> - self._store = places.get_store()
> -
> - def addPage(self, url):
> - self.addURI(url, False, True, None)
> -
> - def isVisited(self, uri):
> - place = self._store.lookup_place(uri.spec)
> - return place != None
> -
> - def addURI(self, uri, redirect, toplevel, referrer):
> - place = self._store.lookup_place(uri.spec)
> - if place:
> - place.visits += 1
> - place.last_visit = datetime.now()
> - self._store.update_place(place)
> - else:
> - place = places.Place(uri.spec)
> - self._store.add_place(place)
> -
> - def setPageTitle(self, uri, title):
> - place = self._store.lookup_place(uri.spec)
> - if place:
> - place.title = title
> - self._store.update_place(place)
> -
> - def addDocumentRedirect(self, old_channel, new_channel, flags, toplevel):
> - pass
> -
> - def getURIGeckoFlags(self, uri):
> - place = self._store.lookup_place(uri.spec)
> - if place:
> - return place.gecko_flags
> - else:
> - return 0
> -
> - def setURIGeckoFlags(self, uri, flags):
> - place = self._store.lookup_place(uri.spec)
> - if place:
> - place.gecko_flags = flags
> - self._store.update_place(place)
> -
> -
> -components.registrar.registerFactory(GlobalHistory.cid,
> - GlobalHistory.description,
> - '@mozilla.org/browser/global-history;2',
> - Factory(GlobalHistory))
> diff --git a/linkbutton.py b/linkbutton.py
> index 49f6451..bf2456e 100644
> --- a/linkbutton.py
> +++ b/linkbutton.py
> @@ -18,14 +18,15 @@
> from gi.repository import Gtk
> import os
> from gi.repository import GObject
> +from gi.repository import GdkPixbuf
> from gettext import gettext as _
> import rsvg
> import re
> import gc
>
> -from sugar.graphics.palette import Palette
> -from sugar.graphics.tray import TrayButton
> -from sugar.graphics import style
> +from sugar3.graphics.palette import Palette
> +from sugar3.graphics.tray import TrayButton
> +from sugar3.graphics import style
>
>
> class LinkButton(TrayButton, GObject.GObject):
> diff --git a/palettes.py b/palettes.py
> index 5c8f242..49e319a 100644
> --- a/palettes.py
> +++ b/palettes.py
> @@ -22,22 +22,17 @@ from gettext import gettext as _
>
> from gi.repository import Gtk
> from gi.repository import GObject
> -import xpcom
> -from xpcom import components
> -from xpcom.components import interfaces
>
> -from sugar.graphics.palette import Palette, Invoker
> -from sugar.graphics.menuitem import MenuItem
> -from sugar.graphics.icon import Icon
> -from sugar import profile
> -from sugar.activity import activity
> +from sugar3.graphics.palette import Palette, Invoker
> +from sugar3.graphics.menuitem import MenuItem
> +from sugar3.graphics.icon import Icon
> +from sugar3 import profile
> +from sugar3.activity import activity
>
> import downloadmanager
>
>
> class MouseOutListener(GObject.GObject):
> - _com_interfaces_ = interfaces.nsIDOMEventListener
> -
> __gsignals__ = {
> 'mouse-out': (GObject.SignalFlags.RUN_FIRST,
> None,
> @@ -53,8 +48,6 @@ class MouseOutListener(GObject.GObject):
>
>
> class ContentInvoker(Invoker):
> - _com_interfaces_ = interfaces.nsIDOMEventListener
> -
> def __init__(self, browser):
> Invoker.__init__(self)
> self._position_hint = self.AT_CURSOR
> @@ -108,21 +101,23 @@ class ContentInvoker(Invoker):
> 'popdown', self.__palette_popdown_cb)
>
> self._mouseout_listener = MouseOutListener(target)
> - wrapper = xpcom.server.WrapObject(self._mouseout_listener,
> - interfaces.nsIDOMEventListener)
> - target.addEventListener('mouseout', wrapper, False)
> + # FIXME
> + # wrapper = xpcom.server.WrapObject(self._mouseout_listener,
> + # interfaces.nsIDOMEventListener)
> + # target.addEventListener('mouseout', wrapper, False)
> self._mouseout_listener.connect('mouse-out', self.__moved_out_cb)
>
> def __moved_out_cb(self, listener):
> self.palette.popdown()
>
> def __palette_popdown_cb(self, palette):
> - if self._mouseout_listener is not None:
> - wrapper = xpcom.server.WrapObject(self._mouseout_listener,
> - interfaces.nsIDOMEventListener)
> - self._mouseout_listener.target.removeEventListener('mouseout',
> - wrapper, False)
> - del self._mouseout_listener
> + pass # FIXME
> + # if self._mouseout_listener is not None:
> + # wrapper = xpcom.server.WrapObject(self._mouseout_listener,
> + # interfaces.nsIDOMEventListener)
> + # self._mouseout_listener.target.removeEventListener('mouseout',
> + # wrapper, False)
> + # del self._mouseout_listener
>
>
> class LinkPalette(Palette):
> @@ -246,29 +241,30 @@ class ImagePalette(Palette):
> os.close(fd)
> os.chmod(temp_file, 0664)
>
> - cls = components.classes['@mozilla.org/network/io-service;1']
> - io_service = cls.getService(interfaces.nsIIOService)
> - uri = io_service.newURI(self._url, None, None)
> + # FIXME
> + # cls = components.classes['@mozilla.org/network/io-service;1']
> + # io_service = cls.getService(interfaces.nsIIOService)
> + # uri = io_service.newURI(self._url, None, None)
>
> - cls = components.classes['@mozilla.org/file/local;1']
> - target_file = cls.createInstance(interfaces.nsILocalFile)
> - target_file.initWithPath(temp_file)
> + # cls = components.classes['@mozilla.org/file/local;1']
> + # target_file = cls.createInstance(interfaces.nsILocalFile)
> + # target_file.initWithPath(temp_file)
>
> - cls = components.classes[ \
> - '@mozilla.org/embedding/browser/nsWebBrowserPersist;1']
> - persist = cls.createInstance(interfaces.nsIWebBrowserPersist)
> - persist.persistFlags = 1 # PERSIST_FLAGS_FROM_CACHE
> - listener = xpcom.server.WrapObject(_ImageProgressListener(temp_file),
> - interfaces.nsIWebProgressListener)
> - persist.progressListener = listener
> - persist.saveURI(uri, None, None, None, None, target_file)
> + # cls = components.classes[ \
> + # '@mozilla.org/embedding/browser/nsWebBrowserPersist;1']
> + # persist = cls.createInstance(interfaces.nsIWebBrowserPersist)
> + # persist.persistFlags = 1 # PERSIST_FLAGS_FROM_CACHE
> + # listener = xpcom.server.WrapObject(_ImageProgressListener(temp_file),
> + # interfaces.nsIWebProgressListener)
> + # persist.progressListener = listener
> + # persist.saveURI(uri, None, None, None, None, target_file)
>
> def __download_activate_cb(self, menu_item):
> downloadmanager.save_link(self._url, self._title, self._owner_document)
>
>
> class _ImageProgressListener(object):
> - _com_interfaces_ = interfaces.nsIWebProgressListener
> +# _com_interfaces_ = interfaces.nsIWebProgressListener
>
> def __init__(self, temp_file):
> self._temp_file = temp_file
> @@ -287,13 +283,14 @@ class _ImageProgressListener(object):
> pass
>
> def onStateChange(self, webProgress, request, stateFlags, status):
> - if (stateFlags& interfaces.nsIWebProgressListener.STATE_IS_REQUEST and
> - stateFlags& interfaces.nsIWebProgressListener.STATE_STOP):
> - clipboard = Gtk.Clipboard()
> - clipboard.set_with_data([('text/uri-list', 0, 0)],
> - _clipboard_get_func_cb,
> - _clipboard_clear_func_cb,
> - self._temp_file)
> + pass # FIXME
> + # if (stateFlags& interfaces.nsIWebProgressListener.STATE_IS_REQUEST and
> + # stateFlags& interfaces.nsIWebProgressListener.STATE_STOP):
> + # clipboard = Gtk.Clipboard()
> + # clipboard.set_with_data([('text/uri-list', 0, 0)],
> + # _clipboard_get_func_cb,
> + # _clipboard_clear_func_cb,
> + # self._temp_file)
>
>
> def _clipboard_get_func_cb(clipboard, selection_data, info, temp_file):
> diff --git a/places.py b/places.py
> index d44d747..90956fe 100644
> --- a/places.py
> +++ b/places.py
> @@ -18,7 +18,7 @@ import os
> import sqlite3
> from datetime import datetime, timedelta
>
> -from sugar.activity import activity
> +from sugar3.activity import activity
>
> _store = None
>
> diff --git a/progresslistener.py b/progresslistener.py
> deleted file mode 100644
> index 2a78c42..0000000
> --- a/progresslistener.py
> +++ /dev/null
> @@ -1,103 +0,0 @@
> -# Copyright (C) 2006, Red Hat, Inc.
> -# Copyright (C) 2007, One Laptop Per Child
> -# Copyright (C) 2009, Tomeu Vizoso
> -#
> -# This program is free software; you can redistribute it and/or modify
> -# it under the terms of the GNU General Public License as published by
> -# the Free Software Foundation; either version 2 of the License, or
> -# (at your option) any later version.
> -#
> -# This program is distributed in the hope that it will be useful,
> -# but WITHOUT ANY WARRANTY; without even the implied warranty of
> -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> -# GNU General Public License for more details.
> -#
> -# You should have received a copy of the GNU General Public License
> -# along with this program; if not, write to the Free Software
> -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> -
> -from gi.repository import GObject
> -import xpcom
> -from xpcom.components import interfaces
> -
> -
> -class ProgressListener(GObject.GObject):
> - _com_interfaces_ = interfaces.nsIWebProgressListener
> -
> - def __init__(self):
> - GObject.GObject.__init__(self)
> -
> - self._location = None
> - self._loading = False
> - self._progress = 0.0
> - self._total_requests = 0
> - self._completed_requests = 0
> -
> - self._wrapped_self = xpcom.server.WrapObject( \
> - self, interfaces.nsIWebProgressListener)
> - weak_ref = xpcom.client.WeakReference(self._wrapped_self)
> -
> - def setup(self, browser):
> - mask = interfaces.nsIWebProgress.NOTIFY_STATE_NETWORK | \
> - interfaces.nsIWebProgress.NOTIFY_STATE_REQUEST | \
> - interfaces.nsIWebProgress.NOTIFY_LOCATION
> -
> - browser.web_progress.addProgressListener(self._wrapped_self, mask)
> -
> - def _reset_requests_count(self):
> - self._total_requests = 0
> - self._completed_requests = 0
> -
> - def onLocationChange(self, webProgress, request, location):
> - self._location = location
> - self.notify('location')
> -
> - def onProgressChange(self, webProgress, request, curSelfProgress,
> - maxSelfProgress, curTotalProgress, maxTotalProgress):
> - pass
> -
> - def onSecurityChange(self, webProgress, request, state):
> - pass
> -
> - def onStateChange(self, webProgress, request, stateFlags, status):
> - if stateFlags& interfaces.nsIWebProgressListener.STATE_IS_REQUEST:
> - if stateFlags& interfaces.nsIWebProgressListener.STATE_START:
> - self._total_requests += 1
> - elif stateFlags& interfaces.nsIWebProgressListener.STATE_STOP:
> - self._completed_requests += 1
> -
> - if stateFlags& interfaces.nsIWebProgressListener.STATE_IS_NETWORK:
> - if stateFlags& interfaces.nsIWebProgressListener.STATE_START:
> - self._loading = True
> - self._reset_requests_count()
> - self.notify('loading')
> - elif stateFlags& interfaces.nsIWebProgressListener.STATE_STOP:
> - self._loading = False
> - self.notify('loading')
> -
> - if self._total_requests< self._completed_requests:
> - self._progress = 1.0
> - elif self._total_requests> 0:
> - self._progress = \
> - self._completed_requests / float(self._total_requests)
> - else:
> - self._progress = 0.0
> - self.notify('progress')
> -
> - def onStatusChange(self, webProgress, request, status, message):
> - pass
> -
> - def _get_location(self):
> - return self._location
> -
> - location = GObject.property(type=object, getter=_get_location)
> -
> - def _get_loading(self):
> - return self._loading
> -
> - loading = GObject.property(type=bool, default=False, getter=_get_loading)
> -
> - def _get_progress(self):
> - return self._progress
> -
> - progress = GObject.property(type=float, getter=_get_progress)
> diff --git a/promptservice.py b/promptservice.py
> deleted file mode 100644
> index 31ba0da..0000000
> --- a/promptservice.py
> +++ /dev/null
> @@ -1,67 +0,0 @@
> -# Copyright (C) 2007, One Laptop Per Child
> -#
> -# This program is free software; you can redistribute it and/or modify
> -# it under the terms of the GNU General Public License as published by
> -# the Free Software Foundation; either version 2 of the License, or
> -# (at your option) any later version.
> -#
> -# This program is distributed in the hope that it will be useful,
> -# but WITHOUT ANY WARRANTY; without even the implied warranty of
> -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> -# GNU General Public License for more details.
> -#
> -# You should have received a copy of the GNU General Public License
> -# along with this program; if not, write to the Free Software
> -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> -
> -import logging
> -
> -from xpcom.components import interfaces
> -
> -
> -class PromptService:
> - _com_interfaces_ = interfaces.nsIPromptService
> -
> - cid = '{836a90cb-6304-44f0-97df-c29913b908b7}'
> - description = 'Sugar Prompt Service'
> -
> - def __init__(self):
> - pass
> -
> - def alert(self, parent, dialogTitle, text):
> - logging.debug('nsIPromptService.alert()')
> -
> - def alertCheck(self, parent, dialogTitle, text, checkMsg, checkState):
> - logging.debug('nsIPromptService.alertCheck()')
> -
> - def confirm(self, parent, dialogTitle, text):
> - logging.debug('nsIPromptService.confirm()')
> -
> - def confirmCheck(self, parent, dialogTitle, text, checkMsg, checkState):
> - logging.debug('nsIPromptService.confirmCheck()')
> -
> - def confirmEx(self, parent, dialogTitle, text, buttonFlags, button0Title,
> - button1Title, button2Title, checkMsg, checkState):
> - logging.debug('nsIPromptService.confirmEx()')
> -
> - def prompt(self, parent, dialogTitle, text, value, checkMsg, checkState):
> - logging.debug('nsIPromptService.prompt()')
> -
> - def promptPassword(self, parent, dialogTitle, text, password, checkMsg,
> - checkState):
> - logging.debug('nsIPromptService.promptPassword()')
> -
> - def promptUsernameAndPassword(self, parent, dialogTitle, text, username,
> - password, checkMsg, checkState):
> - logging.debug('nsIPromptService.promptUsernameAndPassword()')
> -
> - def select(self, parent, dialogTitle, text, count, selectList,
> - outSelection):
> - logging.debug('nsIPromptService.select()')
> -
> -
> -#components.registrar.registerFactory(
> -# PromptService.cid,
> -# PromptService.description,
> -# '@mozilla.org/embedcomp/prompt-service;1',
> -# Factory(PromptService))
> diff --git a/securitydialogs.py b/securitydialogs.py
> deleted file mode 100644
> index f3d20fb..0000000
> --- a/securitydialogs.py
> +++ /dev/null
> @@ -1,51 +0,0 @@
> -# Copyright (C) 2007, One Laptop Per Child
> -#
> -# This program is free software; you can redistribute it and/or modify
> -# it under the terms of the GNU General Public License as published by
> -# the Free Software Foundation; either version 2 of the License, or
> -# (at your option) any later version.
> -#
> -# This program is distributed in the hope that it will be useful,
> -# but WITHOUT ANY WARRANTY; without even the implied warranty of
> -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> -# GNU General Public License for more details.
> -#
> -# You should have received a copy of the GNU General Public License
> -# along with this program; if not, write to the Free Software
> -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> -
> -import logging
> -
> -from xpcom.components import interfaces
> -
> -
> -class SecurityDialogs:
> - _com_interfaces_ = interfaces.nsIBadCertListener
> -
> - cid = '{267d2fc2-1810-11dc-8314-0800200c9a66}'
> - description = 'Sugar Security Dialogs'
> -
> - def __init__(self):
> - pass
> -
> - def confirmCertExpired(socketInfo, cert):
> - logging.debug('UNIMPLEMENTED: SecurityDialogs.confirmCertExpired()')
> - return interfaces.nsIBadCertListener.ADD_TRUSTED_FOR_SESSION, True
> -
> - def confirmMismatchDomain(socketInfo, targetURL, cert):
> - logging.debug('UNIMPLEMENTED: SecurityDialogs.confirmMismatchDomain()')
> - return interfaces.nsIBadCertListener.ADD_TRUSTED_FOR_SESSION, True
> -
> - def confirmUnknownIssuer(socketInfo, cert, certAddType):
> - logging.debug('UNIMPLEMENTED: SecurityDialogs.confirmUnknownIssuer()')
> - return interfaces.nsIBadCertListener.ADD_TRUSTED_FOR_SESSION, True
> -
> - def notifyCrlNextupdate(socketInfo, targetURL, cert):
> - logging.debug('UNIMPLEMENTED: SecurityDialogs.notifyCrlNextupdate()')
> -
> -"""
> -components.registrar.registerFactory(SecurityDialogs.cid,
> - SecurityDialogs.description,
> - '@mozilla.org/nsBadCertListener;1',
> - Factory(SecurityDialogs))
> -"""
> diff --git a/sessionhistory.py b/sessionhistory.py
> index 615a98d..c369293 100644
> --- a/sessionhistory.py
> +++ b/sessionhistory.py
> @@ -17,13 +17,9 @@
> import logging
>
> from gi.repository import GObject
> -import xpcom
> -from xpcom.components import interfaces
>
>
> class HistoryListener(GObject.GObject):
> - _com_interfaces_ = interfaces.nsISHistoryListener
> -
> __gsignals__ = {
> 'session-history-changed': (GObject.SignalFlags.RUN_FIRST,
> None,
> @@ -35,10 +31,6 @@ class HistoryListener(GObject.GObject):
> def __init__(self):
> GObject.GObject.__init__(self)
>
> - self._wrapped_self = xpcom.server.WrapObject( \
> - self, interfaces.nsISHistoryListener)
> - weak_ref = xpcom.client.WeakReference(self._wrapped_self)
> -
> def setup(self, web_navigation):
> self._session_history = web_navigation.sessionHistory
> self._session_history.addSHistoryListener(self._wrapped_self)
> diff --git a/sessionstore.py b/sessionstore.py
> index 73edb24..f7a2fed 100644
> --- a/sessionstore.py
> +++ b/sessionstore.py
> @@ -19,9 +19,6 @@
>
> import logging
>
> -from xpcom import components
> -from xpcom.components import interfaces
> -
>
> def get_session(browser):
> session_history = browser.web_navigation.sessionHistory
> @@ -54,21 +51,22 @@ def _get_history(history):
>
>
> def _set_history(history, history_data):
> - history_internal = history.queryInterface(interfaces.nsISHistoryInternal)
> + pass # FIXME
> + # history_internal = history.queryInterface(interfaces.nsISHistoryInternal)
>
> - if history_internal.count> 0:
> - history_internal.purgeHistory(history_internal.count)
> + # if history_internal.count> 0:
> + # history_internal.purgeHistory(history_internal.count)
>
> - for entry_dict in history_data:
> - logging.debug('entry_dict: %r', entry_dict)
> - entry_class = components.classes[ \
> - "@mozilla.org/browser/session-history-entry;1"]
> - entry = entry_class.createInstance(interfaces.nsISHEntry)
> + # for entry_dict in history_data:
> + # logging.debug('entry_dict: %r', entry_dict)
> + # entry_class = components.classes[ \
> + # "@mozilla.org/browser/session-history-entry;1"]
> + # entry = entry_class.createInstance(interfaces.nsISHEntry)
>
> - io_service_class = components.classes[ \
> - "@mozilla.org/network/io-service;1"]
> - io_service = io_service_class.getService(interfaces.nsIIOService)
> - entry.setURI(io_service.newURI(entry_dict['url'], None, None))
> - entry.setTitle(entry_dict['title'])
> + # io_service_class = components.classes[ \
> + # "@mozilla.org/network/io-service;1"]
> + # io_service = io_service_class.getService(interfaces.nsIIOService)
> + # entry.setURI(io_service.newURI(entry_dict['url'], None, None))
> + # entry.setTitle(entry_dict['title'])
>
> - history_internal.addEntry(entry, True)
> + # history_internal.addEntry(entry, True)
> diff --git a/viewtoolbar.py b/viewtoolbar.py
> index 7f74035..7daadc9 100644
> --- a/viewtoolbar.py
> +++ b/viewtoolbar.py
> @@ -18,8 +18,9 @@
> from gettext import gettext as _
>
> from gi.repository import Gtk
> +from gi.repository import GObject
>
> -from sugar.graphics.toolbutton import ToolButton
> +from sugar3.graphics.toolbutton import ToolButton
>
>
> class ViewToolbar(Gtk.Toolbar):
> diff --git a/webactivity.py b/webactivity.py
> index cb7b351..95ac284 100644
> --- a/webactivity.py
> +++ b/webactivity.py
> @@ -22,6 +22,7 @@ from gettext import ngettext
> import os
>
> from gi.repository import GObject
> +from gi.repository import GdkPixbuf
> GObject.threads_init()
>
> from gi.repository import Gtk
> @@ -35,22 +36,23 @@ import locale
> import cairo
> from hashlib import sha1
>
> +# FIXME
> # HACK: Needed by http://dev.sugarlabs.org/ticket/456
> -import gnome
> -gnome.init('Hulahop', '1.0')
> +# import gnome
> +# gnome.init('Hulahop', '1.0')
You can remove that code, that is not needed anymore. Was a workaround
for a bug with mozilla.
> -from sugar.activity import activity
> -from sugar.graphics import style
> +from sugar3.activity import activity
> +from sugar3.graphics import style
> import telepathy
> import telepathy.client
> -from sugar.presence import presenceservice
> -from sugar.graphics.tray import HTray
> -from sugar import profile
> -from sugar.graphics.alert import Alert
> -from sugar.graphics.icon import Icon
> -from sugar import mime
> +from sugar3.presence import presenceservice
> +from sugar3.graphics.tray import HTray
> +from sugar3 import profile
> +from sugar3.graphics.alert import Alert
> +from sugar3.graphics.icon import Icon
> +from sugar3 import mime
>
> -from sugar.graphics.toolbarbox import ToolbarButton
> +from sugar3.graphics.toolbarbox import ToolbarButton
>
> PROFILE_VERSION = 2
>
> @@ -132,18 +134,12 @@ def _seed_xs_cookie():
> _logger.debug('seed_xs_cookie: Updated cookie successfully')
>
>
> -import hulahop
> -hulahop.set_app_version(os.environ['SUGAR_BUNDLE_VERSION'])
> -hulahop.startup(_profile_path)
> -
> -from xpcom import components
> -
> -
> def _set_char_preference(name, value):
> - cls = components.classes["@mozilla.org/preferences-service;1"]
> - prefService = cls.getService(components.interfaces.nsIPrefService)
> - branch = prefService.getBranch('')
> - branch.setCharPref(name, value)
> + pass # FIXME
> + # cls = components.classes["@mozilla.org/preferences-service;1"]
> + # prefService = cls.getService(components.interfaces.nsIPrefService)
> + # branch = prefService.getBranch('')
> + # branch.setCharPref(name, value)
>
>
> def _set_accept_languages():
> @@ -167,11 +163,9 @@ from viewtoolbar import ViewToolbar
> import downloadmanager
>
> # TODO: make the registration clearer SL #3087
> -import globalhistory # pylint: disable=W0611
> -import filepicker # pylint: disable=W0611
>
> from model import Model
> -from sugar.presence.tubeconn import TubeConnection
> +from sugar3.presence.tubeconn import TubeConnection
> from messenger import Messenger
> from linkbutton import LinkButton
>
> @@ -197,15 +191,16 @@ class WebActivity(activity.Activity):
> _set_accept_languages()
> _seed_xs_cookie()
>
> - # don't pick up the sugar theme - use the native mozilla one instead
> - cls = components.classes['@mozilla.org/preferences-service;1']
> - pref_service = cls.getService(components.interfaces.nsIPrefService)
> - branch = pref_service.getBranch("mozilla.widget.")
> - branch.setBoolPref("disable-native-theme", True)
> + # FIXME
> + # # don't pick up the sugar theme - use the native mozilla one instead
> + # cls = components.classes['@mozilla.org/preferences-service;1']
> + # pref_service = cls.getService(components.interfaces.nsIPrefService)
> + # branch = pref_service.getBranch("mozilla.widget.")
> + # branch.setBoolPref("disable-native-theme", True)
>
> - # Start password manager
> - cls = components.classes["@mozilla.org/login-manager;1"]
> - login_manager = cls.getService(components.interfaces.nsILoginManager)
> + # # Start password manager
> + # cls = components.classes["@mozilla.org/login-manager;1"]
> + # login_manager = cls.getService(components.interfaces.nsILoginManager)
>
> # HACK
> # Currently, the multiple tabs feature crashes the Browse activity
> @@ -501,8 +496,9 @@ class WebActivity(activity.Activity):
> elif key_name == 'Right':
> browser.web_navigation.goForward()
> elif key_name == 'r':
> - flags = components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE
> - browser.web_navigation.reload(flags)
> + pass # FIXME
> + # flags = components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE
> + # browser.web_navigation.reload(flags)
> elif Gdk.keyval_name(event.keyval) == "t":
> if not self._disable_multiple_tabs:
> self._tabbed_view.add_tab()
> @@ -629,9 +625,5 @@ class WebActivity(activity.Activity):
> downloadmanager.remove_all_downloads()
> self.close()
>
> - def get_document_path(self, async_cb, async_err_cb):
> - browser = self._tabbed_view.props.current_browser
> - browser.get_source(async_cb, async_err_cb)
> -
> def get_canvas(self):
> return self._tabbed_view
> diff --git a/webtoolbar.py b/webtoolbar.py
> index 7d5b284..4c555f9 100644
> --- a/webtoolbar.py
> +++ b/webtoolbar.py
> @@ -20,15 +20,15 @@ from gettext import gettext as _
>
> from gi.repository import GObject
> from gi.repository import Gtk
> +from gi.repository import Gdk
> from gi.repository import Pango
> -from xpcom.components import interfaces
>
> -from sugar.graphics.toolbutton import ToolButton
> -from sugar.graphics.menuitem import MenuItem
> -from sugar.graphics import iconentry
> -from sugar.graphics.toolbarbox import ToolbarBox as ToolbarBase
> -from sugar.activity.widgets import ActivityToolbarButton
> -from sugar.activity.widgets import StopButton
> +from sugar3.graphics.toolbutton import ToolButton
> +from sugar3.graphics.menuitem import MenuItem
> +from sugar3.graphics import iconentry
> +from sugar3.graphics.toolbarbox import ToolbarBox as ToolbarBase
> +from sugar3.activity.widgets import ActivityToolbarButton
> +from sugar3.activity.widgets import StopButton
>
> import filepicker
> import places
> @@ -102,7 +102,7 @@ class WebEntry(iconentry.IconEntry):
> cell.props.font = 'Bold'
> column.pack_start(cell, True)
>
> - column.set_attributes(cell, text=self._COL_TITLE)
> + column.add_attribute(cell, 'text', self._COL_TITLE)
>
> cell = Gtk.CellRendererText()
> cell.props.ellipsize = Pango.EllipsizeMode.END
> @@ -412,12 +412,13 @@ class PrimaryToolbar(ToolbarBase):
> self._set_title(embed.props.title)
>
> def _stop_and_reload_cb(self, entry, icon_pos, button):
> - browser = self._tabbed_view.props.current_browser
> - if self._loading:
> - browser.web_navigation.stop(interfaces.nsIWebNavigation.STOP_ALL)
> - else:
> - flags = interfaces.nsIWebNavigation.LOAD_FLAGS_NONE
> - browser.web_navigation.reload(flags)
> + pass # FIXME
> + # browser = self._tabbed_view.props.current_browser
> + # if self._loading:
> + # browser.web_navigation.stop(interfaces.nsIWebNavigation.STOP_ALL)
> + # else:
> + # flags = interfaces.nsIWebNavigation.LOAD_FLAGS_NONE
> + # browser.web_navigation.reload(flags)
>
> def _set_loading(self, loading):
> self._loading = loading
> diff --git a/widgets.py b/widgets.py
> index 9fc0b9f..608dbb6 100644
> --- a/widgets.py
> +++ b/widgets.py
> @@ -19,7 +19,7 @@
> from gi.repository import GObject
> from gi.repository import Gtk
>
> -from sugar.graphics.icon import Icon
> +from sugar3.graphics.icon import Icon
>
>
> class TabAdd(Gtk.HBox):
More information about the Sugar-devel
mailing list