commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 02/11: grc: Fixed scroll functionality in G


From: git
Subject: [Commit-gnuradio] [gnuradio] 02/11: grc: Fixed scroll functionality in GRC. Also added clear and scrollback capability for the logging window
Date: Fri, 13 Jun 2014 22:44:32 +0000 (UTC)

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

jcorgan pushed a commit to branch master
in repository gnuradio.

commit 8949a9e00e989e98abf334f839b7a4e91a2339e4
Author: Seth Hitefield <address@hidden>
Date:   Thu Jun 5 14:23:50 2014 -0400

    grc: Fixed scroll functionality in GRC.
    Also added clear and scrollback capability for the logging window
---
 grc/gui/ActionHandler.py | 14 +++++++++++++-
 grc/gui/Actions.py       |  9 +++++++++
 grc/gui/Bars.py          |  3 +++
 grc/gui/Dialogs.py       | 41 +++++++++++++++++++++++++++++++++++++++++
 grc/gui/MainWindow.py    |  3 +--
 grc/gui/Preferences.py   |  6 ++++++
 6 files changed, 73 insertions(+), 3 deletions(-)

diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index 65969e0..d769405 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()
         ##################################################
diff --git a/grc/gui/Actions.py b/grc/gui/Actions.py
index f633e7c..bf05ea7 100644
--- a/grc/gui/Actions.py
+++ b/grc/gui/Actions.py
@@ -281,6 +281,10 @@ TOGGLE_BLOCKS_WINDOW = ToggleAction(
     tooltip='Toggle visibility of the block tree widget',
     keypresses=(gtk.keysyms.b, gtk.gdk.CONTROL_MASK),
 )
+TOGGLE_SCROLL_LOCK = ToggleAction(
+    label='_Scroll Lock',
+    tooltip='Toggle scrool lock of the logging window',
+)
 ABOUT_WINDOW_DISPLAY = Action(
     label='_About',
     tooltip='About this program',
@@ -345,6 +349,11 @@ FIND_BLOCKS = Action(
     keypresses=(gtk.keysyms.f, gtk.gdk.CONTROL_MASK,
                 gtk.keysyms.slash, NO_MODS_MASK),
 )
+CLEAR_REPORTS = Action(
+    label='_Clear Logs',
+    tooltip='Clear Logs',
+    stock_id=gtk.STOCK_CLEAR,
+)
 OPEN_HIER = Action(
     label='Open H_ier',
     tooltip='Open the source of the selected hierarchical block',
diff --git a/grc/gui/Bars.py b/grc/gui/Bars.py
index da1b146..defde1c 100644
--- a/grc/gui/Bars.py
+++ b/grc/gui/Bars.py
@@ -55,6 +55,7 @@ TOOLBAR_LIST = (
     Actions.RELOAD_BLOCKS,
     Actions.OPEN_HIER,
     Actions.BUSSIFY_SOURCES,
+    Actions.CLEAR_REPORTS,
 )
 
 ##The list of actions and categories for the menu bar.
@@ -88,10 +89,12 @@ MENU_BAR_LIST = (
         Actions.BLOCK_DISABLE,
         None,
         Actions.BLOCK_PARAM_MODIFY,
+        Actions.CLEAR_REPORTS,
     ]),
     (gtk.Action('View', '_View', None, None), [
         Actions.TOGGLE_BLOCKS_WINDOW,
         Actions.TOGGLE_REPORTS_WINDOW,
+        Actions.TOGGLE_SCROLL_LOCK,
         None,
         Actions.ERRORS_WINDOW_DISPLAY,
         Actions.FIND_BLOCKS,
diff --git a/grc/gui/Dialogs.py b/grc/gui/Dialogs.py
index 04e4f0a..f9a3551 100644
--- a/grc/gui/Dialogs.py
+++ b/grc/gui/Dialogs.py
@@ -39,12 +39,20 @@ class TextDisplay(gtk.TextView):
         self.set_editable(False)
         self.set_cursor_visible(False)
         self.set_wrap_mode(gtk.WRAP_WORD_CHAR)
+        
+        # Added for scroll locking
+        self.scroll_lock = True
+        
+        # Add a signal for populating the popup menu
+        self.connect("populate-popup", self.populate_popup)
 
     def insert(self, line):
         # make backspaces work
         line = self._consume_backspaces(line)
         # add the remaining text to buffer
         self.get_buffer().insert(self.get_buffer().get_end_iter(), line)
+        # Automatically scroll on insert
+        self.scroll_to_end()
 
     def _consume_backspaces(self, line):
         """removes text from the buffer if line starts with \b*"""
@@ -61,6 +69,39 @@ class TextDisplay(gtk.TextView):
         # return remaining text
         return line[back_count:]
 
+    def scroll_to_end(self):
+        if (self.scroll_lock == True):
+            buffer = self.get_buffer()
+            buffer.move_mark(buffer.get_insert(), buffer.get_end_iter())
+            self.scroll_to_mark(buffer.get_insert(), 0.0)
+            
+    def clear(self):
+        buffer = self.get_buffer()
+        buffer.delete(buffer.get_start_iter(), buffer.get_end_iter())
+
+    # Callback functions to handle the scrolling lock and clear context menus 
options
+    # Action functions are set by the ActionHandler's init function
+    def clear_cb(self, menu_item, web_view):
+        self.clear_action()
+    def scroll_back_cb(self, menu_item, web_view):
+        # Trigger the toggle action
+        self.scroll_action()
+       
+    # Create a popup menu for the scroll lock and clear functions.
+    def populate_popup(self, view, menu):
+        menu.append(gtk.SeparatorMenuItem())
+        
+        lock = gtk.CheckMenuItem("Scroll Lock")
+        menu.append(lock)
+        lock.set_active(self.scroll_lock)       
+        lock.connect('activate', self.scroll_back_cb, view)        
+    
+        clear = gtk.ImageMenuItem(gtk.STOCK_CLEAR)
+        menu.append(clear)
+        clear.connect('activate', self.clear_cb, view)
+        menu.show_all()
+        return False
+
 def MessageDialogHelper(type, buttons, title=None, markup=None):
     """
     Create a modal message dialog and run it.
diff --git a/grc/gui/MainWindow.py b/grc/gui/MainWindow.py
index 12f3b20..e763855 100644
--- a/grc/gui/MainWindow.py
+++ b/grc/gui/MainWindow.py
@@ -155,8 +155,7 @@ class MainWindow(gtk.Window):
             line: the new text
         """
         self.text_display.insert(line)
-        
self.text_display.scroll_mark_onscreen(self.text_display.get_buffer().get_insert())
-
+      
     ############################################################
     # Pages: create and close
     ############################################################
diff --git a/grc/gui/Preferences.py b/grc/gui/Preferences.py
index b15fb97..a6bd0d6 100644
--- a/grc/gui/Preferences.py
+++ b/grc/gui/Preferences.py
@@ -95,3 +95,9 @@ def blocks_window_visibility(visible=None):
     else:
         try: return _config_parser.getboolean('main', 'blocks_window_visible')
         except: return True
+
+def scroll_lock(visible=None):
+    if visible is not None: _config_parser.set('main', 'scroll_lock', visible)
+    else:
+        try: return _config_parser.getboolean('main', 'scroll_lock')
+        except: return True



reply via email to

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