Class: Alexandria::UI::ExportDialog
- Inherits:
-
Gtk::FileChooserDialog
- Object
- Gtk::FileChooserDialog
- Alexandria::UI::ExportDialog
- Extended by:
- GetText
- Includes:
- GetText
- Defined in:
- lib/alexandria/ui/dialogs/export_dialog.rb
Constant Summary collapse
- FORMATS =
Alexandria::ExportFormat.all
- THEMES =
Alexandria::WebTheme.all
Instance Method Summary collapse
-
#initialize(parent, library, sort_order) ⇒ ExportDialog
constructor
A new instance of ExportDialog.
Constructor Details
#initialize(parent, library, sort_order) ⇒ ExportDialog
Returns a new instance of ExportDialog.
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/alexandria/ui/dialogs/export_dialog.rb', line 53 def initialize(parent, library, sort_order) super(title: _("Export '%s'") % library.name, action: :save, buttons: [[Gtk::Stock::HELP, :help], [Gtk::Stock::CANCEL, :cancel], [_('_Export'), :accept]]) self.transient_for = parent self.current_name = library.name signal_connect('destroy') { 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 grid while ((response = run) != :cancel) && (response != :delete_event) if response == :help Alexandria::UI.display_help(self, 'exporting') else begin break if on_export(FORMATS[types_combo.active], THEMES[theme_combo.active]) rescue => e raise ErrorDialog.new(self, _('Export failed'), e.) end end end destroy end |