From 7f7fa2f91467fdb2b11312be8562e7b51fdeb199 Mon Sep 17 00:00:00 2001
From: Sebastian Koslowski <sebastian.koslowski@gmail.com>
Date: Tue, 3 May 2016 17:13:08 +0200
Subject: grc: added yaml/mako support

Includes basic converter from XML/Cheetah to YAML/Mako based block format.
---
 grc/gui/canvas/param.py | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

(limited to 'grc/gui/canvas/param.py')

diff --git a/grc/gui/canvas/param.py b/grc/gui/canvas/param.py
index b027b7653a..e2c335d9cf 100644
--- a/grc/gui/canvas/param.py
+++ b/grc/gui/canvas/param.py
@@ -39,20 +39,20 @@ class Param(CoreParam):
         Returns:
             gtk input class
         """
-        type_ = self.get_type()
-        if type_ in ('file_open', 'file_save'):
+        dtype = self.dtype
+        if dtype in ('file_open', 'file_save'):
             input_widget_cls = ParamWidgets.FileParam
 
-        elif self.is_enum():
+        elif dtype == 'enum':
             input_widget_cls = ParamWidgets.EnumParam
 
         elif self.options:
             input_widget_cls = ParamWidgets.EnumEntryParam
 
-        elif type_ == '_multiline':
+        elif dtype == '_multiline':
             input_widget_cls = ParamWidgets.MultiLineEntryParam
 
-        elif type_ == '_multiline_python_external':
+        elif dtype == '_multiline_python_external':
             input_widget_cls = ParamWidgets.PythonEditorParam
 
         else:
@@ -64,8 +64,8 @@ class Param(CoreParam):
         block = self.parent
         # fixme: using non-public attribute here
         has_callback = \
-            hasattr(block, 'get_callbacks') and \
-            any(self.key in callback for callback in block._callbacks)
+            hasattr(block, 'templates') and \
+            any(self.key in callback for callback in block.templates.get('callbacks', ''))
 
         return '<span {underline} {foreground} font_desc="Sans 9">{label}</span>'.format(
             underline='underline="low"' if has_callback else '',
@@ -76,7 +76,7 @@ class Param(CoreParam):
 
     def format_tooltip_text(self):
         errors = self.get_error_messages()
-        tooltip_lines = ['Key: ' + self.key, 'Type: ' + self.get_type()]
+        tooltip_lines = ['Key: ' + self.key, 'Type: ' + self.dtype]
         if self.is_valid():
             value = str(self.get_evaluated())
             if len(value) > 100:
@@ -117,7 +117,7 @@ class Param(CoreParam):
         if not self.is_valid():
             return _truncate(value)
         if value in self.options:
-            return self.options_names[self.options.index(value)]
+            return self.options[value]  # its name
 
         ##################################################
         # Split up formatting by type
@@ -125,7 +125,7 @@ class Param(CoreParam):
         # Default center truncate
         truncate = 0
         e = self.get_evaluated()
-        t = self.get_type()
+        t = self.dtype
         if isinstance(e, bool):
             return str(e)
         elif isinstance(e, Constants.COMPLEX_TYPES):
-- 
cgit v1.2.3