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-02-16 19:54:43 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2009-02-16 19:54:43 (GMT)
commit6b2f65861c9a87e8ac75eb63cfac7639f1762680 (patch)
tree610d89fe54208c4ff97b8084485eb7afedd0d1f2
parent5fb1950b51a4414471599975b51c30b815c7ac9a (diff)
Update connections after every move
-rw-r--r--thoughtview.py1
-rw-r--r--view.py32
2 files changed, 23 insertions, 10 deletions
diff --git a/thoughtview.py b/thoughtview.py
index eeae9e8..809d1ac 100644
--- a/thoughtview.py
+++ b/thoughtview.py
@@ -39,6 +39,7 @@ class ThoughtView(Box):
self._handles.append(self.new_thought_handle)
self.id = thought_id
+ self.line_to_parent = None
self._name = name
self._color = color
diff --git a/view.py b/view.py
index 029f3da..afe5568 100644
--- a/view.py
+++ b/view.py
@@ -113,18 +113,27 @@ class MindMapView(GtkView):
raise ValueError('Rect %r and line %r dont intersect!' % (rect, line,))
- def _connect_items(self, parent_view, thought_view):
- line = Line()
- self.canvas.add(line)
-
+ def _update_connection(self, parent_view, thought_view):
handle_tool = tool.ConnectHandleTool()
+ if thought_view.line_to_parent is None:
+ line = Line()
+ self.canvas.add(line)
+ thought_view.line_to_parent = line
+ else:
+ line = thought_view.line_to_parent
+ line_handle = line.handles()[0]
+ handle_tool.disconnect(self, line, line_handle)
+ handle_tool.disconnect(self, line, line.opposite(line_handle))
+
start, end = self._calculate_ports(thought_view, parent_view)
line_handle = line.handles()[0]
handle_tool.connect(self, line, line_handle, start)
handle_tool.connect(self, line, line.opposite(line_handle), end)
+ self.canvas.request_update(line)
+
def __row_changed_cb(self, model, path, iter):
row = model[iter]
#logging.debug('__row_changed_cb %r' % ((row[0], row[1], row[2], row[3], row[4],),))
@@ -133,17 +142,20 @@ class MindMapView(GtkView):
if thought_view is None:
thought_view = ThoughtView(row[0], row[1], row[2], row[3], row[4])
self.canvas.add(thought_view)
-
- if row.parent is not None:
- parent_view = self._get_thought_by_id(row.parent[0])
- gobject.idle_add(lambda: self._connect_items(parent_view,
- thought_view))
else:
thought_view.name = row[1]
thought_view.set_position(row[2], row[3])
thought_view.color = row[4]
- self.canvas.request_update(thought_view)
+ self.canvas.request_update(thought_view)
+
+ if row.parent is not None:
+ parent_view = self._get_thought_by_id(row.parent[0])
+ self._update_connection(parent_view, thought_view)
+
+ for child in row.iterchildren():
+ child_view = self._get_thought_by_id(child[0])
+ self._update_connection(thought_view, child_view)
def __row_deleted_cb(self, model, path):
logging.debug('__row_deleted_cb %r' % path)