Changeset 9751

Show
Ignore:
Timestamp:
10/08/08 14:17:18
Author:
jblum
Message:

read-only aware

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gnuradio/trunk/grc/src/gui/ActionHandler.py

    r9668 r9751  
    329329                        self.main_window.close_page() 
    330330                elif state == Actions.FLOW_GRAPH_SAVE: 
    331                         if not self.get_page().get_file_path(): self.handle_states(Actions.FLOW_GRAPH_SAVE_AS) 
     331                        #read-only or undefines file path, do save-as 
     332                        if self.get_page().get_read_only() or not self.get_page().get_file_path(): 
     333                                self.handle_states(Actions.FLOW_GRAPH_SAVE_AS) 
     334                        #otherwise try to save 
    332335                        else: 
    333336                                try: 
     
    339342                elif state == Actions.FLOW_GRAPH_SAVE_AS: 
    340343                        file_path = SaveFlowGraphFileDialog(self.get_page().get_file_path()).run() 
    341                         if file_path != None: 
     344                        if file_path is not None: 
    342345                                self.get_page().set_file_path(file_path) 
    343346                                self.handle_states(Actions.FLOW_GRAPH_SAVE) 
    344347                elif state == Actions.FLOW_GRAPH_SCREEN_CAPTURE: 
    345348                        file_path = SaveImageFileDialog(self.get_page().get_file_path()).run() 
    346                         if file_path != None: 
     349                        if file_path is not None: 
    347350                                pixmap = self.get_flow_graph().get_drawing_area().pixmap 
    348351                                width, height = pixmap.get_size() 
  • gnuradio/trunk/grc/src/gui/MainWindow.py

    r9705 r9751  
    247247                                        (self.get_page().get_file_path() or NEW_FLOGRAPH_TITLE), 
    248248                                        (self.get_page().get_saved() and ' ' or '*'), #blank must be non empty 
     249                                        (self.get_page().get_read_only() and ' (read-only)' or ''), 
    249250                                ) 
    250251                        ) 
     
    263264                                                (title or NEW_FLOGRAPH_TITLE), 
    264265                                                (page.get_saved() and ' ' or '*'), #blank must be non empty 
     266                                                (page.get_read_only() and ' (ro)' or ''), 
    265267                                        ) 
    266268                                ) 
  • gnuradio/trunk/grc/src/gui/NotebookPage.py

    r9525 r9751  
    136136                return self._flow_graph 
    137137 
     138        def get_read_only(self): 
     139                """ 
     140                Get the read-only state of the file. 
     141                Always false for empty path. 
     142                @return true for read-only 
     143                """ 
     144                if not self.get_file_path(): return False 
     145                return not os.access(self.get_file_path(), os.W_OK) 
     146 
    138147        def get_file_path(self): 
    139148                """ 
  • gnuradio/trunk/grc/todo.txt

    r9745 r9751  
    3333-dont generate py files in .grc file dir 
    3434-save/restore cwd 
    35 -check for .grc file readonly, ro message in window, no save option 
    3635 
    3736##################################################