diff options
author | Peng Wu <alexepico@gmail.com> | 2015-01-27 15:59:36 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2015-01-27 15:59:36 +0800 |
commit | 89c7ba0666772f5d92fecb2b433d500c2a0c51d0 (patch) | |
tree | 63c7d29363bc1c7fc9c5b0e852bc44ec98388c5a | |
parent | b3a40e01b7f60a26e61a0c728b489c0023a68ebe (diff) | |
download | ibus-libpinyin-89c7ba0666772f5d92fecb2b433d500c2a0c51d0.tar.gz ibus-libpinyin-89c7ba0666772f5d92fecb2b433d500c2a0c51d0.tar.xz ibus-libpinyin-89c7ba0666772f5d92fecb2b433d500c2a0c51d0.zip |
update main2.py
-rw-r--r-- | setup/main2.py | 23 |
1 files changed, 22 insertions, 1 deletions
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) |