Class: Alexandria::UI::NewBookDialogManual

Inherits:
BookPropertiesDialogBase show all
Extended by:
GetText
Includes:
GetText
Defined in:
lib/alexandria/ui/dialogs/new_book_dialog_manual.rb

Defined Under Namespace

Classes: AddError

Constant Summary collapse

TMP_COVER_FILE =
File.join(Dir.tmpdir, 'tmp_cover')

Constants inherited from BookPropertiesDialogBase

BookPropertiesDialogBase::COVER_ABSOLUTE_MAXHEIGHT, BookPropertiesDialogBase::COVER_MAXWIDTH

Instance Method Summary collapse

Methods inherited from BookPropertiesDialogBase

#clear_date_entry, #display_calendar_popup, #get_entry_popup_coords, #hide_calendar_popup, #on_add_author, #on_change_cover, #on_destroy, #on_image_no_rating_press, #on_image_rating1_press, #on_image_rating2_press, #on_image_rating3_press, #on_image_rating4_press, #on_image_rating5_press, #on_loaned, #on_loaned_date_changed, #on_remove_author, #own_toggled, #redd_toggled, #setup_calendar_widgets, #want_toggled, #widget_names

Constructor Details

#initialize(parent, library, &on_add_cb) ⇒ NewBookDialogManual

Returns a new instance of NewBookDialogManual.



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
# File 'lib/alexandria/ui/dialogs/new_book_dialog_manual.rb', line 29

def initialize(parent, library, &on_add_cb)
  super(parent, TMP_COVER_FILE)

  @library = library
  @on_add_cb = on_add_cb
  FileUtils.rm_f(TMP_COVER_FILE)

  cancel_button = Gtk::Button.new(Gtk::Stock::CANCEL)
  cancel_button.signal_connect('clicked') { on_cancel }
  cancel_button.show
  @button_box << cancel_button

  add_button = Gtk::Button.new(Gtk::Stock::ADD)
  add_button.signal_connect('clicked') { on_add }
  add_button.show
  @button_box << add_button

  help_button = Gtk::Button.new(Gtk::Stock::HELP)
  help_button.signal_connect('clicked') { on_help }
  help_button.show
  @button_box << help_button
  @button_box.set_child_secondary(help_button, true)

  self.rating = Book::DEFAULT_RATING
  self.cover = Icons::BOOK_ICON

  on_title_changed
end

Instance Method Details

#on_title_changedObject



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/alexandria/ui/dialogs/new_book_dialog_manual.rb', line 58

def on_title_changed
  title = @entry_title.text.strip
  begin
    @book_properties_dialog.title = if title.empty?
                                      _('Adding a Book')
                                    else
                                      _("Adding '%s'") % title
                                    end
  rescue
    raise "There's a problem with a book somewhere"
  end
end