From: anishmangal2002 <anishmangal2...@gmail.com> volumestoolbar.py now catches the IOError exception and emits 'data-ioerror' which is caught in journalactivity.py which displayes the error as a NotifyRedAlert message.
Signed-off-by: anishmangal2002 <anishmangal2...@gmail.com> --- src/jarabe/journal/journalactivity.py | 13 +++++++++++++ src/jarabe/journal/volumestoolbar.py | 19 ++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletions(-) diff --git a/src/jarabe/journal/journalactivity.py b/src/jarabe/journal/journalactivity.py index 0559560..9536ca3 100644 --- a/src/jarabe/journal/journalactivity.py +++ b/src/jarabe/journal/journalactivity.py @@ -27,6 +27,7 @@ import statvfs import os from sugar.graphics.window import Window +from sugar.graphics.alert import NotifyRedAlert from sugar.bundle.bundle import ZipExtractException, RegistrationException from sugar import env from sugar.activity import activityfactory @@ -138,6 +139,17 @@ class JournalActivity(Window): self._critical_space_alert = None self._check_available_space() + def _alert_notify_cb(self, _volumes_toolbar, strerror): + alert = NotifyRedAlert(10) + alert.props.title=_('Alert') + alert.props.msg = _(strerror) + 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 +173,7 @@ class JournalActivity(Window): self._volumes_toolbar = VolumesToolbar() self._volumes_toolbar.connect('volume-changed', self.__volume_changed_cb) + self._volumes_toolbar.connect('data-ioerror', self._alert_notify_cb) self._main_view.pack_start(self._volumes_toolbar, expand=False) search_toolbar = self._main_toolbox.search_toolbar diff --git a/src/jarabe/journal/volumestoolbar.py b/src/jarabe/journal/volumestoolbar.py index 74b974c..33e7b88 100644 --- a/src/jarabe/journal/volumestoolbar.py +++ b/src/jarabe/journal/volumestoolbar.py @@ -35,6 +35,9 @@ class VolumesToolbar(gtk.Toolbar): __gsignals__ = { 'volume-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, + ([str])), + 'data-ioerror': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, ([str])) } @@ -81,6 +84,7 @@ class VolumesToolbar(gtk.Toolbar): button = VolumeButton(mount) button.props.group = self._volume_buttons[0] button.connect('toggled', self._button_toggled_cb) + button.connect('data-ioerror', self._data_ioerror_cb) position = self.get_item_index(self._volume_buttons[-1]) + 1 self.insert(button, position) button.show() @@ -90,6 +94,9 @@ class VolumesToolbar(gtk.Toolbar): if len(self.get_children()) > 1: self.show() + def _data_ioerror_cb(self, button, strerror): + self.emit('data-ioerror', strerror) + def _button_toggled_cb(self, button): if button.props.active: self.emit('volume-changed', button.mount_point) @@ -123,6 +130,12 @@ class VolumesToolbar(gtk.Toolbar): button.props.active = True class BaseButton(RadioToolButton): + __gsignals__ = { + 'data-ioerror': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, + ([str])) + } + def __init__(self, mount_point): RadioToolButton.__init__(self) @@ -137,7 +150,11 @@ class BaseButton(RadioToolButton): info, timestamp): object_id = selection_data.data metadata = model.get(object_id) - model.copy(metadata, self.mount_point) + try: + model.copy(metadata, self.mount_point) + except IOError as (errno, strerror): + logging.error('BaseButton._drag_data_received_cb: %s; %s' % (errno, strerror)) + self.emit('data-ioerror', strerror) class VolumeButton(BaseButton): def __init__(self, mount): -- 1.7.0.4 _______________________________________________ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel