Alert when an activity cannot be saved.

This commit is contained in:
Marco Pesenti Gritti 2007-11-13 15:59:24 +01:00
parent 0aa31147db
commit f022f98815
2 changed files with 32 additions and 2 deletions

2
NEWS
View File

@ -1,3 +1,5 @@
* Alert when an activity cannot be saved. (rwh)
Snapshot 47e231311b Snapshot 47e231311b
* Get rid of sound competely to be sure we don't block the device. (marco) * Get rid of sound competely to be sure we don't block the device. (marco)

View File

@ -50,6 +50,7 @@ import os
import time import time
import tempfile import tempfile
from hashlib import sha1 from hashlib import sha1
import traceback
import gtk, gobject import gtk, gobject
import dbus import dbus
@ -63,6 +64,8 @@ from sugar.graphics.window import Window
from sugar.graphics.toolbox import Toolbox from sugar.graphics.toolbox import Toolbox
from sugar.graphics.toolbutton import ToolButton from sugar.graphics.toolbutton import ToolButton
from sugar.graphics.toolcombobox import ToolComboBox 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.datastore import datastore
from sugar import wm from sugar import wm
from sugar import profile from sugar import profile
@ -805,13 +808,38 @@ class Activity(Window, gtk.Container):
self.__share_cb) self.__share_cb)
self._pservice.share_activity(self, private=private) 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 """Request that the activity be stopped and saved to the Journal
Activities should not override this method, but should implement write_file() to Activities should not override this method, but should implement write_file() to
do any state saving instead. do any state saving instead.
""" """
try:
if not skip_save:
self.save() self.save()
except:
logging.info(traceback.format_exc())
self._display_keep_failed_dialog()
return
if self._shared_activity: if self._shared_activity:
self._shared_activity.leave() self._shared_activity.leave()