[Sugar-devel] Bug in Sugar Commander, Fun With The Journal needs review

James Simmons nicestep at gmail.com
Mon Apr 12 11:17:35 EDT 2010

The version of Sugar Commander I released this weekend works.
However, I woke up Sunday morning realizing that it was not necessary
to reload the whole ListStore I was using to show Journal objects
every time I changed anything.  I could update the ListStore in place
and the TreeView would redraw itself to show the latest contents
automatically, or so I thought.  Well, deleting rows that way works,
but not updating a row.

This is the code is use for the callbacks:

    def datastore_updated_cb(self,  uid):
        iter = self.ls_journal.get_iter_first()
        for row in self.ls_journal:
            jobject = row[COLUMN_JOBJECT]
            if jobject.object_id == uid:
                title = jobject.metadata['title']
                self.ls_journal.set(iter, COLUMN_TITLE, title)
                mime = jobject.metadata['mime_type']
                self.ls_journal.set(iter, COLUMN_MIME, mime)
            iter = self.ls_journal.iter_next(iter)
        object_id = self.selected_journal_entry.object_id
        if object_id == uid:
            jobject = datastore.get(object_id)

    def datastore_deleted_cb(self,  uid):
        save_path = self.selected_path
        iter = self.ls_journal.get_iter_first()
        for row in self.ls_journal:
            jobject = row[COLUMN_JOBJECT]
            if jobject.object_id == uid:
            iter = self.ls_journal.iter_next(iter)

        if not save_path is None:
            description_textbuffer = self.description_textview.get_buffer()
            tags_textbuffer = self.tags_textview.get_buffer()
            self.btn_save.props.sensitive = False
            self.btn_delete.props.sensitive = False

The whole thing is here:


For reasons I won't go into I was convinced that this code actually
worked so I updated the "Fun With The Journal" chapter of "Make Your
Own Sugar Activities!" with the new code, plus I mode other changes to
explain things like how to add your own preview to a Journal entry.
The revised chapter is here:


I was hoping to just ask for a review of the revised chapter this
morning but I'm really stuck on the TreeView issue.  I can't
understand why updating the ListStore doesn't cause the cells in the
TreeView to be redrawn with the new content.

James Simmons

More information about the Sugar-devel mailing list