From 1ef3f5a643e992f9a24b2d6ad74a5f8dc5f6664e Mon Sep 17 00:00:00 2001 From: Wade Brainerd Date: Mon, 26 Oct 2009 17:46:43 +0000 Subject: Add alert when deleting lessons. --- diff --git a/editlessonlistscreen.py b/editlessonlistscreen.py index 5da2d0b..7fa5a9f 100644 --- a/editlessonlistscreen.py +++ b/editlessonlistscreen.py @@ -28,6 +28,7 @@ import gobject, pygtk, gtk, pango # Import Sugar UI modules. import sugar.activity.activity import sugar.graphics.style +import sugar.graphics.alert import sugar.mime import sugar.datastore.datastore @@ -196,12 +197,24 @@ class EditLessonListScreen(gtk.VBox): if len(self.lessons) > 1: path = self.treeview.get_cursor()[0] if path: + msg = sugar.graphics.alert.ConfirmationAlert() + msg.props.title = _('Delete Lesson?') + msg.props.msg = _('Deleting the lesson will erase the lesson content.') + + def alert_response_cb(alert, response_id, self, id): + self.activity.remove_alert(alert) + if response_id is gtk.RESPONSE_OK: + self.lessons.pop(id) + del self.liststore[id] + self.treeview.get_selection().select_path(id) + self.treeview.grab_focus() + self.update_sensitivity() + id = path[0] - self.lessons.pop(id) - del self.liststore[id] - self.treeview.get_selection().select_path(id) - self.treeview.grab_focus() - self.update_sensitivity() + msg.connect('response', alert_response_cb, self, id) + + self.activity.add_alert(msg) + msg.show_all() def move_lesson_up_clicked_cb(self, btn): path = self.treeview.get_cursor()[0] -- cgit v0.9.1