Shutdown/Rebbot syncs activities data #6014 (marco)
This commit is contained in:
parent
756b9309e8
commit
7fc7b39f14
@ -436,6 +436,7 @@ class Activity(Window, gtk.Container):
|
|||||||
self._preview = _sugarext.Preview()
|
self._preview = _sugarext.Preview()
|
||||||
self._updating_jobject = False
|
self._updating_jobject = False
|
||||||
self._closing = False
|
self._closing = False
|
||||||
|
self._quit_requested = False
|
||||||
self._deleting = False
|
self._deleting = False
|
||||||
self._max_participants = 0
|
self._max_participants = 0
|
||||||
self._invites_queue = []
|
self._invites_queue = []
|
||||||
@ -564,10 +565,15 @@ class Activity(Window, gtk.Container):
|
|||||||
canvas.connect('map', self.__canvas_map_cb)
|
canvas.connect('map', self.__canvas_map_cb)
|
||||||
|
|
||||||
def __sm_quit_requested_cb(self, client):
|
def __sm_quit_requested_cb(self, client):
|
||||||
|
self._quit_requested = True
|
||||||
|
|
||||||
|
if not self._prepare_close():
|
||||||
|
client.will_quit(False)
|
||||||
|
elif not self._updating_jobject:
|
||||||
client.will_quit(True)
|
client.will_quit(True)
|
||||||
|
|
||||||
def __sm_quit_cb(self, client):
|
def __sm_quit_cb(self, client):
|
||||||
self.close(force=True)
|
self._complete_close()
|
||||||
|
|
||||||
def __canvas_map_cb(self, canvas):
|
def __canvas_map_cb(self, canvas):
|
||||||
if self._jobject and self._jobject.file_path:
|
if self._jobject and self._jobject.file_path:
|
||||||
@ -641,16 +647,19 @@ class Activity(Window, gtk.Container):
|
|||||||
def __save_cb(self):
|
def __save_cb(self):
|
||||||
logging.debug('Activity.__save_cb')
|
logging.debug('Activity.__save_cb')
|
||||||
self._updating_jobject = False
|
self._updating_jobject = False
|
||||||
if self._closing:
|
if self._quit_requested:
|
||||||
self._cleanup_jobject()
|
self._xsmp_client.will_quit(True)
|
||||||
self.destroy()
|
elif self._closing:
|
||||||
|
self._complete_close()
|
||||||
|
|
||||||
def __save_error_cb(self, err):
|
def __save_error_cb(self, err):
|
||||||
logging.debug('Activity.__save_error_cb')
|
logging.debug('Activity.__save_error_cb')
|
||||||
self._updating_jobject = False
|
self._updating_jobject = False
|
||||||
|
if self._quit_requested:
|
||||||
|
self._xsmp_client.will_quit(False)
|
||||||
if self._closing:
|
if self._closing:
|
||||||
self._cleanup_jobject()
|
self._show_keep_failed_dialog()
|
||||||
self.destroy()
|
self._closing = False
|
||||||
logging.debug("Error saving activity object to datastore: %s" % err)
|
logging.debug("Error saving activity object to datastore: %s" % err)
|
||||||
|
|
||||||
def _cleanup_jobject(self):
|
def _cleanup_jobject(self):
|
||||||
@ -713,6 +722,10 @@ class Activity(Window, gtk.Container):
|
|||||||
own implementation of write_file() to save your Activity specific data.
|
own implementation of write_file() to save your Activity specific data.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if self._jobject is None:
|
||||||
|
logging.debug('Cannot save, no journal object.')
|
||||||
|
return
|
||||||
|
|
||||||
logging.debug('Activity.save: %r' % self._jobject.object_id)
|
logging.debug('Activity.save: %r' % self._jobject.object_id)
|
||||||
|
|
||||||
if self._updating_jobject:
|
if self._updating_jobject:
|
||||||
@ -852,7 +865,7 @@ 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 _display_keep_failed_dialog(self):
|
def _show_keep_failed_dialog(self):
|
||||||
alert = Alert()
|
alert = Alert()
|
||||||
alert.props.title = _('Keep error')
|
alert.props.title = _('Keep error')
|
||||||
alert.props.msg = _('Keep error: all changes will be lost')
|
alert.props.msg = _('Keep error: all changes will be lost')
|
||||||
@ -877,7 +890,30 @@ class Activity(Window, gtk.Container):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def close(self, force=False, skip_save=False):
|
def _prepare_close(self, skip_save=False):
|
||||||
|
if not skip_save:
|
||||||
|
try:
|
||||||
|
self.save()
|
||||||
|
except Exception:
|
||||||
|
logging.info(traceback.format_exc())
|
||||||
|
self._show_keep_failed_dialog()
|
||||||
|
return False
|
||||||
|
|
||||||
|
if self._shared_activity:
|
||||||
|
self._shared_activity.leave()
|
||||||
|
|
||||||
|
self._closing = True
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def _complete_close(self):
|
||||||
|
self._cleanup_jobject()
|
||||||
|
self.destroy()
|
||||||
|
|
||||||
|
# Make the exported object inaccessible
|
||||||
|
dbus.service.Object.remove_from_connection(self._bus)
|
||||||
|
|
||||||
|
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
|
Activities should not override this method, but should implement
|
||||||
@ -885,28 +921,15 @@ class Activity(Window, gtk.Container):
|
|||||||
to control wether it can close, it should override can_close().
|
to control wether it can close, it should override can_close().
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not force:
|
|
||||||
if not self.can_close():
|
if not self.can_close():
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
if not self._closing:
|
||||||
if not skip_save:
|
if not self._prepare_close(skip_save):
|
||||||
self.save()
|
|
||||||
except Exception:
|
|
||||||
logging.info(traceback.format_exc())
|
|
||||||
self._display_keep_failed_dialog()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if self._shared_activity:
|
if not self._updating_jobject:
|
||||||
self._shared_activity.leave()
|
self._complete_close()
|
||||||
|
|
||||||
if self._updating_jobject:
|
|
||||||
self._closing = True
|
|
||||||
else:
|
|
||||||
self.destroy()
|
|
||||||
|
|
||||||
# Make the exported object inaccessible
|
|
||||||
dbus.service.Object.remove_from_connection(self._bus)
|
|
||||||
|
|
||||||
def __realize_cb(self, window):
|
def __realize_cb(self, window):
|
||||||
wm.set_bundle_id(window.window, self.get_bundle_id())
|
wm.set_bundle_id(window.window, self.get_bundle_id())
|
||||||
|
Loading…
Reference in New Issue
Block a user