Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorReinier Heeres <reinier@heeres.eu>2008-01-10 16:55:57 (GMT)
committer Reinier Heeres <reinier@heeres.eu>2008-01-10 16:55:57 (GMT)
commit802267cd2172eb0929bdadafc309f3c7322f4300 (patch)
treea0317dcdc637fbefeb760ee6014b0077ac0edc20 /lib
parent6c5025bd74040d25f31d259a6bc09b9072ffcde5 (diff)
Implement Activity.can_close(), #5493
Diffstat (limited to 'lib')
-rw-r--r--lib/sugar/activity/activity.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/sugar/activity/activity.py b/lib/sugar/activity/activity.py
index d9886f9..f6dbd37 100644
--- a/lib/sugar/activity/activity.py
+++ b/lib/sugar/activity/activity.py
@@ -838,12 +838,24 @@ class Activity(Window, gtk.Container):
if response_id == gtk.RESPONSE_OK:
self.close(skip_save=True)
- def close(self, skip_save=False):
+ def can_close(self):
+ """Activities should override this function if they want to perform
+ extra checks before actually closing."""
+
+ return True
+
+ def close(self, force=False, 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.
+ do any state saving instead. If the application wants to control wether it can
+ close, it should override can_close().
"""
+
+ if not force:
+ if not self.can_close():
+ return
+
try:
if not skip_save:
self.save()