Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/model.py
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2009-01-29 12:23:47 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2009-01-29 12:23:47 (GMT)
commit05a816a38fe398e9b80712764bd4946df23eb4d0 (patch)
treeb8629666f6c7a2b39b1c9a82f5f047a4c2a9d038 /model.py
parenta924e1c2bcca44554760ce067d0cc9ecf810d87b (diff)
Create a new descendant thought by dragging a handle
Diffstat (limited to 'model.py')
-rw-r--r--model.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/model.py b/model.py
index 38d1ca6..f15758b 100644
--- a/model.py
+++ b/model.py
@@ -31,9 +31,14 @@ class MindMapModel(gtk.TreeStore):
self._thoughts_by_id = {}
self._thoughts = []
- def create_new_thought(self, name='', x=0, y=0, color=''):
+ def create_new_thought(self, name='', x=0, y=0, color='', parent_id=None):
thought_id = self._next_thought_id
- self.append(None, (thought_id, name, x, y, color))
+
+ parent = None
+ if parent_id is not None:
+ parent = self.find_by_id(parent_id).iter
+
+ self.append(parent, (thought_id, name, x, y, color))
self._next_thought_id += 1
return thought_id
@@ -68,5 +73,11 @@ class MindMapModel(gtk.TreeStore):
for row in rows:
if row[0] == thought_id:
return row
- self.find_by_id(thought_id, row.iterchildren())
+
+ children = row.iterchildren()
+ found_row = self.find_by_id(thought_id, children)
+ if found_row is not None:
+ return found_row
+
+ return None