diff options
Diffstat (limited to 'grc')
-rw-r--r-- | grc/core/Config.py | 13 | ||||
-rw-r--r-- | grc/core/Constants.py | 1 | ||||
-rw-r--r-- | grc/core/Platform.py | 9 | ||||
-rw-r--r-- | grc/core/generator/flow_graph.tmpl | 2 | ||||
-rw-r--r-- | grc/grc.conf.in | 1 |
5 files changed, 19 insertions, 7 deletions
diff --git a/grc/core/Config.py b/grc/core/Config.py index ac38d9978c..78ff344998 100644 --- a/grc/core/Config.py +++ b/grc/core/Config.py @@ -20,6 +20,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA import os from os.path import expanduser, normpath, expandvars, exists +from . import Constants + class Config(object): @@ -28,7 +30,7 @@ class Config(object): license = __doc__.strip() website = 'http://gnuradio.org' - hier_block_lib_dir = os.environ.get('GRC_HIER_PATH', expanduser('~/.grc_gnuradio')) + hier_block_lib_dir = os.environ.get('GRC_HIER_PATH', Constants.DEFAULT_HIER_BLOCK_LIB_DIR) def __init__(self, prefs_file, version, version_parts=None): self.prefs = prefs_file @@ -53,3 +55,12 @@ class Config(object): for path in collected_paths if exists(path)] return valid_paths + + @property + def default_flow_graph(self): + user_default = ( + os.environ.get('GRC_DEFAULT_FLOW_GRAPH') or + self.prefs.get_string('grc', 'default_flow_graph', '') or + os.path.join(self.hier_block_lib_dir, 'default_flow_graph.grc') + ) + return user_default if exists(user_default) else Constants.DEFAULT_FLOW_GRAPH diff --git a/grc/core/Constants.py b/grc/core/Constants.py index eeb1d7f848..61a44d0c78 100644 --- a/grc/core/Constants.py +++ b/grc/core/Constants.py @@ -27,6 +27,7 @@ FLOW_GRAPH_DTD = os.path.join(DATA_DIR, 'flow_graph.dtd') BLOCK_TREE_DTD = os.path.join(DATA_DIR, 'block_tree.dtd') BLOCK_DTD = os.path.join(DATA_DIR, 'block.dtd') DEFAULT_FLOW_GRAPH = os.path.join(DATA_DIR, 'default_flow_graph.grc') +DEFAULT_HIER_BLOCK_LIB_DIR = os.path.expanduser('~/.grc_gnuradio') DOMAIN_DTD = os.path.join(DATA_DIR, 'domain.dtd') # File format versions: diff --git a/grc/core/Platform.py b/grc/core/Platform.py index 416e61615f..297e8b0ae5 100644 --- a/grc/core/Platform.py +++ b/grc/core/Platform.py @@ -60,9 +60,6 @@ class Platform(Element): callback_finished=lambda: self.block_docstrings_loaded_callback() ) - self._block_dtd = Constants.BLOCK_DTD - self._default_flow_graph = Constants.DEFAULT_FLOW_GRAPH - # Create a dummy flow graph for the blocks self._flow_graph = Element(self) self._flow_graph.connections = [] @@ -188,7 +185,7 @@ class Platform(Element): def load_block_xml(self, xml_file): """Load block description from xml file""" # Validate and import - ParseXML.validate_dtd(xml_file, self._block_dtd) + ParseXML.validate_dtd(xml_file, Constants.BLOCK_DTD) n = ParseXML.from_file(xml_file).find('block') n['block_wrapper_path'] = xml_file # inject block wrapper path # Get block instance and add it to the list of blocks @@ -291,8 +288,8 @@ class Platform(Element): nested data @throws exception if the validation fails """ - flow_graph_file = flow_graph_file or self._default_flow_graph - open(flow_graph_file, 'r') # Test open + flow_graph_file = flow_graph_file or self.config.default_flow_graph + open(flow_graph_file, 'r').close() # Test open ParseXML.validate_dtd(flow_graph_file, Constants.FLOW_GRAPH_DTD) return ParseXML.from_file(flow_graph_file) diff --git a/grc/core/generator/flow_graph.tmpl b/grc/core/generator/flow_graph.tmpl index 07c4169525..1ef251c46b 100644 --- a/grc/core/generator/flow_graph.tmpl +++ b/grc/core/generator/flow_graph.tmpl @@ -91,6 +91,7 @@ class $(class_name)(grc_wxgui.top_block_gui): self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) #end if #elif $generate_options == 'qt_gui' +from gnuradio import qtgui class $(class_name)(gr.top_block, Qt.QWidget): @@ -99,6 +100,7 @@ class $(class_name)(gr.top_block, Qt.QWidget): gr.top_block.__init__(self, "$title") Qt.QWidget.__init__(self) self.setWindowTitle("$title") + qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: diff --git a/grc/grc.conf.in b/grc/grc.conf.in index 71c4f63bca..1dbb13bfaa 100644 --- a/grc/grc.conf.in +++ b/grc/grc.conf.in @@ -5,6 +5,7 @@ [grc] global_blocks_path = @blocksdir@ local_blocks_path = +default_flow_graph = xterm_executable = @GRC_XTERM_EXE@ canvas_font_size = 8 canvas_default_size = 1280, 1024 |