From dbb1e04ee6f544d9b18f2b78633138602dab0d4b Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sat, 24 Jan 2009 14:52:05 +0000 Subject: Place a first thought in new models --- 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() diff --git a/model.py b/model.py index aaead38..38d1ca6 100644 --- a/model.py +++ b/model.py @@ -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 = [] diff --git a/view.py b/view.py index cbe31d7..3708b6a 100644 --- a/view.py +++ b/view.py @@ -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) -- cgit v0.9.1