diff options
author | Sebastian Koslowski <koslowski@kit.edu> | 2016-02-11 22:45:55 +0100 |
---|---|---|
committer | Sebastian Koslowski <koslowski@kit.edu> | 2016-02-17 19:55:17 +0100 |
commit | 7453e24321e6ca237ded87a6bbed8d645d2a6b53 (patch) | |
tree | e62d0989c9e7082768dfece98372845658dbef9f /grc | |
parent | d905f0d803574acd158183135e113b807bd7c878 (diff) |
grc-refactor: Platform.py
Diffstat (limited to 'grc')
-rw-r--r-- | grc/core/Connection.py | 8 | ||||
-rw-r--r-- | grc/core/Constants.py | 2 | ||||
-rw-r--r-- | grc/core/FlowGraph.py | 2 | ||||
-rw-r--r-- | grc/core/Messages.py | 2 | ||||
-rw-r--r-- | grc/core/Platform.py | 272 | ||||
-rw-r--r-- | grc/core/Port.py | 2 | ||||
-rw-r--r-- | grc/core/generator/FlowGraphProxy.py | 2 | ||||
-rw-r--r-- | grc/core/generator/Generator.py | 36 | ||||
-rw-r--r-- | grc/gui/ActionHandler.py | 3 | ||||
-rw-r--r-- | grc/gui/BlockTreeWindow.py | 6 | ||||
-rw-r--r-- | grc/gui/Connection.py | 2 | ||||
-rw-r--r-- | grc/gui/Dialogs.py | 12 | ||||
-rw-r--r-- | grc/gui/MainWindow.py | 6 | ||||
-rw-r--r-- | grc/gui/NotebookPage.py | 6 | ||||
-rw-r--r-- | grc/gui/Platform.py | 3 |
15 files changed, 176 insertions, 188 deletions
diff --git a/grc/core/Connection.py b/grc/core/Connection.py index b55ba7e4e5..3aa32ef183 100644 --- a/grc/core/Connection.py +++ b/grc/core/Connection.py @@ -101,17 +101,15 @@ class Connection(Element): platform = self.get_parent().get_parent() source_domain = self.get_source().get_domain() sink_domain = self.get_sink().get_domain() - if (source_domain, sink_domain) not in platform.get_connection_templates(): + if (source_domain, sink_domain) not in platform.connection_templates: self.add_error_message('No connection known for domains "{}", "{}"'.format( source_domain, sink_domain)) too_many_other_sinks = ( - source_domain in platform.get_domains() and - not platform.get_domain(key=source_domain)['multiple_sinks'] and + not platform.domains.get(source_domain, []).get('multiple_sinks', False) and len(self.get_source().get_enabled_connections()) > 1 ) too_many_other_sources = ( - sink_domain in platform.get_domains() and - not platform.get_domain(key=sink_domain)['multiple_sources'] and + not platform.domains.get(sink_domain, []).get('multiple_sources', False) and len(self.get_sink().get_enabled_connections()) > 1 ) if too_many_other_sinks: diff --git a/grc/core/Constants.py b/grc/core/Constants.py index f1dae1d953..b067886595 100644 --- a/grc/core/Constants.py +++ b/grc/core/Constants.py @@ -66,7 +66,7 @@ DEFAULT_DOMAIN = GR_STREAM_DOMAIN BLOCK_FLAG_THROTTLE = 'throttle' BLOCK_FLAG_DISABLE_BYPASS = 'disable_bypass' BLOCK_FLAG_NEED_QT_GUI = 'need_qt_gui' -BLOCK_FLAG_NEED_WX_GUI = 'need_ex_gui' +BLOCK_FLAG_NEED_WX_GUI = 'need_wx_gui' # Block States BLOCK_DISABLED = 0 diff --git a/grc/core/FlowGraph.py b/grc/core/FlowGraph.py index 86d2bf63b4..3d744f74c4 100644 --- a/grc/core/FlowGraph.py +++ b/grc/core/FlowGraph.py @@ -370,7 +370,7 @@ class FlowGraph(Element): 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(), + 'created': '.'.join(self.get_parent().config.version2), 'format': FLOW_GRAPH_FILE_FORMAT_VERSION, }) return odict({'flow_graph': n, '_instructions': instructions}) diff --git a/grc/core/Messages.py b/grc/core/Messages.py index 641ff72659..f794fdbba5 100644 --- a/grc/core/Messages.py +++ b/grc/core/Messages.py @@ -64,7 +64,7 @@ def send_init(platform): return os.path.abspath(os.path.expanduser(x)), x send('\n'.join([ - "<<< Welcome to %s %s >>>" % (p.get_name(), p.get_version()), + "<<< Welcome to %s %s >>>" % (p.config.name, p.config.version), "", "Preferences file: " + p.get_prefs_file(), "Block paths:" diff --git a/grc/core/Platform.py b/grc/core/Platform.py index 2907342be5..f6bb756b4e 100644 --- a/grc/core/Platform.py +++ b/grc/core/Platform.py @@ -1,5 +1,5 @@ """ -Copyright 2008-2015 Free Software Foundation, Inc. +Copyright 2008-2016 Free Software Foundation, Inc. This file is part of GNU Radio GNU Radio Companion is free software; you can redistribute it and/or @@ -21,30 +21,89 @@ import os import sys from gnuradio import gr -from . import ParseXML, Messages -from .Constants import ( - BLOCK_TREE_DTD, FLOW_GRAPH_DTD, DOMAIN_DTD, - HIER_BLOCKS_LIB_DIR, BLOCK_DTD, DEFAULT_FLOW_GRAPH, BLOCKS_DIRS, - PREFS_FILE, CORE_TYPES, PREFS_FILE_OLD, -) +from . import ParseXML, Messages, Constants + from .Element import Element from .generator import Generator +from .FlowGraph import FlowGraph +from .Connection import Connection +from .Block import Block +from .Port import Port +from .Param import Param + from .utils import odict, extract_docs +from os.path import expanduser, normpath, expandvars, dirname, exists + + +class Config(object): + + key = 'grc' + name = 'GNU Radio Companion' + license = __doc__.strip() + website = 'http://gnuradio.org' + version = gr.version() + version2 = (gr.major_version(), gr.api_version(), gr.minor_version()) + + hier_block_lib_dir = os.environ.get('GRC_HIER_PATH', expanduser('~/.grc_gnuradio')) + + def __init__(self): + self.prefs = self._get_prefs() + + # Ensure hier and conf directories + if not exists(self.hier_block_lib_dir): + os.mkdir(self.hier_block_lib_dir) + if not exists(dirname(Constants.PREFS_FILE)): + os.mkdir(dirname(Constants.PREFS_FILE)) + + @staticmethod + def _get_prefs(): + try: + from gnuradio import gr + prefs = gr.prefs() + except ImportError: + import ConfigParser + prefs = ConfigParser.ConfigParser() + + return prefs + + @property + def block_paths(self): + path_list_sep = {'/': ':', '\\': ';'}[os.path.sep] + + paths_sources = ( + self.hier_block_lib_dir, + os.environ.get('GRC_BLOCKS_PATH', ''), + self.prefs.get_string('grc', 'local_blocks_path', ''), + self.prefs.get_string('grc', 'global_blocks_path', ''), + ) + + collected_paths = sum((paths.split(path_list_sep) + for paths in paths_sources), []) + + valid_paths = [normpath(expanduser(expandvars(path))) + for path in collected_paths if exists(path)] + + return valid_paths + + class Platform(Element): + Generator = Generator + FlowGraph = FlowGraph + Connection = Connection + Block = Block + Port = Port + Param = Param + is_platform = True def __init__(self): - """ Make a platform for gnuradio """ + """ Make a platform for GNU Radio """ Element.__init__(self) - # Ensure hier and conf directories - if not os.path.exists(HIER_BLOCKS_LIB_DIR): - os.mkdir(HIER_BLOCKS_LIB_DIR) - if not os.path.exists(os.path.dirname(PREFS_FILE)): - os.mkdir(os.path.dirname(PREFS_FILE)) + self.config = Config() self.block_docstrings = {} self.block_docstrings_loaded_callback = lambda: None # dummy to be replaced by BlockTreeWindow @@ -54,37 +113,27 @@ class Platform(Element): callback_finished=lambda: self.block_docstrings_loaded_callback() ) - self._name = 'GNU Radio Companion' - # Save the version string to the first - version = (gr.version(), gr.major_version(), gr.api_version(), gr.minor_version()) - self._version = version[0] - self._version_major = version[1] - self._version_api = version[2] - self._version_minor = version[3] - self._version_short = version[1] + "." + version[2] + "." + version[3] - - self._key = 'grc' - self._license = __doc__.strip() - self._website = 'http://gnuradio.org' - self._block_paths = list(set(BLOCKS_DIRS)) - self._block_dtd = BLOCK_DTD - self._default_flow_graph = DEFAULT_FLOW_GRAPH - self._generator = Generator - self._colors = [(name, color) for name, key, sizeof, color in CORE_TYPES] + self._block_paths = list(set(Constants.BLOCKS_DIRS)) + 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 = [] - self._blocks = None + self.blocks = None self._blocks_n = None self._category_trees_n = None - self._domains = dict() - self._connection_templates = dict() - self.load_blocks() + self.domains = dict() + self.connection_templates = dict() - _move_old_pref_file() self._auto_hier_block_generate_chain = set() + self.load_blocks() + + def __str__(self): + return 'Platform - {}({})'.format(self.config.key, self.config.name) + @staticmethod def find_file_in_paths(filename, paths, cwd): """Checks the provided paths relative to cwd for a certain filename""" @@ -102,7 +151,7 @@ class Platform(Element): return file_path def load_and_generate_flow_graph(self, file_path): - """Loads a flowgraph from file and generates it""" + """Loads a flow graph from file and generates it""" Messages.set_indent(len(self._auto_hier_block_generate_chain)) Messages.send('>>> Loading: %r\n' % file_path) if file_path in self._auto_hier_block_generate_chain: @@ -127,7 +176,7 @@ class Platform(Element): try: Messages.send('>>> Generating: {}\n'.format(file_path)) - generator = self.get_generator()(flow_graph, file_path) + generator = self.Generator(flow_graph, file_path) generator.write() except Exception as e: Messages.send('>>> Generate Error: {}: {}\n'.format(file_path, str(e))) @@ -140,11 +189,11 @@ class Platform(Element): """load the blocks and block tree from the search paths""" self._docstring_extractor.start() # Reset - self._blocks = odict() + self.blocks = odict() self._blocks_n = odict() self._category_trees_n = list() - self._domains.clear() - self._connection_templates.clear() + self.domains.clear() + self.connection_templates.clear() ParseXML.xml_failures.clear() # Try to parse and load blocks for xml_file in self.iter_xml_files(): @@ -159,7 +208,6 @@ class Platform(Element): # print >> sys.stderr, 'Warning: Block validation failed:\n\t%s\n\tIgnoring: %s' % (e, xml_file) pass except Exception as e: - raise print >> sys.stderr, 'Warning: XML parsing failed:\n\t%r\n\tIgnoring: %s' % (e, xml_file) self._docstring_extractor.finish() @@ -184,10 +232,10 @@ class Platform(Element): # Get block instance and add it to the list of blocks block = self.Block(self._flow_graph, n) key = block.get_key() - if key in self._blocks: + if key in self.blocks: print >> sys.stderr, 'Warning: Block with key "{}" already exists.\n\tIgnoring: {}'.format(key, xml_file) else: # Store the block - self._blocks[key] = block + self.blocks[key] = block self._blocks_n[key] = n self._docstring_extractor.query( @@ -196,31 +244,22 @@ class Platform(Element): block.get_make(raw=True) ) - def _save_docstring_extraction_result(self, key, docstrings): - docs = {} - for match, docstring in docstrings.iteritems(): - if not docstring or match.endswith('_sptr'): - continue - docstring = docstring.replace('\n\n', '\n').strip() - docs[match] = docstring - self.block_docstrings[key] = docs - def load_category_tree_xml(self, xml_file): """Validate and parse category tree file and add it to list""" - ParseXML.validate_dtd(xml_file, BLOCK_TREE_DTD) + ParseXML.validate_dtd(xml_file, Constants.BLOCK_TREE_DTD) n = ParseXML.from_file(xml_file).find('cat') self._category_trees_n.append(n) def load_domain_xml(self, xml_file): """Load a domain properties and connection templates from XML""" - ParseXML.validate_dtd(xml_file, DOMAIN_DTD) + ParseXML.validate_dtd(xml_file, Constants.DOMAIN_DTD) n = ParseXML.from_file(xml_file).find('domain') key = n.find('key') if not key: - print >> sys.stderr, 'Warning: Domain with emtpy key.\n\tIgnoring: {}'.foramt(xml_file) + print >> sys.stderr, 'Warning: Domain with emtpy key.\n\tIgnoring: {}'.format(xml_file) return - if key in self.get_domains(): # test against repeated keys + if key in self.domains: # test against repeated keys print >> sys.stderr, 'Warning: Domain with key "{}" already exists.\n\tIgnoring: {}'.format(key, xml_file) return @@ -239,7 +278,7 @@ class Platform(Element): print >> sys.stderr, 'Warning: Can\'t parse color code "{}" for domain "{}" '.format(color, key) color = None - self._domains[key] = dict( + self.domains[key] = dict( name=n.find('name') or key, multiple_sinks=to_bool(n.find('multiple_sinks'), True), multiple_sources=to_bool(n.find('multiple_sources'), False), @@ -249,27 +288,10 @@ class Platform(Element): key = (connection_n.find('source_domain'), connection_n.find('sink_domain')) if not all(key): print >> sys.stderr, 'Warning: Empty domain key(s) in connection template.\n\t{}'.format(xml_file) - elif key in self._connection_templates: + elif key in self.connection_templates: print >> sys.stderr, 'Warning: Connection template "{}" already exists.\n\t{}'.format(key, xml_file) else: - self._connection_templates[key] = connection_n.find('make') or '' - - def parse_flow_graph(self, flow_graph_file): - """ - Parse a saved flow graph file. - Ensure that the file exists, and passes the dtd check. - - Args: - flow_graph_file: the flow graph file - - Returns: - 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 - ParseXML.validate_dtd(flow_graph_file, FLOW_GRAPH_DTD) - return ParseXML.from_file(flow_graph_file) + self.connection_templates[key] = connection_n.find('make') or '' def load_block_tree(self, block_tree): """ @@ -289,10 +311,10 @@ class Platform(Element): map(lambda c: load_category(c, parent), cat_n.findall('cat')) # Add blocks in this category for block_key in cat_n.findall('block'): - if block_key not in self.get_block_keys(): + if block_key not in self.blocks: print >> sys.stderr, 'Warning: Block key "{}" not found when loading category tree.'.format(block_key) continue - block = self.get_block(block_key) + block = self.blocks[block_key] # If it exists, the block's category shall not be overridden by the xml tree if not block.get_category(): block.set_category(parent) @@ -302,85 +324,53 @@ class Platform(Element): load_category(category_tree_n) # Add blocks to block tree - for block in self.get_blocks(): + for block in self.blocks.itervalues(): # Blocks with empty categories are hidden if not block.get_category(): continue block_tree.add_block(block.get_category(), block) - def __str__(self): - return 'Platform - {}({})'.format(self.get_key(), self.get_name()) - - def get_new_flow_graph(self): - return self.FlowGraph(platform=self) - - def get_generator(self): - return self._generator + def _save_docstring_extraction_result(self, key, docstrings): + docs = {} + for match, docstring in docstrings.iteritems(): + if not docstring or match.endswith('_sptr'): + continue + docstring = docstring.replace('\n\n', '\n').strip() + docs[match] = docstring + self.block_docstrings[key] = docs ############################################## - # Access Blocks + # Access ############################################## - def get_block_keys(self): - return self._blocks.keys() - - def get_block(self, key): - return self._blocks[key] - - def get_blocks(self): - return self._blocks.values() - - def get_new_block(self, flow_graph, key): - return self.Block(flow_graph, n=self._blocks_n[key]) - - def get_domains(self): - return self._domains - - def get_domain(self, key): - return self._domains.get(key) - - def get_connection_templates(self): - return self._connection_templates - - def get_name(self): - return self._name - def get_version(self): - return self._version - - def get_version_major(self): - return self._version_major - - def get_version_api(self): - return self._version_api + def parse_flow_graph(self, flow_graph_file): + """ + Parse a saved flow graph file. + Ensure that the file exists, and passes the dtd check. - def get_version_minor(self): - return self._version_minor + Args: + flow_graph_file: the flow graph file - def get_version_short(self): - return self._version_short + Returns: + 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 + ParseXML.validate_dtd(flow_graph_file, Constants.FLOW_GRAPH_DTD) + return ParseXML.from_file(flow_graph_file) - def get_key(self): - return self._key + def get_new_flow_graph(self): + return self.FlowGraph(platform=self) - def get_license(self): - return self._license + def get_blocks(self): + return self.blocks.values() - def get_website(self): - return self._website + def get_new_block(self, flow_graph, key): + return self.Block(flow_graph, n=self._blocks_n[key]) def get_colors(self): - return self._colors + return [(name, color) for name, key, sizeof, color in Constants.CORE_TYPES] def get_block_paths(self): return self._block_paths - - -def _move_old_pref_file(): - if PREFS_FILE == PREFS_FILE_OLD: - return # prefs file overridden with env var - if os.path.exists(PREFS_FILE_OLD) and not os.path.exists(PREFS_FILE): - try: - import shutil - shutil.move(PREFS_FILE_OLD, PREFS_FILE) - except Exception as e: - print >> sys.stderr, e diff --git a/grc/core/Port.py b/grc/core/Port.py index bfa48102a7..4964a94c2b 100644 --- a/grc/core/Port.py +++ b/grc/core/Port.py @@ -157,7 +157,7 @@ class Port(Element): if self.get_type() not in self.get_types(): self.add_error_message('Type "{}" is not a possible type.'.format(self.get_type())) platform = self.get_parent().get_parent().get_parent() - if self.get_domain() not in platform.get_domains(): + if self.get_domain() not in platform.domains: self.add_error_message('Domain key "{}" is not registered.'.format(self.get_domain())) if not self.get_enabled_connections() and not self.get_optional(): self.add_error_message('Port is not connected.') diff --git a/grc/core/generator/FlowGraphProxy.py b/grc/core/generator/FlowGraphProxy.py index e0e28fc7b0..3723005576 100644 --- a/grc/core/generator/FlowGraphProxy.py +++ b/grc/core/generator/FlowGraphProxy.py @@ -1,4 +1,4 @@ -# Copyright 2008-2015 Free Software Foundation, Inc. +# Copyright 2016 Free Software Foundation, Inc. # This file is part of GNU Radio # # GNU Radio Companion is free software; you can redistribute it and/or diff --git a/grc/core/generator/Generator.py b/grc/core/generator/Generator.py index e83b74db18..a303a6f4cd 100644 --- a/grc/core/generator/Generator.py +++ b/grc/core/generator/Generator.py @@ -1,21 +1,19 @@ -""" -Copyright 2008-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-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 shlex import subprocess @@ -249,7 +247,7 @@ class TopBlockGenerator(object): c.get_source().get_parent().get_id(), c.get_sink().get_parent().get_id() )) - connection_templates = fg.get_parent().get_connection_templates() + connection_templates = fg.get_parent().connection_templates msgs = filter(lambda c: c.is_msg(), fg.get_enabled_connections()) # List of variable names var_ids = [var.get_id() for var in parameters + variables] diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py index ab7839b20e..41eb6f12b6 100644 --- a/grc/gui/ActionHandler.py +++ b/grc/gui/ActionHandler.py @@ -372,7 +372,8 @@ class ActionHandler: # Window stuff ################################################## elif action == Actions.ABOUT_WINDOW_DISPLAY: - Dialogs.AboutDialog(self.get_flow_graph().get_parent()) + platform = self.get_flow_graph().get_parent() + Dialogs.AboutDialog(platform.config) elif action == Actions.HELP_WINDOW_DISPLAY: Dialogs.HelpDialog() elif action == Actions.TYPES_WINDOW_DISPLAY: diff --git a/grc/gui/BlockTreeWindow.py b/grc/gui/BlockTreeWindow.py index 8a29120102..4279e8c61d 100644 --- a/grc/gui/BlockTreeWindow.py +++ b/grc/gui/BlockTreeWindow.py @@ -175,7 +175,7 @@ class BlockTreeWindow(gtk.VBox): if model.iter_has_child(iter_): return # category node, no doc string key = model.get_value(iter_, KEY_INDEX) - block = self.platform.get_block(key) + block = self.platform.blocks[key] doc = Utils.parse_template(DOC_MARKUP_TMPL, doc=block.get_doc()) model.set_value(iter_, DOC_INDEX, doc) @@ -228,8 +228,8 @@ class BlockTreeWindow(gtk.VBox): self.treeview.set_model(self.treestore) self.treeview.collapse_all() else: - blocks = self.get_flow_graph().get_parent().get_blocks() - matching_blocks = filter(lambda b: key in b.get_key().lower() or key in b.get_name().lower(), blocks) + matching_blocks = filter(lambda b: key in b.get_key().lower() or key in b.get_name().lower(), + self.platform.blocks.values()) self.treestore_search.clear() self._categories_search = {tuple(): None} diff --git a/grc/gui/Connection.py b/grc/gui/Connection.py index 733c6b7218..50361c19d0 100644 --- a/grc/gui/Connection.py +++ b/grc/gui/Connection.py @@ -92,7 +92,7 @@ class Connection(Element, _Connection): if not source_domain == sink_domain == GR_MESSAGE_DOMAIN \ else gtk.gdk.LINE_ON_OFF_DASH get_domain_color = lambda d: Colors.get_color(( - self.get_parent().get_parent().get_domain(d) or {} + self.get_parent().get_parent().domains.get(d, {}) ).get('color') or Colors.DEFAULT_DOMAIN_COLOR_CODE) self._color = get_domain_color(source_domain) self._bg_color = get_domain_color(sink_domain) diff --git a/grc/gui/Dialogs.py b/grc/gui/Dialogs.py index 7d55e1b2e7..c5b4d8b2a7 100644 --- a/grc/gui/Dialogs.py +++ b/grc/gui/Dialogs.py @@ -175,14 +175,14 @@ def ErrorsDialog(flowgraph): MessageDialogHelper( class AboutDialog(gtk.AboutDialog): """A cute little about dialog.""" - def __init__(self, platform): + def __init__(self, config): """AboutDialog constructor.""" gtk.AboutDialog.__init__(self) - self.set_name(platform.get_name()) - self.set_version(platform.get_version()) - self.set_license(platform.get_license()) - self.set_copyright(platform.get_license().splitlines()[0]) - self.set_website(platform.get_website()) + self.set_name(config.name) + self.set_version(config.version) + self.set_license(config.license) + self.set_copyright(config.license.splitlines()[0]) + self.set_website(config.website) self.run() self.destroy() diff --git a/grc/gui/MainWindow.py b/grc/gui/MainWindow.py index 18118dbd79..6da240d85b 100644 --- a/grc/gui/MainWindow.py +++ b/grc/gui/MainWindow.py @@ -69,11 +69,13 @@ class MainWindow(gtk.Window): Setup the menu, toolbar, flowgraph editor notebook, block selection window... """ self._platform = platform - gen_opts = platform.get_block('options').get_param('generate_options') + + gen_opts = platform.blocks['options'].get_param('generate_options') generate_mode_default = gen_opts.get_value() generate_modes = [ (o.get_key(), o.get_name(), o.get_key() == generate_mode_default) for o in gen_opts.get_options()] + # load preferences Preferences.load(platform) #setup window @@ -281,7 +283,7 @@ class MainWindow(gtk.Window): new_flowgraph_title=NEW_FLOGRAPH_TITLE, read_only=self.get_page().get_read_only(), saved=self.get_page().get_saved(), - platform_name=self._platform.get_name(), + platform_name=self._platform.config.name, ) ) #set tab titles diff --git a/grc/gui/NotebookPage.py b/grc/gui/NotebookPage.py index 481aca4eea..2c1fd7c3b3 100644 --- a/grc/gui/NotebookPage.py +++ b/grc/gui/NotebookPage.py @@ -95,10 +95,8 @@ class NotebookPage(gtk.HBox): Returns: generator """ - return self.get_flow_graph().get_parent().get_generator()( - self.get_flow_graph(), - self.get_file_path(), - ) + platform = self.get_flow_graph().get_parent() + return platform.Generator(self.get_flow_graph(), self.get_file_path()) def _handle_button(self, button): """ diff --git a/grc/gui/Platform.py b/grc/gui/Platform.py index 793065b025..85a6872027 100644 --- a/grc/gui/Platform.py +++ b/grc/gui/Platform.py @@ -40,7 +40,8 @@ class Platform(Element, _Platform): self._move_old_pref_file() self._prefs_file = PREFS_FILE - def get_prefs_file(self): return self._prefs_file + def get_prefs_file(self): + return self._prefs_file @staticmethod def _move_old_pref_file(): |