Class: Alexandria::UI::ExportDialog
- Inherits:
-
Object
- Object
- Alexandria::UI::ExportDialog
- Extended by:
- GetText
- Includes:
- GetText
- Defined in:
- lib/alexandria/ui/export_dialog.rb
Constant Summary collapse
- FORMATS =
Alexandria::ExportFormat.all
- THEMES =
Alexandria::WebTheme.all
Instance Attribute Summary collapse
-
#dialog ⇒ Object
readonly
Returns the value of attribute dialog.
Instance Method Summary collapse
-
#initialize(parent, library, sort_order) ⇒ ExportDialog
constructor
A new instance of ExportDialog.
- #perform ⇒ Object
Constructor Details
#initialize(parent, library, sort_order) ⇒ ExportDialog
Returns a new instance of ExportDialog.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/alexandria/ui/export_dialog.rb', line 23 def initialize(parent, library, sort_order) @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 } @parent = parent @library = library @sort_order = sort_order preview_image = Gtk::Image.new @theme_combo = Gtk::ComboBoxText.new @theme_combo.valign = :center @theme_combo. = false THEMES.each do |theme| @theme_combo.append_text(theme.name) end @theme_combo.signal_connect("changed") do file = THEMES[@theme_combo.active].preview_file preview_image.pixbuf = GdkPixbuf::Pixbuf.new(file: file) end @theme_combo.active = 0 theme_label = Gtk::Label.new(_("_Theme:"), use_underline: true) theme_label.xalign = 0 theme_label. = @theme_combo @types_combo = Gtk::ComboBoxText.new @types_combo. = false @types_combo.valign = :center FORMATS.each do |format| text = format.name + " (" text += if format.ext "*." + format.ext else _("directory") end text += ")" @types_combo.append_text(text) end @types_combo.active = 0 @types_combo.signal_connect("changed") do visible = FORMATS[@types_combo.active].needs_preview? theme_label.visible = @theme_combo.visible = preview_image.visible = visible end @types_combo.show types_label = Gtk::Label.new(_("Export for_mat:"), use_underline: true) types_label.xalign = 0 types_label. = @types_combo types_label.show # TODO: Re-design extra widget layout grid = Gtk::Grid.new grid.column_spacing = 6 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 @dialog. grid end |
Instance Attribute Details
#dialog ⇒ Object (readonly)
Returns the value of attribute dialog.
21 22 23 |
# File 'lib/alexandria/ui/export_dialog.rb', line 21 def dialog @dialog end |
Instance Method Details
#perform ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/alexandria/ui/export_dialog.rb', line 90 def perform while ((response = dialog.run) != Gtk::ResponseType::CANCEL) && (response != Gtk::ResponseType::DELETE_EVENT) if response == Gtk::ResponseType::HELP Alexandria::UI.display_help(self, "exporting") else begin break if on_export(FORMATS[@types_combo.active], THEMES[@theme_combo.active]) rescue StandardError => ex ErrorDialog.new(@dialog, _("Export failed"), ex.).display break end end end dialog.destroy end |