Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2009-01-24 14:52:05 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2009-01-24 14:52:05 (GMT)
commitdbb1e04ee6f544d9b18f2b78633138602dab0d4b (patch)
tree2ed8f0876f1fbd545afd2ed0e653883bd75ebbaa
parent852766ad7192a6b53eea8127643e8a81ecf49efa (diff)
Place a first thought in new modelsmodel-as-a-tree
-rwxr-xr-xmindmapactivity.py16
-rw-r--r--model.py6
-rw-r--r--view.py1
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()
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)