[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 15/101: grc: gtk3: fix paste and domain col
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 15/101: grc: gtk3: fix paste and domain color settings |
Date: |
Thu, 16 Mar 2017 14:57:58 +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 7ac7cf6246e4d984d36c64df10ba4d2b2f6b2204
Author: Sebastian Koslowski <address@hidden>
Date: Thu Jun 9 14:45:24 2016 +0200
grc: gtk3: fix paste and domain color settings
---
grc/core/Connection.py | 6 ++---
grc/core/Element.py | 68 +++++++++++++++++++++++++-------------------------
grc/core/FlowGraph.py | 2 +-
grc/core/Param.py | 2 +-
grc/core/Platform.py | 3 +--
grc/core/Port.py | 2 +-
grc/gui/Colors.py | 2 ++
grc/gui/Connection.py | 11 +++++---
grc/gui/FlowGraph.py | 6 ++---
9 files changed, 52 insertions(+), 50 deletions(-)
diff --git a/grc/core/Connection.py b/grc/core/Connection.py
index 2309d15..52cba42 100644
--- a/grc/core/Connection.py
+++ b/grc/core/Connection.py
@@ -24,7 +24,7 @@ import collections
from six.moves import range
from . import Constants
-from .Element import Element, lazyproperty
+from .Element import Element, lazy_property
class Connection(Element):
@@ -131,11 +131,11 @@ class Connection(Element):
"""
return self.source_block.get_enabled() and
self.sink_block.get_enabled()
- @lazyproperty
+ @lazy_property
def source_block(self):
return self.source_port.parent_block
- @lazyproperty
+ @lazy_property
def sink_block(self):
return self.sink_port.parent_block
diff --git a/grc/core/Element.py b/grc/core/Element.py
index a046d6b..f07bb11 100644
--- a/grc/core/Element.py
+++ b/grc/core/Element.py
@@ -1,36 +1,37 @@
-"""
-Copyright 2008, 2009, 2015 Free Software Foundation, Inc.
-This file is part of GNU Radio
-
-GNU Radio Companion is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-GNU Radio Companion is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-"""
+# Copyright 2008, 2009, 2015, 2016 Free Software Foundation, Inc.
+# This file is part of GNU Radio
+#
+# GNU Radio Companion is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# GNU Radio Companion is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA
import weakref
+import functools
-class lazyproperty(object):
+class lazy_property(object):
+
def __init__(self, func):
self.func = func
+ functools.update_wrapper(self, func)
def __get__(self, instance, cls):
if instance is None:
return self
- else:
- value = self.func(instance)
- setattr(instance, self.func.__name__, value)
- return value
+ value = self.func(instance)
+ weak_value = weakref.proxy(value) if not weakref.ProxyType else value
+ setattr(instance, self.func.__name__, weak_value)
+ return weak_value
class Element(object):
@@ -108,35 +109,34 @@ class Element(object):
def parent(self):
return self._parent()
- def get_parent_of_type(self, cls):
+ def get_parent_by_type(self, cls):
parent = self.parent
if parent is None:
return None
elif isinstance(parent, cls):
return parent
else:
- return parent.get_parent_of_type(cls)
+ return parent.get_parent_by_type(cls)
- @lazyproperty
+ @lazy_property
def parent_platform(self):
from .Platform import Platform
- return self.get_parent_of_type(Platform)
+ return self.get_parent_by_type(Platform)
- @lazyproperty
+ @lazy_property
def parent_flowgraph(self):
from .FlowGraph import FlowGraph
- return self.get_parent_of_type(FlowGraph)
+ return self.get_parent_by_type(FlowGraph)
- @lazyproperty
+ @lazy_property
def parent_block(self):
from .Block import Block
- return self.get_parent_of_type(Block)
+ return self.get_parent_by_type(Block)
- def reset_parents(self):
+ def reset_parents_by_type(self):
"""Reset all lazy properties"""
- # todo: use case?
for name, obj in vars(Element):
- if isinstance(obj, lazyproperty):
+ if isinstance(obj, lazy_property):
delattr(self, name)
def get_children(self):
diff --git a/grc/core/FlowGraph.py b/grc/core/FlowGraph.py
index 1684259..67e86f3 100644
--- a/grc/core/FlowGraph.py
+++ b/grc/core/FlowGraph.py
@@ -53,7 +53,7 @@ class FlowGraph(Element):
Returns:
the flow graph object
"""
- Element.__init__(self, platform)
+ Element.__init__(self, parent=platform)
self._timestamp = time.ctime()
self._options_block = self.parent_platform.get_new_block(self,
'options')
diff --git a/grc/core/Param.py b/grc/core/Param.py
index b21cbcd..35bb176 100644
--- a/grc/core/Param.py
+++ b/grc/core/Param.py
@@ -172,7 +172,7 @@ class Param(Element):
if self._tab_label not in block.get_param_tab_labels():
block.get_param_tab_labels().append(self._tab_label)
# Build the param
- Element.__init__(self, block)
+ Element.__init__(self, parent=block)
# Create the Option objects from the n data
self._options = list()
self._evaluated = None
diff --git a/grc/core/Platform.py b/grc/core/Platform.py
index 2c0b83d..069870d 100644
--- a/grc/core/Platform.py
+++ b/grc/core/Platform.py
@@ -53,10 +53,9 @@ class Platform(Element):
def __init__(self, *args, **kwargs):
""" Make a platform for GNU Radio """
- Element.__init__(self)
+ Element.__init__(self, parent=None)
self.config = self.Config(*args, **kwargs)
-
self.block_docstrings = {}
self.block_docstrings_loaded_callback = lambda: None # dummy to be
replaced by BlockTreeWindow
diff --git a/grc/core/Port.py b/grc/core/Port.py
index 99b5a25..9a33c5c 100644
--- a/grc/core/Port.py
+++ b/grc/core/Port.py
@@ -128,7 +128,7 @@ class Port(Element):
n.setdefault('key', str(next(block.port_counters[dir == 'source'])))
# Build the port
- Element.__init__(self, block)
+ Element.__init__(self, parent=block)
# Grab the data
self._name = n['name']
self._key = n['key']
diff --git a/grc/gui/Colors.py b/grc/gui/Colors.py
index b2ed55b..6ee31e5 100644
--- a/grc/gui/Colors.py
+++ b/grc/gui/Colors.py
@@ -47,6 +47,8 @@ CONNECTION_ENABLED_COLOR = get_color('#000000')
CONNECTION_DISABLED_COLOR = get_color('#BBBBBB')
CONNECTION_ERROR_COLOR = get_color('#FF0000')
+DEFAULT_DOMAIN_COLOR = get_color('#777777')
+
#################################################################################
# param box colors
#################################################################################
diff --git a/grc/gui/Connection.py b/grc/gui/Connection.py
index 3af6bad..d893060 100644
--- a/grc/gui/Connection.py
+++ b/grc/gui/Connection.py
@@ -26,7 +26,6 @@ from . import Utils
from .Constants import CONNECTOR_ARROW_BASE, CONNECTOR_ARROW_HEIGHT
from .Element import Element
-from ..core.Constants import GR_MESSAGE_DOMAIN
from ..core.Connection import Connection as _Connection
@@ -93,9 +92,13 @@ class Connection(Element, _Connection):
# self.line_attributes[1] = Gdk.LINE_DOUBLE_DASH \
# if not source_domain == sink_domain == GR_MESSAGE_DOMAIN \
# else Gdk.LINE_ON_OFF_DASH
- get_domain_color = lambda d: Colors.get_color((
- self.get_parent().get_parent().domains.get(d, {})
- ).get('color') or Colors.DEFAULT_DOMAIN_COLOR_CODE)
+
+ def get_domain_color(domain_name):
+ domain = self.parent_platform.domains.get(domain_name, {})
+ color_spec = domain.get('color')
+ return Colors.get_color(color_spec) if color_spec else \
+ Colors.DEFAULT_DOMAIN_COLOR
+
self._color = get_domain_color(source_domain)
self._bg_color = get_domain_color(sink_domain)
self._arrow_color = self._bg_color if self.is_valid() else
Colors.CONNECTION_ERROR_COLOR
diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py
index 8e4a26e..d7745a5 100644
--- a/grc/gui/FlowGraph.py
+++ b/grc/gui/FlowGraph.py
@@ -131,8 +131,6 @@ class FlowGraph(Element, _Flowgraph):
###########################################################################
def get_drawing_area(self): return self.drawing_area
def queue_draw(self): self.get_drawing_area().queue_draw()
- def get_size(self): return self.get_drawing_area().get_size_request()
- def set_size(self, *args): self.get_drawing_area().set_size_request(*args)
def get_scroll_pane(self): return
self.drawing_area.get_parent().get_parent()
def get_ctrl_mask(self): return self.drawing_area.ctrl_mask
def get_mod1_mask(self): return self.drawing_area.mod1_mask
@@ -207,8 +205,8 @@ class FlowGraph(Element, _Flowgraph):
#recalc the position
h_adj = self.get_scroll_pane().get_hadjustment()
v_adj = self.get_scroll_pane().get_vadjustment()
- x_off = h_adj.get_value() - x_min + h_adj.page_size/4
- y_off = v_adj.get_value() - y_min + v_adj.page_size/4
+ x_off = h_adj.get_value() - x_min + h_adj.get_page_size() / 4
+ y_off = v_adj.get_value() - y_min + v_adj.get_page_size() / 4
if len(self.get_elements()) <= 1:
x_off, y_off = 0, 0
#create blocks
- [Commit-gnuradio] [gnuradio] branch python3 updated (50bfc3d -> 00e775f), git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 07/101: grc-refactor: move param input widgets to separate file, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 04/101: grc: remove all Cheetah templates from GUI, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 03/101: grc-refactor: start clean-up Block.py, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 05/101: grc-refactor: move param entry colors spec in gui package, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 10/101: grc: gtk3: remove some deprecated warnings, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 19/101: grc-refactor: block documentation prop, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 18/101: grc-refactor: block state handling, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 20/101: grc-refactor: Block: remove name getter, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 15/101: grc: gtk3: fix paste and domain color settings,
git <=
- [Commit-gnuradio] [gnuradio] 08/101: grc: gtk3: remove canvas size and enable zooming, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 06/101: grc: gtk3: update props dialog, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 17/101: grc-refactor: move more port type color stuff to gui, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 09/101: grc-refactor: replace some unnecessary getters, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 24/101: grc-refactor: the hopeless cause of bus ports..., git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 25/101: Merge branch 'next_grcwg' into gtk3 (v3.7.10 release), git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 34/101: grc: fix parent getter in rewrite_epy_block, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 13/101: grc-refactor: Connections, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 28/101: grc: refactor: block state handling, git, 2017/03/16
- [Commit-gnuradio] [gnuradio] 26/101: grc: gtk3: enable block comments, git, 2017/03/16