diff options
Diffstat (limited to 'src/jarabe/journal/journalactivity.py')
-rw-r--r-- | src/jarabe/journal/journalactivity.py | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/src/jarabe/journal/journalactivity.py b/src/jarabe/journal/journalactivity.py index 0559560..a33038a 100644 --- a/src/jarabe/journal/journalactivity.py +++ b/src/jarabe/journal/journalactivity.py @@ -17,8 +17,6 @@ import logging from gettext import gettext as _ -import sys -import traceback import uuid import gtk @@ -27,6 +25,8 @@ import statvfs import os from sugar.graphics.window import Window +from sugar.graphics.alert import ErrorAlert + from sugar.bundle.bundle import ZipExtractException, RegistrationException from sugar import env from sugar.activity import activityfactory @@ -42,6 +42,8 @@ from jarabe.journal.journalentrybundle import JournalEntryBundle from jarabe.journal.objectchooser import ObjectChooser from jarabe.journal.modalalert import ModalAlert from jarabe.journal import model +from jarabe.journal.journalwindow import JournalWindow + J_DBUS_SERVICE = 'org.laptop.Journal' J_DBUS_INTERFACE = 'org.laptop.Journal' @@ -50,6 +52,9 @@ J_DBUS_PATH = '/org/laptop/Journal' _SPACE_TRESHOLD = 52428800 _BUNDLE_ID = 'org.laptop.JournalActivity' +_journal = None + + class JournalActivityDBusService(dbus.service.Object): def __init__(self, parent): self._parent = parent @@ -79,7 +84,8 @@ class JournalActivityDBusService(dbus.service.Object): chooser.destroy() del chooser - @dbus.service.method(J_DBUS_INTERFACE, in_signature='is', out_signature='s') + @dbus.service.method(J_DBUS_INTERFACE, in_signature='is', + out_signature='s') def ChooseObject(self, parent_xid, what_filter=''): chooser_id = uuid.uuid4().hex if parent_xid > 0: @@ -92,18 +98,19 @@ class JournalActivityDBusService(dbus.service.Object): return chooser_id - @dbus.service.signal(J_DBUS_INTERFACE, signature="ss") + @dbus.service.signal(J_DBUS_INTERFACE, signature='ss') def ObjectChooserResponse(self, chooser_id, object_id): pass - @dbus.service.signal(J_DBUS_INTERFACE, signature="s") + @dbus.service.signal(J_DBUS_INTERFACE, signature='s') def ObjectChooserCancelled(self, chooser_id): pass -class JournalActivity(Window): + +class JournalActivity(JournalWindow): def __init__(self): - logging.debug("STARTUP: Loading the journal") - Window.__init__(self) + logging.debug('STARTUP: Loading the journal') + JournalWindow.__init__(self) self.set_title(_('Journal')) @@ -138,6 +145,15 @@ class JournalActivity(Window): self._critical_space_alert = None self._check_available_space() + def __volume_error_cb(self, gobject, message, severity): + alert = ErrorAlert(title=severity, msg=message) + alert.connect('response', self.__alert_response_cb) + self.add_alert(alert) + alert.show() + + def __alert_response_cb(self, alert, response_id): + self.remove_alert(alert) + def __realize_cb(self, window): wm.set_bundle_id(window.window, _BUNDLE_ID) activity_id = activityfactory.create_activity_id() @@ -161,6 +177,7 @@ class JournalActivity(Window): self._volumes_toolbar = VolumesToolbar() self._volumes_toolbar.connect('volume-changed', self.__volume_changed_cb) + self._volumes_toolbar.connect('volume-error', self.__volume_error_cb) self._main_view.pack_start(self._volumes_toolbar, expand=False) search_toolbar = self._main_toolbox.search_toolbar @@ -171,7 +188,8 @@ class JournalActivity(Window): self._secondary_view = gtk.VBox() self._detail_toolbox = DetailToolbox() - entry_toolbar = self._detail_toolbox.entry_toolbar + self._detail_toolbox.entry_toolbar.connect('volume-error', + self.__volume_error_cb) self._detail_view = DetailView() self._detail_view.connect('go-back-clicked', self.__go_back_clicked_cb) @@ -210,8 +228,7 @@ class JournalActivity(Window): try: self._detail_toolbox.entry_toolbar.set_metadata(metadata) except Exception: - logging.error('Exception while displaying entry:\n' + \ - ''.join(traceback.format_exception(*sys.exc_info()))) + logging.exception('Exception while displaying entry:') self.set_toolbar_box(self._detail_toolbox) self._detail_toolbox.show() @@ -219,8 +236,7 @@ class JournalActivity(Window): try: self._detail_view.props.metadata = metadata except Exception: - logging.error('Exception while displaying entry:\n' + \ - ''.join(traceback.format_exception(*sys.exc_info()))) + logging.exception('Exception while displaying entry:') self.set_canvas(self._secondary_view) self._secondary_view.show() @@ -314,11 +330,11 @@ class JournalActivity(Window): self._list_view.set_is_visible(visible) def _check_available_space(self): - ''' Check available space on device + """Check available space on device If the available space is below 50MB an alert will be shown which encourages to delete old journal entries. - ''' + """ if self._critical_space_alert: return @@ -345,7 +361,6 @@ class JournalActivity(Window): self.show_main_view() self.search_grab_focus() -_journal = None def get_journal(): global _journal @@ -354,6 +369,6 @@ def get_journal(): _journal.show() return _journal + def start(): get_journal() - |