diff options
author | Agustin Zubiaga <aguzubiaga97@gmail.com> | 2011-12-07 00:53:05 (GMT) |
---|---|---|
committer | Agustin Zubiaga <aguzubiaga97@gmail.com> | 2011-12-07 00:53:05 (GMT) |
commit | 415d35ce73334472f479e3ead2b9db4e05dbccb1 (patch) | |
tree | 73d447dccdaa69dd615351f68a313797c2377a93 | |
parent | 682dd2de9c41c44c0f3cb2f0ba162d978596c699 (diff) |
Save as button connected
-rw-r--r-- | activity.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/activity.py b/activity.py index e9629fc..2295e01 100644 --- a/activity.py +++ b/activity.py @@ -100,6 +100,7 @@ class JAMEdit(activity.Activity): activity_toolbar.stop.hide() save_as = gtk.MenuItem(_("Save on the file system.")) activity_toolbar.keep.props.palette.menu.append(save_as) + save_as.connect("activate", self.save_file_as) save_as.show() activity_toolbar.keep.show() @@ -244,6 +245,20 @@ class JAMEdit(activity.Activity): self.editor._search_and_active_language(mime_type) file.close() + def save_file_as(self, widget): + file_path = file_choosers.save_file_dialog() + if file_path: + self.editor.file = file_path + file = open(self.editor.file, "w") + file.write(self.editor._get_all_text()) + file.close() + + self.set_title(os.path.split(file_path)[-1]) + mime_type = mime.get_from_file_name(file_path) + self.metadata["mime_type"] = mime_type + self.editor.file = file_path + self.editor._search_and_active_language(mime_type) + def save_file(self, widget): if self.editor.file: file = open(self.editor.file, "w") |