grc: snippets in init before blocks

Allow new snippet insertion point in the init function but before blocks
are instantiated.  This allows actions or objects that might be required
in the constructors of the blocks, such as connecting to a server, to be
initialized

Signed-off-by: Josh Morman <jmorman@gnuradio.org>
This commit is contained in:
Josh Morman 2022-12-22 06:43:49 -05:00 committed by mormj
parent 9e007e5bc6
commit 883bb7c240
2 changed files with 4 additions and 3 deletions

View File

@ -6,8 +6,8 @@ parameters:
- id: section
label: Section of Flowgraph
dtype: string
options: ['main_after_init', 'main_after_start', 'main_after_stop' ]
option_labels: ['Main - After Init', 'Main - After Start', 'Main - After Stop']
options: ['main_after_init', 'main_after_start', 'main_after_stop', 'init_before_blocks' ]
option_labels: ['Main - After Init', 'Main - After Start', 'Main - After Stop', 'Init - Before Blocks']
- id: priority
label: Priority
dtype: int

View File

@ -55,7 +55,7 @@ ${indent(snip['def'])}
% endfor
\
<%
snippet_sections = ['main_after_init', 'main_after_start', 'main_after_stop']
snippet_sections = ['main_after_init', 'main_after_start', 'main_after_stop', 'init_before_blocks']
snippets = {}
for section in snippet_sections:
snippets[section] = flow_graph.get_snippets_dict(section)
@ -205,6 +205,7 @@ gr.io_signature.makev(${len(io_sigs)}, ${len(io_sigs)}, [${', '.join(size_strs)}
# Blocks
${'##################################################'}
% endif
${'snippets_init_before_blocks(self)' if snippets['init_before_blocks'] else ''}
% for blk, blk_make in blocks:
% if blk_make:
${ indent(blk_make.strip('\n')) }