commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 20/37: grc: toogle action to disable auto-h


From: git
Subject: [Commit-gnuradio] [gnuradio] 20/37: grc: toogle action to disable auto-hiding port labels
Date: Thu, 17 Jul 2014 20:23:41 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

trondeau pushed a commit to branch master
in repository gnuradio.

commit 9f4a4eae44cfbe146fd32b3015cd3b014673ed47
Author: Sebastian Koslowski <address@hidden>
Date:   Fri Jul 11 23:24:47 2014 +0200

    grc: toogle action to disable auto-hiding port labels
---
 grc/gui/ActionHandler.py |  5 +++++
 grc/gui/Actions.py       |  4 ++++
 grc/gui/Bars.py          |  3 +++
 grc/gui/FlowGraph.py     |  4 +++-
 grc/gui/Port.py          | 25 +++++++++++++++++++++----
 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 6ad2d55..4b7a305 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 3aa9e61..3ead795 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 11e35c9..8dae0f6 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 2fb452f..97707f0 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 2b8facf..284a030 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 a6bd0d6..d2ffc71 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]