lib/alexandria/ui/export_dialog.rb in alexandria-book-collection-manager-0.7.5 vs lib/alexandria/ui/export_dialog.rb in alexandria-book-collection-manager-0.7.6

- old
+ new

@@ -8,30 +8,28 @@ require "alexandria/ui/confirm_erase_dialog" require "alexandria/ui/error_dialog" module Alexandria module UI - class ExportDialog < SimpleDelegator + class ExportDialog include GetText extend GetText GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8") FORMATS = Alexandria::ExportFormat.all THEMES = Alexandria::WebTheme.all def initialize(parent, library, sort_order) - @export_dialog = Gtk::FileChooserDialog.new(title: _("Export '%s'") % library.name, - parent: parent, - action: :save, - buttons: [[Gtk::Stock::HELP, :help], - [Gtk::Stock::CANCEL, :cancel], - [_("_Export"), :accept]]) - super(@export_dialog) + @dialog = Gtk::FileChooserDialog.new(title: _("Export '%s'") % library.name, + parent: parent, + action: :save, + buttons: [[Gtk::Stock::HELP, :help], + [Gtk::Stock::CANCEL, :cancel], + [_("_Export"), :accept]]) + @dialog.current_name = library.name + @dialog.signal_connect("destroy") { @dialog.hide } - self.current_name = library.name - signal_connect("destroy") { hide } - @parent = parent @library = library @sort_order = sort_order preview_image = Gtk::Image.new @@ -82,11 +80,11 @@ grid.attach types_label, 0, 0, 1, 1 grid.attach @types_combo, 1, 0, 1, 1 grid.attach theme_label, 0, 1, 1, 1 grid.attach @theme_combo, 1, 1, 1, 1 grid.attach preview_image, 2, 0, 1, 3 - set_extra_widget grid + @dialog.set_extra_widget grid end def perform while ((response = run) != Gtk::ResponseType::CANCEL) && (response != Gtk::ResponseType::DELETE_EVENT) @@ -96,11 +94,11 @@ else begin break if on_export(FORMATS[@types_combo.active], THEMES[@theme_combo.active]) rescue StandardError => ex - ErrorDialog.new(@export_dialog, _("Export failed"), ex.message).display + ErrorDialog.new(@dialog, _("Export failed"), ex.message).display end end end destroy end @@ -110,11 +108,11 @@ def on_export(format, theme) filename = self.filename if format.ext filename += "." + format.ext if File.extname(filename).empty? if File.exist?(filename) - dialog = ConfirmEraseDialog.new(@export_dialog, filename) + dialog = ConfirmEraseDialog.new(@dialog, filename) return unless dialog.erase? FileUtils.rm(filename) end args = [] @@ -123,10 +121,10 @@ unless File.directory?(filename) msg = _("The target, named '%s', is a regular " \ "file. A directory is needed for this " \ "operation. Please select a directory and " \ "try again.") % filename - ErrorDialog.new(@export_dialog, _("Not a directory"), msg).display + ErrorDialog.new(@dialog, _("Not a directory"), msg).display return end else Dir.mkdir(filename) end