alexandria-book-collection-manager 0.7.1 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/dependabot.yml +9 -0
- data/.gitignore +5 -2
- data/.hound.yml +2 -0
- data/.rubocop.yml +113 -45
- data/.rubocop_todo.yml +82 -170
- data/.simplecov +5 -1
- data/.travis.yml +45 -0
- data/.yardopts +1 -1
- data/CHANGELOG.md +60 -0
- data/ChangeLog.0 +33 -35
- data/Gemfile +6 -5
- data/INSTALL.md +164 -0
- data/README.md +52 -42
- data/Rakefile +95 -109
- data/TODO.md +9 -1
- data/alexandria-book-collection-manager.gemspec +52 -45
- data/bin/alexandria +31 -53
- data/doc/AUTHORS +61 -0
- data/doc/BUGS +31 -0
- data/doc/FAQ +365 -0
- data/doc/HACKING +19 -0
- data/doc/NEWS +341 -0
- data/doc/alexandria.1 +120 -0
- data/doc/cuecat_support.rdoc +67 -0
- data/doc/dependency_decisions.yml +80 -0
- data/lib/alexandria.rb +29 -37
- data/lib/alexandria/about.rb +52 -51
- data/lib/alexandria/book_providers.rb +94 -101
- data/lib/alexandria/book_providers/adlibris.rb +45 -85
- data/lib/alexandria/book_providers/amazon_aws.rb +105 -113
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +293 -324
- data/lib/alexandria/book_providers/barnes_and_noble.rb +54 -53
- data/lib/alexandria/book_providers/douban.rb +29 -51
- data/lib/alexandria/book_providers/proxis.rb +42 -59
- data/lib/alexandria/book_providers/pseudomarc.rb +79 -99
- data/lib/alexandria/book_providers/siciliano.rb +68 -70
- data/lib/alexandria/book_providers/thalia.rb +46 -45
- data/lib/alexandria/book_providers/web.rb +17 -33
- data/lib/alexandria/book_providers/worldcat.rb +74 -102
- data/lib/alexandria/book_providers/z3950.rb +170 -174
- data/lib/alexandria/config.rb +5 -3
- data/lib/alexandria/console.rb +10 -21
- data/lib/alexandria/default_preferences.rb +37 -0
- data/lib/alexandria/execution_queue.rb +17 -15
- data/lib/alexandria/export_format.rb +47 -0
- data/lib/alexandria/export_library.rb +188 -302
- data/lib/alexandria/import_library.rb +114 -155
- data/lib/alexandria/import_library_csv.rb +46 -96
- data/lib/alexandria/library_collection.rb +79 -0
- data/lib/alexandria/library_sort_order.rb +45 -0
- data/lib/alexandria/library_store.rb +233 -0
- data/lib/alexandria/logging.rb +15 -19
- data/lib/alexandria/models/book.rb +15 -20
- data/lib/alexandria/models/library.rb +81 -363
- data/lib/alexandria/net.rb +7 -6
- data/lib/alexandria/preferences.rb +73 -91
- data/lib/alexandria/scanners.rb +4 -2
- data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +24 -20
- data/lib/alexandria/scanners/keyboard.rb +10 -8
- data/lib/alexandria/smart_library.rb +135 -171
- data/lib/alexandria/ui.rb +17 -15
- data/lib/alexandria/ui/about_dialog.rb +49 -0
- data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +129 -152
- data/lib/alexandria/ui/alert_dialog.rb +64 -0
- data/lib/alexandria/ui/bad_isbns_dialog.rb +41 -0
- data/lib/alexandria/ui/{dialogs/barcode_animation.rb → barcode_animation.rb} +18 -15
- data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +44 -61
- data/lib/alexandria/ui/{dialogs/book_properties_dialog_base.rb → book_properties_dialog_base.rb} +84 -89
- data/lib/alexandria/ui/builder_base.rb +9 -27
- data/lib/alexandria/ui/callbacks.rb +188 -186
- data/lib/alexandria/ui/columns.rb +2 -0
- data/lib/alexandria/ui/completion_models.rb +12 -23
- 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 +10 -8
- data/lib/alexandria/ui/error_dialog.rb +25 -0
- data/lib/alexandria/ui/export_dialog.rb +139 -0
- data/lib/alexandria/ui/icons.rb +49 -65
- data/lib/alexandria/ui/iconview.rb +15 -13
- data/lib/alexandria/ui/iconview_tooltips.rb +43 -58
- data/lib/alexandria/ui/import_dialog.rb +157 -0
- data/lib/alexandria/ui/init.rb +23 -33
- data/lib/alexandria/ui/keep_bad_isbn_dialog.rb +36 -0
- data/lib/alexandria/ui/libraries_combo.rb +18 -14
- data/lib/alexandria/ui/listview.rb +77 -88
- data/lib/alexandria/ui/main_app.rb +26 -26
- data/lib/alexandria/ui/misc_dialogs.rb +10 -0
- data/lib/alexandria/ui/multi_drag_treeview.rb +30 -41
- data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +168 -215
- data/lib/alexandria/ui/new_book_dialog_manual.rb +139 -0
- 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/really_delete_dialog.rb +53 -0
- data/lib/alexandria/ui/{sidepane.rb → sidepane_manager.rb} +62 -72
- 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/{dialogs/smart_library_properties_dialog_base.rb → smart_library_properties_dialog_base.rb} +96 -172
- data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
- data/lib/alexandria/ui/sound.rb +13 -13
- data/lib/alexandria/ui/ui_manager.rb +262 -283
- data/lib/alexandria/undo_manager.rb +3 -0
- data/lib/alexandria/version.rb +6 -19
- data/lib/alexandria/web_themes.rb +24 -21
- data/po/Makefile +2 -2
- data/po/cs.po +993 -880
- data/po/cy.po +957 -874
- data/po/de.po +990 -869
- data/po/el.po +989 -869
- data/po/es.po +985 -865
- data/po/fr.po +986 -870
- data/po/ga.po +907 -823
- data/po/gl.po +981 -865
- data/po/it.po +986 -868
- data/po/ja.po +969 -853
- data/po/mk.po +983 -863
- data/po/nb.po +979 -863
- data/po/nl.po +983 -864
- data/po/pl.po +1020 -969
- data/po/pt.po +988 -861
- data/po/pt_BR.po +984 -868
- data/po/ru.po +992 -873
- data/po/sk.po +987 -869
- data/po/sv.po +977 -861
- data/po/uk.po +975 -865
- data/po/zh_TW.po +976 -860
- data/schemas/alexandria.schemas +25 -3
- data/share/alexandria/glade/acquire_dialog__builder.glade +15 -12
- data/share/alexandria/glade/book_properties_dialog__builder.glade +171 -299
- data/share/alexandria/glade/main_app__builder.glade +24 -33
- data/share/alexandria/glade/new_book_dialog__builder.glade +27 -59
- data/share/alexandria/glade/preferences_dialog__builder.glade +250 -290
- data/share/gnome/help/alexandria/C/introduction.xml +0 -8
- 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 -8
- data/share/gnome/help/alexandria/ja/smart-libraries.xml +1 -1
- data/spec/alexandria/book_providers/world_cat_provider_spec.rb +160 -0
- data/spec/alexandria/book_providers_spec.rb +77 -210
- data/spec/alexandria/book_spec.rb +16 -12
- data/spec/alexandria/console_spec.rb +27 -0
- data/spec/alexandria/export_library_spec.rb +130 -0
- data/spec/alexandria/library_spec.rb +130 -172
- data/spec/alexandria/library_store_spec.rb +37 -0
- data/spec/alexandria/preferences_spec.rb +46 -17
- data/spec/alexandria/scanners/cue_cat_spec.rb +52 -0
- data/spec/alexandria/smart_library_spec.rb +32 -25
- 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 +17 -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 +15 -0
- data/spec/alexandria/ui/icons_spec.rb +26 -0
- data/spec/alexandria/ui/iconview_spec.rb +9 -21
- data/spec/alexandria/ui/import_dialog_spec.rb +41 -0
- data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +17 -0
- data/spec/alexandria/ui/main_app_spec.rb +8 -33
- data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +15 -0
- data/spec/alexandria/ui/new_book_dialog_spec.rb +22 -0
- 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 +32 -0
- data/spec/alexandria/ui/sound_spec.rb +4 -2
- data/spec/alexandria/ui/ui_manager_spec.rb +45 -20
- data/spec/end_to_end/basic_run_spec.rb +57 -0
- data/spec/spec_helper.rb +66 -33
- data/tasks/setup.rb +5 -3
- data/tasks/spec.rake +18 -3
- data/util/rake/fileinstall.rb +38 -40
- data/util/rake/gettextgenerate.rb +15 -70
- data/util/rake/omfgenerate.rb +10 -10
- metadata +176 -60
- data/INSTALL.rdoc +0 -148
- data/dogtail/basic_run_test.py +0 -9
- data/lib/alexandria/book_providers/bol_it.rb +0 -160
- data/lib/alexandria/book_providers/deastore.rb +0 -273
- data/lib/alexandria/book_providers/ibs_it.rb +0 -147
- data/lib/alexandria/book_providers/mcu.rb +0 -169
- data/lib/alexandria/book_providers/renaud.rb +0 -140
- data/lib/alexandria/book_providers/webster_it.rb +0 -167
- data/lib/alexandria/ui/dialogs/about_dialog.rb +0 -59
- data/lib/alexandria/ui/dialogs/alert_dialog.rb +0 -70
- data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +0 -43
- data/lib/alexandria/ui/dialogs/export_dialog.rb +0 -171
- data/lib/alexandria/ui/dialogs/import_dialog.rb +0 -196
- data/lib/alexandria/ui/dialogs/misc_dialogs.rb +0 -85
- data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +0 -154
- data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +0 -74
- data/lib/alexandria/ui/dialogs/preferences_dialog.rb +0 -578
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +0 -57
- data/spec/alexandria/scanners/cuecat_spec.rb +0 -65
- data/spec/alexandria/ui/dialogs_spec.rb +0 -94
- data/spec/alexandria/ui/sidepane_spec.rb +0 -27
- data/spec/alexandria/ui/ui_utilities_spec.rb +0 -60
- data/spec/alexandria/utilities_spec.rb +0 -50
- data/tasks/dogtail.rake +0 -4
data/lib/alexandria/ui.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
4
|
#
|
3
5
|
# Alexandria is free software; you can redistribute it and/or
|
@@ -15,35 +17,35 @@
|
|
15
17
|
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
16
18
|
# Fifth Floor, Boston, MA 02110-1301 USA.
|
17
19
|
|
18
|
-
require
|
19
|
-
require
|
20
|
+
require "gdk_pixbuf2"
|
21
|
+
require "gtk3"
|
20
22
|
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
26
|
-
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"
|
27
29
|
|
28
30
|
module Alexandria
|
29
31
|
module UI
|
30
32
|
include Logging
|
31
33
|
def self.init_icons
|
32
|
-
log.info {
|
34
|
+
log.info { "Initializing Icons" }
|
33
35
|
Icons.init
|
34
36
|
end
|
35
37
|
|
36
38
|
def self.start_main_app
|
37
|
-
|
38
|
-
log.info {
|
39
|
-
|
39
|
+
log.debug { "==========================" }
|
40
|
+
log.info { "Starting MainApp" }
|
41
|
+
log.debug { "==========================" }
|
40
42
|
MainApp.instance
|
41
43
|
end
|
42
44
|
|
43
45
|
def self.start_gtk
|
44
|
-
|
45
|
-
log.info {
|
46
|
-
|
46
|
+
log.debug { "====================================" }
|
47
|
+
log.info { "Starting Gtk" }
|
48
|
+
log.debug { "====================================" }
|
47
49
|
Gtk.main
|
48
50
|
end
|
49
51
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file is part of Alexandria.
|
4
|
+
#
|
5
|
+
# See the file README.md for authorship and licensing information.
|
6
|
+
|
7
|
+
module Alexandria
|
8
|
+
module UI
|
9
|
+
class AboutDialog
|
10
|
+
GPL = <<~EOL # rubocop:disable GetText/DecorateString
|
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.
|
15
|
+
|
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.
|
20
|
+
|
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
|
26
|
+
|
27
|
+
def initialize(parent)
|
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
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,34 +1,20 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
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.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file is part of Alexandria.
|
14
4
|
#
|
15
|
-
#
|
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
|
-
|
21
|
-
require
|
22
|
-
require
|
7
|
+
require "monitor"
|
8
|
+
require "alexandria/scanners/cue_cat"
|
9
|
+
require "alexandria/scanners/keyboard"
|
23
10
|
|
24
|
-
require
|
25
|
-
require
|
11
|
+
require "alexandria/ui/builder_base"
|
12
|
+
require "alexandria/ui/barcode_animation"
|
13
|
+
require "alexandria/ui/error_dialog"
|
14
|
+
require "alexandria/ui/sound"
|
26
15
|
|
27
16
|
module Alexandria
|
28
17
|
module UI
|
29
|
-
require 'thread'
|
30
|
-
require 'monitor'
|
31
|
-
|
32
18
|
# assists in turning on progress bar when searching
|
33
19
|
# and turning it off when all search threads have completed...
|
34
20
|
class SearchThreadCounter < Monitor
|
@@ -56,17 +42,15 @@ module Alexandria
|
|
56
42
|
include GetText
|
57
43
|
include Logging
|
58
44
|
extend GetText
|
59
|
-
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset:
|
45
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
60
46
|
|
61
47
|
def initialize(parent, selected_library = nil, &block)
|
62
|
-
super(
|
48
|
+
super("acquire_dialog__builder.glade", widget_names)
|
63
49
|
@acquire_dialog.transient_for = @parent = parent
|
64
50
|
@block = block
|
65
51
|
|
66
|
-
libraries =
|
67
|
-
if selected_library.is_a?(SmartLibrary)
|
68
|
-
selected_library = libraries.first
|
69
|
-
end
|
52
|
+
libraries = LibraryCollection.instance.all_regular_libraries
|
53
|
+
selected_library = libraries.first if selected_library.is_a?(SmartLibrary)
|
70
54
|
@combo_libraries.populate_with_libraries(libraries,
|
71
55
|
selected_library)
|
72
56
|
|
@@ -80,25 +64,22 @@ module Alexandria
|
|
80
64
|
@search_threads_running = @search_thread_counter.new_cond
|
81
65
|
end
|
82
66
|
|
67
|
+
def show
|
68
|
+
@acquire_dialog.show
|
69
|
+
end
|
70
|
+
|
83
71
|
def widget_names
|
84
|
-
[:acquire_dialog, :
|
85
|
-
:
|
86
|
-
:barcode_label, :scan_area, :scan_frame, :scrolledwindow1,
|
87
|
-
:barcodes_treeview, :hbox1, :label1, :combo_libraries]
|
72
|
+
[:acquire_dialog, :add_button, :barcodes_treeview, :barcode_label,
|
73
|
+
:scan_area, :scan_frame, :combo_libraries]
|
88
74
|
end
|
89
75
|
|
90
76
|
def book_in_library(isbn10, library)
|
91
77
|
isbn13 = Library.canonicalise_ean(isbn10)
|
92
|
-
# puts "new book #{isbn10} (or #{isbn13})"
|
93
78
|
match = library.find do |book|
|
94
|
-
# puts "testing #{book.isbn}"
|
95
79
|
(book.isbn == isbn10 || book.isbn == isbn13)
|
96
|
-
# puts "book #{book.isbn}"
|
97
|
-
# book == new_book
|
98
80
|
end
|
99
|
-
# puts "book_in_library match #{match.inspect}"
|
100
81
|
!match.nil?
|
101
|
-
rescue
|
82
|
+
rescue StandardError
|
102
83
|
log.warn { "Failed to check for book #{isbn10} in library #{library}" }
|
103
84
|
true
|
104
85
|
end
|
@@ -106,7 +87,7 @@ module Alexandria
|
|
106
87
|
def on_add
|
107
88
|
model = @barcodes_treeview.model
|
108
89
|
|
109
|
-
libraries =
|
90
|
+
libraries = LibraryCollection.instance.all_libraries
|
110
91
|
library, is_new_library =
|
111
92
|
@combo_libraries.selection_from_libraries(libraries)
|
112
93
|
|
@@ -208,9 +189,7 @@ module Alexandria
|
|
208
189
|
book = result[0]
|
209
190
|
cover_uri = result[1]
|
210
191
|
|
211
|
-
unless cover_uri.nil?
|
212
|
-
library.save_cover(book, cover_uri)
|
213
|
-
end
|
192
|
+
library.save_cover(book, cover_uri) unless cover_uri.nil?
|
214
193
|
books << book
|
215
194
|
library << book
|
216
195
|
library.save(book)
|
@@ -220,13 +199,13 @@ module Alexandria
|
|
220
199
|
if isbn_duplicates.empty?
|
221
200
|
@acquire_dialog.destroy unless adding_a_selection
|
222
201
|
else
|
223
|
-
message = n_(
|
224
|
-
|
202
|
+
message = n_("There was %d duplicate",
|
203
|
+
"There were %d duplicates",
|
225
204
|
isbn_duplicates.size) % isbn_duplicates.size
|
226
205
|
title = n_("Couldn't add this book",
|
227
206
|
"Couldn't add these books",
|
228
207
|
isbn_duplicates.size)
|
229
|
-
ErrorDialog.new(@
|
208
|
+
ErrorDialog.new(@acquire_dialog, title, message).display
|
230
209
|
end
|
231
210
|
|
232
211
|
@block.call(books, library, is_new_library)
|
@@ -240,7 +219,7 @@ module Alexandria
|
|
240
219
|
|
241
220
|
def read_barcode_scan
|
242
221
|
@animation.start
|
243
|
-
play_sound(
|
222
|
+
play_sound("scanning") if @test_scan
|
244
223
|
log.debug { "reading scanner data #{@scanner_buffer}" }
|
245
224
|
barcode_text = nil
|
246
225
|
isbn = nil
|
@@ -250,25 +229,25 @@ module Alexandria
|
|
250
229
|
isbn = Library.canonicalise_isbn(barcode_text)
|
251
230
|
# TODO: : use an AppFacade
|
252
231
|
# isbn = LookupBook.get_isbn(barcode_text)
|
253
|
-
rescue StandardError =>
|
254
|
-
log.error { "Bad scan: #{@scanner_buffer} #{
|
232
|
+
rescue StandardError => ex
|
233
|
+
log.error { "Bad scan: #{@scanner_buffer} #{ex}" }
|
255
234
|
ensure
|
256
|
-
@scanner_buffer =
|
235
|
+
@scanner_buffer = ""
|
257
236
|
end
|
258
237
|
if isbn
|
259
238
|
log.debug { "Got ISBN #{isbn}" }
|
260
|
-
play_sound(
|
239
|
+
play_sound("good_scan")
|
261
240
|
|
262
241
|
@barcodes_treeview.model.freeze_notify do
|
263
242
|
iter = @barcodes_treeview.model.append
|
264
243
|
iter[0] = isbn
|
265
244
|
iter[1] = Icons::BOOK
|
266
|
-
iter[2] =
|
245
|
+
iter[2] = ""
|
267
246
|
end
|
268
247
|
lookup_book(isbn)
|
269
248
|
else
|
270
|
-
log.debug {
|
271
|
-
play_sound(
|
249
|
+
log.debug { "was not an ISBN barcode" }
|
250
|
+
play_sound("bad_scan")
|
272
251
|
end
|
273
252
|
end
|
274
253
|
|
@@ -320,8 +299,11 @@ module Alexandria
|
|
320
299
|
|
321
300
|
def start_search
|
322
301
|
@search_thread_counter.synchronize do
|
323
|
-
|
324
|
-
|
302
|
+
first_search = @search_thread_counter.count.zero?
|
303
|
+
|
304
|
+
@search_thread_counter.new_search
|
305
|
+
|
306
|
+
if first_search
|
325
307
|
@progress_bar_thread = Thread.new do
|
326
308
|
notify_start_add_by_isbn
|
327
309
|
Alexandria::BookProviders.instance.add_observer(self)
|
@@ -333,8 +315,6 @@ module Alexandria
|
|
333
315
|
notify_end_add_by_isbn
|
334
316
|
Alexandria::BookProviders.instance.add_observer(self)
|
335
317
|
end
|
336
|
-
else
|
337
|
-
@search_thread_counter.new_search
|
338
318
|
end
|
339
319
|
end
|
340
320
|
end
|
@@ -348,88 +328,82 @@ module Alexandria
|
|
348
328
|
|
349
329
|
def lookup_book(isbn)
|
350
330
|
Thread.new do
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
@barcodes_treeview.model.
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
model.row_changed(path, iter)
|
364
|
-
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)
|
365
343
|
end
|
366
344
|
end
|
367
|
-
|
368
|
-
@add_button.sensitive = true
|
369
|
-
rescue StandardError => err
|
370
|
-
log.error { "Book Search failed: #{err.message}" }
|
371
|
-
log << err if log.error?
|
372
|
-
ensure
|
373
|
-
stop_search
|
374
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
|
375
353
|
end
|
376
354
|
end
|
377
355
|
|
378
356
|
def set_cover_image_async(isbn, cover_uri)
|
379
357
|
Thread.new do
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
image_data = io.read
|
387
|
-
end
|
388
|
-
else
|
389
|
-
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
|
390
364
|
end
|
391
|
-
loader = GdkPixbuf::PixbufLoader.new
|
392
|
-
loader.last_write(image_data)
|
393
|
-
pixbuf = loader.pixbuf
|
394
365
|
else
|
395
|
-
|
366
|
+
image_data = URI.parse(cover_uri).read
|
396
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
|
397
374
|
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
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)
|
404
380
|
end
|
405
381
|
end
|
406
|
-
|
407
|
-
rescue StandardError => err
|
408
|
-
log.error {
|
409
|
-
"Failed to load cover image icon: #{err.message}"
|
410
|
-
}
|
411
|
-
log << err if log.error?
|
412
|
-
|
413
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?
|
414
388
|
end
|
415
389
|
end
|
416
390
|
|
417
391
|
def on_destroy
|
418
|
-
MainApp.instance.ui_manager.set_status_label(
|
392
|
+
MainApp.instance.ui_manager.set_status_label("")
|
419
393
|
notify_end_add_by_isbn
|
420
394
|
# TODO: possibly make sure all threads have stopped running
|
421
395
|
@animation.destroy
|
422
396
|
end
|
423
397
|
|
424
398
|
def setup_scanner_area
|
425
|
-
@scanner_buffer =
|
399
|
+
@scanner_buffer = ""
|
426
400
|
scanner_name = @prefs.barcode_scanner
|
427
401
|
|
428
|
-
@scanner = Alexandria::Scanners.find_scanner
|
402
|
+
@scanner = Alexandria::Scanners.find_scanner(scanner_name) ||
|
429
403
|
Alexandria::Scanners.default_scanner # CueCat is default
|
430
404
|
|
431
405
|
log.debug { "Using #{@scanner.name} scanner" }
|
432
|
-
message = _(
|
406
|
+
message = _("Ready to use %s barcode scanner") % @scanner.name
|
433
407
|
MainApp.instance.ui_manager.set_status_label(message)
|
434
408
|
|
435
409
|
@prev_time = 0
|
@@ -439,40 +413,41 @@ module Alexandria
|
|
439
413
|
@scan_frame.add(@animation.canvas)
|
440
414
|
|
441
415
|
# attach signals
|
442
|
-
@scan_area.signal_connect(
|
416
|
+
@scan_area.signal_connect("button-press-event") do |_widget, _event|
|
443
417
|
@scan_area.grab_focus
|
444
418
|
end
|
445
|
-
@scan_area.signal_connect(
|
446
|
-
@barcode_label.label =
|
447
|
-
|
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 = ""
|
448
423
|
begin
|
449
424
|
@animation.set_active
|
450
|
-
rescue StandardError =>
|
451
|
-
log <<
|
425
|
+
rescue StandardError => ex
|
426
|
+
log << ex if log.error?
|
452
427
|
end
|
453
428
|
end
|
454
|
-
@scan_area.signal_connect(
|
455
|
-
@barcode_label.label = _(
|
456
|
-
@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 = ""
|
457
432
|
@animation.set_passive
|
458
433
|
# @scanner_background.destroy
|
459
434
|
end
|
460
435
|
|
461
436
|
@@debug_index = 0
|
462
|
-
@scan_area.signal_connect(
|
437
|
+
@scan_area.signal_connect("key-press-event") do |_button, event|
|
463
438
|
# log.debug { event.keyval }
|
464
439
|
# event.keyval == 65293 means Enter key
|
465
440
|
# HACK, this disallows numeric keypad entry of data...
|
466
441
|
if event.keyval < 255
|
467
442
|
if @scanner_buffer.empty?
|
468
|
-
if event.keyval.chr ==
|
443
|
+
if event.keyval.chr == "`" # backtick key for devs
|
469
444
|
developer_test_scan
|
470
445
|
next
|
471
446
|
else
|
472
447
|
# this is our first character, notify user
|
473
|
-
log.debug {
|
448
|
+
log.debug { "Scanning! Received first character." }
|
474
449
|
end
|
475
|
-
play_sound(
|
450
|
+
play_sound("scanning")
|
476
451
|
end
|
477
452
|
@scanner_buffer << event.keyval.chr
|
478
453
|
|
@@ -496,7 +471,7 @@ module Alexandria
|
|
496
471
|
if @scanner.match? @scanner_buffer
|
497
472
|
|
498
473
|
Thread.new(@interval, @scanner_buffer) do |interval, buffer|
|
499
|
-
log.debug {
|
474
|
+
log.debug { "Waiting for more scanner input" }
|
500
475
|
GLib::Idle.add do
|
501
476
|
@animation.manual_input
|
502
477
|
false
|
@@ -504,7 +479,7 @@ module Alexandria
|
|
504
479
|
time_to_wait = [3, interval * 4].min
|
505
480
|
sleep(time_to_wait)
|
506
481
|
if buffer == @scanner_buffer
|
507
|
-
log.debug {
|
482
|
+
log.debug { "Buffer unchanged; scanning complete" }
|
508
483
|
GLib::Idle.add do
|
509
484
|
@animation.scanner_input
|
510
485
|
false
|
@@ -515,7 +490,9 @@ module Alexandria
|
|
515
490
|
@interval = 0
|
516
491
|
|
517
492
|
else
|
518
|
-
log.debug
|
493
|
+
log.debug do
|
494
|
+
"Buffer has changed while waiting; reading more characters"
|
495
|
+
end
|
519
496
|
end
|
520
497
|
end
|
521
498
|
|
@@ -525,36 +502,38 @@ module Alexandria
|
|
525
502
|
|
526
503
|
# @sound_player = SoundEffectsPlayer.new
|
527
504
|
@sound_players = {}
|
528
|
-
@sound_players[
|
529
|
-
@sound_players[
|
530
|
-
@sound_players[
|
505
|
+
@sound_players["scanning"] = SoundEffectsPlayer.new
|
506
|
+
@sound_players["good_scan"] = SoundEffectsPlayer.new
|
507
|
+
@sound_players["bad_scan"] = SoundEffectsPlayer.new
|
531
508
|
@test_scan = false
|
532
509
|
end
|
533
510
|
|
534
511
|
def play_sound(effect)
|
535
|
-
if effect ==
|
536
|
-
|
512
|
+
if effect == "scanning"
|
513
|
+
log.debug { "Effect: #{effect}, playing: #{@prefs.play_scanning_sound}" }
|
537
514
|
return unless @prefs.play_scanning_sound
|
538
|
-
|
515
|
+
|
516
|
+
@sound_players["scanning"].play("scanning")
|
539
517
|
else
|
540
|
-
|
518
|
+
log.debug { "Effect: #{effect}, playing: #{@prefs.play_scan_sound}" }
|
541
519
|
return unless @prefs.play_scan_sound
|
520
|
+
|
542
521
|
# sleep(0.5) # "scanning" effect lasts 0.5 seconds, wait for it to end
|
543
522
|
@sound_players[effect].play(effect)
|
544
523
|
end
|
545
524
|
end
|
546
525
|
|
547
526
|
def developer_test_scan
|
548
|
-
log.info {
|
549
|
-
scans = [
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
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."]
|
558
537
|
@scanner_buffer = scans[@@debug_index % scans.size]
|
559
538
|
@@debug_index += 1
|
560
539
|
@test_scan = true
|
@@ -573,12 +552,12 @@ module Alexandria
|
|
573
552
|
text_renderer.editable = false
|
574
553
|
|
575
554
|
# Add column using our renderer
|
576
|
-
col = Gtk::TreeViewColumn.new(
|
555
|
+
col = Gtk::TreeViewColumn.new("ISBN", text_renderer, text: 0)
|
577
556
|
@barcodes_treeview.append_column(col)
|
578
557
|
|
579
558
|
# Middle colulmn is cover-image renderer
|
580
559
|
pixbuf_renderer = Gtk::CellRendererPixbuf.new
|
581
|
-
col = Gtk::TreeViewColumn.new(
|
560
|
+
col = Gtk::TreeViewColumn.new("Cover", pixbuf_renderer)
|
582
561
|
|
583
562
|
col.set_cell_data_func(pixbuf_renderer) do |_column, cell, _model, iter|
|
584
563
|
pixbuf = iter[1]
|
@@ -597,13 +576,11 @@ module Alexandria
|
|
597
576
|
@barcodes_treeview.append_column(col)
|
598
577
|
|
599
578
|
# Add column using the second renderer
|
600
|
-
col = Gtk::TreeViewColumn.new(
|
579
|
+
col = Gtk::TreeViewColumn.new("Title", text_renderer, text: 2)
|
601
580
|
@barcodes_treeview.append_column(col)
|
602
581
|
|
603
|
-
@barcodes_treeview.model.signal_connect(
|
604
|
-
unless model.iter_first
|
605
|
-
@add_button.sensitive = false
|
606
|
-
end
|
582
|
+
@barcodes_treeview.model.signal_connect("row-deleted") do |model, _path|
|
583
|
+
@add_button.sensitive = false unless model.iter_first
|
607
584
|
end
|
608
585
|
end
|
609
586
|
end
|