From 89c7ba0666772f5d92fecb2b433d500c2a0c51d0 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Tue, 27 Jan 2015 15:59:36 +0800 Subject: update main2.py --- setup/main2.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'setup/main2.py') diff --git a/setup/main2.py b/setup/main2.py index a860e3e..f66726b 100644 --- a/setup/main2.py +++ b/setup/main2.py @@ -367,6 +367,9 @@ class PreferencesDialog: self.__import_dictionary = self.__builder.get_object("ImportDictionary") self.__import_dictionary.connect("clicked", self.__import_dictionary_cb) + self.__export_dictionary = self.__builder.get_object("ExportDictionary") + self.__export_dictionary.connect("clicked", self.__export_dictionary_cb) + self.__clear_user_data = self.__builder.get_object("ClearUserData") self.__clear_user_data.connect("clicked", self.__clear_user_data_cb, "user") self.__clear_all_data = self.__builder.get_object("ClearAllData") @@ -384,7 +387,7 @@ class PreferencesDialog: def __import_dictionary_cb(self, widget): dialog = Gtk.FileChooserDialog \ - (_("Please choose a file"), None, + (_("Please choose a file"), self.__dialog, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) @@ -400,6 +403,24 @@ class PreferencesDialog: dialog.destroy() + def __export_dictionary_cb(self, widget): + dialog = Gtk.FileChooserDialog \ + (_("Please save a file"), self.__dialog, + Gtk.FileChooserAction.SAVE, + (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, + Gtk.STOCK_SAVE, Gtk.ResponseType.OK)) + + filter_text = Gtk.FileFilter() + filter_text.set_name("Text files") + filter_text.add_mime_type("text/plain") + dialog.add_filter(filter_text) + + response = dialog.run() + if response == Gtk.ResponseType.OK: + self.__set_value("ExportDictionary", dialog.get_filename()) + + dialog.destroy() + def __clear_user_data_cb(self, widget, name): self.__set_value("ClearUserData", name) -- cgit