]> git.gag.com Git - debian/gnuradio/commitdiff
read-only aware
authorjblum <jblum@221aa14e-8319-0410-a670-987f0aec2ac5>
Wed, 8 Oct 2008 20:17:18 +0000 (20:17 +0000)
committerjblum <jblum@221aa14e-8319-0410-a670-987f0aec2ac5>
Wed, 8 Oct 2008 20:17:18 +0000 (20:17 +0000)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9751 221aa14e-8319-0410-a670-987f0aec2ac5

grc/src/gui/ActionHandler.py
grc/src/gui/MainWindow.py
grc/src/gui/NotebookPage.py
grc/todo.txt

index 7558d16aec311d95dd6a3609f4683248ef847ebf..cc41e937c02ff3bb4b7fa299624969d53cb8bf22 100644 (file)
@@ -328,7 +328,10 @@ class ActionHandler:
                elif state == Actions.FLOW_GRAPH_CLOSE:
                        self.main_window.close_page()
                elif state == Actions.FLOW_GRAPH_SAVE:
-                       if not self.get_page().get_file_path(): self.handle_states(Actions.FLOW_GRAPH_SAVE_AS)
+                       #read-only or undefines file path, do save-as
+                       if self.get_page().get_read_only() or not self.get_page().get_file_path():
+                               self.handle_states(Actions.FLOW_GRAPH_SAVE_AS)
+                       #otherwise try to save
                        else:
                                try:
                                        ParseXML.to_file(self.get_flow_graph().export_data(), self.get_page().get_file_path())
@@ -338,12 +341,12 @@ class ActionHandler:
                                        self.get_page().set_saved(False)
                elif state == Actions.FLOW_GRAPH_SAVE_AS:
                        file_path = SaveFlowGraphFileDialog(self.get_page().get_file_path()).run()
-                       if file_path != None:
+                       if file_path is not None:
                                self.get_page().set_file_path(file_path)
                                self.handle_states(Actions.FLOW_GRAPH_SAVE)
                elif state == Actions.FLOW_GRAPH_SCREEN_CAPTURE:
                        file_path = SaveImageFileDialog(self.get_page().get_file_path()).run()
-                       if file_path != None:
+                       if file_path is not None:
                                pixmap = self.get_flow_graph().get_drawing_area().pixmap
                                width, height = pixmap.get_size()
                                pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, 0, 8, width, height)
index b86ec4cbdc960310a691ceb159734093d8de2236..95a362688dce509f0e7cc671f811f247d761d97d 100644 (file)
@@ -246,6 +246,7 @@ class MainWindow(gtk.Window):
                                        ' - Editing: ',
                                        (self.get_page().get_file_path() or NEW_FLOGRAPH_TITLE),
                                        (self.get_page().get_saved() and ' ' or '*'), #blank must be non empty
+                                       (self.get_page().get_read_only() and ' (read-only)' or ''),
                                )
                        )
                else: title = MAIN_WINDOW_PREFIX + ' - Editor '
@@ -262,6 +263,7 @@ class MainWindow(gtk.Window):
                        page.set_text(''.join((
                                                (title or NEW_FLOGRAPH_TITLE),
                                                (page.get_saved() and ' ' or '*'), #blank must be non empty
+                                               (page.get_read_only() and ' (ro)' or ''),
                                        )
                                )
                        )
index a25243b188f6fb4a8f372eb2fd4156b8d14fede0..e2e627a2d5fda11f11a1f95a88f62ddd382835f3 100644 (file)
@@ -135,6 +135,15 @@ class NotebookPage(gtk.HBox):
                """
                return self._flow_graph
 
+       def get_read_only(self):
+               """
+               Get the read-only state of the file.
+               Always false for empty path.
+               @return true for read-only
+               """
+               if not self.get_file_path(): return False
+               return not os.access(self.get_file_path(), os.W_OK)
+
        def get_file_path(self):
                """
                Get the file path for the flow graph.
index bce1028eae78d1939e90668db9b68bd27aaca7d2..97c59f1e8af484ffa61640e8cc3cff90fb9b7975 100644 (file)
@@ -32,7 +32,6 @@
 -dont hide vlen controller when vlen > 1
 -dont generate py files in .grc file dir
 -save/restore cwd
--check for .grc file readonly, ro message in window, no save option
 
 ##################################################
 # External