plugins/c_ext/c_ext.py
changeset 427 7ac746c07ff2
parent 420 c093ec48f2fd
child 430 5981ad8547f5
--- a/plugins/c_ext/c_ext.py	Thu Oct 22 17:20:24 2009 +0200
+++ b/plugins/c_ext/c_ext.py	Fri Oct 23 15:41:48 2009 +0200
@@ -222,14 +222,28 @@
     _View = None
     def _OpenView(self):
         if not self._View:
-            def _onclose():
-                self._View = None
-            def _onsave():
-                self.GetPlugRoot().SaveProject()
-            self._View = CFileEditor(self.GetPlugRoot().AppFrame, self)
-            self._View._onclose = _onclose
-            self._View._onsave = _onsave
-            self._View.Show()
+            open_cfileeditor = True
+            has_permissions = self.GetPlugRoot().CheckProjectPathPerm()
+            if not has_permissions:
+                dialog = wx.MessageDialog(self.GetPlugRoot().AppFrame,
+                                          _("You don't have write permissions.\nOpen CFileEditor anyway ?"),
+                                          _("Open CFileEditor"),
+                                          wx.YES_NO|wx.ICON_QUESTION)
+                open_cfileeditor = dialog.ShowModal() == wx.ID_YES
+                dialog.Destroy()
+            if open_cfileeditor:
+                def _onclose():
+                    self._View = None
+                if has_permissions:
+                    def _onsave():
+                        self.GetPlugRoot().SaveProject()
+                else:
+                    def _onsave():
+                        pass
+                self._View = CFileEditor(self.GetPlugRoot().AppFrame, self)
+                self._View._onclose = _onclose
+                self._View._onsave = _onsave
+                self._View.Show()
 
     PluginMethods = [
         {"bitmap" : os.path.join("images", "EditCfile"),