Class: Alexandria::UI::BookPropertiesDialog

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

Constant Summary

Constants inherited from BookPropertiesDialogBase

Alexandria::UI::BookPropertiesDialogBase::COVER_ABSOLUTE_MAXHEIGHT, Alexandria::UI::BookPropertiesDialogBase::COVER_MAXWIDTH

Instance Method Summary collapse

Methods inherited from BookPropertiesDialogBase

#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, #on_title_changed, #own_toggled, #redd_toggled, #setup_date_widgets, #show, #want_toggled, #widget_names

Methods included from Logging

included, #log

Methods included from CalendarPopup

#assign_selected_date, #clear_date_entry, #display_calendar_popup, #setup_calendar_widgets

Constructor Details

#initialize(parent, library, book) ⇒ BookPropertiesDialog

Returns a new instance of BookPropertiesDialog.



16
17
18
19
20
21
22
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
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/alexandria/ui/book_properties_dialog.rb', line 16

def initialize(parent, library, book)
  super(parent, library.cover(book))
  log.debug { "Initializing Book Properties Dialog" }

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

  close_button = Gtk::Button.new(stock_id: Gtk::Stock::SAVE)
  close_button.signal_connect("clicked") { on_close }
  close_button.show
  @button_box << close_button

  help_button = Gtk::Button.new(stock_id: 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)

  @entry_title.text = @book_properties_dialog.title = book.title
  @entry_isbn.text = (book.isbn || "")
  @entry_publisher.text = book.publisher
  @entry_publish_date.text = book.publishing_year.to_s
  @entry_publish_date.signal_connect("focus-out-event") do
    text = @entry_publish_date.text
    if text.empty?
      false
    else
      year = text.to_i
      if year.zero? || year > (Time.now.year + 10) || year < 10
        @entry_publish_date.text = ""
        @entry_publish_date.grab_focus
        true
      elsif year < 100
        @entry_publish_date.text = "19" + year.to_s
        false
      end
    end
  end
  @entry_edition.text = book.edition
  if book.tags
    @entry_tags.text = book.tags.join(",") # tags are comma-separated
  end

  book.authors.each do |author|
    iter = @treeview_authors.model.append
    iter[0] = author
    iter[1] = true
  end

  buffer = Gtk::TextBuffer.new
  buffer.text = (book.notes || "")
  @textview_notes.buffer = buffer

  @library = library
  @book = book
  self.cover = Icons.cover(library, book)
  self.rating = (book.rating || Book::DEFAULT_RATING)

  if (@checkbutton_loaned.active = book.loaned?)
    @entry_loaned_to.text = (book.loaned_to || "")
    self.loaned_since = book.loaned_since
    @date_loaned_since.sensitive = true
  else
    @date_loaned_since.sensitive = false
  end

  @checkbutton_own.active = book.own?
  if (@checkbutton_redd.active = book.redd?)
    @redd_date.sensitive = true
    if book.redd_when.nil?
      log.debug { "no redd_when" }
    else
      @redd_date.text = format_date(book.redd_when)
    end
    # self.redd_when = (book.redd_when or Time.now)
  else
    @redd_date.sensitive = false
  end
  @checkbutton_want.active = book.want?

  @checkbutton_want.inconsistent = true if (@checkbutton_own.active = book.own?)
end