diff options
author | Sebastian Koslowski <koslowski@kit.edu> | 2014-07-11 23:24:47 +0200 |
---|---|---|
committer | Sebastian Koslowski <koslowski@kit.edu> | 2014-07-11 23:25:38 +0200 |
commit | 9f4a4eae44cfbe146fd32b3015cd3b014673ed47 (patch) | |
tree | 089317100416d30c0e3023bddf3f6ca6dbd42dcd /grc | |
parent | 02db08d26e992a0c9c90b382ce9809d39283a910 (diff) |
grc: toogle action to disable auto-hiding port labels
Diffstat (limited to 'grc')
-rw-r--r-- | grc/gui/ActionHandler.py | 5 | ||||
-rw-r--r-- | grc/gui/Actions.py | 4 | ||||
-rw-r--r-- | grc/gui/Bars.py | 3 | ||||
-rw-r--r-- | grc/gui/FlowGraph.py | 4 | ||||
-rw-r--r-- | grc/gui/Port.py | 25 | ||||
-rw-r--r-- | grc/gui/Preferences.py | 6 |
6 files changed, 42 insertions, 5 deletions
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py index 6ad2d5576f..4b7a30576b 100644 --- a/grc/gui/ActionHandler.py +++ b/grc/gui/ActionHandler.py @@ -118,6 +118,7 @@ class ActionHandler: Actions.TYPES_WINDOW_DISPLAY, Actions.TOGGLE_BLOCKS_WINDOW, Actions.TOGGLE_REPORTS_WINDOW, Actions.TOGGLE_HIDE_DISABLED_BLOCKS, Actions.TOOLS_RUN_FDESIGN, Actions.TOGGLE_SCROLL_LOCK, Actions.CLEAR_REPORTS, + Actions.TOGGLE_AUTO_HIDE_PORT_LABELS ): action.set_sensitive(True) if ParseXML.xml_failures: Messages.send_xml_errors_if_any(ParseXML.xml_failures) @@ -136,6 +137,7 @@ class ActionHandler: Actions.TOGGLE_REPORTS_WINDOW.set_active(Preferences.reports_window_visibility()) Actions.TOGGLE_BLOCKS_WINDOW.set_active(Preferences.blocks_window_visibility()) Actions.TOGGLE_SCROLL_LOCK.set_active(Preferences.scroll_lock()) + Actions.TOGGLE_AUTO_HIDE_PORT_LABELS.set_active(Preferences.auto_hide_port_labels()) elif action == Actions.APPLICATION_QUIT: if self.main_window.close_pages(): gtk.main_quit() @@ -383,6 +385,9 @@ class ActionHandler: self.main_window.text_display.clear() elif action == Actions.TOGGLE_HIDE_DISABLED_BLOCKS: Actions.NOTHING_SELECT() + elif action == Actions.TOGGLE_AUTO_HIDE_PORT_LABELS: + Preferences.auto_hide_port_labels(action.get_active()) + self.main_window.get_flow_graph().create_shapes() ################################################## # Param Modifications ################################################## diff --git a/grc/gui/Actions.py b/grc/gui/Actions.py index 3aa9e61472..3ead795e33 100644 --- a/grc/gui/Actions.py +++ b/grc/gui/Actions.py @@ -242,6 +242,10 @@ TOGGLE_HIDE_DISABLED_BLOCKS = ToggleAction( stock_id=gtk.STOCK_MISSING_IMAGE, keypresses=(gtk.keysyms.d, gtk.gdk.CONTROL_MASK), ) +TOGGLE_AUTO_HIDE_PORT_LABELS = ToggleAction( + label='Auto-hide port _labels', + tooltip='Automatically hide port labels', +) BLOCK_CREATE_HIER = Action( label='C_reate Hier', tooltip='Create hier block from selected blocks', diff --git a/grc/gui/Bars.py b/grc/gui/Bars.py index 11e35c992b..8dae0f6981 100644 --- a/grc/gui/Bars.py +++ b/grc/gui/Bars.py @@ -97,6 +97,9 @@ MENU_BAR_LIST = ( Actions.TOGGLE_SCROLL_LOCK, Actions.CLEAR_REPORTS, None, + Actions.TOGGLE_HIDE_DISABLED_BLOCKS, + Actions.TOGGLE_AUTO_HIDE_PORT_LABELS, + None, Actions.ERRORS_WINDOW_DISPLAY, Actions.FIND_BLOCKS, ]), diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py index 2fb452fe2d..97707f0c5d 100644 --- a/grc/gui/FlowGraph.py +++ b/grc/gui/FlowGraph.py @@ -546,13 +546,15 @@ class FlowGraph(Element): def handle_mouse_motion(self, coordinate): """ - The mouse has moved, respond to mouse dragging. + The mouse has moved, respond to mouse dragging or notify elements Move a selected element to the new coordinate. Auto-scroll the scroll bars at the boundaries. """ #to perform a movement, the mouse must be pressed # (no longer checking pending events via gtk.events_pending() - always true in Windows) if not self.mouse_pressed: + # only continue if mouse-over stuff is enabled (just the auto-hide port label stuff for now) + if not Actions.TOGGLE_AUTO_HIDE_PORT_LABELS.get_active(): return redraw = False for element in reversed(self.get_elements()): over_element = element.what_is_selected(coordinate) diff --git a/grc/gui/Port.py b/grc/gui/Port.py index 2b8facfcff..284a030e4c 100644 --- a/grc/gui/Port.py +++ b/grc/gui/Port.py @@ -23,6 +23,7 @@ from Constants import \ CONNECTOR_EXTENSION_INCREMENT, \ PORT_LABEL_PADDING, PORT_MIN_WIDTH import Utils +import Actions import Colors import pygtk pygtk.require('2.0') @@ -33,6 +34,7 @@ PORT_HIDDEN_MARKUP_TMPL="""\ PORT_MARKUP_TMPL="""\ <span foreground="black" font_desc="Sans 7.5">$encode($port.get_name())</span>""" + class Port(Element): """The graphical port.""" @@ -57,7 +59,7 @@ class Port(Element): elif self.is_sink(): ports = self.get_parent().get_sinks_gui() #get the max width self.W = max([port.W for port in ports] + [PORT_MIN_WIDTH]) - W = self.W if not self._label_hidden else 10 + W = self.W if not self.label_hidden() else 10 #get a numeric index for this port relative to its sibling ports try: index = ports.index(self) @@ -136,7 +138,7 @@ class Port(Element): border_color=self.is_highlighted() and Colors.HIGHLIGHT_COLOR or self.get_parent().is_dummy_block() and Colors.MISSING_BLOCK_BORDER_COLOR or Colors.BORDER_COLOR, ) - if self._label_hidden: + if self.label_hidden(): return X,Y = self.get_coordinate() (x,y),(w,h) = self._areas_list[0] #use the first area's sizes to place the labels @@ -232,10 +234,25 @@ class Port(Element): """ return self.get_parent().is_highlighted() + def label_hidden(self): + """ + Figure out if the label should be shown + + Returns: + true if the label should be hidden + """ + return self._label_hidden and Actions.TOGGLE_AUTO_HIDE_PORT_LABELS.get_active() + def mouse_over(self): + """ + Called from flow graph on mouse-over + """ self._label_hidden = False - return True + return Actions.TOGGLE_AUTO_HIDE_PORT_LABELS.get_active() # only redraw if necessary def mouse_out(self): + """ + Called from flow graph on mouse-out + """ self._label_hidden = True - return True
\ No newline at end of file + return Actions.TOGGLE_AUTO_HIDE_PORT_LABELS.get_active() # only redraw if necessary
\ No newline at end of file diff --git a/grc/gui/Preferences.py b/grc/gui/Preferences.py index a6bd0d6603..d2ffc71410 100644 --- a/grc/gui/Preferences.py +++ b/grc/gui/Preferences.py @@ -101,3 +101,9 @@ def scroll_lock(visible=None): else: try: return _config_parser.getboolean('main', 'scroll_lock') except: return True + +def auto_hide_port_labels(hide=None): + if hide is not None: _config_parser.set('main', 'auto_hide_port_labels', hide) + else: + try: return _config_parser.getboolean('main', 'auto_hide_port_labels') + except: return True |