Thanks, reviewed and pushed.<div><br></div><div>Gonzalo<br><br><div class="gmail_quote">On Fri, Aug 10, 2012 at 5:53 PM, Manuel Kaufmann <span dir="ltr"><<a href="mailto:humitos@gmail.com" target="_blank">humitos@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">After the port to Gtk3 the Edit Lessons section didn't work<br>
anymore. This commits solves this and make this section available<br>
again.<br>
<br>
Signed-off-by: Manuel Kaufmann <<a href="mailto:humitos@gmail.com">humitos@gmail.com</a>><br>
---<br>
 editlessonlistscreen.py | 57 ++++++++++++++++++++++++++-----------------------<br>
 editlessonscreen.py     | 43 +++++++++++++++++++++++++------------<br>
 2 files changed, 59 insertions(+), 41 deletions(-)<br>
<br>
diff --git a/editlessonlistscreen.py b/editlessonlistscreen.py<br>
index 6ac2c34..984f3b7 100644<br>
--- a/editlessonlistscreen.py<br>
+++ b/editlessonlistscreen.py<br>
@@ -61,9 +61,6 @@ class EditLessonListScreen(Gtk.VBox):<br>
         self.treeview.set_rules_hint(True)<br>
         self.treeview.set_enable_search(False)<br>
<br>
-        self.treeview.connect('cursor-changed', self.lesson_selected_cb)<br>
-        self.treeview.connect('row-activated', self.lesson_activated_cb)<br>
-<br>
         # Note that the only thing we store in our liststore is the lesson id.<br>
         # All the actual data is in the lessons list.<br>
         self.liststore = Gtk.ListStore(GObject.TYPE_INT)<br>
@@ -136,6 +133,11 @@ class EditLessonListScreen(Gtk.VBox):<br>
         self.pack_start(scroll, True, True, 10)<br>
         self.pack_start(btnbox, False, False, 10)<br>
<br>
+        # README: I had to move these two lines here because the<br>
+        # signal was emitted before all the widget are created<br>
+        self.treeview.connect('cursor-changed', self.lesson_selected_cb)<br>
+        self.treeview.connect('row-activated', self.lesson_activated_cb)<br>
+<br>
         self.build()<br>
<br>
         self.show_all()<br>
@@ -146,18 +148,18 @@ class EditLessonListScreen(Gtk.VBox):<br>
         for t in range(0, len(self.lessons)):<br>
             self.liststore.append((0,))<br>
<br>
-    def name_render_cb(self, column, cell_renderer, model, iter):<br>
-        id = model.get_path(iter)[0]<br>
+    def name_render_cb(self, column, cell_renderer, model, iter, data):<br>
+        id = model.get_path(iter).get_indices()[0]<br>
         t = self.lessons[id]<br>
         cell_renderer.set_property('text', t['name'])<br>
<br>
-    def description_render_cb(self, column, cell_renderer, model, iter):<br>
-        id = model.get_path(iter)[0]<br>
+    def description_render_cb(self, column, cell_renderer, model, iter, data):<br>
+        id = model.get_path(iter).get_indices()[0]<br>
         t = self.lessons[id]<br>
         cell_renderer.set_property('text', t['description'])<br>
<br>
-    def type_render_cb(self, column, cell_renderer, model, iter):<br>
-        id = model.get_path(iter)[0]<br>
+    def type_render_cb(self, column, cell_renderer, model, iter, data):<br>
+        id = model.get_path(iter).get_indices()[0]<br>
         t = self.lessons[id]<br>
         if t['type'] == 'normal':<br>
             cell_renderer.set_property('text', _('Text'))<br>
@@ -195,31 +197,32 @@ class EditLessonListScreen(Gtk.VBox):<br>
<br>
     def del_lesson_clicked_cb(self, btn):<br>
         if len(self.lessons) > 1:<br>
-            path = self.treeview.get_cursor()[0]<br>
+            path, focus_column = self.treeview.get_cursor()<br>
+<br>
             if path:<br>
                 msg = sugar3.graphics.alert.ConfirmationAlert()<br>
                 msg.props.title = _('Delete Lesson?')<br>
                 msg.props.msg = _('Deleting the lesson will erase the lesson content.')<br>
<br>
-                def alert_response_cb(alert, response_id, self, id):<br>
+                def alert_response_cb(alert, response_id, self, path):<br>
                     self.activity.remove_alert(alert)<br>
                     if response_id is Gtk.ResponseType.OK:<br>
+                        id = path.get_indices()[0]<br>
                         self.lessons.pop(id)<br>
-                        del self.liststore[id]<br>
+                        del self.liststore[path]<br>
                         self.treeview.get_selection().select_path(id)<br>
                         self.treeview.grab_focus()<br>
                         self.update_sensitivity()<br>
-<br>
-                id = path[0]<br>
-                msg.connect('response', alert_response_cb, self, id)<br>
+<br>
+                msg.connect('response', alert_response_cb, self, path)<br>
<br>
                 self.activity.add_alert(msg)<br>
                 msg.show_all()<br>
<br>
     def move_lesson_up_clicked_cb(self, btn):<br>
-        path = self.treeview.get_cursor()[0]<br>
+        path, focus_column = self.treeview.get_cursor()<br>
         if path:<br>
-            id = path[0]<br>
+            id = path.get_indices()[0]<br>
             if id > 0:<br>
                 lesson = self.lessons.pop(id)<br>
                 self.lessons.insert(id - 1, lesson)<br>
@@ -229,9 +232,9 @@ class EditLessonListScreen(Gtk.VBox):<br>
                 self.update_sensitivity()<br>
<br>
     def move_lesson_down_clicked_cb(self, btn):<br>
-        path = self.treeview.get_cursor()[0]<br>
+        path, focus_column = self.treeview.get_cursor()<br>
         if path:<br>
-            id = path[0]<br>
+            id = path.get_indices()[0]<br>
             if id < len(self.lessons) - 1:<br>
                 lesson = self.lessons.pop(id)<br>
                 self.lessons.insert(id + 1, lesson)<br>
@@ -244,7 +247,8 @@ class EditLessonListScreen(Gtk.VBox):<br>
         self.update_sensitivity()<br>
<br>
     def lesson_activated_cb(self, treeview, path, column):<br>
-        id = path[0]<br>
+        path, focus_column = self.treeview.get_cursor()<br>
+        id = path.get_indices()[0]<br>
         lesson = self.lessons[id]<br>
         self.activity.push_screen(editlessonscreen.EditLessonScreen(self.activity, lesson))<br>
<br>
@@ -252,21 +256,20 @@ class EditLessonListScreen(Gtk.VBox):<br>
         self.update_sensitivity()<br>
<br>
     def update_sensitivity(self):<br>
-        path = self.treeview.get_cursor()[0]<br>
-<br>
+        path, focus_column = self.treeview.get_cursor()<br>
         if path:<br>
             self.delbtn.set_sensitive(True)<br>
-<br>
-            if path[0] > 0:<br>
+<br>
+            id = path.get_indices()[0]<br>
+            if id > 0:<br>
                 self.moveupbtn.set_sensitive(True)<br>
             else:<br>
                 self.moveupbtn.set_sensitive(False)<br>
-<br>
-            if path[0] < len(self.lessons) - 1:<br>
+<br>
+            if id < len(self.lessons) - 1:<br>
                 self.movedownbtn.set_sensitive(True)<br>
             else:<br>
                 self.movedownbtn.set_sensitive(False)<br>
-<br>
         else:<br>
             self.delbtn.set_sensitive(False)<br>
             self.moveupbtn.set_sensitive(False)<br>
diff --git a/editlessonscreen.py b/editlessonscreen.py<br>
index e5ce0b4..d81d250 100644<br>
--- a/editlessonscreen.py<br>
+++ b/editlessonscreen.py<br>
@@ -157,7 +157,8 @@ class EditLessonScreen(Gtk.VBox):<br>
<br>
         btnbox = Gtk.HBox()<br>
         btnbox.pack_start(steplabel, False, False, 0)<br>
-        btnbox.pack_start(stepbox.typecombo, expand=False, padding=10)<br>
+        btnbox.pack_start(stepbox.typecombo, expand=False,<br>
+                          fill=False, padding=10)<br>
         btnbox.pack_end(addstepbtn, False, False, 0)<br>
         btnbox.pack_end(delstepbtn, False, False, 0)<br>
         btnbox.pack_end(moveupbtn, False, False, 0)<br>
@@ -171,7 +172,8 @@ class EditLessonScreen(Gtk.VBox):<br>
<br>
         self.labelsizegroup.add_widget(instlabel)<br>
<br>
-        stepbox.insttext = Gtk.TextView(Gtk.TextBuffer())<br>
+        stepbox.insttext = Gtk.TextView()<br>
+        stepbox.insttext.set_buffer(Gtk.TextBuffer())<br>
         stepbox.insttext.props.wrap_mode = Gtk.WrapMode.WORD<br>
         stepbox.insttext.modify_font(Pango.FontDescription('Monospace'))<br>
         instscroll = Gtk.ScrolledWindow()<br>
@@ -192,7 +194,8 @@ class EditLessonScreen(Gtk.VBox):<br>
<br>
         self.labelsizegroup.add_widget(textlabel)<br>
<br>
-        stepbox.texttext = Gtk.TextView(Gtk.TextBuffer())<br>
+        stepbox.texttext = Gtk.TextView()<br>
+        stepbox.texttext.set_buffer(Gtk.TextBuffer())<br>
         stepbox.texttext.props.wrap_mode = Gtk.WrapMode.WORD<br>
         stepbox.texttext.modify_font(Pango.FontDescription('monospace'))<br>
         textscroll = Gtk.ScrolledWindow()<br>
@@ -304,7 +307,8 @@ class EditLessonScreen(Gtk.VBox):<br>
         desclabel.set_alignment(0.0, 0.5)<br>
         desclabel.set_padding(20, 0)<br>
<br>
-        self.desctext = Gtk.TextView(Gtk.TextBuffer())<br>
+        self.desctext = Gtk.TextView()<br>
+        self.desctext.set_buffer(Gtk.TextBuffer())<br>
         self.desctext.props.wrap_mode = Gtk.WrapMode.WORD<br>
         descscroll = Gtk.ScrolledWindow()<br>
         descscroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)<br>
@@ -350,7 +354,8 @@ class EditLessonScreen(Gtk.VBox):<br>
         generatelabel.set_padding(10, 0)<br>
<br>
         generatebox = self.build_generate()<br>
-        self.vbox.pack_start(generatelabel, expand=False, padding=10)<br>
+        self.vbox.pack_start(generatelabel, expand=False,<br>
+                             fill=False, padding=10)<br>
         self.vbox.pack_start(generatebox, False, True, 0)<br>
<br>
         self.has_normal_widgets = False<br>
@@ -385,7 +390,8 @@ class EditLessonScreen(Gtk.VBox):<br>
<br>
             self.labelsizegroup.add_widget(textlabel)<br>
<br>
-            self.wordstext = Gtk.TextView(Gtk.TextBuffer())<br>
+            self.wordstext = Gtk.TextView()<br>
+            self.wordstext.set_buffer(Gtk.TextBuffer())<br>
             self.wordstext.props.wrap_mode = Gtk.WrapMode.WORD<br>
             self.wordstext.modify_font(Pango.FontDescription('Monospace'))<br>
             textscroll = Gtk.ScrolledWindow()<br>
@@ -406,7 +412,8 @@ class EditLessonScreen(Gtk.VBox):<br>
         medalslabel.set_alignment(0.0, 0.5)<br>
         medalslabel.set_padding(10, 0)<br>
<br>
-        self.vbox.pack_start(medalslabel, expand=False, padding=10)<br>
+        self.vbox.pack_start(medalslabel, expand=False,<br>
+                             fill=False, padding=10)<br>
<br>
         self.medalboxes = []<br>
         self.medalboxes.append(self.build_medal(self.lesson['medals'][0], _('Bronze')))<br>
@@ -436,7 +443,8 @@ class EditLessonScreen(Gtk.VBox):<br>
         self.lesson['name'] = self.nameent.get_text()<br>
<br>
         buf = self.desctext.get_buffer()<br>
-        self.lesson['description'] = buf.get_text(buf.get_start_iter(), buf.get_end_iter())<br>
+        self.lesson['description'] = buf.get_text(buf.get_start_iter(),<br>
+                                                  buf.get_end_iter(), False)<br>
<br>
         if not self.lesson.has_key('options'):<br>
             self.lesson['options'] = {}<br>
@@ -453,10 +461,13 @@ class EditLessonScreen(Gtk.VBox):<br>
                     step = {}<br>
<br>
                     buf = sb.insttext.get_buffer()<br>
-                    step['instructions'] = buf.get_text(buf.get_start_iter(), buf.get_end_iter())<br>
+                    step['instructions'] = buf.get_text(buf.get_start_iter(),<br>
+                                                        buf.get_end_iter(),<br>
+                                                        False)<br>
<br>
                     buf = sb.texttext.get_buffer()<br>
-                    step['text'] = buf.get_text(buf.get_start_iter(), buf.get_end_iter())<br>
+                    step['text'] = buf.get_text(buf.get_start_iter(),<br>
+                                                buf.get_end_iter(), False)<br>
<br>
                     if sb.typecombo.get_active() == 0:<br>
                         step['mode'] = 'key'<br>
@@ -476,7 +487,8 @@ class EditLessonScreen(Gtk.VBox):<br>
<br>
             if self.has_balloon_widgets:<br>
                 buf = self.wordstext.get_buffer()<br>
-                text = buf.get_text(buf.get_start_iter(), buf.get_end_iter())<br>
+                text = buf.get_text(buf.get_start_iter(),<br>
+                                    buf.get_end_iter(), False)<br>
                 self.lesson['words'] = text.split(' ')<br>
<br>
                 for i in range(0, 3):<br>
@@ -581,7 +593,8 @@ class WordListScreen(Gtk.VBox):<br>
         subtitle.set_markup("<span size='10000'>" + _("Type or paste words here, for the Automatic Lesson Generator.  If empty, the dictionary will be used.") + "</span>")<br>

         subtitle.set_alignment(1.0, 0.0)<br>
<br>
-        self.wordlisttext = Gtk.TextView(Gtk.TextBuffer())<br>
+        self.wordlisttext = Gtk.TextView()<br>
+        self.wordlisttext.set_buffer(Gtk.TextBuffer())<br>
         self.wordlisttext.props.wrap_mode = Gtk.WrapMode.WORD<br>
         wordlistscroll = Gtk.ScrolledWindow()<br>
         wordlistscroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)<br>
@@ -591,14 +604,16 @@ class WordListScreen(Gtk.VBox):<br>
<br>
         self.pack_start(titlebox, False, True, 0)<br>
         self.pack_start(subtitle, False, True, 0)<br>
-        self.pack_start(Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL), expand=False, padding=0)<br>
+        separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)<br>
+        self.pack_start(separator, expand=False, fill=False, padding=0)<br>
         self.pack_start(wordlistscroll, True, True, 0)<br>
<br>
         self.show_all()<br>
<br>
     def stop_clicked_cb(self, btn):<br>
         buf = self.wordlisttext.get_buffer()<br>
-        wordstext = buf.get_text(buf.get_start_iter(), buf.get_end_iter())<br>
+        wordstext = buf.get_text(buf.get_start_iter(),<br>
+                                 buf.get_end_iter(), False)<br>
         self.activity.wordlist = wordstext.split()<br>
<br>
         self.activity.pop_screen()<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.11.2<br>
<br>
</font></span></blockquote></div><br></div>