diff options
author | Wade Brainerd <wadetb@gmail.com> | 2009-10-22 00:54:52 (GMT) |
---|---|---|
committer | Wade Brainerd <wadetb@gmail.com> | 2009-10-22 00:54:52 (GMT) |
commit | ad5f42958afb67606d88087a64f7322abc794bce (patch) | |
tree | ba6af18a418d0febf843064937f4776f1046d053 /editlessonlistscreen.py | |
parent | 5dc6b5235e97c18d625f9c776840fab80c6e16b4 (diff) |
Add a button to update the lessons in the activity bundle.
Diffstat (limited to 'editlessonlistscreen.py')
-rw-r--r-- | editlessonlistscreen.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/editlessonlistscreen.py b/editlessonlistscreen.py index 4388f24..5da2d0b 100644 --- a/editlessonlistscreen.py +++ b/editlessonlistscreen.py @@ -100,6 +100,11 @@ class EditLessonListScreen(gtk.VBox): self.exportbtn.add(exportlabel) self.exportbtn.connect('clicked', self.export_clicked_cb) + exportlabel = gtk.Label(_('Save Lessons to Activity')) + self.defaultsbtn = gtk.Button() + self.defaultsbtn.add(exportlabel) + self.defaultsbtn.connect('clicked', self.set_default_clicked_cb) + self.addbtn = gtk.Button() self.addbtn.add(sugar.graphics.icon.Icon(icon_name='list-add')) self.addbtn.connect('clicked', self.add_lesson_clicked_cb) @@ -119,6 +124,7 @@ class EditLessonListScreen(gtk.VBox): btnbox = gtk.HBox() btnbox.pack_start(self.importbtn, False, False, 10) btnbox.pack_start(self.exportbtn, False, False) + btnbox.pack_start(self.defaultsbtn, False, False, 10) btnbox.pack_end(self.addbtn, False, False) btnbox.pack_end(self.delbtn, False, False) btnbox.pack_end(self.moveupbtn, False, False) @@ -297,4 +303,16 @@ class EditLessonListScreen(gtk.VBox): fileObject.destroy() del fileObject -
\ No newline at end of file + def set_default_clicked_cb(self, btn): + code = locale.getdefaultlocale()[0] or 'en_US' + path = sugar.activity.activity.get_bundle_path() + '/lessons/%s.lessons' % code + + fd = open(path, 'w') + + try: + data = { 'lessons': self.lessons } + fd.write(json.dumps(data)) + + finally: + fd.close() +
\ No newline at end of file |