Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TurtleArt/tawindow.py7
-rw-r--r--TurtleArtActivity.py19
2 files changed, 24 insertions, 2 deletions
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index a03240b..9ec057e 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -1596,7 +1596,10 @@ before making changes to your program'))
elif blk.name == 'restore':
self.restore_latest_from_trash()
elif blk.name == 'empty':
- self._empty_trash()
+ if self.running_sugar:
+ self.activity.empty_trash_alert()
+ else:
+ self.empty_trash()
elif blk.name == 'trashall':
for b in self.just_blocks():
if b.type != 'trash':
@@ -2150,7 +2153,7 @@ before making changes to your program'))
self.trash_stack.remove(blk)
- def _empty_trash(self):
+ def empty_trash(self):
''' Permanently remove all blocks presently in the trash can. '''
for blk in self.block_list.list:
if blk.type == 'trash':
diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py
index 3b83236..4187229 100644
--- a/TurtleArtActivity.py
+++ b/TurtleArtActivity.py
@@ -1526,6 +1526,25 @@ in order to use the plugin.'))
self._old_cursor = self.get_window().get_cursor()
self.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND1))
+ def empty_trash_alert(self):
+ ''' We get confirmation from the user before emptying the trash '''
+ alert = ConfirmationAlert()
+ alert.props.title = _('Empty the trash')
+ alert.props.msg = _('Do you really want to empty trash?')
+
+ def _empty_trash_alert_response_cb(alert, response_id, self):
+ if response_id is gtk.RESPONSE_OK:
+ _logger.debug('emptying the trash')
+ self.remove_alert(alert)
+ self.tw.empty_trash()
+ elif response_id is gtk.RESPONSE_CANCEL:
+ _logger.debug('cancel emptying the trash')
+ self.remove_alert(alert)
+
+ alert.connect('response', _empty_trash_alert_response_cb, self)
+ self.add_alert(alert)
+ alert.show()
+
def _add_label(self, string, toolbar, width=None):
''' Add a label to a toolbar. '''
label = gtk.Label(string)