diff options
-rwxr-xr-x | mindmapactivity.py | 16 | ||||
-rw-r--r-- | model.py | 6 | ||||
-rw-r--r-- | view.py | 1 |
3 files changed, 21 insertions, 2 deletions
diff --git a/mindmapactivity.py b/mindmapactivity.py index e972f79..4a5e2b2 100755 --- a/mindmapactivity.py +++ b/mindmapactivity.py @@ -17,6 +17,7 @@ import logging from gettext import gettext as _ +import gobject import gtk from sugar.activity import activity @@ -27,6 +28,9 @@ from view import MindMapView from treeview import TreeView class MindMapActivity(activity.Activity): + + __gtype_name__ = 'MindMapActivity' + def __init__(self, handle): activity.Activity.__init__(self, handle) @@ -54,6 +58,18 @@ class MindMapActivity(activity.Activity): pane.pack2(self._view) self._view.show() + if handle.object_id is None: + gobject.idle_add(self.__add_first_thought_cb) + + def __add_first_thought_cb(self): + x, y, width, height = self._view.get_allocation() + #TODO: place better the first thought + thought_id = self._model.create_new_thought(name=_('Initial thought'), + color='#999900', + x=width / 2, + y=height / 2) + return False + def __new_thought_button_cb(self, button): self._model.create_new_thought() @@ -31,9 +31,11 @@ class MindMapModel(gtk.TreeStore): self._thoughts_by_id = {} self._thoughts = [] - def create_new_thought(self): - self.append(None, (self._next_thought_id, '', 0, 0, '')) + def create_new_thought(self, name='', x=0, y=0, color=''): + thought_id = self._next_thought_id + self.append(None, (thought_id, name, x, y, color)) self._next_thought_id += 1 + return thought_id def serialize(self): thoughts = [] @@ -129,6 +129,7 @@ class MindMapView(Canvas): def __row_deleted_cb(self, model, path): logging.debug('__row_deleted_cb %r' % path) + raise NotImplementedError() thought_view = self._get_thought_by_id(path[0]) self.remove_element(thought_view) |