diff options
author | Sebastian Koslowski <koslowski@kit.edu> | 2016-05-07 13:32:45 +0200 |
---|---|---|
committer | Seth Hitefield <sdhitefield@gmail.com> | 2016-05-18 18:59:31 -0400 |
commit | c1231897581423b6402beaba02c2b22b3445925c (patch) | |
tree | ee3567b0d493c13c9855a8871d46824d51197aea /grc/gui | |
parent | d535ba24c44247630555d95efc9bde1696d555a4 (diff) |
grc: optionally hide all variable blocks
Diffstat (limited to 'grc/gui')
-rw-r--r-- | grc/gui/ActionHandler.py | 12 | ||||
-rw-r--r-- | grc/gui/Actions.py | 6 | ||||
-rw-r--r-- | grc/gui/Bars.py | 1 | ||||
-rw-r--r-- | grc/gui/FlowGraph.py | 16 |
4 files changed, 28 insertions, 7 deletions
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py index 1d8167491a..422d10748a 100644 --- a/grc/gui/ActionHandler.py +++ b/grc/gui/ActionHandler.py @@ -136,6 +136,7 @@ class ActionHandler: Actions.TOGGLE_SHOW_CODE_PREVIEW_TAB, Actions.TOGGLE_SHOW_FLOWGRAPH_COMPLEXITY, Actions.FLOW_GRAPH_OPEN_QSS_THEME, + Actions.TOGGLE_HIDE_VARIABLES, Actions.SELECT_ALL, ): action.set_sensitive(True) @@ -413,16 +414,17 @@ class ActionHandler: action.save_to_preferences() for page in self.main_window.get_pages(): page.get_flow_graph().create_shapes() - elif action == Actions.TOGGLE_SNAP_TO_GRID: - action.save_to_preferences() - elif action == Actions.TOGGLE_SHOW_BLOCK_COMMENTS: - action.save_to_preferences() - elif action == Actions.TOGGLE_SHOW_CODE_PREVIEW_TAB: + elif action in (Actions.TOGGLE_SNAP_TO_GRID, + Actions.TOGGLE_SHOW_BLOCK_COMMENTS, + Actions.TOGGLE_SHOW_CODE_PREVIEW_TAB): action.save_to_preferences() elif action == Actions.TOGGLE_SHOW_FLOWGRAPH_COMPLEXITY: action.save_to_preferences() for page in self.main_window.get_pages(): page.get_flow_graph().update() + elif action == Actions.TOGGLE_HIDE_VARIABLES: + Actions.NOTHING_SELECT() + action.save_to_preferences() ################################################## # Param Modifications ################################################## diff --git a/grc/gui/Actions.py b/grc/gui/Actions.py index ce5bc4eba8..e2670292b5 100644 --- a/grc/gui/Actions.py +++ b/grc/gui/Actions.py @@ -329,6 +329,12 @@ TOGGLE_HIDE_DISABLED_BLOCKS = ToggleAction( stock_id=gtk.STOCK_MISSING_IMAGE, keypresses=(gtk.keysyms.d, gtk.gdk.CONTROL_MASK), ) +TOGGLE_HIDE_VARIABLES = ToggleAction( + label='Hide Variables', + tooltip='Hide all variable blocks', + preference_name='hide_variables', + default=False, +) TOGGLE_AUTO_HIDE_PORT_LABELS = ToggleAction( label='Auto-Hide _Port Labels', tooltip='Automatically hide port labels', diff --git a/grc/gui/Bars.py b/grc/gui/Bars.py index b758f3c444..c0c4beef75 100644 --- a/grc/gui/Bars.py +++ b/grc/gui/Bars.py @@ -102,6 +102,7 @@ MENU_BAR_LIST = ( Actions.SAVE_REPORTS, Actions.CLEAR_REPORTS, None, + Actions.TOGGLE_HIDE_VARIABLES, Actions.TOGGLE_HIDE_DISABLED_BLOCKS, Actions.TOGGLE_AUTO_HIDE_PORT_LABELS, Actions.TOGGLE_SNAP_TO_GRID, diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py index 9c6bd8f169..c3a88e91e0 100644 --- a/grc/gui/FlowGraph.py +++ b/grc/gui/FlowGraph.py @@ -363,7 +363,8 @@ class FlowGraph(Element, _Flowgraph): Returns: true if changed, otherwise false. """ - if not self.get_selected_blocks(): return False + if not self.get_selected_blocks(): + return False #initialize min and max coordinates min_x, min_y = self.get_selected_block().get_coordinate() max_x, max_y = self.get_selected_block().get_coordinate() @@ -428,10 +429,14 @@ class FlowGraph(Element, _Flowgraph): window.draw_rectangle(gc, False, x, y, w, h) #draw blocks on top of connections hide_disabled_blocks = Actions.TOGGLE_HIDE_DISABLED_BLOCKS.get_active() + hide_variables = Actions.TOGGLE_HIDE_VARIABLES.get_active() blocks = sorted(self.blocks, key=methodcaller('get_enabled')) + for element in chain(self.connections, blocks): if hide_disabled_blocks and not element.get_enabled(): continue # skip hidden disabled blocks and connections + if hide_variables and (element.is_variable or element.is_import): + continue # skip hidden disabled blocks and connections element.draw(gc, window) #draw selected blocks on top of selected connections for selected_element in self.get_selected_connections() + self.get_selected_blocks(): @@ -515,9 +520,16 @@ class FlowGraph(Element, _Flowgraph): selected_port = None selected = set() #check the elements + hide_disabled_blocks = Actions.TOGGLE_HIDE_DISABLED_BLOCKS.get_active() + hide_variables = Actions.TOGGLE_HIDE_VARIABLES.get_active() for element in reversed(self.get_elements()): + if hide_disabled_blocks and not element.get_enabled(): + continue # skip hidden disabled blocks and connections + if hide_variables and (element.is_variable or element.is_import): + continue # skip hidden disabled blocks and connections selected_element = element.what_is_selected(coor, coor_m) - if not selected_element: continue + if not selected_element: + continue # hidden disabled connections, blocks and their ports can not be selected if Actions.TOGGLE_HIDE_DISABLED_BLOCKS.get_active() and ( selected_element.is_block and not selected_element.get_enabled() or |