From 8949a9e00e989e98abf334f839b7a4e91a2339e4 Mon Sep 17 00:00:00 2001
From: Seth Hitefield <sdhitefield@gmail.com>
Date: Thu, 5 Jun 2014 14:23:50 -0400
Subject: grc: Fixed scroll functionality in GRC. Also added clear and
 scrollback capability for the logging window

---
 grc/gui/ActionHandler.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

(limited to 'grc/gui/ActionHandler.py')

diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index 65969e0d6f..d76940515f 100644
--- a/grc/gui/ActionHandler.py
+++ b/grc/gui/ActionHandler.py
@@ -61,6 +61,9 @@ class ActionHandler:
         self.main_window = MainWindow(platform)
         self.main_window.connect('delete-event', self._quit)
         self.main_window.connect('key-press-event', self._handle_key_press)
+        # Add actions the report/log text_view can call back to from its context menu
+        self.main_window.text_display.clear_action = Actions.CLEAR_REPORTS
+        self.main_window.text_display.scroll_action = Actions.TOGGLE_SCROLL_LOCK
         self.get_page = self.main_window.get_page
         self.get_flow_graph = self.main_window.get_flow_graph
         self.get_focus_flag = self.main_window.get_focus_flag
@@ -117,7 +120,7 @@ class ActionHandler:
                 Actions.FLOW_GRAPH_SCREEN_CAPTURE, Actions.HELP_WINDOW_DISPLAY,
                 Actions.TYPES_WINDOW_DISPLAY, Actions.TOGGLE_BLOCKS_WINDOW,
                 Actions.TOGGLE_REPORTS_WINDOW, Actions.TOGGLE_HIDE_DISABLED_BLOCKS,
-                Actions.TOOLS_RUN_FDESIGN,
+                Actions.TOOLS_RUN_FDESIGN, Actions.TOGGLE_SCROLL_LOCK, Actions.CLEAR_REPORTS,
             ): action.set_sensitive(True)
             if ParseXML.xml_failures:
                 Messages.send_xml_errors_if_any(ParseXML.xml_failures)
@@ -135,6 +138,7 @@ class ActionHandler:
             self.main_window.btwin.search_entry.hide()
             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())
         elif action == Actions.APPLICATION_QUIT:
             if self.main_window.close_pages():
                 gtk.main_quit()
@@ -373,6 +377,14 @@ class ActionHandler:
             else:
                 self.main_window.btwin.hide()
             Preferences.blocks_window_visibility(visible)
+        elif action == Actions.TOGGLE_SCROLL_LOCK:
+            visible = action.get_active()
+            self.main_window.text_display.scroll_lock = visible
+            if visible:
+                self.main_window.text_display.scroll_to_end()
+        elif action == Actions.CLEAR_REPORTS:
+            self.main_window.text_display.clear()
+                        
         elif action == Actions.TOGGLE_HIDE_DISABLED_BLOCKS:
             Actions.NOTHING_SELECT()
         ##################################################
-- 
cgit v1.2.3