def _show_size_warning_dialog(self, basename, size): """Show a warning dialog when trying to open a large file.""" title = _('Open abnormally large file "{}"?').format(basename) message = _( "Size of the file is {:.1f} MB, which is abnormally large for a text-based subtitle file. Please, check that you are not trying to open a binary file." ).format(size) dialog = gaupol.WarningDialog(self.window, title, message) dialog.add_button(_("_Cancel"), Gtk.ResponseType.NO) dialog.add_button(_("_Open"), Gtk.ResponseType.YES) dialog.set_default_response(Gtk.ResponseType.NO) response = gaupol.util.flash_dialog(dialog) gaupol.util.raise_default(response != Gtk.ResponseType.YES)
def _show_sort_warning_dialog(self, basename, count): """Show a warning dialog when subtitles have been sorted.""" title = _('Open unsorted file "{}"?').format(basename) message = _( "The order of {:d} subtitles needs to be changed. If {:d} sounds like a lot, the file may be erroneously composed." ) message = message.format(count, count) dialog = gaupol.WarningDialog(self.window, title, message) dialog.add_button(_("_Cancel"), Gtk.ResponseType.NO) dialog.add_button(_("_Open"), Gtk.ResponseType.YES) dialog.set_default_response(Gtk.ResponseType.YES) response = gaupol.util.flash_dialog(dialog) gaupol.util.raise_default(response != Gtk.ResponseType.YES)
def _confirm_close_document(self, page, doc): """Close `page` after asking to save `doc`.""" title = _('Save changes to document "{}" before closing?') title = title.format(page.get_basename(doc)) message = _("If you don't save, changes will be permanently lost.") dialog = gaupol.WarningDialog(self.window, title, message) dialog.add_button(_("Close _Without Saving"), Gtk.ResponseType.NO) dialog.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL) dialog.add_button(_("_Save"), Gtk.ResponseType.YES) dialog.set_default_response(Gtk.ResponseType.YES) response = gaupol.util.flash_dialog(dialog) gaupol.util.raise_default(not response in (Gtk.ResponseType.YES, Gtk.ResponseType.NO)) if response == Gtk.ResponseType.YES: self.save(page, doc)
def _show_translation_warning_dialog(self, page): """Show a warning dialog if opening a new translation file.""" title = _( 'Save changes to translation document "{}" before opening a new one?' ).format(page.get_translation_basename()) message = _("If you don't save, changes will be permanently lost.") dialog = gaupol.WarningDialog(self.window, title, message) dialog.add_button(_("Open _Without Saving"), Gtk.ResponseType.NO) dialog.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL) dialog.add_button(_("_Save"), Gtk.ResponseType.YES) dialog.set_default_response(Gtk.ResponseType.YES) response = gaupol.util.flash_dialog(dialog) if response == Gtk.ResponseType.YES: return self.save_translation(page) gaupol.util.raise_default(response != Gtk.ResponseType.NO)
def _confirm_close_main(self, page): """ Close `page` after asking to save its main document. Raise :exc:`gaupol.Default` if cancelled and `page` not closed. """ title = _('Save changes to main document "{}" before closing?') title = title.format(page.get_main_basename()) message = _("If you don't save, changes will be permanently lost.") dialog = gaupol.WarningDialog(self.window, title, message) dialog.add_button(_("Close _Without Saving"), Gtk.ResponseType.NO) dialog.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL) dialog.add_button(_("_Save"), Gtk.ResponseType.YES) dialog.set_default_response(Gtk.ResponseType.YES) response = gaupol.util.flash_dialog(dialog) if not response in (Gtk.ResponseType.YES, Gtk.ResponseType.NO): raise gaupol.Default if response == Gtk.ResponseType.YES: self.save_main(page)
def setup_method(self, method): self.dialog = gaupol.WarningDialog(Gtk.Window(), "test", "test") self.dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK) self.dialog.show()
def setup_method(self, method): self.dialog = gaupol.WarningDialog(Gtk.Window(), "test", "test") self.dialog.add_button("_OK", Gtk.ResponseType.OK) self.dialog.set_default_response(Gtk.ResponseType.OK) self.dialog.show()