[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 02/13: grc: show preview of generated code
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 02/13: grc: show preview of generated code in each blocks properties dialog |
Date: |
Fri, 24 Jul 2015 15:33:48 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 93caad2a76027d0026dc021da2fd925ca295d477
Author: Sebastian Koslowski <address@hidden>
Date: Fri Jul 17 09:58:55 2015 +0200
grc: show preview of generated code in each blocks properties dialog
---
grc/gui/PropsDialog.py | 49 +++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 41 insertions(+), 8 deletions(-)
diff --git a/grc/gui/PropsDialog.py b/grc/gui/PropsDialog.py
index 470e2d5..009c763 100644
--- a/grc/gui/PropsDialog.py
+++ b/grc/gui/PropsDialog.py
@@ -21,9 +21,11 @@ import pygtk
pygtk.require('2.0')
import gtk
+import Actions
from Dialogs import SimpleTextDisplay
-from Constants import MIN_DIALOG_WIDTH, MIN_DIALOG_HEIGHT
+from Constants import MIN_DIALOG_WIDTH, MIN_DIALOG_HEIGHT, FONT_SIZE
import Utils
+import pango
TAB_LABEL_MARKUP_TMPL="""\
#set $foreground = $valid and 'black' or 'red'
@@ -101,6 +103,17 @@ class PropsDialog(gtk.Dialog):
self._docs_box.add_with_viewport(self._docs_text_display)
notebook.append_page(self._docs_box, gtk.Label("Documentation"))
+ # Generated code for the block
+ self._code_text_display = code_view = SimpleTextDisplay()
+ code_view.set_wrap_mode(gtk.WRAP_NONE)
+ code_view.get_buffer().create_tag('b', weight=pango.WEIGHT_BOLD)
+ code_view.modify_font(pango.FontDescription(
+ 'monospace %d' % FONT_SIZE))
+ code_box = gtk.ScrolledWindow()
+ code_box.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ code_box.add_with_viewport(self._code_text_display)
+ notebook.append_page(code_box, gtk.Label("Generated Code"))
+
# Error Messages for the block
self._error_messages_text_display = SimpleTextDisplay()
self._error_box = gtk.ScrolledWindow()
@@ -127,7 +140,7 @@ class PropsDialog(gtk.Dialog):
true if changed
"""
old_hash = self._hash
- #create a tuple of things from each param that affects the params box
+ # create a tuple of things from each param that affects the params box
self._hash = hash(tuple([(
hash(param), param.get_type(), param.get_hide() == 'all',
) for param in self._block.get_params()]))
@@ -138,7 +151,7 @@ class PropsDialog(gtk.Dialog):
A change occurred within a param:
Rewrite/validate the block and update the gui.
"""
- #update for the block
+ # update for the block
self._block.rewrite()
self._block.validate()
self._update_gui()
@@ -155,9 +168,9 @@ class PropsDialog(gtk.Dialog):
Update the documentation block.
Hide the box if there are no docs.
"""
- #update the params box
+ # update the params box
if self._params_changed():
- #hide params box before changing
+ # hide params box before changing
for tab, label, vbox in self._params_boxes:
vbox.hide_all()
# empty the params box
@@ -173,17 +186,35 @@ class PropsDialog(gtk.Dialog):
input_widget = param.get_input(self._handle_changed,
self._activate_apply)
vbox.pack_start(input_widget, input_widget.expand)
label.set_markup(Utils.parse_template(TAB_LABEL_MARKUP_TMPL,
valid=box_all_valid, tab=tab))
- #show params box with new params
+ # show params box with new params
vbox.show_all()
- #update the errors box
+ # update the errors box
if self._block.is_valid():
self._error_box.hide()
else:
self._error_box.show()
messages = '\n\n'.join(self._block.get_error_messages())
self._error_messages_text_display.set_text(messages)
- #update the docs box
+ # update the docs box
self._docs_text_display.set_text(self._block.get_doc())
+ # update the generated code
+ self._update_generated_code_page()
+
+ def _update_generated_code_page(self):
+ buffer = self._code_text_display.get_buffer()
+ block = self._block
+
+ def insert(header, text):
+ if not text:
+ return
+ buffer.insert_with_tags_by_name(buffer.get_end_iter(), header, 'b')
+ buffer.insert(buffer.get_end_iter(), text)
+
+ buffer.delete(buffer.get_start_iter(), buffer.get_end_iter())
+ insert('# Imports\n', '\n'.join(block.get_imports()))
+ if block.get_key().startswith('variable'):
+ insert('\n\n# Variables\n', block.get_var_make())
+ insert('\n\n# Blocks\n', block.get_make())
def _handle_key_press(self, widget, event):
"""
@@ -209,3 +240,5 @@ class PropsDialog(gtk.Dialog):
self.set_response_sensitive(gtk.RESPONSE_APPLY, False)
return True
return False
+
+
- [Commit-gnuradio] [gnuradio] branch master updated (cc973de -> 65d6523), git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 12/13: Merge branch 'maint', git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 13/13: Merge remote-tracking branch 'gnuradio-wg-grc/master_grcwg', git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 06/13: grc: align default flowgraph block with canvas grid, git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 11/13: grc: clean-up Block port counters, git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 02/13: grc: show preview of generated code in each blocks properties dialog,
git <=
- [Commit-gnuradio] [gnuradio] 07/13: grc: fix bus ports spacing in gui, git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 03/13: grc: add default value to ToggleActions, git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 04/13: grc: only show code preview tab after user enables it, git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 01/13: grc: refactor Preferences.py, git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 05/13: grc: add user settings for canvas default size and canvas font size (+ clean-ups), git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 08/13: grc: add QT GUI hier blocks (#727), git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 09/13: grc: add support for dynamic param names, git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 10/13: grc: add struct variable block, git, 2015/07/24