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.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/ruby.yml +77 -0
- data/.gitignore +4 -1
- data/.rubocop.yml +86 -36
- data/.rubocop_todo.yml +58 -161
- data/.simplecov +5 -2
- data/CHANGELOG.md +56 -2
- data/Gemfile +4 -3
- data/INSTALL.md +23 -11
- data/README.md +52 -41
- data/Rakefile +78 -75
- data/alexandria-book-collection-manager.gemspec +50 -44
- data/bin/alexandria +12 -22
- data/doc/FAQ +1 -2
- data/doc/dependency_decisions.yml +27 -8
- data/lib/alexandria.rb +25 -23
- data/lib/alexandria/about.rb +50 -50
- data/lib/alexandria/book_providers.rb +86 -91
- data/lib/alexandria/book_providers/adlibris.rb +37 -74
- data/lib/alexandria/book_providers/amazon_aws.rb +94 -100
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +289 -324
- data/lib/alexandria/book_providers/barnes_and_noble.rb +42 -42
- data/lib/alexandria/book_providers/douban.rb +25 -41
- data/lib/alexandria/book_providers/proxis.rb +34 -29
- data/lib/alexandria/book_providers/pseudomarc.rb +77 -85
- data/lib/alexandria/book_providers/siciliano.rb +60 -64
- data/lib/alexandria/book_providers/thalia_provider.rb +161 -0
- data/lib/alexandria/book_providers/web.rb +5 -5
- data/lib/alexandria/book_providers/worldcat.rb +66 -95
- data/lib/alexandria/book_providers/z3950.rb +153 -169
- data/lib/alexandria/config.rb +1 -1
- data/lib/alexandria/console.rb +3 -3
- data/lib/alexandria/default_preferences.rb +37 -0
- data/lib/alexandria/execution_queue.rb +13 -12
- data/lib/alexandria/export_format.rb +8 -8
- data/lib/alexandria/export_library.rb +128 -127
- data/lib/alexandria/import_library.rb +102 -126
- data/lib/alexandria/import_library_csv.rb +41 -41
- data/lib/alexandria/library_collection.rb +6 -5
- data/lib/alexandria/library_sort_order.rb +4 -2
- data/lib/alexandria/library_store.rb +39 -28
- data/lib/alexandria/logging.rb +10 -14
- data/lib/alexandria/models/book.rb +5 -4
- data/lib/alexandria/models/library.rb +63 -53
- data/lib/alexandria/net.rb +5 -6
- data/lib/alexandria/preferences.rb +66 -63
- data/lib/alexandria/scanners.rb +2 -2
- data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +17 -17
- data/lib/alexandria/scanners/keyboard.rb +8 -8
- data/lib/alexandria/smart_library.rb +110 -112
- data/lib/alexandria/ui.rb +15 -15
- data/lib/alexandria/ui/{dialogs/about_dialog.rb → about_dialog.rb} +2 -2
- data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +108 -109
- data/lib/alexandria/ui/alert_dialog.rb +66 -0
- data/lib/alexandria/ui/{dialogs/bad_isbns_dialog.rb → bad_isbns_dialog.rb} +13 -9
- data/lib/alexandria/ui/{dialogs/barcode_animation.rb → barcode_animation.rb} +16 -15
- data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +25 -38
- data/lib/alexandria/ui/{dialogs/book_properties_dialog_base.rb → book_properties_dialog_base.rb} +64 -157
- data/lib/alexandria/ui/builder_base.rb +1 -1
- data/lib/alexandria/ui/calendar_popup.rb +58 -0
- data/lib/alexandria/ui/callbacks.rb +187 -155
- data/lib/alexandria/ui/completion_models.rb +8 -22
- data/lib/alexandria/ui/confirm_erase_dialog.rb +33 -0
- data/lib/alexandria/ui/conflict_while_copying_dialog.rb +34 -0
- data/lib/alexandria/ui/dndable.rb +7 -7
- data/lib/alexandria/ui/error_dialog.rb +25 -0
- data/lib/alexandria/ui/{dialogs/export_dialog.rb → export_dialog.rb} +37 -58
- data/lib/alexandria/ui/icons.rb +38 -43
- data/lib/alexandria/ui/iconview.rb +12 -10
- data/lib/alexandria/ui/iconview_tooltips.rb +41 -54
- data/lib/alexandria/ui/import_dialog.rb +157 -0
- data/lib/alexandria/ui/init.rb +30 -41
- data/lib/alexandria/ui/{dialogs/keep_bad_isbn_dialog.rb → keep_bad_isbn_dialog.rb} +9 -6
- data/lib/alexandria/ui/libraries_combo.rb +15 -14
- data/lib/alexandria/ui/listview.rb +69 -67
- data/lib/alexandria/ui/main_app.rb +24 -26
- data/lib/alexandria/ui/misc_dialogs.rb +10 -0
- data/lib/alexandria/ui/multi_drag_treeview.rb +8 -9
- data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +113 -114
- data/lib/alexandria/ui/{dialogs/new_book_dialog_manual.rb → new_book_dialog_manual.rb} +22 -19
- data/lib/alexandria/ui/new_provider_dialog.rb +100 -0
- data/lib/alexandria/ui/new_smart_library_dialog.rb +74 -0
- data/lib/alexandria/ui/preferences_dialog.rb +313 -0
- data/lib/alexandria/ui/provider_preferences_base_dialog.rb +95 -0
- data/lib/alexandria/ui/provider_preferences_dialog.rb +35 -0
- data/lib/alexandria/ui/{dialogs/misc_dialogs.rb → really_delete_dialog.rb} +7 -28
- data/lib/alexandria/ui/{sidepane.rb → sidepane_manager.rb} +53 -48
- data/lib/alexandria/ui/skip_entry_dialog.rb +33 -0
- data/lib/alexandria/ui/smart_library_properties_dialog.rb +60 -0
- data/lib/alexandria/ui/smart_library_properties_dialog_base.rb +242 -0
- data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
- data/lib/alexandria/ui/sound.rb +11 -13
- data/lib/alexandria/ui/ui_manager.rb +216 -200
- data/lib/alexandria/version.rb +4 -19
- data/lib/alexandria/web_themes.rb +21 -21
- data/po/Makefile +2 -2
- data/po/cs.po +992 -875
- data/po/cy.po +961 -874
- data/po/de.po +990 -865
- data/po/el.po +989 -865
- data/po/es.po +985 -861
- data/po/fr.po +987 -867
- data/po/ga.po +908 -820
- data/po/gl.po +980 -860
- data/po/it.po +986 -864
- data/po/ja.po +969 -849
- data/po/mk.po +984 -860
- data/po/nb.po +979 -859
- data/po/nl.po +983 -860
- data/po/pl.po +1018 -971
- data/po/pt.po +988 -857
- data/po/pt_BR.po +983 -863
- data/po/ru.po +994 -871
- data/po/sk.po +989 -867
- data/po/sv.po +976 -856
- data/po/uk.po +972 -858
- data/po/zh_TW.po +974 -854
- data/schemas/alexandria.schemas +24 -2
- data/share/alexandria/glade/acquire_dialog__builder.glade +1 -1
- data/share/alexandria/glade/book_properties_dialog__builder.glade +1 -1
- data/share/alexandria/glade/main_app__builder.glade +6 -21
- data/share/alexandria/glade/new_book_dialog__builder.glade +1 -1
- data/share/alexandria/glade/preferences_dialog__builder.glade +1 -1
- data/share/gnome/help/alexandria/C/introduction.xml +0 -4
- data/share/gnome/help/alexandria/C/searching.xml +1 -1
- data/share/gnome/help/alexandria/C/smart-libraries.xml +2 -2
- data/share/gnome/help/alexandria/C/working-with-libraries.xml +1 -1
- data/share/gnome/help/alexandria/fr/alexandria.xml +1 -1
- data/share/gnome/help/alexandria/ja/introduction.xml +0 -4
- data/share/gnome/help/alexandria/ja/smart-libraries.xml +1 -1
- data/spec/alexandria/book_providers/thalia_provider_spec.rb +119 -0
- data/spec/alexandria/book_providers/world_cat_provider_spec.rb +160 -0
- data/spec/alexandria/book_providers_spec.rb +62 -156
- data/spec/alexandria/book_spec.rb +12 -10
- data/spec/alexandria/console_spec.rb +6 -11
- data/spec/alexandria/export_library_spec.rb +47 -58
- data/spec/alexandria/library_spec.rb +121 -109
- data/spec/alexandria/library_store_spec.rb +8 -8
- data/spec/alexandria/preferences_spec.rb +44 -17
- data/spec/alexandria/scanners/cue_cat_spec.rb +52 -0
- data/spec/alexandria/smart_library_spec.rb +15 -15
- data/spec/alexandria/ui/about_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/acquire_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/alert_dialog_spec.rb +16 -0
- data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/book_properties_dialog_spec.rb +59 -0
- data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +16 -0
- data/spec/alexandria/ui/error_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/export_dialog_spec.rb +36 -0
- data/spec/alexandria/ui/icons_spec.rb +26 -0
- data/spec/alexandria/ui/iconview_spec.rb +7 -21
- data/spec/alexandria/ui/import_dialog_spec.rb +46 -0
- data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +17 -0
- data/spec/alexandria/ui/main_app_spec.rb +7 -34
- data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +51 -0
- data/spec/alexandria/ui/{dialogs/new_book_dialog_spec.rb → new_book_dialog_spec.rb} +4 -4
- data/spec/alexandria/ui/new_provider_dialog_spec.rb +30 -0
- data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +39 -0
- data/spec/alexandria/ui/preferences_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +34 -0
- data/spec/alexandria/ui/really_delete_dialog_spec.rb +16 -0
- data/spec/alexandria/ui/sidepane_manager_spec.rb +15 -0
- data/spec/alexandria/ui/skip_entry_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +49 -0
- data/spec/alexandria/ui/sound_spec.rb +2 -2
- data/spec/alexandria/ui/ui_manager_spec.rb +44 -20
- data/spec/end_to_end/basic_run_spec.rb +21 -38
- data/spec/fixtures/cover.jpg +0 -0
- data/spec/spec_helper.rb +54 -10
- data/tasks/setup.rb +2 -2
- data/tasks/spec.rake +11 -11
- data/util/rake/fileinstall.rb +38 -35
- data/util/rake/gettextgenerate.rb +7 -7
- data/util/rake/omfgenerate.rb +7 -7
- metadata +158 -45
- data/dogtail/basic_run_test.py +0 -9
- data/lib/alexandria/book_providers/renaud.rb +0 -155
- data/lib/alexandria/book_providers/thalia.rb +0 -198
- data/lib/alexandria/ui/dialogs/alert_dialog.rb +0 -63
- data/lib/alexandria/ui/dialogs/import_dialog.rb +0 -176
- data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +0 -62
- data/lib/alexandria/ui/dialogs/preferences_dialog.rb +0 -563
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +0 -61
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +0 -423
- data/spec/alexandria/scanners/cuecat_spec.rb +0 -67
- data/spec/alexandria/ui/dialogs_spec.rb +0 -162
- data/spec/alexandria/ui/sidepane_spec.rb +0 -29
- data/spec/alexandria/ui/ui_utilities_spec.rb +0 -62
- data/spec/alexandria/utilities_spec.rb +0 -52
- data/tasks/dogtail.rake +0 -6
data/lib/alexandria/ui.rb
CHANGED
@@ -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
|
21
|
-
require
|
20
|
+
require "gdk_pixbuf2"
|
21
|
+
require "gtk3"
|
22
22
|
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
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 {
|
34
|
+
log.info { "Initializing Icons" }
|
35
35
|
Icons.init
|
36
36
|
end
|
37
37
|
|
38
38
|
def self.start_main_app
|
39
|
-
|
40
|
-
log.info {
|
41
|
-
|
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
|
-
|
47
|
-
log.info {
|
48
|
-
|
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(
|
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
|
8
|
-
require
|
9
|
-
require
|
7
|
+
require "monitor"
|
8
|
+
require "alexandria/scanners/cue_cat"
|
9
|
+
require "alexandria/scanners/keyboard"
|
10
10
|
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
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:
|
45
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
45
46
|
|
46
47
|
def initialize(parent, selected_library = nil, &block)
|
47
|
-
super(
|
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_(
|
203
|
-
|
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(
|
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 =>
|
233
|
-
log.error { "Bad scan: #{@scanner_buffer} #{
|
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(
|
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 {
|
250
|
-
play_sound(
|
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
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
@barcodes_treeview.model.
|
340
|
-
|
341
|
-
|
342
|
-
|
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
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
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
|
-
|
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
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
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 = _(
|
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(
|
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(
|
424
|
-
@barcode_label.label =
|
425
|
-
|
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 =>
|
429
|
-
log <<
|
425
|
+
rescue StandardError => ex
|
426
|
+
log << ex if log.error?
|
430
427
|
end
|
431
428
|
end
|
432
|
-
@scan_area.signal_connect(
|
433
|
-
@barcode_label.label = _(
|
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(
|
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 ==
|
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 {
|
448
|
+
log.debug { "Scanning! Received first character." }
|
452
449
|
end
|
453
|
-
play_sound(
|
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 {
|
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 {
|
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
|
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[
|
507
|
-
@sound_players[
|
508
|
-
@sound_players[
|
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 ==
|
514
|
-
|
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[
|
516
|
+
@sound_players["scanning"].play("scanning")
|
518
517
|
else
|
519
|
-
|
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 {
|
529
|
-
scans = [
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
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(
|
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(
|
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(
|
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(
|
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
|