commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r6375 - in grc/trunk: notes src src/Graphics


From: jblum
Subject: [Commit-gnuradio] r6375 - in grc/trunk: notes src src/Graphics
Date: Sun, 9 Sep 2007 01:14:51 -0600 (MDT)

Author: jblum
Date: 2007-09-09 01:14:51 -0600 (Sun, 09 Sep 2007)
New Revision: 6375

Modified:
   grc/trunk/notes/notes.txt
   grc/trunk/src/Constants.py
   grc/trunk/src/Graphics/FlowGraph.py
   grc/trunk/src/Graphics/MainWindow.py
   grc/trunk/src/Preferences.py
Log:
improved notebook pages GUI

Modified: grc/trunk/notes/notes.txt
===================================================================
--- grc/trunk/notes/notes.txt   2007-09-09 03:42:11 UTC (rev 6374)
+++ grc/trunk/notes/notes.txt   2007-09-09 07:14:51 UTC (rev 6375)
@@ -8,14 +8,12 @@
 -blocks need to fix themselves when they go out of bounds, like in a resize
 -socket controllers should be intelligent on shrinkage
 -usrp transmit dies in lock/unlock
--packet blocks freeze in lock/unlock
--packet: remove flush when freezes fixed
 -audio dies lock/unlock
 
 ############   Features to Add:        ####################
 -startup tips
 -math expr from file
--save settings after close (working directory)
+-save working directory after close
 -create sub-flow graphs to be used in larger flow graphs
 -include dtd in saved flow graphs
 -immediate display of tool tips in entry boxes

Modified: grc/trunk/src/Constants.py
===================================================================
--- grc/trunk/src/Constants.py  2007-09-09 03:42:11 UTC (rev 6374)
+++ grc/trunk/src/Constants.py  2007-09-09 07:14:51 UTC (rev 6375)
@@ -34,7 +34,7 @@
 
######################################################################################################
 
 ##The current version of this code
-VERSION = '0.70 beta'
+VERSION = '0.69 beta'
 
 ##The name to appear in the main window for a flow graph that has not been 
saved to file.
 NEW_FLOGRAPH_TITLE = 'untitled'

Modified: grc/trunk/src/Graphics/FlowGraph.py
===================================================================
--- grc/trunk/src/Graphics/FlowGraph.py 2007-09-09 03:42:11 UTC (rev 6374)
+++ grc/trunk/src/Graphics/FlowGraph.py 2007-09-09 07:14:51 UTC (rev 6375)
@@ -46,9 +46,6 @@
        and the connections between inputs and outputs.
        """     
                
-       signal_block_constructor = GraphicalSignalBlock
-       connection_contructor = GraphicalConnection     
-       
        def __init__(self, handle_states, variable_modification_window):
                """!
                FlowGraph contructor.
@@ -67,8 +64,13 @@
                self.connect('motion-notify-event', self._handle_mouse_motion)
                self.connect('button-press-event', 
self._handle_mouse_button_press)  
                self.connect('button-release-event', 
self._handle_mouse_button_release)         
-               self.set_events(gtk.gdk.BUTTON_PRESS_MASK | 
gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.BUTTON_RELEASE_MASK\
-                | gtk.gdk.LEAVE_NOTIFY_MASK | gtk.gdk.ENTER_NOTIFY_MASK)       
+               self.set_events(
+                       gtk.gdk.BUTTON_PRESS_MASK | \
+                       gtk.gdk.POINTER_MOTION_MASK | \
+                       gtk.gdk.BUTTON_RELEASE_MASK | \
+                       gtk.gdk.LEAVE_NOTIFY_MASK | \
+                       gtk.gdk.ENTER_NOTIFY_MASK
+               )       
                #       setup the focus flag    #               
                self.focus_flag = False
                self.get_focus_flag = lambda: self.focus_flag           

Modified: grc/trunk/src/Graphics/MainWindow.py
===================================================================
--- grc/trunk/src/Graphics/MainWindow.py        2007-09-09 03:42:11 UTC (rev 
6374)
+++ grc/trunk/src/Graphics/MainWindow.py        2007-09-09 07:14:51 UTC (rev 
6375)
@@ -53,7 +53,7 @@
                self.main_window = main_window
                initial_state = ParseXML.from_xml(ParseXML.from_file(file_path 
or INITIAL_FLOW_GRAPH_FILE))
                
self.main_window.get_flow_graph().from_nested_data(initial_state)
-               self.state_cache = StateCache(initial_state)
+               self.state_cache = 
StateCache(self.main_window.get_flow_graph().to_nested_data())
                self.set_pid_file('')
                self.set_file_path(file_path)           
                self.set_saved(True)    
@@ -73,7 +73,7 @@
                image_box.pack_start(image, True, False, 0)
                #setup the button
                button = gtk.Button()
-               button.connect("clicked", self.handle_button)
+               button.connect("clicked", self._handle_button)
                button.set_relief(gtk.RELIEF_NONE)
                button.add(image_box)
                #button size            
@@ -82,7 +82,7 @@
                self.tab.pack_start(button)             
                self.tab.show_all()
                
-       def handle_button(self, button):
+       def _handle_button(self, button):
                """
                The button was clicked.
                Make the current page selected, then close.
@@ -189,8 +189,8 @@
                self.page_to_be_closed = None
                self.current_page = None
                self.notebook.set_show_border(False)
-               self.notebook.set_scrollable(True)
-               self.notebook.connect("switch-page", self.handle_page_change)
+               self.notebook.set_scrollable(True)      #scroll arrows for page 
tabs
+               self.notebook.connect("switch-page", self._handle_page_change)
                fg_and_report_box = gtk.VBox(False, 0)
                fg_and_report_box.pack_start(self.notebook, False, False, 0)
                fg_and_report_box.pack_start(self.scrolled_window)
@@ -215,6 +215,10 @@
                # load preferences and show the main window 
                Preferences.load(self)
                self.show()#show after resize in preferences
+
+       ############################################################
+       ##      Event Handlers
+       ############################################################
                
        def _quit(self, window, event):
                """!
@@ -226,6 +230,24 @@
                self.handle_states(APPLICATION_QUIT)
                return True     
                
+       def _handle_page_change(self, notebook, page, page_num):
+               """!
+               Handle a page change. When the user clicks on a new tab,
+               reload the flow graph to update the vars window and 
+               call handle states (select nothing) to update the buttons.
+               @param notebook the notebook
+               @param page new page
+               @param page_num new page number
+               """             
+               self.current_page = self.notebook.get_nth_page(page_num)
+               state = self.get_page().get_state_cache().get_current_state()
+               self.get_flow_graph().from_nested_data(state)
+               self.handle_states(NOTHING_SELECT) 
+               
+       ############################################################
+       ##      Report Window
+       ############################################################
+       
        def add_report_line(self, line):
                """!
                Place line plus a newline at the end of the text buffer, then 
scroll its window all the way down.
@@ -234,32 +256,7 @@
                self.text_display.insert(line)          
                vadj = self.reports_scrolled_window.get_vadjustment()
                vadj.set_value(vadj.upper)
-                               
-       def set_title(self):
-               """!
-               Set the title and prepend the program name.
-               @param title the window title
-               """     
-               if self.get_page():
-                       title = ''.join((
-                                       MAIN_WINDOW_PREFIX,
-                                       ' - Editing: ',
-                                       (self.get_page().get_file_path() or 
NEW_FLOGRAPH_TITLE),
-                                       (self.get_page().get_saved() and ' ' or 
'*'), #blank must be non empty
-                               )
-                       )
-               else: title = MAIN_WINDOW_PREFIX + ' - Editor '
-               gtk.Window.set_title(self, title)       
-               #set tab titles
-               for page_num in range(self.notebook.get_n_pages()):
-                       page = self.notebook.get_nth_page(page_num)
-                       page.set_text(''.join((
-                                               
(os.path.split(page.file_path)[1] or NEW_FLOGRAPH_TITLE),
-                                               (page.saved and ' ' or '*'), 
#blank must be non empty
-                                       )
-                               )
-                       )
-               
+                                               
        def show_reports_window(self, show):
                """!
                Show the reports window when show is True.
@@ -270,16 +267,9 @@
                else: self.reports_scrolled_window.hide()
                
        ############################################################
-       ##      Pages: New/Open, Close, Change 
+       ##      Pages: create and close
        ############################################################
        
-       def _get_files(self):
-               """
-               Get the file names for all the pages, in order.
-               @return list of file paths
-               """
-               return [self.notebook.get_nth_page(page_num).get_file_path() 
for page_num in range(self.notebook.get_n_pages())]
-               
        def new_page(self, file_path=''):
                """!
                Create a new notebook page.
@@ -288,7 +278,7 @@
                """
                if file_path and file_path in self._get_files(): #already open
                        page = 
self.notebook.get_nth_page(self._get_files().index(file_path))
-                       self.set_page(page)
+                       self._set_page(page)
                        return          
                try: #try to load from file
                        if file_path: Messages.send_start_load(file_path)
@@ -298,29 +288,15 @@
                        Messages.send_fail_load(e)
                        return  
                self.notebook.append_page(page, page.get_tab())
-               self.set_page(page)
+               self._set_page(page)
                
-       def handle_page_change(self, notebook, page, page_num):
-               """!
-               Handle a page change. When the user clicks on a new tab,
-               reload the flow graph to update the vars window and 
-               call handle states (select nothing) to update the buttons.
-               @param notebook the notebook
-               @param page new page
-               @param page_num new page number
-               """             
-               self.current_page = self.notebook.get_nth_page(page_num)
-               state = self.get_page().get_state_cache().get_current_state()
-               self.get_flow_graph().from_nested_data(state)
-               self.handle_states(NOTHING_SELECT) 
-                       
        def close_pages(self):
                """
                Close all the pages in this notebook.           
                @return true if all closed
                """
                files = filter(lambda file: file, self._get_files()) #filter 
blank files
-               for page in [self.notebook.get_nth_page(page_num) for page_num 
in range(self.notebook.get_n_pages())]:
+               for page in self._get_pages():
                        self.page_to_be_closed = page
                        self.close_page(False)
                if self.notebook.get_n_pages(): return False
@@ -329,53 +305,103 @@
                        
        def close_page(self, ensure=True):
                """
-               Close the current flow graph.
+               Close the current page.
                If ensure: ensure there is at least one page in the notebook,
                call new page if get page is none.
                @param ensure boolean
                """
                if not self.page_to_be_closed: self.page_to_be_closed = 
self.get_page()
-               if self._loose_changes(): 
-                       self.handle_states(FLOW_GRAPH_STOP)
-                       
self.notebook.remove_page(self.notebook.page_num(self.page_to_be_closed))
+               #show the page if it has an executing flow graph or is unsaved
+               if self.page_to_be_closed.get_pid_file() or not 
self.page_to_be_closed.get_saved():
+                       self._set_page(self.page_to_be_closed)
+               #unsaved? ask the user
+               if not self.page_to_be_closed.get_saved() and 
self._save_changes(): 
+                       self.handle_states(FLOW_GRAPH_SAVE) #try to save
+                       if not self.page_to_be_closed.get_saved(): #still 
unsaved?
+                               self.page_to_be_closed = None   #set the page 
to be closed back to None
+                               return
+               #stop the flow graph if executing
+               if self.page_to_be_closed.get_pid_file(): 
self.handle_states(FLOW_GRAPH_STOP)
+               #remove the page
+               
self.notebook.remove_page(self.notebook.page_num(self.page_to_be_closed))
                if ensure and self.notebook.get_n_pages() == 0: self.new_page() 
#no pages, make a new one
                self.page_to_be_closed = None   #set the page to be closed back 
to None
        
-       def _loose_changes(self):
+       ############################################################
+       ##      Misc
+       ############################################################
+
+       def set_title(self):
                """!
-               Loose unsaved changes to flow graph?            
-               If the save was not greyed-out, the user is presented with a 
dialog.
-               @return true if save is greyed-out, or the user's choice.
+               Set the title and prepend the program name.
+               @param title the window title
+               """     
+               if self.get_page():
+                       title = ''.join((
+                                       MAIN_WINDOW_PREFIX,
+                                       ' - Editing: ',
+                                       (self.get_page().get_file_path() or 
NEW_FLOGRAPH_TITLE),
+                                       (self.get_page().get_saved() and ' ' or 
'*'), #blank must be non empty
+                               )
+                       )
+               else: title = MAIN_WINDOW_PREFIX + ' - Editor '
+               gtk.Window.set_title(self, title)       
+               #set tab titles
+               for page in self._get_pages():
+                       page.set_text(''.join((
+                                               
(os.path.split(page.get_file_path())[1] or NEW_FLOGRAPH_TITLE),
+                                               (page.get_saved() and ' ' or 
'*'), #blank must be non empty
+                                       )
+                               )
+                       )
+                       
+       def get_flow_graph(self):
                """
-               if self.page_to_be_closed.saved: return True
-               self.set_page(self.page_to_be_closed) #show the page before 
showing the confirm dialog
-               return MessageDialogHelper(
-                       gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, 'Unsaved 
Changes!', 
-                       'Would you like to discard your unsaved changes?'
-               ) == gtk.RESPONSE_YES
-                       
+               Get the flow graph in this main window.
+               @return the flow graph
+               """
+               return self.flow_graph
+               
        def get_page(self):
                """!
                Get the selected page.
                @return the selected page
                """
                return self.current_page
-               
-       def set_page(self, page):
+
+       ############################################################
+       ##      Helpers
+       ############################################################
+
+       def _set_page(self, page):
                """
                Set the current page.
                @param page the page widget
                """
                self.current_page = page
-               
self.notebook.set_current_page(self.notebook.page_num(self.current_page))       
                                
-                               
-       def get_flow_graph(self):
+               
self.notebook.set_current_page(self.notebook.page_num(self.current_page))       
                
+
+       def _save_changes(self):
+               """!
+               Save changes to flow graph?             
+               @return true if yes
                """
-               Get the flow graph in this main window.
-               @return the flow graph
+               return MessageDialogHelper(
+                       gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, 'Unsaved 
Changes!', 
+                       'Would you like to save changes before closing?'
+               ) == gtk.RESPONSE_YES
+               
+       def _get_files(self):
                """
-               return self.flow_graph
-       
+               Get the file names for all the pages, in order.
+               @return list of file paths
+               """
+               return map(lambda page: page.get_file_path(), self._get_pages())
 
-               
-                       
\ No newline at end of file
+       def _get_pages(self):
+               """
+               Get a list of all pages in the notebook.
+               @return list of pages
+               """
+               return [self.notebook.get_nth_page(page_num) for page_num in 
range(self.notebook.get_n_pages())]        
+

Modified: grc/trunk/src/Preferences.py
===================================================================
--- grc/trunk/src/Preferences.py        2007-09-09 03:42:11 UTC (rev 6374)
+++ grc/trunk/src/Preferences.py        2007-09-09 07:14:51 UTC (rev 6375)
@@ -27,11 +27,11 @@
 import ParseXML
 import Messages
 
+PARAM_CHECKING_PREF = GraphicalParam('Parameter Checking', Bool(true='Verify 
Parameters', false='Ignore Invalid Params', default=True))
 CONNECTION_CHECKING_PREF = GraphicalParam('Connection Checking', 
Bool(true='Match Data Types', false='Ignore Data Types', default=True))
-PARAM_CHECKING_PREF = GraphicalParam('Parameter Checking', Bool(true='Verify 
Parameters', false='Ignore Invalid Params', default=True))
 SOCKET_CHECKING_PREF = GraphicalParam('Socket Checking', Bool(true='Require 
Connections', false='Allow Open Sockets', default=True))
 FILES_OPEN_PREF = Param('Files Open', String())
-RESTORE_FILES_PREF = GraphicalParam('Restore Open Files', Bool(true='Yes', 
false='No', default=True))
+RESTORE_FILES_PREF = GraphicalParam('Restore Files', Bool(true='Restore 
Previous Files', false='Restore Nothing', default=True))
 SNAP_TO_GRID_PREF = GraphicalParam('Snap to Grid', Bool(true='On', 
false='Off', default=False))
 GRID_SIZE_PREF = GraphicalParam('Grid Size (pixels)', Enum([
        ('10 pixels', 10), 
@@ -54,9 +54,17 @@
 ###########################################################################
 
 PREFS_LIST = [ #(title, notes, list of preferences)
-       ("Verification", '', [  
+       ("Verification", '''\
+Verification ensures that:
+       signal block parameters pass validation,
+       data types on either side of a connection match,
+       and input/output sockets connect.
+       
+You may disable any one of these validation checks. \
+However, the resulting flow graph may fail execution. \
+''', [ 
+                       (PARAM_CHECKING_PREF, 'param_check'),
                        (CONNECTION_CHECKING_PREF, 'connection_check'),
-                       (PARAM_CHECKING_PREF, 'param_check'),
                        (SOCKET_CHECKING_PREF, 'socket_check'),
                ]
        ),





reply via email to

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