Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/activity.py
diff options
context:
space:
mode:
Diffstat (limited to 'activity.py')
-rw-r--r--activity.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/activity.py b/activity.py
index d7a3d76..9994dea 100644
--- a/activity.py
+++ b/activity.py
@@ -32,6 +32,7 @@ from sugar.activity.widgets import ActivityToolbarButton
from sugar.activity.widgets import StopButton
from sugar.graphics.radiotoolbutton import RadioToolButton
from sugar.graphics.toolbutton import ToolButton
+from sugar.graphics.alert import ConfirmationAlert
from sugar.graphics.toolbarbox import ToolbarBox
from sugar.graphics.toolbarbox import ToolbarButton
from sugar.graphics.style import GRID_CELL_SIZE
@@ -120,6 +121,12 @@ class PhysicsActivity(activity.Activity):
self._insert_stop_play_button(toolbar_box.toolbar)
separator = gtk.SeparatorToolItem()
+ toolbar_box.toolbar.insert(separator, -1)
+ separator.show()
+
+ self._insert_clear_all_button(toolbar_box.toolbar)
+
+ separator = gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_size_request(0, -1)
separator.set_expand(True)
@@ -149,6 +156,14 @@ class PhysicsActivity(activity.Activity):
toolbar.insert(self.stop_play, -1)
self.stop_play.show()
+ def _insert_clear_all_button(self, toolbar):
+ self.clear_all = ToolButton('clear_all')
+ self.clear_all.set_tooltip(_("Erase All"))
+ self.clear_all.set_accelerator(_('<ctrl>a'))
+ self.clear_all.connect('clicked', self.clear_all_cb)
+ toolbar.insert(self.clear_all, -1)
+ self.clear_all.show()
+
def _insert_create_tools(self, create_toolbar):
def _insert_item(toolbar, item, pos=-1):
@@ -186,6 +201,21 @@ class PhysicsActivity(activity.Activity):
self.stop_play.set_icon('media-playback-start')
self.stop_play.set_tooltip(_("Start"))
+ def clear_all_cb(self, button):
+ clear_all_alert = ConfirmationAlert()
+ clear_all_alert.props.title=_('Are You Sure?')
+ clear_all_alert.props.msg = _('All you work will be discarded. This cannot be undone!')
+ clear_all_alert.connect('response', self.clear_all_alert_cb)
+ self.add_alert(clear_all_alert)
+
+ def clear_all_alert_cb(self, alert, response_id):
+ self.remove_alert(alert)
+ if response_id is gtk.RESPONSE_OK:
+ pygame.event.post(pygame.event.Event(pygame.USEREVENT,
+ action="clear_all"))
+ else:
+ pass
+
def radioClicked(self, button):
pygame.event.post(pygame.event.Event(pygame.USEREVENT,
action=self.radioList[button]))