def __init__(self): gobject.GObject.__init__(self) self._xsmp_client = XSMPClient() self._xsmp_client.connect('quit-requested', self.__sm_quit_requested_cb) self._xsmp_client.connect('quit', self.__sm_quit_cb) self._xsmp_client.startup() self._activities = [] self._will_quit = []
class _ActivitySession(gobject.GObject): __gsignals__ = { 'quit-requested': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])), 'quit': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])), } def __init__(self): gobject.GObject.__init__(self) self._xsmp_client = XSMPClient() self._xsmp_client.connect('quit-requested', self.__sm_quit_requested_cb) self._xsmp_client.connect('quit', self.__sm_quit_cb) self._xsmp_client.startup() self._activities = [] self._will_quit = [] def register(self, activity): self._activities.append(activity) def unregister(self, activity): self._activities.remove(activity) if len(self._activities) == 0: logging.debug('Quitting the activity process.') gtk.main_quit() def will_quit(self, activity, will_quit): if will_quit: self._will_quit.append(activity) # We can quit only when all the instances agreed to for activity in self._activities: if activity not in self._will_quit: return self._xsmp_client.will_quit(True) else: self._will_quit = [] self._xsmp_client.will_quit(False) def __sm_quit_requested_cb(self, client): self.emit('quit-requested') def __sm_quit_cb(self, client): self.emit('quit')