From c975b11606400043a49cae8a90bbd5ed044e9233 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 15 Oct 2007 23:47:02 +0200 Subject: [PATCH] Try to cleanup the activity destruction mess. --- shell/kbdconfig | 1 - sugar/activity/activity.py | 50 ++++++++++++++------------------------ 2 files changed, 18 insertions(+), 33 deletions(-) diff --git a/shell/kbdconfig b/shell/kbdconfig index 073ac801..415c69ff 100644 --- a/shell/kbdconfig +++ b/shell/kbdconfig @@ -5,4 +5,3 @@ n=next p=prev c=close -f=fullscreen diff --git a/sugar/activity/activity.py b/sugar/activity/activity.py index e659be05..c581c15f 100644 --- a/sugar/activity/activity.py +++ b/sugar/activity/activity.py @@ -130,7 +130,6 @@ class ActivityToolbar(gtk.Toolbar): def _stop_clicked_cb(self, button): self._activity.close() - self._activity.destroy() def _jobject_updated_cb(self, jobject): self.title.set_text(jobject['title']) @@ -260,8 +259,7 @@ class Activity(Window, gtk.Container): util.set_proc_title(proc_title) self.connect('realize', self._realize_cb) - self.connect('delete-event', self._delete_event_cb) - self.connect('window-state-event', self._window_state_event_cb) + self.connect('delete-event', self.__delete_event_cb) self._active = False self._activity_id = handle.activity_id @@ -269,10 +267,10 @@ class Activity(Window, gtk.Container): self._shared_activity = None self._share_id = None self._join_id = None - self._can_close = True self._preview = None self._updating_jobject = False self._closing = False + self._deleting = False self._max_participants = 0 self._invites_queue = [] @@ -345,9 +343,6 @@ class Activity(Window, gtk.Container): else: logging.debug("Unknown share scope %r" % share_scope) - def _window_state_event_cb(self, window, event): - logging.info(event.new_window_state) - def do_set_property(self, pspec, value): if pspec.name == 'active': if self._active != value: @@ -597,35 +592,26 @@ class Activity(Window, gtk.Container): self._internal_share_cb) self._pservice.share_activity(self, private=private) + def close(self): + self._preview = self._get_preview() + + self.save() + + if self._shared_activity: + self._shared_activity.leave() + + if self._updating_jobject: + self._closing = True + else: + self.destroy() + def _realize_cb(self, window): wm.set_bundle_id(window.window, self.get_bundle_id()) wm.set_activity_id(window.window, self._activity_id) - def _delete_event_cb(self, window, event): - if self._can_close: - self.close() - return False - else: - return True - - def close(self): - self._closing = True - - if self._bus: - del self._bus - self._bus = None - if self._shared_activity: - self._shared_activity.leave() - - self._preview = self._get_preview() - self.save() - - def destroy(self): - if self._updating_jobject: - # Delay destruction - self.hide() - else: - Window.destroy(self) + def __delete_event_cb(self, widget, event): + self.close() + return True def get_metadata(self): if self._jobject: