[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 50/101: grc: refactor: move type and port c
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 50/101: grc: refactor: move type and port controllers to gui |
Date: |
Thu, 16 Mar 2017 14:58:05 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch python3
in repository gnuradio.
commit 8c47e64c9e40a4b4835ba0f8e4c5fdf77480aadc
Author: Sebastian Koslowski <address@hidden>
Date: Wed Jul 20 15:04:05 2016 +0200
grc: refactor: move type and port controllers to gui
---
grc/core/Block.py | 73 +------------------------------------------------------
grc/gui/Block.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 72 deletions(-)
diff --git a/grc/core/Block.py b/grc/core/Block.py
index 10deec8..8999026 100644
--- a/grc/core/Block.py
+++ b/grc/core/Block.py
@@ -420,24 +420,18 @@ class Block(Element):
return BLOCK_FLAG_DEPRECATED in self.flags
##############################################
- # Access Params
+ # Access
##############################################
def get_param(self, key):
return self.params[key]
- ##############################################
- # Access Sinks
- ##############################################
def get_sink(self, key):
return _get_elem(self.sinks, key)
def get_sinks_gui(self):
return self.filter_bus_port(self.sinks)
- ##############################################
- # Access Sources
- ##############################################
def get_source(self, key):
return _get_elem(self.sources, key)
@@ -471,71 +465,6 @@ class Block(Element):
return "Template error: {}\n {}".format(tmpl, err)
##############################################
- # Controller Modify
- ##############################################
- def type_controller_modify(self, direction):
- """
- Change the type controller.
-
- Args:
- direction: +1 or -1
-
- Returns:
- true for change
- """
- type_templates = ' '.join(p._type for p in self.get_children())
- type_param = None
- for key, param in six.iteritems(self.params):
- if not param.is_enum():
- continue
- # Priority to the type controller
- if param.key in type_templates:
- type_param = param
- break
- # Use param if type param is unset
- if not type_param:
- type_param = param
- if not type_param:
- return False
-
- # Try to increment the enum by direction
- try:
- keys = list(type_param.options.keys())
- old_index = keys.index(type_param.get_value())
- new_index = (old_index + direction + len(keys)) % len(keys)
- type_param.set_value(keys[new_index])
- return True
- except:
- return False
-
- def port_controller_modify(self, direction):
- """
- Change the port controller.
-
- Args:
- direction: +1 or -1
-
- Returns:
- true for change
- """
- changed = False
- # Concat the nports string from the private nports settings of all
ports
- nports_str = ' '.join(port._nports for port in self.get_ports())
- # Modify all params whose keys appear in the nports string
- for key, param in six.iteritems(self.params):
- if param.is_enum() or param.key not in nports_str:
- continue
- # Try to increment the port controller by direction
- try:
- value = param.get_evaluated() + direction
- if value > 0:
- param.set_value(value)
- changed = True
- except:
- pass
- return changed
-
- ##############################################
# Import/Export Methods
##############################################
def export_data(self):
diff --git a/grc/gui/Block.py b/grc/gui/Block.py
index c861193..616396c 100644
--- a/grc/gui/Block.py
+++ b/grc/gui/Block.py
@@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA
from __future__ import absolute_import
import math
+import six
from gi.repository import Gtk, Pango, PangoCairo
from . import Actions, Colors, Utils, Constants
@@ -305,3 +306,68 @@ class Block(CoreBlock, Element):
PangoCairo.update_layout(cr, self._comment_layout)
PangoCairo.show_layout(cr, self._comment_layout)
cr.restore()
+
+ ##############################################
+ # Controller Modify
+ ##############################################
+ def type_controller_modify(self, direction):
+ """
+ Change the type controller.
+
+ Args:
+ direction: +1 or -1
+
+ Returns:
+ true for change
+ """
+ type_templates = ' '.join(p._type for p in self.get_children())
+ type_param = None
+ for key, param in six.iteritems(self.params):
+ if not param.is_enum():
+ continue
+ # Priority to the type controller
+ if param.key in type_templates:
+ type_param = param
+ break
+ # Use param if type param is unset
+ if not type_param:
+ type_param = param
+ if not type_param:
+ return False
+
+ # Try to increment the enum by direction
+ try:
+ keys = list(type_param.options)
+ old_index = keys.index(type_param.get_value())
+ new_index = (old_index + direction + len(keys)) % len(keys)
+ type_param.set_value(keys[new_index])
+ return True
+ except:
+ return False
+
+ def port_controller_modify(self, direction):
+ """
+ Change the port controller.
+
+ Args:
+ direction: +1 or -1
+
+ Returns:
+ true for change
+ """
+ changed = False
+ # Concat the nports string from the private nports settings of all
ports
+ nports_str = ' '.join(port._nports for port in self.get_ports())
+ # Modify all params whose keys appear in the nports string
+ for key, param in six.iteritems(self.params):
+ if param.is_enum() or param.key not in nports_str:
+ continue
+ # Try to increment the port controller by direction
+ try:
+ value = param.get_evaluated() + direction
+ if value > 0:
+ param.set_value(value)
+ changed = True
+ except:
+ pass
+ return changed
- [Commit-gnuradio] [gnuradio] 65/101: grc: gtk3: dashed lines for message connections, thicker ones for custom domains, (continued)
- [Commit-gnuradio] [gnuradio] 65/101: grc: gtk3: dashed lines for message connections, thicker ones for custom domains, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 54/101: grc: refactor: replace get_enabled by prop, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 67/101: grc: remove support for old msg queues, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 60/101: grc: gtk3: update various deprecated gtk calls, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 52/101: grc: refactor: remove get for port and param name, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 40/101: grc: gtk3: remove coordinate getter/setter, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 69/101: grc: gtk3: use darkened bg color for port border, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 55/101: grc: various clean-ups and fixes, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 48/101: grc: refactor: class for nports port clones, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 49/101: grc: refactor: some more bus ports stuff, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 50/101: grc: refactor: move type and port controllers to gui,
git <=
- [Commit-gnuradio] [gnuradio] 66/101: grc: gtk3: remove deprecated add_with_viewport(), git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 73/101: grc: gtk3: Tweaked color styles for ports, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 63/101: grc: gtk3: speed up what_is_selected(), git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 76/101: grc: gtk3: calculate flowgraph canvas size, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 39/101: grc: gtk3: update gui element class, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 86/101: grc: gtk3: Renamed the ActionHandler to Application, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 58/101: grc: gtk3: fix bug in mouse motion handling, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 51/101: grc: gtk3: fix port label hiding, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 59/101: grc: gtk3: fix drag and drop from block tree, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 30/101: grc: refactor: selected blocks handling, git, 2017/03/16