commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r11030 - gnuradio/trunk/grc/src/gui


From: jblum
Subject: [Commit-gnuradio] r11030 - gnuradio/trunk/grc/src/gui
Date: Thu, 14 May 2009 15:18:29 -0600 (MDT)

Author: jblum
Date: 2009-05-14 15:18:28 -0600 (Thu, 14 May 2009)
New Revision: 11030

Modified:
   gnuradio/trunk/grc/src/gui/ActionHandler.py
   gnuradio/trunk/grc/src/gui/DrawingArea.py
   gnuradio/trunk/grc/src/gui/MainWindow.py
   gnuradio/trunk/grc/src/gui/NotebookPage.py
Log:
Create one drawing area per flowgraph/notebook page.
Previously, there was one global drawing area, and empty notebook pages.

This has the advantage of saving the scroll position though mutiple scroll 
windows,
rendering the flow graph only when the notebook page is realized,
and proper use + appearance of the gtk notebook



Modified: gnuradio/trunk/grc/src/gui/ActionHandler.py
===================================================================
--- gnuradio/trunk/grc/src/gui/ActionHandler.py 2009-05-14 18:47:15 UTC (rev 
11029)
+++ gnuradio/trunk/grc/src/gui/ActionHandler.py 2009-05-14 21:18:28 UTC (rev 
11030)
@@ -61,7 +61,7 @@
                self.main_window.connect('key-press-event', 
self._handle_key_press)
                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.drawing_area.get_focus_flag
+               self.get_focus_flag = self.main_window.get_focus_flag
                #setup the messages
                Messages.register_messenger(self.main_window.add_report_line)
                Messages.send_init()
@@ -170,8 +170,8 @@
                # Cut/Copy/Paste
                ##################################################
                elif state == Actions.BLOCK_CUT:
-                       self.handle_states(BLOCK_COPY)
-                       self.handle_states(ELEMENT_DELETE)
+                       self.handle_states(Actions.BLOCK_COPY)
+                       self.handle_states(Actions.ELEMENT_DELETE)
                elif state == Actions.BLOCK_COPY:
                        self.clipboard = 
self.get_flow_graph().copy_to_clipboard()
                elif state == Actions.BLOCK_PASTE:

Modified: gnuradio/trunk/grc/src/gui/DrawingArea.py
===================================================================
--- gnuradio/trunk/grc/src/gui/DrawingArea.py   2009-05-14 18:47:15 UTC (rev 
11029)
+++ gnuradio/trunk/grc/src/gui/DrawingArea.py   2009-05-14 21:18:28 UTC (rev 
11030)
@@ -28,18 +28,17 @@
        The drawing area also responds to mouse and key events.
        """
 
-       def __init__(self, main_window):
+       def __init__(self, flow_graph):
                """
                DrawingArea contructor.
                Connect event handlers.
                @param main_window the main_window containing all flow graphs
                """
                self.ctrl_mask = False
-               self._main_window = main_window
-               #inject drawing area into main_window
-               self._main_window.drawing_area = self
+               self._flow_graph = flow_graph
                gtk.DrawingArea.__init__(self)
                self.set_size_request(MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT)
+               self.connect('realize', self._handle_window_realize)
                self.connect('configure-event', self._handle_window_configure)
                self.connect('expose-event', self._handle_window_expose)
                self.connect('motion-notify-event', self._handle_mouse_motion)
@@ -58,8 +57,9 @@
                #setup the focus flag
                self._focus_flag = False
                self.get_focus_flag = lambda: self._focus_flag
-               self.connect('leave-notify-event', self._handle_focus_event, 
False)
-               self.connect('enter-notify-event', self._handle_focus_event, 
True)
+               def _handle_focus_event(widget, event, focus_flag): 
self._focus_flag = focus_flag
+               self.connect('leave-notify-event', _handle_focus_event, False)
+               self.connect('enter-notify-event', _handle_focus_event, True)
 
        def new_pixmap(self, width, height): return gtk.gdk.Pixmap(self.window, 
width, height, -1)
 
@@ -70,18 +70,14 @@
                """
                Handle a drag and drop by adding a block at the given 
coordinate.
                """
-               
self._main_window.get_flow_graph().add_new_block(selection_data.data, (x, y))
+               self._flow_graph.add_new_block(selection_data.data, (x, y))
 
-       def _handle_focus_event(self, widget, event, focus_flag):
-               """Record the focus state of the flow graph window."""
-               self._focus_flag = focus_flag
-
        def _handle_mouse_button_press(self, widget, event):
                """
                Forward button click information to the flow graph.
                """
                self.ctrl_mask = event.state & gtk.gdk.CONTROL_MASK
-               self._main_window.get_flow_graph().handle_mouse_button_press(
+               self._flow_graph.handle_mouse_button_press(
                        left_click=(event.button == 1),
                        double_click=(event.type == gtk.gdk._2BUTTON_PRESS),
                        coordinate=(event.x, event.y),
@@ -92,7 +88,7 @@
                Forward button release information to the flow graph.
                """
                self.ctrl_mask = event.state & gtk.gdk.CONTROL_MASK
-               self._main_window.get_flow_graph().handle_mouse_button_release(
+               self._flow_graph.handle_mouse_button_release(
                        left_click=(event.button == 1),
                        coordinate=(event.x, event.y),
                )
@@ -102,10 +98,17 @@
                Forward mouse motion information to the flow graph.
                """
                self.ctrl_mask = event.state & gtk.gdk.CONTROL_MASK
-               self._main_window.get_flow_graph().handle_mouse_motion(
+               self._flow_graph.handle_mouse_motion(
                        coordinate=(event.x, event.y),
                )
 
+       def _handle_window_realize(self, widget):
+               """
+               Called when the window is realized.
+               Update the flowgraph, which calls new pixmap.
+               """
+               self._flow_graph.update()
+
        def _handle_window_configure(self, widget, event):
                """
                Called when the window is resized.
@@ -119,5 +122,5 @@
                Double buffering: draw to pixmap, then draw pixmap to window.
                """
                gc = self.window.new_gc()
-               self._main_window.get_flow_graph().draw(gc, self._pixmap)
+               self._flow_graph.draw(gc, self._pixmap)
                self.window.draw_drawable(gc, self._pixmap, 0, 0, 0, 0, -1, -1)

Modified: gnuradio/trunk/grc/src/gui/MainWindow.py
===================================================================
--- gnuradio/trunk/grc/src/gui/MainWindow.py    2009-05-14 18:47:15 UTC (rev 
11029)
+++ gnuradio/trunk/grc/src/gui/MainWindow.py    2009-05-14 21:18:28 UTC (rev 
11030)
@@ -18,7 +18,6 @@
 """
 
 from Constants import \
-       MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT, \
        NEW_FLOGRAPH_TITLE, DEFAULT_REPORTS_WINDOW_WIDTH
 from Actions import \
        APPLICATION_QUIT, FLOW_GRAPH_KILL, \
@@ -29,7 +28,6 @@
 import Bars
 from BlockTreeWindow import BlockTreeWindow
 from Dialogs import TextDisplay, MessageDialogHelper
-from DrawingArea import DrawingArea
 from NotebookPage import NotebookPage
 import Preferences
 import Messages
@@ -59,12 +57,6 @@
                vbox.pack_start(Bars.MenuBar(), False)
                vbox.pack_start(Bars.Toolbar(), False)
                vbox.pack_start(self.hpaned)
-               #setup scrolled window
-               self.scrolled_window = gtk.ScrolledWindow()
-               self.scrolled_window.set_size_request(MIN_WINDOW_WIDTH, 
MIN_WINDOW_HEIGHT)
-               self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, 
gtk.POLICY_AUTOMATIC)
-               self.drawing_area = DrawingArea(self)
-               self.scrolled_window.add_with_viewport(self.drawing_area)
                #create the notebook
                self.notebook = gtk.Notebook()
                self.page_to_be_closed = None
@@ -73,11 +65,9 @@
                self.notebook.set_scrollable(True) #scroll arrows for page tabs
                self.notebook.connect('switch-page', self._handle_page_change)
                #setup containers
-               flow_graph_box = gtk.VBox(False, 0)
                self.flow_graph_vpaned = gtk.VPaned()
-               flow_graph_box.pack_start(self.notebook, False, False, 0)
-               flow_graph_box.pack_start(self.scrolled_window)
-               self.flow_graph_vpaned.pack1(flow_graph_box)
+               #flow_graph_box.pack_start(self.scrolled_window)
+               self.flow_graph_vpaned.pack1(self.notebook)
                self.hpaned.pack1(self.flow_graph_vpaned)
                self.hpaned.pack2(BlockTreeWindow(platform, 
self.get_flow_graph), False) #dont allow resize
                #create the reports window
@@ -155,8 +145,6 @@
                try: #try to load from file
                        if file_path: Messages.send_start_load(file_path)
                        flow_graph = self._platform.get_new_flow_graph()
-                       #inject drawing area and handle states into flow graph
-                       flow_graph.drawing_area = self.drawing_area
                        flow_graph.handle_states = self.handle_states
                        page = NotebookPage(
                                self,
@@ -252,8 +240,7 @@
                                )
                        )
                #show/hide notebook tabs
-               if len(self._get_pages()) > 1: self.notebook.show()
-               else: self.notebook.hide()
+               self.notebook.set_show_tabs(len(self._get_pages()) > 1)
 
        def get_page(self):
                """
@@ -269,6 +256,13 @@
                """
                return self.get_page().get_flow_graph()
 
+       def get_focus_flag(self):
+               """
+               Get the focus flag from the current page.
+               @return the focus flag
+               """
+               return self.get_page().get_drawing_area().get_focus_flag()
+
        ############################################################
        # Helpers
        ############################################################

Modified: gnuradio/trunk/grc/src/gui/NotebookPage.py
===================================================================
--- gnuradio/trunk/grc/src/gui/NotebookPage.py  2009-05-14 18:47:15 UTC (rev 
11029)
+++ gnuradio/trunk/grc/src/gui/NotebookPage.py  2009-05-14 21:18:28 UTC (rev 
11030)
@@ -24,6 +24,8 @@
 from .. utils import ParseXML
 from StateCache import StateCache
 from .. platforms.base.Constants import FLOW_GRAPH_DTD
+from Constants import MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT
+from DrawingArea import DrawingArea
 import os
 
 ############################################################
@@ -56,7 +58,6 @@
                self.set_saved(True)
                #import the data to the flow graph
                self.get_flow_graph().import_data(initial_state)
-               self.get_flow_graph().update()
                #initialize page gui
                gtk.HBox.__init__(self, False, 0)
                self.show()
@@ -81,7 +82,19 @@
                button.set_size_request(w+6, h+6)
                self.tab.pack_start(button, False)
                self.tab.show_all()
+               #setup scroll window and drawing area
+               self.scrolled_window = gtk.ScrolledWindow()
+               self.scrolled_window.set_size_request(MIN_WINDOW_WIDTH, 
MIN_WINDOW_HEIGHT)
+               self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, 
gtk.POLICY_AUTOMATIC)
+               self.drawing_area = DrawingArea(self.get_flow_graph())
+               self.scrolled_window.add_with_viewport(self.get_drawing_area())
+               self.pack_start(self.scrolled_window)
+               #inject drawing area and handle states into flow graph
+               self.get_flow_graph().drawing_area = self.get_drawing_area()
+               self.show_all()
 
+       def get_drawing_area(self): return self.drawing_area
+
        def get_generator(self):
                """
                Get the generator object for this flow graph.





reply via email to

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