diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2007-11-13 14:59:24 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2007-11-13 14:59:24 (GMT) |
commit | f022f98815da003e70e7b01b32fd4b54127d2d2b (patch) | |
tree | 7b0675876de9bcc56c707c0b92af8161d27a4c0b /lib | |
parent | 0aa31147dbd744e41a165b4cb45283340a069f90 (diff) |
Alert when an activity cannot be saved.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sugar/activity/activity.py | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/lib/sugar/activity/activity.py b/lib/sugar/activity/activity.py index ffbd9ec..19d67fe 100644 --- a/lib/sugar/activity/activity.py +++ b/lib/sugar/activity/activity.py @@ -50,6 +50,7 @@ import os import time import tempfile from hashlib import sha1 +import traceback import gtk, gobject import dbus @@ -63,6 +64,8 @@ from sugar.graphics.window import Window from sugar.graphics.toolbox import Toolbox from sugar.graphics.toolbutton import ToolButton from sugar.graphics.toolcombobox import ToolComboBox +from sugar.graphics.alert import Alert +from sugar.graphics.icon import Icon from sugar.datastore import datastore from sugar import wm from sugar import profile @@ -805,13 +808,38 @@ class Activity(Window, gtk.Container): self.__share_cb) self._pservice.share_activity(self, private=private) - def close(self): + def _display_keep_failed_dialog(self): + alert = Alert() + alert.props.title = _('Keep error') + alert.props.msg = _('Keep error: all changes will be lost') + + cancel_icon = Icon(icon_name='dialog-cancel') + alert.add_button(gtk.RESPONSE_CANCEL, _('Don\'t stop'), cancel_icon) + + stop_icon = Icon(icon_name='dialog-ok') + alert.add_button(gtk.RESPONSE_OK, _('Stop anyway'), stop_icon) + + self.add_alert(alert) + alert.connect('response', self._keep_failed_dialog_response_cb) + + def _keep_failed_dialog_response_cb(self, alert, response_id): + self.remove_alert(alert) + if response_id == gtk.RESPONSE_OK: + self.close(skip_save=True) + + def close(self, skip_save=False): """Request that the activity be stopped and saved to the Journal Activities should not override this method, but should implement write_file() to do any state saving instead. """ - self.save() + try: + if not skip_save: + self.save() + except: + logging.info(traceback.format_exc()) + self._display_keep_failed_dialog() + return if self._shared_activity: self._shared_activity.leave() |