Class: Smartdict::Gui::ExportDialog
- Inherits:
-
Gtk::FileChooserDialog
- Object
- Gtk::FileChooserDialog
- Smartdict::Gui::ExportDialog
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/smartdict/gui/export_dialog.rb
Defined Under Namespace
Classes: FormatComboBox, Label
Constant Summary collapse
- DATE_RANGES =
{ "Today" => lambda { Date.today }, "Week" => lambda { 1.week.ago }, "Month" => lambda { 1.month.ago } }
Instance Method Summary collapse
- #export_translations ⇒ Object
- #init_date_range_buttons ⇒ Object
-
#initialize(controller) ⇒ ExportDialog
constructor
A new instance of ExportDialog.
- #options_table ⇒ Gtk::Table
- #since_date ⇒ Object
Constructor Details
#initialize(controller) ⇒ ExportDialog
Returns a new instance of ExportDialog.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/smartdict/gui/export_dialog.rb', line 22 def initialize(controller) @controller = controller super( "Export translations", nil, Gtk::FileChooser::ACTION_SAVE, nil, [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL], [Gtk::Stock::SAVE, Gtk::Dialog::RESPONSE_ACCEPT] ) self.vbox.pack_start(, false, false) show_all if run == Gtk::Dialog::RESPONSE_ACCEPT export_translations end destroy end |
Instance Method Details
#export_translations ⇒ Object
43 44 45 46 47 |
# File 'lib/smartdict/gui/export_dialog.rb', line 43 def export_translations format = @format_combo_box.selected_format = {:since => since_date} @controller.export_translations(format, filename, ) end |
#init_date_range_buttons ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/smartdict/gui/export_dialog.rb', line 49 def @date_range_buttons = {} = nil DATE_RANGES.each do |name, block| args = ? [, name] : [name] = Gtk::RadioButton.new(*args) @date_range_buttons[] = block end end |
#options_table ⇒ Gtk::Table
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/smartdict/gui/export_dialog.rb', line 60 def table_width = DATE_RANGES.size + 2 # Create table itself table = Gtk::Table.new(table_width, 2, false) table.column_spacings = 5 # Format format_label = Label.new("Format:") @format_combo_box = FormatComboBox.new table.attach(format_label, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0) table.attach_defaults(@format_combo_box, 1, table_width, 0, 1) # Date range date_range_label = Label.new("Date range:") table.attach(date_range_label, 0, 1, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0) @date_range_buttons.keys.each_with_index do |, index| table.attach(, index+1, index+2, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0) end # A trick to make radio buttons have left alignment table.attach_defaults(Label.new(''), table_width-1, table_width, 1, 2) end |
#since_date ⇒ Object
85 86 87 88 89 |
# File 'lib/smartdict/gui/export_dialog.rb', line 85 def since_date @date_range_buttons.each do |, block| return block.call if .active? end end |