diff options
author | Wade Brainerd <wadetb@gmail.com> | 2009-10-26 17:46:43 (GMT) |
---|---|---|
committer | Wade Brainerd <wadetb@gmail.com> | 2009-10-26 17:46:43 (GMT) |
commit | 1ef3f5a643e992f9a24b2d6ad74a5f8dc5f6664e (patch) | |
tree | 525eb4b07baf80357622f14ca6a3b924b5671765 | |
parent | c58be83fd781cf6cf79c8def9866573ef69ed490 (diff) |
Add alert when deleting lessons.
-rw-r--r-- | editlessonlistscreen.py | 23 |
1 files changed, 18 insertions, 5 deletions
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] |