commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 03/07: grc: sort blocks in export_data(), d


From: git
Subject: [Commit-gnuradio] [gnuradio] 03/07: grc: sort blocks in export_data(), draw disabled blocks first (fixes #830)
Date: Fri, 4 Sep 2015 12:57:49 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit 791c1a705d9e1457d9c09c79c7f1300c2ac63f5e
Author: Sebastian Koslowski <address@hidden>
Date:   Wed Aug 19 14:37:55 2015 +0200

    grc: sort blocks in export_data(), draw disabled blocks first (fixes #830)
---
 grc/base/FlowGraph.py | 22 ++++++++++------------
 grc/gui/FlowGraph.py  |  3 ++-
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/grc/base/FlowGraph.py b/grc/base/FlowGraph.py
index 61e60f9..217c4d7 100644
--- a/grc/base/FlowGraph.py
+++ b/grc/base/FlowGraph.py
@@ -131,17 +131,8 @@ class FlowGraph(Element):
     def iter_blocks(self):
         return ifilter(methodcaller('is_block'), self.get_elements())
 
-    def get_blocks_unordered(self):
-        return list(self.iter_blocks())
-
     def get_blocks(self):
-        # refactored the slow, ugly version
-        # don't know why we need this here, using it for sorted export_data()
-        return sorted(self.iter_blocks(), key=lambda b: (
-            b.get_key() != 'options',  # options to the front
-            not b.get_key().startswith('variable'),  # then vars
-            str(b)
-        ))
+        return list(self.iter_blocks())
 
     def iter_connections(self):
         return ifilter(methodcaller('is_connection'), self.get_elements())
@@ -273,10 +264,17 @@ class FlowGraph(Element):
         Returns:
             a nested data odict
         """
+        # sort blocks and connections for nicer diffs
+        blocks = sorted(self.iter_blocks(), key=lambda b: (
+            b.get_key() != 'options',  # options to the front
+            not b.get_key().startswith('variable'),  # then vars
+            str(b)
+        ))
+        connections = sorted(self.get_connections(), key=str)
         n = odict()
         n['timestamp'] = self._timestamp
-        n['block'] = [b.export_data() for b in self.get_blocks()]  # already 
sorted
-        n['connection'] = [c.export_data() for c in 
sorted(self.get_connections(), key=str)]
+        n['block'] = [b.export_data() for b in blocks]
+        n['connection'] = [c.export_data() for c in connections]
         instructions = odict({
             'created': self.get_parent().get_version_short(),
             'format': FLOW_GRAPH_FILE_FORMAT_VERSION,
diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py
index 4a9fb0b..b1e88aa 100644
--- a/grc/gui/FlowGraph.py
+++ b/grc/gui/FlowGraph.py
@@ -309,7 +309,8 @@ class FlowGraph(Element):
             window.draw_rectangle(gc, False, x, y, w, h)
         #draw blocks on top of connections
         hide_disabled_blocks = Actions.TOGGLE_HIDE_DISABLED_BLOCKS.get_active()
-        for element in chain(self.iter_connections(), self.iter_blocks()):
+        blocks = sorted(self.iter_blocks(), key=methodcaller('get_enabled'))
+        for element in chain(self.iter_connections(), blocks):
             if hide_disabled_blocks and not element.get_enabled():
                 continue  # skip hidden disabled blocks and connections
             element.draw(gc, window)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]