Differential D3659 Diff 8958 plugins/extensions/pykrita/plugin/plugins/scripter/documentcontroller.py
Changeset View
Changeset View
Standalone View
Standalone View
plugins/extensions/pykrita/plugin/plugins/scripter/documentcontroller.py
Show All 10 Lines | 10 | def activeDocument(self): | |||
---|---|---|---|---|---|
11 | return self._activeDocument | 11 | return self._activeDocument | ||
12 | 12 | | |||
13 | def openDocument(self, filePath): | 13 | def openDocument(self, filePath): | ||
14 | if filePath: | 14 | if filePath: | ||
15 | newDocument = document.Document(filePath) | 15 | newDocument = document.Document(filePath) | ||
16 | newDocument.open() | 16 | newDocument.open() | ||
17 | self._activeDocument = newDocument | 17 | self._activeDocument = newDocument | ||
18 | return newDocument | 18 | return newDocument | ||
19 | | ||||
20 | def saveDocument(self, data, filePath): | ||||
21 | if not self._activeDocument: | ||||
22 | self._activeDocument = document.Document(filePath) | ||||
23 | | ||||
24 | dataList = str(data).splitlines() | ||||
25 | | ||||
26 | if not self._activeDocument.compare(dataList): | ||||
27 | self._activeDocument.data = dataList | ||||
28 | self._activeDocument.save() | ||||
29 | | ||||
30 | return self._activeDocument | ||||
31 | | ||||
32 | def clearActiveDocument(self): | ||||
33 | self._activeDocument = None |