summaryrefslogtreecommitdiff
diff options
-rw-r--r--miaowandpurr/kitten/l10n/handlers/po.py4
-rw-r--r--miaowandpurr/miaow/controller.py15
-rw-r--r--miaowandpurr/miaow/model.py8
3 files changed, 22 insertions, 5 deletions
diff --git a/miaowandpurr/kitten/l10n/handlers/po.py b/miaowandpurr/kitten/l10n/handlers/po.py
index b1dff1b..fd15ea8 100644
--- a/miaowandpurr/kitten/l10n/handlers/po.py
+++ b/miaowandpurr/kitten/l10n/handlers/po.py
@@ -45,7 +45,7 @@ class PoHandler(HandlerBase):
document.append(miaow_file)
return document
- def write(self, file_path, document):
+ def write(self, filename, document):
"""Write self.data to file_path as Po."""
po = polib.POFile()
miaow_file = document[0]
@@ -53,7 +53,7 @@ class PoHandler(HandlerBase):
for unit in miaow_file.body:
entry = polib.POEntry(msgid=unit.source.content,
msgstr=unit.target.content)
- po.append(entry)
+ po.append(entry)
po.save_as_pofile(filename)
if __name__ == '__main__':
diff --git a/miaowandpurr/miaow/controller.py b/miaowandpurr/miaow/controller.py
index 438d82f..68b52a8 100644
--- a/miaowandpurr/miaow/controller.py
+++ b/miaowandpurr/miaow/controller.py
@@ -16,6 +16,9 @@
# along with miaowandpurr; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+# [NOTE]
+# I don't want to have the controller making any call to gtk methods so we can
+# implement an ncurses view if necessary.
try:
import pygtk
pygtk.require('2.0')
@@ -28,6 +31,7 @@ try:
except:
print "GTK is not installed"
sys.exit(1)
+#.
from miaowandpurr.felis import widgets
from miaowandpurr.miaow import view, model
@@ -48,8 +52,11 @@ class MiaowController:
# [TODO]
# Check if the entry has been modified.
# modified = target_buffer.get_modified()
- # We need to set set_modified(False) when the TextView go to the next
+ # 1. We need to set set_modified(False) when the TextView go to the next
# entry.
+ # 2. As we are updating the model everytime we move up/down the entry
+ # list, the exit() method always warn the user for a unsave file (even
+ # when the file has been saved). Fix.
#.
target_start = target_buffer.get_start_iter()
target_end = target_buffer.get_end_iter()
@@ -62,6 +69,8 @@ class MiaowController:
self.model.update_entry(transunit)
def quit(self, obj):
+ # [TODO]
+ # The main window is closing before the dialog. FIX IT
if self.model.modified:
txt = 'The current file has not been saved.\rWould you like to save it?'
if widgets.request_dialog('Save File?', txt):
@@ -69,13 +78,15 @@ class MiaowController:
window = obj.get_toplevel()
window.destroy()
gtk.main_quit()
+ # .
def open(self, obj):
filename = widgets.file_chooser('Open...', gtk.FILE_CHOOSER_ACTION_OPEN)
self.model.open(filename)
def save(self, obj):
- widgets.error_dialog("This feature has not been implemented yet")
+ self._update_model_()
+ self.model.save(self.model.filename)
def save_as(self, obj):
widgets.error_dialog("This feature has not been implemented yet")
diff --git a/miaowandpurr/miaow/model.py b/miaowandpurr/miaow/model.py
index 703b346..760e2d2 100644
--- a/miaowandpurr/miaow/model.py
+++ b/miaowandpurr/miaow/model.py
@@ -74,7 +74,13 @@ class MiaowModel:
self.notify()
def save(self, filename):
- pass
+ for i in self.data:
+ i.node.target.content = i.target
+ i.node.state = i.state
+ self.filename = filename
+ self.l10n_store.write(filename, self.document)
+ self.modified = False
+ self.notify()
def get_states(self):
return self.l10n_store.get_states(self.filename)