def _on_add_button_clicked(self, *args): """Add a new fallback encoding.""" dialog = gaupol.EncodingDialog(self._dialog) response = gaupol.util.run_dialog(dialog) encoding = dialog.get_encoding() dialog.destroy() if response != Gtk.ResponseType.OK: return if encoding is None: return if encoding in gaupol.conf.encoding.fallback: return gaupol.conf.encoding.fallback.append(encoding) self._reload_tree_view() self._tree_view.grab_focus() store = self._tree_view.get_model() self._tree_view.set_cursor(len(store) - 1)
def setup_method(self, method): self.dialog = gaupol.EncodingDialog(Gtk.Window()) self.dialog.show()