diff options
-rw-r--r-- | grc/gui/ActionHandler.py | 4 | ||||
-rw-r--r-- | grc/gui/Actions.py | 11 | ||||
-rw-r--r-- | grc/gui/Bars.py | 2 | ||||
-rw-r--r-- | grc/gui/PropsDialog.py | 24 |
4 files changed, 30 insertions, 11 deletions
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py index 1ce4aeda2d..584b4120e6 100644 --- a/grc/gui/ActionHandler.py +++ b/grc/gui/ActionHandler.py @@ -124,6 +124,7 @@ class ActionHandler: Actions.CLEAR_REPORTS, Actions.SAVE_REPORTS, Actions.TOGGLE_AUTO_HIDE_PORT_LABELS, Actions.TOGGLE_SNAP_TO_GRID, Actions.TOGGLE_SHOW_BLOCK_COMMENTS, + Actions.TOGGLE_SHOW_CODE_PREVIEW_TAB, ): action.set_sensitive(True) if ParseXML.xml_failures: Messages.send_xml_errors_if_any(ParseXML.xml_failures) @@ -146,6 +147,7 @@ class ActionHandler: Actions.TOGGLE_SCROLL_LOCK, Actions.TOGGLE_SNAP_TO_GRID, Actions.TOGGLE_SHOW_BLOCK_COMMENTS, + Actions.TOGGLE_SHOW_CODE_PREVIEW_TAB, ): action.load_from_preferences() elif action == Actions.APPLICATION_QUIT: if self.main_window.close_pages(): @@ -410,6 +412,8 @@ class ActionHandler: action.save_to_preferences() elif action == Actions.TOGGLE_SHOW_BLOCK_COMMENTS: action.save_to_preferences() + elif action == Actions.TOGGLE_SHOW_CODE_PREVIEW_TAB: + action.save_to_preferences() ################################################## # Param Modifications ################################################## diff --git a/grc/gui/Actions.py b/grc/gui/Actions.py index cfb72d3c50..d864db7e16 100644 --- a/grc/gui/Actions.py +++ b/grc/gui/Actions.py @@ -278,6 +278,13 @@ TOGGLE_SHOW_BLOCK_COMMENTS = ToggleAction( tooltip="Show comment beneath each block", preference_name='show_block_comments' ) +TOGGLE_SHOW_CODE_PREVIEW_TAB = ToggleAction( + label='Generated Code Preview', + tooltip="Show a preview of the code generated for each Block in its " + "Properties Dialog", + preference_name='show_generated_code_tab', + default=False, +) BLOCK_CREATE_HIER = Action( label='C_reate Hier', tooltip='Create hier block from selected blocks', @@ -308,13 +315,13 @@ ERRORS_WINDOW_DISPLAY = Action( stock_id=gtk.STOCK_DIALOG_ERROR, ) TOGGLE_REPORTS_WINDOW = ToggleAction( - label='Show _Reports', + label='Show _Reports Panel', tooltip='Toggle visibility of the Report widget', keypresses=(gtk.keysyms.r, gtk.gdk.CONTROL_MASK), preference_name='reports_window_visible' ) TOGGLE_BLOCKS_WINDOW = ToggleAction( - label='Show _Block Tree', + label='Show _Block Tree Panel', tooltip='Toggle visibility of the block tree widget', keypresses=(gtk.keysyms.b, gtk.gdk.CONTROL_MASK), preference_name='blocks_window_visible' diff --git a/grc/gui/Bars.py b/grc/gui/Bars.py index abcc3c6434..f0f8dac7fb 100644 --- a/grc/gui/Bars.py +++ b/grc/gui/Bars.py @@ -103,6 +103,8 @@ MENU_BAR_LIST = ( Actions.TOGGLE_SNAP_TO_GRID, Actions.TOGGLE_SHOW_BLOCK_COMMENTS, None, + Actions.TOGGLE_SHOW_CODE_PREVIEW_TAB, + None, Actions.ERRORS_WINDOW_DISPLAY, Actions.FIND_BLOCKS, ]), diff --git a/grc/gui/PropsDialog.py b/grc/gui/PropsDialog.py index 009c763dd4..9594470588 100644 --- a/grc/gui/PropsDialog.py +++ b/grc/gui/PropsDialog.py @@ -104,15 +104,18 @@ class PropsDialog(gtk.Dialog): 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")) + if Actions.TOGGLE_SHOW_CODE_PREVIEW_TAB.get_active(): + 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")) + else: + self._code_text_display = None # Error Messages for the block self._error_messages_text_display = SimpleTextDisplay() @@ -201,6 +204,9 @@ class PropsDialog(gtk.Dialog): self._update_generated_code_page() def _update_generated_code_page(self): + if not self._code_text_display: + return # user disabled code preview + buffer = self._code_text_display.get_buffer() block = self._block |