alexandria-book-collection-manager 0.7.3 → 0.7.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.github/workflows/ruby.yml +77 -0
  4. data/.gitignore +4 -1
  5. data/.rubocop.yml +86 -36
  6. data/.rubocop_todo.yml +58 -161
  7. data/.simplecov +5 -2
  8. data/CHANGELOG.md +56 -2
  9. data/Gemfile +4 -3
  10. data/INSTALL.md +23 -11
  11. data/README.md +52 -41
  12. data/Rakefile +78 -75
  13. data/alexandria-book-collection-manager.gemspec +50 -44
  14. data/bin/alexandria +12 -22
  15. data/doc/FAQ +1 -2
  16. data/doc/dependency_decisions.yml +27 -8
  17. data/lib/alexandria.rb +25 -23
  18. data/lib/alexandria/about.rb +50 -50
  19. data/lib/alexandria/book_providers.rb +86 -91
  20. data/lib/alexandria/book_providers/adlibris.rb +37 -74
  21. data/lib/alexandria/book_providers/amazon_aws.rb +94 -100
  22. data/lib/alexandria/book_providers/amazon_ecs_util.rb +289 -324
  23. data/lib/alexandria/book_providers/barnes_and_noble.rb +42 -42
  24. data/lib/alexandria/book_providers/douban.rb +25 -41
  25. data/lib/alexandria/book_providers/proxis.rb +34 -29
  26. data/lib/alexandria/book_providers/pseudomarc.rb +77 -85
  27. data/lib/alexandria/book_providers/siciliano.rb +60 -64
  28. data/lib/alexandria/book_providers/thalia_provider.rb +161 -0
  29. data/lib/alexandria/book_providers/web.rb +5 -5
  30. data/lib/alexandria/book_providers/worldcat.rb +66 -95
  31. data/lib/alexandria/book_providers/z3950.rb +153 -169
  32. data/lib/alexandria/config.rb +1 -1
  33. data/lib/alexandria/console.rb +3 -3
  34. data/lib/alexandria/default_preferences.rb +37 -0
  35. data/lib/alexandria/execution_queue.rb +13 -12
  36. data/lib/alexandria/export_format.rb +8 -8
  37. data/lib/alexandria/export_library.rb +128 -127
  38. data/lib/alexandria/import_library.rb +102 -126
  39. data/lib/alexandria/import_library_csv.rb +41 -41
  40. data/lib/alexandria/library_collection.rb +6 -5
  41. data/lib/alexandria/library_sort_order.rb +4 -2
  42. data/lib/alexandria/library_store.rb +39 -28
  43. data/lib/alexandria/logging.rb +10 -14
  44. data/lib/alexandria/models/book.rb +5 -4
  45. data/lib/alexandria/models/library.rb +63 -53
  46. data/lib/alexandria/net.rb +5 -6
  47. data/lib/alexandria/preferences.rb +66 -63
  48. data/lib/alexandria/scanners.rb +2 -2
  49. data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +17 -17
  50. data/lib/alexandria/scanners/keyboard.rb +8 -8
  51. data/lib/alexandria/smart_library.rb +110 -112
  52. data/lib/alexandria/ui.rb +15 -15
  53. data/lib/alexandria/ui/{dialogs/about_dialog.rb → about_dialog.rb} +2 -2
  54. data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +108 -109
  55. data/lib/alexandria/ui/alert_dialog.rb +66 -0
  56. data/lib/alexandria/ui/{dialogs/bad_isbns_dialog.rb → bad_isbns_dialog.rb} +13 -9
  57. data/lib/alexandria/ui/{dialogs/barcode_animation.rb → barcode_animation.rb} +16 -15
  58. data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +25 -38
  59. data/lib/alexandria/ui/{dialogs/book_properties_dialog_base.rb → book_properties_dialog_base.rb} +64 -157
  60. data/lib/alexandria/ui/builder_base.rb +1 -1
  61. data/lib/alexandria/ui/calendar_popup.rb +58 -0
  62. data/lib/alexandria/ui/callbacks.rb +187 -155
  63. data/lib/alexandria/ui/completion_models.rb +8 -22
  64. data/lib/alexandria/ui/confirm_erase_dialog.rb +33 -0
  65. data/lib/alexandria/ui/conflict_while_copying_dialog.rb +34 -0
  66. data/lib/alexandria/ui/dndable.rb +7 -7
  67. data/lib/alexandria/ui/error_dialog.rb +25 -0
  68. data/lib/alexandria/ui/{dialogs/export_dialog.rb → export_dialog.rb} +37 -58
  69. data/lib/alexandria/ui/icons.rb +38 -43
  70. data/lib/alexandria/ui/iconview.rb +12 -10
  71. data/lib/alexandria/ui/iconview_tooltips.rb +41 -54
  72. data/lib/alexandria/ui/import_dialog.rb +157 -0
  73. data/lib/alexandria/ui/init.rb +30 -41
  74. data/lib/alexandria/ui/{dialogs/keep_bad_isbn_dialog.rb → keep_bad_isbn_dialog.rb} +9 -6
  75. data/lib/alexandria/ui/libraries_combo.rb +15 -14
  76. data/lib/alexandria/ui/listview.rb +69 -67
  77. data/lib/alexandria/ui/main_app.rb +24 -26
  78. data/lib/alexandria/ui/misc_dialogs.rb +10 -0
  79. data/lib/alexandria/ui/multi_drag_treeview.rb +8 -9
  80. data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +113 -114
  81. data/lib/alexandria/ui/{dialogs/new_book_dialog_manual.rb → new_book_dialog_manual.rb} +22 -19
  82. data/lib/alexandria/ui/new_provider_dialog.rb +100 -0
  83. data/lib/alexandria/ui/new_smart_library_dialog.rb +74 -0
  84. data/lib/alexandria/ui/preferences_dialog.rb +313 -0
  85. data/lib/alexandria/ui/provider_preferences_base_dialog.rb +95 -0
  86. data/lib/alexandria/ui/provider_preferences_dialog.rb +35 -0
  87. data/lib/alexandria/ui/{dialogs/misc_dialogs.rb → really_delete_dialog.rb} +7 -28
  88. data/lib/alexandria/ui/{sidepane.rb → sidepane_manager.rb} +53 -48
  89. data/lib/alexandria/ui/skip_entry_dialog.rb +33 -0
  90. data/lib/alexandria/ui/smart_library_properties_dialog.rb +60 -0
  91. data/lib/alexandria/ui/smart_library_properties_dialog_base.rb +242 -0
  92. data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
  93. data/lib/alexandria/ui/sound.rb +11 -13
  94. data/lib/alexandria/ui/ui_manager.rb +216 -200
  95. data/lib/alexandria/version.rb +4 -19
  96. data/lib/alexandria/web_themes.rb +21 -21
  97. data/po/Makefile +2 -2
  98. data/po/cs.po +992 -875
  99. data/po/cy.po +961 -874
  100. data/po/de.po +990 -865
  101. data/po/el.po +989 -865
  102. data/po/es.po +985 -861
  103. data/po/fr.po +987 -867
  104. data/po/ga.po +908 -820
  105. data/po/gl.po +980 -860
  106. data/po/it.po +986 -864
  107. data/po/ja.po +969 -849
  108. data/po/mk.po +984 -860
  109. data/po/nb.po +979 -859
  110. data/po/nl.po +983 -860
  111. data/po/pl.po +1018 -971
  112. data/po/pt.po +988 -857
  113. data/po/pt_BR.po +983 -863
  114. data/po/ru.po +994 -871
  115. data/po/sk.po +989 -867
  116. data/po/sv.po +976 -856
  117. data/po/uk.po +972 -858
  118. data/po/zh_TW.po +974 -854
  119. data/schemas/alexandria.schemas +24 -2
  120. data/share/alexandria/glade/acquire_dialog__builder.glade +1 -1
  121. data/share/alexandria/glade/book_properties_dialog__builder.glade +1 -1
  122. data/share/alexandria/glade/main_app__builder.glade +6 -21
  123. data/share/alexandria/glade/new_book_dialog__builder.glade +1 -1
  124. data/share/alexandria/glade/preferences_dialog__builder.glade +1 -1
  125. data/share/gnome/help/alexandria/C/introduction.xml +0 -4
  126. data/share/gnome/help/alexandria/C/searching.xml +1 -1
  127. data/share/gnome/help/alexandria/C/smart-libraries.xml +2 -2
  128. data/share/gnome/help/alexandria/C/working-with-libraries.xml +1 -1
  129. data/share/gnome/help/alexandria/fr/alexandria.xml +1 -1
  130. data/share/gnome/help/alexandria/ja/introduction.xml +0 -4
  131. data/share/gnome/help/alexandria/ja/smart-libraries.xml +1 -1
  132. data/spec/alexandria/book_providers/thalia_provider_spec.rb +119 -0
  133. data/spec/alexandria/book_providers/world_cat_provider_spec.rb +160 -0
  134. data/spec/alexandria/book_providers_spec.rb +62 -156
  135. data/spec/alexandria/book_spec.rb +12 -10
  136. data/spec/alexandria/console_spec.rb +6 -11
  137. data/spec/alexandria/export_library_spec.rb +47 -58
  138. data/spec/alexandria/library_spec.rb +121 -109
  139. data/spec/alexandria/library_store_spec.rb +8 -8
  140. data/spec/alexandria/preferences_spec.rb +44 -17
  141. data/spec/alexandria/scanners/cue_cat_spec.rb +52 -0
  142. data/spec/alexandria/smart_library_spec.rb +15 -15
  143. data/spec/alexandria/ui/about_dialog_spec.rb +14 -0
  144. data/spec/alexandria/ui/acquire_dialog_spec.rb +14 -0
  145. data/spec/alexandria/ui/alert_dialog_spec.rb +16 -0
  146. data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +14 -0
  147. data/spec/alexandria/ui/book_properties_dialog_spec.rb +59 -0
  148. data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +14 -0
  149. data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +16 -0
  150. data/spec/alexandria/ui/error_dialog_spec.rb +14 -0
  151. data/spec/alexandria/ui/export_dialog_spec.rb +36 -0
  152. data/spec/alexandria/ui/icons_spec.rb +26 -0
  153. data/spec/alexandria/ui/iconview_spec.rb +7 -21
  154. data/spec/alexandria/ui/import_dialog_spec.rb +46 -0
  155. data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +17 -0
  156. data/spec/alexandria/ui/main_app_spec.rb +7 -34
  157. data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +51 -0
  158. data/spec/alexandria/ui/{dialogs/new_book_dialog_spec.rb → new_book_dialog_spec.rb} +4 -4
  159. data/spec/alexandria/ui/new_provider_dialog_spec.rb +30 -0
  160. data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +39 -0
  161. data/spec/alexandria/ui/preferences_dialog_spec.rb +14 -0
  162. data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +34 -0
  163. data/spec/alexandria/ui/really_delete_dialog_spec.rb +16 -0
  164. data/spec/alexandria/ui/sidepane_manager_spec.rb +15 -0
  165. data/spec/alexandria/ui/skip_entry_dialog_spec.rb +14 -0
  166. data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +49 -0
  167. data/spec/alexandria/ui/sound_spec.rb +2 -2
  168. data/spec/alexandria/ui/ui_manager_spec.rb +44 -20
  169. data/spec/end_to_end/basic_run_spec.rb +21 -38
  170. data/spec/fixtures/cover.jpg +0 -0
  171. data/spec/spec_helper.rb +54 -10
  172. data/tasks/setup.rb +2 -2
  173. data/tasks/spec.rake +11 -11
  174. data/util/rake/fileinstall.rb +38 -35
  175. data/util/rake/gettextgenerate.rb +7 -7
  176. data/util/rake/omfgenerate.rb +7 -7
  177. metadata +158 -45
  178. data/dogtail/basic_run_test.py +0 -9
  179. data/lib/alexandria/book_providers/renaud.rb +0 -155
  180. data/lib/alexandria/book_providers/thalia.rb +0 -198
  181. data/lib/alexandria/ui/dialogs/alert_dialog.rb +0 -63
  182. data/lib/alexandria/ui/dialogs/import_dialog.rb +0 -176
  183. data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +0 -62
  184. data/lib/alexandria/ui/dialogs/preferences_dialog.rb +0 -563
  185. data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +0 -61
  186. data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +0 -423
  187. data/spec/alexandria/scanners/cuecat_spec.rb +0 -67
  188. data/spec/alexandria/ui/dialogs_spec.rb +0 -162
  189. data/spec/alexandria/ui/sidepane_spec.rb +0 -29
  190. data/spec/alexandria/ui/ui_utilities_spec.rb +0 -62
  191. data/spec/alexandria/utilities_spec.rb +0 -52
  192. data/tasks/dogtail.rake +0 -6
@@ -17,35 +17,35 @@
17
17
  # write to the Free Software Foundation, Inc., 51 Franklin Street,
18
18
  # Fifth Floor, Boston, MA 02110-1301 USA.
19
19
 
20
- require 'gdk_pixbuf2'
21
- require 'gtk3'
20
+ require "gdk_pixbuf2"
21
+ require "gtk3"
22
22
 
23
- require 'alexandria/ui/icons'
24
- require 'alexandria/ui/builder_base'
25
- require 'alexandria/ui/completion_models'
26
- require 'alexandria/ui/libraries_combo'
27
- require 'alexandria/ui/multi_drag_treeview'
28
- require 'alexandria/ui/main_app'
23
+ require "alexandria/ui/icons"
24
+ require "alexandria/ui/builder_base"
25
+ require "alexandria/ui/completion_models"
26
+ require "alexandria/ui/libraries_combo"
27
+ require "alexandria/ui/multi_drag_treeview"
28
+ require "alexandria/ui/main_app"
29
29
 
30
30
  module Alexandria
31
31
  module UI
32
32
  include Logging
33
33
  def self.init_icons
34
- log.info { 'Initializing Icons...' }
34
+ log.info { "Initializing Icons" }
35
35
  Icons.init
36
36
  end
37
37
 
38
38
  def self.start_main_app
39
- puts '==========================' if $DEBUG
40
- log.info { 'Starting MainApp...' }
41
- puts '==========================' if $DEBUG
39
+ log.debug { "==========================" }
40
+ log.info { "Starting MainApp" }
41
+ log.debug { "==========================" }
42
42
  MainApp.instance
43
43
  end
44
44
 
45
45
  def self.start_gtk
46
- puts '====================================' if $DEBUG
47
- log.info { 'Starting Gtk...' }
48
- puts '====================================' if $DEBUG
46
+ log.debug { "====================================" }
47
+ log.info { "Starting Gtk" }
48
+ log.debug { "====================================" }
49
49
  Gtk.main
50
50
  end
51
51
 
@@ -7,7 +7,7 @@
7
7
  module Alexandria
8
8
  module UI
9
9
  class AboutDialog
10
- GPL = <<~EOL
10
+ GPL = <<~EOL # rubocop:disable GetText/DecorateString
11
11
  Alexandria is free software; you can redistribute it and/or
12
12
  modify it under the terms of the GNU General Public License as
13
13
  published by the Free Software Foundation; either version 2 of the
@@ -38,7 +38,7 @@ module Alexandria
38
38
  @dialog.website = Alexandria::WEBSITE_URL
39
39
  @dialog.license = GPL
40
40
  @dialog.transient_for = parent
41
- @dialog.signal_connect('response') { @dialog.destroy }
41
+ @dialog.signal_connect("response") { @dialog.destroy }
42
42
  end
43
43
 
44
44
  def show
@@ -4,13 +4,14 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require 'monitor'
8
- require 'alexandria/scanners/cuecat'
9
- require 'alexandria/scanners/keyboard'
7
+ require "monitor"
8
+ require "alexandria/scanners/cue_cat"
9
+ require "alexandria/scanners/keyboard"
10
10
 
11
- require 'alexandria/ui/builder_base'
12
- require 'alexandria/ui/dialogs/barcode_animation'
13
- require 'alexandria/ui/sound'
11
+ require "alexandria/ui/builder_base"
12
+ require "alexandria/ui/barcode_animation"
13
+ require "alexandria/ui/error_dialog"
14
+ require "alexandria/ui/sound"
14
15
 
15
16
  module Alexandria
16
17
  module UI
@@ -41,10 +42,10 @@ module Alexandria
41
42
  include GetText
42
43
  include Logging
43
44
  extend GetText
44
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
45
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
45
46
 
46
47
  def initialize(parent, selected_library = nil, &block)
47
- super('acquire_dialog__builder.glade', widget_names)
48
+ super("acquire_dialog__builder.glade", widget_names)
48
49
  @acquire_dialog.transient_for = @parent = parent
49
50
  @block = block
50
51
 
@@ -63,6 +64,10 @@ module Alexandria
63
64
  @search_threads_running = @search_thread_counter.new_cond
64
65
  end
65
66
 
67
+ def show
68
+ @acquire_dialog.show
69
+ end
70
+
66
71
  def widget_names
67
72
  [:acquire_dialog, :add_button, :barcodes_treeview, :barcode_label,
68
73
  :scan_area, :scan_frame, :combo_libraries]
@@ -70,14 +75,9 @@ module Alexandria
70
75
 
71
76
  def book_in_library(isbn10, library)
72
77
  isbn13 = Library.canonicalise_ean(isbn10)
73
- # puts "new book #{isbn10} (or #{isbn13})"
74
78
  match = library.find do |book|
75
- # puts "testing #{book.isbn}"
76
79
  (book.isbn == isbn10 || book.isbn == isbn13)
77
- # puts "book #{book.isbn}"
78
- # book == new_book
79
80
  end
80
- # puts "book_in_library match #{match.inspect}"
81
81
  !match.nil?
82
82
  rescue StandardError
83
83
  log.warn { "Failed to check for book #{isbn10} in library #{library}" }
@@ -199,8 +199,8 @@ module Alexandria
199
199
  if isbn_duplicates.empty?
200
200
  @acquire_dialog.destroy unless adding_a_selection
201
201
  else
202
- message = n_('There was %d duplicate',
203
- 'There were %d duplicates',
202
+ message = n_("There was %d duplicate",
203
+ "There were %d duplicates",
204
204
  isbn_duplicates.size) % isbn_duplicates.size
205
205
  title = n_("Couldn't add this book",
206
206
  "Couldn't add these books",
@@ -219,7 +219,7 @@ module Alexandria
219
219
 
220
220
  def read_barcode_scan
221
221
  @animation.start
222
- play_sound('scanning') if @test_scan
222
+ play_sound("scanning") if @test_scan
223
223
  log.debug { "reading scanner data #{@scanner_buffer}" }
224
224
  barcode_text = nil
225
225
  isbn = nil
@@ -229,25 +229,25 @@ module Alexandria
229
229
  isbn = Library.canonicalise_isbn(barcode_text)
230
230
  # TODO: : use an AppFacade
231
231
  # isbn = LookupBook.get_isbn(barcode_text)
232
- rescue StandardError => err
233
- log.error { "Bad scan: #{@scanner_buffer} #{err}" }
232
+ rescue StandardError => ex
233
+ log.error { "Bad scan: #{@scanner_buffer} #{ex}" }
234
234
  ensure
235
- @scanner_buffer = ''
235
+ @scanner_buffer = ""
236
236
  end
237
237
  if isbn
238
238
  log.debug { "Got ISBN #{isbn}" }
239
- play_sound('good_scan')
239
+ play_sound("good_scan")
240
240
 
241
241
  @barcodes_treeview.model.freeze_notify do
242
242
  iter = @barcodes_treeview.model.append
243
243
  iter[0] = isbn
244
244
  iter[1] = Icons::BOOK
245
- iter[2] = ''
245
+ iter[2] = ""
246
246
  end
247
247
  lookup_book(isbn)
248
248
  else
249
- log.debug { 'was not an ISBN barcode' }
250
- play_sound('bad_scan')
249
+ log.debug { "was not an ISBN barcode" }
250
+ play_sound("bad_scan")
251
251
  end
252
252
  end
253
253
 
@@ -328,86 +328,82 @@ module Alexandria
328
328
 
329
329
  def lookup_book(isbn)
330
330
  Thread.new do
331
- begin
332
- start_search
333
- results = Alexandria::BookProviders.isbn_search(isbn)
334
- book = results[0]
335
- cover_uri = results[1]
336
- @book_results[isbn] = results
337
- set_cover_image_async(isbn, cover_uri)
338
-
339
- @barcodes_treeview.model.freeze_notify do
340
- @barcodes_treeview.model.each do |model, path, iter|
341
- if iter[0] == isbn
342
- iter[2] = book.title
343
- model.row_changed(path, iter)
344
- end
331
+ start_search
332
+ results = Alexandria::BookProviders.isbn_search(isbn)
333
+ book = results[0]
334
+ cover_uri = results[1]
335
+ @book_results[isbn] = results
336
+ set_cover_image_async(isbn, cover_uri)
337
+
338
+ @barcodes_treeview.model.freeze_notify do
339
+ @barcodes_treeview.model.each do |model, path, iter|
340
+ if iter[0] == isbn
341
+ iter[2] = book.title
342
+ model.row_changed(path, iter)
345
343
  end
346
344
  end
347
-
348
- @add_button.sensitive = true
349
- rescue StandardError => err
350
- log.error { "Book Search failed: #{err.message}" }
351
- log << err if log.error?
352
- ensure
353
- stop_search
354
345
  end
346
+
347
+ @add_button.sensitive = true
348
+ rescue StandardError => ex
349
+ log.error { "Book Search failed: #{ex.message}" }
350
+ log << ex if log.error?
351
+ ensure
352
+ stop_search
355
353
  end
356
354
  end
357
355
 
358
356
  def set_cover_image_async(isbn, cover_uri)
359
357
  Thread.new do
360
- begin
361
- pixbuf = nil
362
- if cover_uri
363
- image_data = nil
364
- if URI.parse(cover_uri).scheme.nil?
365
- File.open(cover_uri, 'r') do |io|
366
- image_data = io.read
367
- end
368
- else
369
- image_data = URI.parse(cover_uri).read
358
+ pixbuf = nil
359
+ if cover_uri
360
+ image_data = nil
361
+ if URI.parse(cover_uri).scheme.nil?
362
+ File.open(cover_uri, "r") do |io|
363
+ image_data = io.read
370
364
  end
371
- loader = GdkPixbuf::PixbufLoader.new
372
- loader.last_write(image_data)
373
- pixbuf = loader.pixbuf
374
365
  else
375
- pixbuf = Icons::BOOK
366
+ image_data = URI.parse(cover_uri).read
376
367
  end
368
+ loader = GdkPixbuf::PixbufLoader.new
369
+ loader.last_write(image_data)
370
+ pixbuf = loader.pixbuf
371
+ else
372
+ pixbuf = Icons::BOOK
373
+ end
377
374
 
378
- @barcodes_treeview.model.freeze_notify do
379
- @barcodes_treeview.model.each do |model, path, iter|
380
- if iter[0] == isbn
381
- iter[1] = pixbuf
382
- model.row_changed(path, iter)
383
- end
375
+ @barcodes_treeview.model.freeze_notify do
376
+ @barcodes_treeview.model.each do |model, path, iter|
377
+ if iter[0] == isbn
378
+ iter[1] = pixbuf
379
+ model.row_changed(path, iter)
384
380
  end
385
381
  end
386
- rescue StandardError => err
387
- log.error {
388
- "Failed to load cover image icon: #{err.message}"
389
- }
390
- log << err if log.error?
391
382
  end
383
+ rescue StandardError => ex
384
+ log.error do
385
+ "Failed to load cover image icon: #{ex.message}"
386
+ end
387
+ log << ex if log.error?
392
388
  end
393
389
  end
394
390
 
395
391
  def on_destroy
396
- MainApp.instance.ui_manager.set_status_label('')
392
+ MainApp.instance.ui_manager.set_status_label("")
397
393
  notify_end_add_by_isbn
398
394
  # TODO: possibly make sure all threads have stopped running
399
395
  @animation.destroy
400
396
  end
401
397
 
402
398
  def setup_scanner_area
403
- @scanner_buffer = ''
399
+ @scanner_buffer = ""
404
400
  scanner_name = @prefs.barcode_scanner
405
401
 
406
402
  @scanner = Alexandria::Scanners.find_scanner(scanner_name) ||
407
403
  Alexandria::Scanners.default_scanner # CueCat is default
408
404
 
409
405
  log.debug { "Using #{@scanner.name} scanner" }
410
- message = _('Ready to use %s barcode scanner') % @scanner.name
406
+ message = _("Ready to use %s barcode scanner") % @scanner.name
411
407
  MainApp.instance.ui_manager.set_status_label(message)
412
408
 
413
409
  @prev_time = 0
@@ -417,40 +413,41 @@ module Alexandria
417
413
  @scan_frame.add(@animation.canvas)
418
414
 
419
415
  # attach signals
420
- @scan_area.signal_connect('button-press-event') do |_widget, _event|
416
+ @scan_area.signal_connect("button-press-event") do |_widget, _event|
421
417
  @scan_area.grab_focus
422
418
  end
423
- @scan_area.signal_connect('focus-in-event') do |_widget, _event|
424
- @barcode_label.label = _(format('%s _Barcode Scanner Ready', _(@scanner.display_name)))
425
- @scanner_buffer = ''
419
+ @scan_area.signal_connect("focus-in-event") do |_widget, _event|
420
+ @barcode_label.label =
421
+ _(format("%s _Barcode Scanner Ready", _(@scanner.display_name)))
422
+ @scanner_buffer = ""
426
423
  begin
427
424
  @animation.set_active
428
- rescue StandardError => err
429
- log << err if log.error?
425
+ rescue StandardError => ex
426
+ log << ex if log.error?
430
427
  end
431
428
  end
432
- @scan_area.signal_connect('focus-out-event') do |_widget, _event|
433
- @barcode_label.label = _('Click below to scan _barcodes')
434
- @scanner_buffer = ''
429
+ @scan_area.signal_connect("focus-out-event") do |_widget, _event|
430
+ @barcode_label.label = _("Click below to scan _barcodes")
431
+ @scanner_buffer = ""
435
432
  @animation.set_passive
436
433
  # @scanner_background.destroy
437
434
  end
438
435
 
439
436
  @@debug_index = 0
440
- @scan_area.signal_connect('key-press-event') do |_button, event|
437
+ @scan_area.signal_connect("key-press-event") do |_button, event|
441
438
  # log.debug { event.keyval }
442
439
  # event.keyval == 65293 means Enter key
443
440
  # HACK, this disallows numeric keypad entry of data...
444
441
  if event.keyval < 255
445
442
  if @scanner_buffer.empty?
446
- if event.keyval.chr == '`' # backtick key for devs
443
+ if event.keyval.chr == "`" # backtick key for devs
447
444
  developer_test_scan
448
445
  next
449
446
  else
450
447
  # this is our first character, notify user
451
- log.debug { 'Scanning! Received first character.' }
448
+ log.debug { "Scanning! Received first character." }
452
449
  end
453
- play_sound('scanning')
450
+ play_sound("scanning")
454
451
  end
455
452
  @scanner_buffer << event.keyval.chr
456
453
 
@@ -474,7 +471,7 @@ module Alexandria
474
471
  if @scanner.match? @scanner_buffer
475
472
 
476
473
  Thread.new(@interval, @scanner_buffer) do |interval, buffer|
477
- log.debug { 'Waiting for more scanner input...' }
474
+ log.debug { "Waiting for more scanner input" }
478
475
  GLib::Idle.add do
479
476
  @animation.manual_input
480
477
  false
@@ -482,7 +479,7 @@ module Alexandria
482
479
  time_to_wait = [3, interval * 4].min
483
480
  sleep(time_to_wait)
484
481
  if buffer == @scanner_buffer
485
- log.debug { 'Buffer unchanged; scanning complete' }
482
+ log.debug { "Buffer unchanged; scanning complete" }
486
483
  GLib::Idle.add do
487
484
  @animation.scanner_input
488
485
  false
@@ -493,7 +490,9 @@ module Alexandria
493
490
  @interval = 0
494
491
 
495
492
  else
496
- log.debug { 'Buffer has changed while waiting, reading more characters...' }
493
+ log.debug do
494
+ "Buffer has changed while waiting; reading more characters"
495
+ end
497
496
  end
498
497
  end
499
498
 
@@ -503,20 +502,20 @@ module Alexandria
503
502
 
504
503
  # @sound_player = SoundEffectsPlayer.new
505
504
  @sound_players = {}
506
- @sound_players['scanning'] = SoundEffectsPlayer.new
507
- @sound_players['good_scan'] = SoundEffectsPlayer.new
508
- @sound_players['bad_scan'] = SoundEffectsPlayer.new
505
+ @sound_players["scanning"] = SoundEffectsPlayer.new
506
+ @sound_players["good_scan"] = SoundEffectsPlayer.new
507
+ @sound_players["bad_scan"] = SoundEffectsPlayer.new
509
508
  @test_scan = false
510
509
  end
511
510
 
512
511
  def play_sound(effect)
513
- if effect == 'scanning'
514
- puts "Effect: #{effect}, playing: #{@prefs.play_scanning_sound}" if $DEBUG
512
+ if effect == "scanning"
513
+ log.debug { "Effect: #{effect}, playing: #{@prefs.play_scanning_sound}" }
515
514
  return unless @prefs.play_scanning_sound
516
515
 
517
- @sound_players['scanning'].play('scanning')
516
+ @sound_players["scanning"].play("scanning")
518
517
  else
519
- puts "Effect: #{effect}, playing: #{@prefs.play_scan_sound}" if $DEBUG
518
+ log.debug { "Effect: #{effect}, playing: #{@prefs.play_scan_sound}" }
520
519
  return unless @prefs.play_scan_sound
521
520
 
522
521
  # sleep(0.5) # "scanning" effect lasts 0.5 seconds, wait for it to end
@@ -525,16 +524,16 @@ module Alexandria
525
524
  end
526
525
 
527
526
  def developer_test_scan
528
- log.info { 'Developer test scan.' }
529
- scans = ['.C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7C3j3C3f1Dxj3Dq.',
530
- '.C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7C3z0CNj3Dhj1EW.',
531
- '.C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7C3r2DNbXCxTZCW.',
532
- '.C3nZC3nZC3n2ChnWENz7DxnY.cGf2.ENr7C3z0DNn0ENnWE3nZDhP6.',
533
- '.C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7CNT2CxT2ChP0Dq.',
534
- '.C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7CNT6E3f7CNbWDa.',
535
- '.C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7C3b3ENjYDxv3EW.',
536
- '.C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7C3b2DxjZE3b3Dq.',
537
- '.C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7C3n6CNr6DxvYDa.']
527
+ log.info { "Developer test scan" }
528
+ scans = [".C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7C3j3C3f1Dxj3Dq.",
529
+ ".C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7C3z0CNj3Dhj1EW.",
530
+ ".C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7C3r2DNbXCxTZCW.",
531
+ ".C3nZC3nZC3n2ChnWENz7DxnY.cGf2.ENr7C3z0DNn0ENnWE3nZDhP6.",
532
+ ".C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7CNT2CxT2ChP0Dq.",
533
+ ".C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7CNT6E3f7CNbWDa.",
534
+ ".C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7C3b3ENjYDxv3EW.",
535
+ ".C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7C3b2DxjZE3b3Dq.",
536
+ ".C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7C3n6CNr6DxvYDa."]
538
537
  @scanner_buffer = scans[@@debug_index % scans.size]
539
538
  @@debug_index += 1
540
539
  @test_scan = true
@@ -553,12 +552,12 @@ module Alexandria
553
552
  text_renderer.editable = false
554
553
 
555
554
  # Add column using our renderer
556
- col = Gtk::TreeViewColumn.new('ISBN', text_renderer, text: 0)
555
+ col = Gtk::TreeViewColumn.new("ISBN", text_renderer, text: 0)
557
556
  @barcodes_treeview.append_column(col)
558
557
 
559
558
  # Middle colulmn is cover-image renderer
560
559
  pixbuf_renderer = Gtk::CellRendererPixbuf.new
561
- col = Gtk::TreeViewColumn.new('Cover', pixbuf_renderer)
560
+ col = Gtk::TreeViewColumn.new("Cover", pixbuf_renderer)
562
561
 
563
562
  col.set_cell_data_func(pixbuf_renderer) do |_column, cell, _model, iter|
564
563
  pixbuf = iter[1]
@@ -577,10 +576,10 @@ module Alexandria
577
576
  @barcodes_treeview.append_column(col)
578
577
 
579
578
  # Add column using the second renderer
580
- col = Gtk::TreeViewColumn.new('Title', text_renderer, text: 2)
579
+ col = Gtk::TreeViewColumn.new("Title", text_renderer, text: 2)
581
580
  @barcodes_treeview.append_column(col)
582
581
 
583
- @barcodes_treeview.model.signal_connect('row-deleted') do |model, _path|
582
+ @barcodes_treeview.model.signal_connect("row-deleted") do |model, _path|
584
583
  @add_button.sensitive = false unless model.iter_first
585
584
  end
586
585
  end