alexandria-book-collection-manager 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.hound.yml +2 -0
  4. data/.rubocop.yml +4 -4
  5. data/.rubocop_todo.yml +55 -82
  6. data/CHANGELOG.md +17 -0
  7. data/INSTALL.md +3 -3
  8. data/README.md +1 -2
  9. data/Rakefile +14 -33
  10. data/TODO.md +9 -1
  11. data/alexandria-book-collection-manager.gemspec +4 -3
  12. data/bin/alexandria +21 -34
  13. data/doc/FAQ +2 -5
  14. data/lib/alexandria.rb +4 -16
  15. data/lib/alexandria/book_providers.rb +5 -7
  16. data/lib/alexandria/book_providers/adlibris.rb +5 -3
  17. data/lib/alexandria/book_providers/amazon_aws.rb +3 -1
  18. data/lib/alexandria/book_providers/amazon_ecs_util.rb +8 -0
  19. data/lib/alexandria/book_providers/barnes_and_noble.rb +7 -4
  20. data/lib/alexandria/book_providers/douban.rb +1 -1
  21. data/lib/alexandria/book_providers/proxis.rb +11 -27
  22. data/lib/alexandria/book_providers/renaud.rb +9 -3
  23. data/lib/alexandria/book_providers/siciliano.rb +7 -4
  24. data/lib/alexandria/book_providers/thalia.rb +5 -3
  25. data/lib/alexandria/book_providers/web.rb +11 -29
  26. data/lib/alexandria/book_providers/worldcat.rb +7 -5
  27. data/lib/alexandria/book_providers/z3950.rb +10 -7
  28. data/lib/alexandria/console.rb +5 -18
  29. data/lib/alexandria/execution_queue.rb +2 -1
  30. data/lib/alexandria/export_format.rb +47 -0
  31. data/lib/alexandria/export_library.rb +72 -180
  32. data/lib/alexandria/import_library.rb +14 -23
  33. data/lib/alexandria/import_library_csv.rb +3 -6
  34. data/lib/alexandria/library_collection.rb +78 -0
  35. data/lib/alexandria/library_sort_order.rb +43 -0
  36. data/lib/alexandria/library_store.rb +222 -0
  37. data/lib/alexandria/logging.rb +2 -0
  38. data/lib/alexandria/models/book.rb +8 -16
  39. data/lib/alexandria/models/library.rb +26 -308
  40. data/lib/alexandria/preferences.rb +7 -24
  41. data/lib/alexandria/scanners/cuecat.rb +3 -1
  42. data/lib/alexandria/smart_library.rb +32 -67
  43. data/lib/alexandria/ui/builder_base.rb +6 -26
  44. data/lib/alexandria/ui/callbacks.rb +8 -34
  45. data/lib/alexandria/ui/completion_models.rb +2 -1
  46. data/lib/alexandria/ui/dialogs/about_dialog.rb +35 -47
  47. data/lib/alexandria/ui/dialogs/acquire_dialog.rb +14 -30
  48. data/lib/alexandria/ui/dialogs/alert_dialog.rb +8 -17
  49. data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +10 -24
  50. data/lib/alexandria/ui/dialogs/book_properties_dialog.rb +17 -18
  51. data/lib/alexandria/ui/dialogs/book_properties_dialog_base.rb +25 -41
  52. data/lib/alexandria/ui/dialogs/export_dialog.rb +48 -56
  53. data/lib/alexandria/ui/dialogs/import_dialog.rb +31 -51
  54. data/lib/alexandria/ui/dialogs/keep_bad_isbn_dialog.rb +33 -0
  55. data/lib/alexandria/ui/dialogs/misc_dialogs.rb +12 -25
  56. data/lib/alexandria/ui/dialogs/new_book_dialog.rb +57 -94
  57. data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +24 -42
  58. data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +9 -21
  59. data/lib/alexandria/ui/dialogs/preferences_dialog.rb +27 -32
  60. data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +5 -3
  61. data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +15 -12
  62. data/lib/alexandria/ui/icons.rb +11 -22
  63. data/lib/alexandria/ui/init.rb +3 -3
  64. data/lib/alexandria/ui/libraries_combo.rb +1 -0
  65. data/lib/alexandria/ui/listview.rb +5 -21
  66. data/lib/alexandria/ui/multi_drag_treeview.rb +20 -32
  67. data/lib/alexandria/ui/sidepane.rb +9 -24
  68. data/lib/alexandria/ui/ui_manager.rb +36 -60
  69. data/lib/alexandria/undo_manager.rb +1 -0
  70. data/lib/alexandria/version.rb +2 -2
  71. data/lib/alexandria/web_themes.rb +1 -0
  72. data/po/cs.po +0 -4
  73. data/po/cy.po +0 -4
  74. data/po/de.po +0 -4
  75. data/po/el.po +0 -4
  76. data/po/es.po +0 -4
  77. data/po/fr.po +0 -4
  78. data/po/ga.po +0 -4
  79. data/po/gl.po +0 -4
  80. data/po/it.po +0 -4
  81. data/po/ja.po +0 -4
  82. data/po/mk.po +0 -4
  83. data/po/nb.po +0 -4
  84. data/po/nl.po +0 -4
  85. data/po/pl.po +0 -4
  86. data/po/pt.po +0 -4
  87. data/po/pt_BR.po +0 -4
  88. data/po/ru.po +0 -4
  89. data/po/sk.po +0 -4
  90. data/po/sv.po +0 -4
  91. data/po/uk.po +0 -4
  92. data/po/zh_TW.po +0 -4
  93. data/schemas/alexandria.schemas +1 -1
  94. data/share/alexandria/glade/acquire_dialog__builder.glade +14 -11
  95. data/share/alexandria/glade/book_properties_dialog__builder.glade +170 -298
  96. data/share/alexandria/glade/main_app__builder.glade +22 -16
  97. data/share/alexandria/glade/new_book_dialog__builder.glade +26 -58
  98. data/share/alexandria/glade/preferences_dialog__builder.glade +249 -289
  99. data/share/gnome/help/alexandria/C/introduction.xml +0 -4
  100. data/share/gnome/help/alexandria/ja/introduction.xml +0 -4
  101. data/spec/alexandria/book_providers_spec.rb +1 -20
  102. data/spec/alexandria/console_spec.rb +32 -0
  103. data/spec/alexandria/export_library_spec.rb +141 -0
  104. data/spec/alexandria/library_spec.rb +24 -80
  105. data/spec/alexandria/library_store_spec.rb +37 -0
  106. data/spec/alexandria/smart_library_spec.rb +27 -22
  107. data/spec/alexandria/ui/dialogs/new_book_dialog_spec.rb +22 -0
  108. data/spec/alexandria/ui/dialogs_spec.rb +104 -38
  109. data/spec/end_to_end/basic_run_spec.rb +69 -0
  110. data/spec/spec_helper.rb +13 -25
  111. data/tasks/spec.rake +15 -2
  112. data/util/rake/fileinstall.rb +1 -0
  113. metadata +38 -16
  114. data/lib/alexandria/book_providers/deastore.rb +0 -265
  115. data/lib/alexandria/book_providers/mcu.rb +0 -182
@@ -63,7 +63,7 @@ module Alexandria
63
63
  else
64
64
  false
65
65
  end
66
- rescue
66
+ rescue StandardError
67
67
  false
68
68
  end
69
69
  else
@@ -200,6 +200,7 @@ module Alexandria
200
200
  iter = nil
201
201
  values.uniq.each do |value|
202
202
  next if value.nil?
203
+
203
204
  iter = iter ? model.insert_after(iter) : model.append
204
205
  iter[0] = value
205
206
  end
@@ -1,60 +1,48 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2004-2006 Laurent Sansonetti
3
+ # This file is part of Alexandria.
4
4
  #
5
- # Alexandria is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU General Public License as
7
- # published by the Free Software Foundation; either version 2 of the
8
- # License, or (at your option) any later version.
9
- #
10
- # Alexandria is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public
16
- # License along with Alexandria; see the file COPYING. If not,
17
- # write to the Free Software Foundation, Inc., 51 Franklin Street,
18
- # Fifth Floor, Boston, MA 02110-1301 USA.
5
+ # See the file README.md for authorship and licensing information.
19
6
 
20
7
  module Alexandria
21
8
  module UI
22
- class AboutDialog < Gtk::AboutDialog
23
- include GetText
24
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
25
-
26
- GPL = <<EOL
27
- Alexandria is free software; you can redistribute it and/or
28
- modify it under the terms of the GNU General Public License as
29
- published by the Free Software Foundation; either version 2 of the
30
- License, or (at your option) any later version.
9
+ class AboutDialog
10
+ GPL = <<~EOL
11
+ Alexandria is free software; you can redistribute it and/or
12
+ modify it under the terms of the GNU General Public License as
13
+ published by the Free Software Foundation; either version 2 of the
14
+ License, or (at your option) any later version.
31
15
 
32
- Alexandria is distributed in the hope that it will be useful,
33
- but WITHOUT ANY WARRANTY; without even the implied warranty of
34
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35
- General Public License for more details.
16
+ Alexandria is distributed in the hope that it will be useful,
17
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
+ General Public License for more details.
36
20
 
37
- You should have received a copy of the GNU General Public
38
- License along with Alexandria; see the file COPYING. If not,
39
- write to the Free Software Foundation, Inc., 51 Franklin Street,
40
- Fifth Floor, Boston, MA 02110-1301 USA.
41
- EOL
21
+ You should have received a copy of the GNU General Public
22
+ License along with Alexandria; see the file COPYING. If not,
23
+ write to the Free Software Foundation, Inc., 51 Franklin Street,
24
+ Fifth Floor, Boston, MA 02110-1301 USA.
25
+ EOL
42
26
 
43
27
  def initialize(parent)
44
- super()
45
- self.name = Alexandria::TITLE
46
- self.version = Alexandria::DISPLAY_VERSION
47
- self.copyright = Alexandria::COPYRIGHT
48
- self.comments = Alexandria::DESCRIPTION
49
- self.authors = Alexandria::AUTHORS
50
- self.documenters = Alexandria::DOCUMENTERS
51
- self.artists = Alexandria::ARTISTS
52
- self.translator_credits = Alexandria::TRANSLATORS.join("\n")
53
- self.logo = Icons::ALEXANDRIA
54
- self.website = Alexandria::WEBSITE_URL
55
- self.license = GPL
56
- self.transient_for = parent
57
- signal_connect('response') { destroy }
28
+ @dialog = Gtk::AboutDialog.new
29
+ @dialog.name = Alexandria::TITLE
30
+ @dialog.version = Alexandria::DISPLAY_VERSION
31
+ @dialog.copyright = Alexandria::COPYRIGHT
32
+ @dialog.comments = Alexandria::DESCRIPTION
33
+ @dialog.authors = Alexandria::AUTHORS
34
+ @dialog.documenters = Alexandria::DOCUMENTERS
35
+ @dialog.artists = Alexandria::ARTISTS
36
+ @dialog.translator_credits = Alexandria::TRANSLATORS.join("\n")
37
+ @dialog.logo = Icons::ALEXANDRIA
38
+ @dialog.website = Alexandria::WEBSITE_URL
39
+ @dialog.license = GPL
40
+ @dialog.transient_for = parent
41
+ @dialog.signal_connect('response') { @dialog.destroy }
42
+ end
43
+
44
+ def show
45
+ @dialog.show
58
46
  end
59
47
  end
60
48
  end
@@ -1,35 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2004-2006 Laurent Sansonetti
4
- # Copyright (C) 2007 Cathal Mc Ginley
5
- # Copyright (C) 2011, 2016 Matijs van Zuijlen
3
+ # This file is part of Alexandria.
6
4
  #
7
- # Alexandria is free software; you can redistribute it and/or
8
- # modify it under the terms of the GNU General Public License as
9
- # published by the Free Software Foundation; either version 2 of the
10
- # License, or (at your option) any later version.
11
- #
12
- # Alexandria is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
- # General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public
18
- # License along with Alexandria; see the file COPYING. If not,
19
- # write to the Free Software Foundation, Inc., 51 Franklin Street,
20
- # Fifth Floor, Boston, MA 02110-1301 USA.
5
+ # See the file README.md for authorship and licensing information.
21
6
 
22
- # require 'monitor'
7
+ require 'monitor'
23
8
  require 'alexandria/scanners/cuecat'
24
9
  require 'alexandria/scanners/keyboard'
25
10
 
26
- require 'alexandria/ui/sound'
11
+ require 'alexandria/ui/builder_base'
27
12
  require 'alexandria/ui/dialogs/barcode_animation'
13
+ require 'alexandria/ui/sound'
28
14
 
29
15
  module Alexandria
30
16
  module UI
31
- require 'monitor'
32
-
33
17
  # assists in turning on progress bar when searching
34
18
  # and turning it off when all search threads have completed...
35
19
  class SearchThreadCounter < Monitor
@@ -64,7 +48,7 @@ module Alexandria
64
48
  @acquire_dialog.transient_for = @parent = parent
65
49
  @block = block
66
50
 
67
- libraries = Libraries.instance.all_regular_libraries
51
+ libraries = LibraryCollection.instance.all_regular_libraries
68
52
  selected_library = libraries.first if selected_library.is_a?(SmartLibrary)
69
53
  @combo_libraries.populate_with_libraries(libraries,
70
54
  selected_library)
@@ -80,10 +64,8 @@ module Alexandria
80
64
  end
81
65
 
82
66
  def widget_names
83
- [:acquire_dialog, :dialog_vbox1, :dialog_action_area1,
84
- :help_button, :cancel_button, :add_button, :vbox1,
85
- :barcode_label, :scan_area, :scan_frame, :scrolledwindow1,
86
- :barcodes_treeview, :hbox1, :label1, :combo_libraries]
67
+ [:acquire_dialog, :add_button, :barcodes_treeview, :barcode_label,
68
+ :scan_area, :scan_frame, :combo_libraries]
87
69
  end
88
70
 
89
71
  def book_in_library(isbn10, library)
@@ -97,7 +79,7 @@ module Alexandria
97
79
  end
98
80
  # puts "book_in_library match #{match.inspect}"
99
81
  !match.nil?
100
- rescue
82
+ rescue StandardError
101
83
  log.warn { "Failed to check for book #{isbn10} in library #{library}" }
102
84
  true
103
85
  end
@@ -105,7 +87,7 @@ module Alexandria
105
87
  def on_add
106
88
  model = @barcodes_treeview.model
107
89
 
108
- libraries = Libraries.instance.all_libraries
90
+ libraries = LibraryCollection.instance.all_libraries
109
91
  library, is_new_library =
110
92
  @combo_libraries.selection_from_libraries(libraries)
111
93
 
@@ -223,7 +205,7 @@ module Alexandria
223
205
  title = n_("Couldn't add this book",
224
206
  "Couldn't add these books",
225
207
  isbn_duplicates.size)
226
- ErrorDialog.new(@parent, title, message)
208
+ ErrorDialog.new(@acquire_dialog, title, message).display
227
209
  end
228
210
 
229
211
  @block.call(books, library, is_new_library)
@@ -421,7 +403,7 @@ module Alexandria
421
403
  @scanner_buffer = ''
422
404
  scanner_name = @prefs.barcode_scanner
423
405
 
424
- @scanner = Alexandria::Scanners.find_scanner scanner_name ||
406
+ @scanner = Alexandria::Scanners.find_scanner(scanner_name) ||
425
407
  Alexandria::Scanners.default_scanner # CueCat is default
426
408
 
427
409
  log.debug { "Using #{@scanner.name} scanner" }
@@ -531,10 +513,12 @@ module Alexandria
531
513
  if effect == 'scanning'
532
514
  puts "Effect: #{effect}, playing: #{@prefs.play_scanning_sound}" if $DEBUG
533
515
  return unless @prefs.play_scanning_sound
516
+
534
517
  @sound_players['scanning'].play('scanning')
535
518
  else
536
519
  puts "Effect: #{effect}, playing: #{@prefs.play_scan_sound}" if $DEBUG
537
520
  return unless @prefs.play_scan_sound
521
+
538
522
  # sleep(0.5) # "scanning" effect lasts 0.5 seconds, wait for it to end
539
523
  @sound_players[effect].play(effect)
540
524
  end
@@ -1,28 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2004-2006 Laurent Sansonetti
3
+ # This file is part of Alexandria.
4
4
  #
5
- # Alexandria is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU General Public License as
7
- # published by the Free Software Foundation; either version 2 of the
8
- # License, or (at your option) any later version.
9
- #
10
- # Alexandria is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public
16
- # License along with Alexandria; see the file COPYING. If not,
17
- # write to the Free Software Foundation, Inc., 51 Franklin Street,
18
- # Fifth Floor, Boston, MA 02110-1301 USA.
5
+ # See the file README.md for authorship and licensing information.
19
6
 
20
7
  # HIG compliant error dialog boxes
21
8
  module Alexandria
22
9
  module UI
23
- class AlertDialog < Gtk::Dialog
10
+ class AlertDialog < SimpleDelegator
24
11
  def initialize(parent, title, stock_icon, buttons, message = nil)
25
- super(title: '', parent: parent, flags: :destroy_with_parent, buttons: buttons)
12
+ dialog = Gtk::Dialog.new(title: '', parent: parent, flags: :destroy_with_parent, buttons: buttons)
13
+ super(dialog)
26
14
 
27
15
  self.border_width = 6
28
16
  self.resizable = false
@@ -64,6 +52,9 @@ module Alexandria
64
52
  [[Gtk::Stock::OK, :ok]], message)
65
53
  # FIXME: Should accept just :ok
66
54
  self.default_response = Gtk::ResponseType::OK
55
+ end
56
+
57
+ def display
67
58
  show_all && run
68
59
  destroy
69
60
  end
@@ -1,35 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2007 Joseph Method
3
+ # This file is part of Alexandria.
4
4
  #
5
- # Alexandria is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU General Public License as
7
- # published by the Free Software Foundation; either version 2 of the
8
- # License, or (at your option) any later version.
9
- #
10
- # Alexandria is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public
16
- # License along with Alexandria; see the file COPYING. If not,
17
- # write to the Free Software Foundation, Inc., 51 Franklin Street,
18
- # Fifth Floor, Boston, MA 02110-1301 USA.
5
+ # See the file README.md for authorship and licensing information.
19
6
 
20
7
  module Alexandria
21
8
  module UI
22
9
  # Generalized Dialog for lists of bad isbns. Used for on_import. Can also
23
10
  # be used for on_load library conversions.
24
- class BadIsbnsDialog < Gtk::MessageDialog
25
- def initialize(parent, message = nil, list = nil)
26
- message ||= _("There's a problem")
27
-
28
- super(parent,
29
- Gtk::Dialog::MODAL,
30
- Gtk::MessageDialog::WARNING,
31
- Gtk::MessageDialog::BUTTONS_CLOSE,
32
- message)
11
+ class BadIsbnsDialog < SimpleDelegator
12
+ def initialize(parent, message, list)
13
+ dialog = Gtk::MessageDialog.new(parent: parent,
14
+ flags: :modal,
15
+ type: :warning,
16
+ buttons: :close,
17
+ message: message)
18
+ super(dialog)
33
19
 
34
20
  isbn_container = Gtk::Box.new :horizontal
35
21
  the_vbox = children.first
@@ -118,24 +118,26 @@ module Alexandria
118
118
  # If set to nil .to_yaml in library.save causes crash
119
119
  @book.isbn = ''
120
120
  else
121
- ary = @library.select { |book| book.ident == @entry_isbn.text }
121
+ isbn = Library.canonicalise_ean(@entry_isbn.text)
122
+ unless isbn
123
+ ErrorDialog.new(@book_properties_dialog,
124
+ _("Couldn't modify the book"),
125
+ _("Couldn't validate the EAN/ISBN you " \
126
+ 'provided. Make sure it is written ' \
127
+ 'correcty, and try again.')).display
128
+ return
129
+ end
130
+
131
+ ary = @library.select { |book| book.ident == isbn }
122
132
  unless ary.empty? || ((ary.length == 1) && (ary.first == @book))
123
- ErrorDialog.new(@parent,
133
+ ErrorDialog.new(@book_properties_dialog,
124
134
  _("Couldn't modify the book"),
125
135
  _('The EAN/ISBN you provided is already ' \
126
- 'used in this library.'))
136
+ 'used in this library.')).display
127
137
  return
128
138
  end
129
- @book.isbn = begin
130
- Library.canonicalise_ean(@entry_isbn.text)
131
- rescue Alexandria::Library::InvalidISBNError
132
- ErrorDialog.new(@parent,
133
- _("Couldn't modify the book"),
134
- _("Couldn't validate the EAN/ISBN you " \
135
- 'provided. Make sure it is written ' \
136
- 'correcty, and try again.'))
137
- return
138
- end
139
+
140
+ @book.isbn = isbn
139
141
  end
140
142
  @book.title = @entry_title.text
141
143
  @book.publisher = @entry_publisher.text
@@ -153,11 +155,8 @@ module Alexandria
153
155
  if loaned_since.strip.empty?
154
156
  @book.loaned_since = nil
155
157
  else
156
- begin
157
- t = parse_date(loaned_since)
158
- @book.loaned_since = t
159
- rescue
160
- end
158
+ t = parse_date(loaned_since)
159
+ @book.loaned_since = t
161
160
  end
162
161
 
163
162
  @book.redd = @checkbutton_redd.active?
@@ -1,24 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2004-2006 Laurent Sansonetti
4
- # Copyright (C) 2011, 2014, 2016 Matijs van Zuijlen
3
+ # This file is part of Alexandria.
5
4
  #
6
- # Alexandria is free software; you can redistribute it and/or
7
- # modify it under the terms of the GNU General Public License as
8
- # published by the Free Software Foundation; either version 2 of the
9
- # License, or (at your option) any later version.
10
- #
11
- # Alexandria is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- # General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public
17
- # License along with Alexandria; see the file COPYING. If not,
18
- # write to the Free Software Foundation, Inc., 51 Franklin Street,
19
- # Fifth Floor, Boston, MA 02110-1301 USA.
5
+ # See the file README.md for authorship and licensing information.
20
6
 
21
- # require 'alexandria/ui/glade_base'
7
+ require 'alexandria/ui/builder_base'
22
8
 
23
9
  module Alexandria
24
10
  module UI
@@ -197,22 +183,14 @@ module Alexandria
197
183
  end
198
184
 
199
185
  def widget_names
200
- [:book_properties_dialog, :dialog_vbox1, :button_box,
201
- :notebook1, :hbox1, :table1, :label1, :label7, :entry_title,
202
- :entry_publisher, :label5, :entry_isbn, :hbox3,
203
- :scrolledwindow2, :treeview_authors, :vbox2, :button3,
204
- :image2, :button4, :image3, :label3, :label9, :entry_edition,
205
- :label16, :entry_publish_date, :label17, :entry_tags,
206
- :vseparator1, :vbox1, :label12, :button_cover, :image_cover,
207
- :vbox4, :vbox5, :checkbutton_own, :vbox6, :checkbutton_redd,
208
- :redd_date, :checkbutton_want, :eventbox8, :hbox2,
209
- :eventbox6, :image5, :eventbox1, :image_rating1, :eventbox5,
210
- :image_rating2, :eventbox4, :image_rating3, :eventbox3,
211
- :image_rating4, :eventbox2, :image_rating5, :eventbox7,
212
- :image4, :label11, :label9, :vbox3, :checkbutton_loaned,
213
- :table2, :entry_loaned_to, :label_loaning_duration, :label15,
214
- :label14, :date_loaned_since, :label13, :scrolledwindow1,
215
- :textview_notes, :label10]
186
+ [:book_properties_dialog, :button_box, :button_cover,
187
+ :checkbutton_loaned, :checkbutton_own, :checkbutton_redd,
188
+ :checkbutton_want, :date_loaned_since, :entry_edition,
189
+ :entry_loaned_to, :entry_publish_date, :entry_publisher, :entry_isbn,
190
+ :entry_tags, :entry_title, :image_cover, :image_rating1,
191
+ :image_rating2, :image_rating3, :image_rating4, :image_rating5,
192
+ :label_loaning_duration, :notebook, :redd_date, :textview_notes,
193
+ :treeview_authors]
216
194
  end
217
195
 
218
196
  def on_title_changed
@@ -279,12 +257,12 @@ module Alexandria
279
257
  @book_properties_dialog,
280
258
  Gtk::FileChooser::ACTION_OPEN,
281
259
  backend,
282
- [_('No Cover'), :reject],
283
- [Gtk::Stock::CANCEL, :cancel],
284
- [Gtk::Stock::OPEN, :accept])
260
+ [_('No Cover'), Gtk::ResponseType::REJECT],
261
+ [Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL],
262
+ [Gtk::Stock::OPEN, Gtk::ResponseType::ACCEPT])
285
263
  dialog.current_folder = @@latest_filechooser_directory
286
264
  response = dialog.run
287
- if response == :accept
265
+ if response == Gtk::ResponseType::ACCEPT
288
266
  begin
289
267
  @delete_cover_file = false
290
268
  cover = GdkPixbuf::Pixbuf.new(file: dialog.filename)
@@ -310,9 +288,9 @@ module Alexandria
310
288
  self.cover = cover
311
289
  @@latest_filechooser_directory = dialog.current_folder
312
290
  rescue RuntimeError => e
313
- ErrorDialog.new(@book_properties_dialog, e.message)
291
+ ErrorDialog.new(@book_properties_dialog, e.message).display
314
292
  end
315
- elsif response == :reject
293
+ elsif response == Gtk::ResponseType::REJECT
316
294
  ## FileUtils.rm_f(@cover_file) # fixing bug #16707
317
295
  @delete_cover_file = true
318
296
 
@@ -321,7 +299,11 @@ module Alexandria
321
299
  dialog.destroy
322
300
  end
323
301
 
324
- def on_destroy; end # no action by default
302
+ def on_destroy
303
+ @book_properties_dialog.hide
304
+ # Stop notebook trying to set tab labels at this time
305
+ @notebook.show_tabs = false
306
+ end
325
307
 
326
308
  def on_loaned
327
309
  loaned = @checkbutton_loaned.active?
@@ -339,6 +321,7 @@ module Alexandria
339
321
  break if matches_regex
340
322
  end
341
323
  return unless matches_regex
324
+
342
325
  t = parse_date(@date_loaned_since.text)
343
326
  if t.nil?
344
327
  @label_loaning_duration.label = ''
@@ -377,6 +360,7 @@ module Alexandria
377
360
  @image_rating5
378
361
  ]
379
362
  raise 'out of range' if rating < 0 || rating > images.length
363
+
380
364
  images[0..rating - 1].each { |x| x.pixbuf = Icons::STAR_SET }
381
365
  images[rating..-1].each { |x| x.pixbuf = Icons::STAR_UNSET }
382
366
  @current_rating = rating
@@ -413,7 +397,7 @@ module Alexandria
413
397
  begin
414
398
  d = Date.strptime(datestring, date_format)
415
399
  Time.gm(d.year, d.month, d.day)
416
- rescue
400
+ rescue StandardError
417
401
  nil
418
402
  end
419
403
  end