alexandria-book-collection-manager 0.7.10 → 0.7.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +5 -1
- data/.github/workflows/ruby.yml +33 -19
- data/.rubocop.yml +12 -3
- data/.rubocop_todo.yml +30 -29
- data/CHANGELOG.md +64 -25
- data/Gemfile +0 -6
- data/Rakefile +2 -2
- data/alexandria-book-collection-manager.gemspec +20 -17
- data/bin/rake +28 -0
- data/bin/rspec +28 -0
- data/doc/dependency_decisions.yml +32 -26
- data/{bin → exe}/alexandria +1 -3
- data/lib/alexandria/about.rb +1 -0
- data/lib/alexandria/book_providers/bl_provider.rb +4 -6
- data/lib/alexandria/book_providers/{douban.rb → douban_provider.rb} +1 -1
- data/lib/alexandria/book_providers/loc_provider.rb +2 -6
- data/lib/alexandria/book_providers/sbn_provider.rb +2 -12
- data/lib/alexandria/book_providers/thalia_provider.rb +5 -6
- data/lib/alexandria/book_providers/{web.rb → website_based_provider.rb} +20 -1
- data/lib/alexandria/book_providers/{worldcat.rb → world_cat_provider.rb} +3 -4
- data/lib/alexandria/book_providers/z3950_provider.rb +24 -26
- data/lib/alexandria/book_providers.rb +14 -10
- data/lib/alexandria/config.rb +2 -2
- data/lib/alexandria/console.rb +12 -10
- data/lib/alexandria/export_format.rb +3 -2
- data/lib/alexandria/export_library.rb +31 -36
- data/lib/alexandria/import_library.rb +3 -4
- data/lib/alexandria/import_library_csv.rb +2 -2
- data/lib/alexandria/library_collection.rb +1 -1
- data/lib/alexandria/library_store.rb +19 -14
- data/lib/alexandria/logging.rb +22 -21
- data/lib/alexandria/models/book.rb +1 -2
- data/lib/alexandria/models/library.rb +5 -6
- data/lib/alexandria/preferences.rb +7 -19
- data/lib/alexandria/pseudo_marc_parser.rb +1 -1
- data/lib/alexandria/scanners/cue_cat.rb +5 -9
- data/lib/alexandria/scanners/{keyboard.rb → keyboard_wedge.rb} +3 -3
- data/lib/alexandria/scanners.rb +2 -2
- data/lib/alexandria/smart_library.rb +7 -3
- data/lib/alexandria/ui/acquire_dialog.rb +42 -45
- data/lib/alexandria/ui/alert_dialog.rb +1 -1
- data/lib/alexandria/ui/barcode_animation.rb +3 -3
- data/lib/alexandria/ui/book_properties_dialog.rb +9 -9
- data/lib/alexandria/ui/book_properties_dialog_base.rb +10 -11
- data/lib/alexandria/ui/builder_base.rb +1 -1
- data/lib/alexandria/ui/callbacks.rb +8 -7
- data/lib/alexandria/ui/confirm_erase_dialog.rb +1 -0
- data/lib/alexandria/ui/conflict_while_copying_dialog.rb +1 -0
- data/lib/alexandria/ui/export_dialog.rb +1 -0
- data/lib/alexandria/ui/{iconview.rb → icon_view_manager.rb} +1 -0
- data/lib/alexandria/ui/iconview_tooltips.rb +1 -1
- data/lib/alexandria/ui/keep_bad_isbn_dialog.rb +1 -0
- data/lib/alexandria/ui/libraries_combo.rb +1 -0
- data/lib/alexandria/ui/listview.rb +2 -0
- data/lib/alexandria/ui/main_app.rb +3 -1
- data/lib/alexandria/ui/multi_drag_treeview.rb +0 -2
- data/lib/alexandria/ui/new_book_dialog.rb +15 -20
- data/lib/alexandria/ui/new_book_dialog_manual.rb +7 -7
- data/lib/alexandria/ui/new_provider_dialog.rb +1 -0
- data/lib/alexandria/ui/new_smart_library_dialog.rb +2 -1
- data/lib/alexandria/ui/preferences_dialog.rb +4 -4
- data/lib/alexandria/ui/provider_preferences_dialog.rb +1 -0
- data/lib/alexandria/ui/really_delete_dialog.rb +1 -0
- data/lib/alexandria/ui/sidepane_manager.rb +49 -48
- data/lib/alexandria/ui/skip_entry_dialog.rb +1 -0
- data/lib/alexandria/ui/smart_library_properties_dialog.rb +1 -0
- data/lib/alexandria/ui/smart_library_properties_dialog_base.rb +2 -1
- data/lib/alexandria/ui/{sound.rb → sound_effects_player.rb} +3 -0
- data/lib/alexandria/ui/ui_manager.rb +192 -141
- data/lib/alexandria/ui.rb +1 -0
- data/lib/alexandria/version.rb +1 -1
- data/po/Makefile +1 -1
- data/po/it.po +64 -82
- data/spec/alexandria/book_providers/bl_provider_spec.rb +10 -1
- data/spec/alexandria/book_providers/douban_provider_spec.rb +17 -0
- data/spec/alexandria/book_providers/loc_provider_spec.rb +8 -0
- data/spec/alexandria/book_providers/sbn_provider_spec.rb +9 -1
- data/spec/alexandria/book_providers/thalia_provider_spec.rb +8 -0
- data/spec/alexandria/book_providers/world_cat_provider_spec.rb +8 -0
- data/spec/alexandria/book_providers/z3950_provider_spec.rb +22 -0
- data/spec/alexandria/console_spec.rb +1 -1
- data/spec/alexandria/export_library_spec.rb +57 -11
- data/spec/alexandria/library_collection_spec.rb +24 -0
- data/spec/alexandria/library_spec.rb +2 -1
- data/spec/alexandria/library_store_spec.rb +32 -0
- data/spec/alexandria/scanners/keyboard_wedge_spec.rb +47 -0
- data/spec/alexandria/ui/about_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/acquire_dialog_spec.rb +8 -3
- data/spec/alexandria/ui/alert_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/book_properties_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/error_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/export_dialog_spec.rb +3 -3
- data/spec/alexandria/ui/{iconview_spec.rb → icon_view_manager_spec.rb} +1 -1
- data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/main_app_spec.rb +0 -2
- data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +1 -1
- data/spec/alexandria/ui/new_book_dialog_spec.rb +6 -3
- data/spec/alexandria/ui/preferences_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +22 -7
- data/spec/alexandria/ui/really_delete_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/sidepane_manager_spec.rb +1 -1
- data/spec/alexandria/ui/skip_entry_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/ui_manager_spec.rb +2 -2
- data/spec/end_to_end/basic_run_spec.rb +2 -1
- data/spec/spec_helper.rb +4 -2
- data/tasks/setup.rb +1 -1
- data/util/rake/fileinstall.rb +5 -6
- data/util/rake/omfgenerate.rb +1 -1
- metadata +93 -61
- /data/spec/alexandria/ui/{sound_spec.rb → sound_effects_player_spec.rb} +0 -0
|
@@ -9,20 +9,18 @@ require "monitor"
|
|
|
9
9
|
require "alexandria/image_fetcher"
|
|
10
10
|
|
|
11
11
|
require "alexandria/scanners/cue_cat"
|
|
12
|
-
require "alexandria/scanners/
|
|
12
|
+
require "alexandria/scanners/keyboard_wedge"
|
|
13
13
|
|
|
14
14
|
require "alexandria/ui/builder_base"
|
|
15
15
|
require "alexandria/ui/barcode_animation"
|
|
16
16
|
require "alexandria/ui/error_dialog"
|
|
17
|
-
require "alexandria/ui/
|
|
17
|
+
require "alexandria/ui/sound_effects_player"
|
|
18
18
|
|
|
19
19
|
module Alexandria
|
|
20
20
|
module UI
|
|
21
21
|
# assists in turning on progress bar when searching
|
|
22
22
|
# and turning it off when all search threads have completed...
|
|
23
|
-
class
|
|
24
|
-
attr_reader :count
|
|
25
|
-
|
|
23
|
+
class SearchThreadMonitor < Monitor
|
|
26
24
|
def initialize
|
|
27
25
|
@count = 0
|
|
28
26
|
super
|
|
@@ -39,6 +37,14 @@ module Alexandria
|
|
|
39
37
|
@count -= 1 unless @count.zero?
|
|
40
38
|
end
|
|
41
39
|
end
|
|
40
|
+
|
|
41
|
+
def any?
|
|
42
|
+
@count > 0
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def none?
|
|
46
|
+
@count.zero?
|
|
47
|
+
end
|
|
42
48
|
end
|
|
43
49
|
|
|
44
50
|
class AcquireDialog < BuilderBase
|
|
@@ -46,10 +52,12 @@ module Alexandria
|
|
|
46
52
|
include ImageFetcher
|
|
47
53
|
include Logging
|
|
48
54
|
extend GetText
|
|
55
|
+
|
|
49
56
|
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
|
50
57
|
|
|
51
|
-
def initialize(parent, selected_library
|
|
58
|
+
def initialize(parent, ui_manager, selected_library, &block)
|
|
52
59
|
super("acquire_dialog__builder.glade", widget_names)
|
|
60
|
+
@ui_manager = ui_manager
|
|
53
61
|
@acquire_dialog.transient_for = @parent = parent
|
|
54
62
|
@block = block
|
|
55
63
|
|
|
@@ -64,8 +72,8 @@ module Alexandria
|
|
|
64
72
|
init_treeview
|
|
65
73
|
@book_results = {}
|
|
66
74
|
|
|
67
|
-
@
|
|
68
|
-
@search_threads_running = @
|
|
75
|
+
@search_thread_monitor = SearchThreadMonitor.new
|
|
76
|
+
@search_threads_running = @search_thread_monitor.new_cond
|
|
69
77
|
end
|
|
70
78
|
|
|
71
79
|
def show
|
|
@@ -79,8 +87,9 @@ module Alexandria
|
|
|
79
87
|
|
|
80
88
|
def book_in_library(isbn10, library)
|
|
81
89
|
isbn13 = Library.canonicalise_ean(isbn10)
|
|
90
|
+
isbns = [isbn10, isbn13]
|
|
82
91
|
match = library.find do |book|
|
|
83
|
-
(book.isbn
|
|
92
|
+
isbns.include?(book.isbn)
|
|
84
93
|
end
|
|
85
94
|
!match.nil?
|
|
86
95
|
rescue StandardError
|
|
@@ -258,28 +267,11 @@ module Alexandria
|
|
|
258
267
|
# begin copy-n-paste from new_book_dialog
|
|
259
268
|
|
|
260
269
|
def notify_start_add_by_isbn
|
|
261
|
-
|
|
262
|
-
main_progress_bar = MainApp.instance.appbar.children.first
|
|
263
|
-
main_progress_bar.visible = true
|
|
264
|
-
@progress_pulsing = GLib::Timeout.add(100) do
|
|
265
|
-
if @destroyed
|
|
266
|
-
@progress_pulsing = nil
|
|
267
|
-
false
|
|
268
|
-
else
|
|
269
|
-
main_progress_bar.pulse
|
|
270
|
-
true
|
|
271
|
-
end
|
|
272
|
-
end
|
|
273
|
-
false
|
|
274
|
-
end
|
|
270
|
+
ui_manager.start_progress_bar_pulsing(self)
|
|
275
271
|
end
|
|
276
272
|
|
|
277
273
|
def notify_end_add_by_isbn
|
|
278
|
-
|
|
279
|
-
MainApp.instance.appbar.children.first.visible = false
|
|
280
|
-
GLib::Source.remove(@progress_pulsing) if @progress_pulsing
|
|
281
|
-
false
|
|
282
|
-
end
|
|
274
|
+
ui_manager.stop_progress_bar_pulsing
|
|
283
275
|
end
|
|
284
276
|
|
|
285
277
|
def update(status, provider)
|
|
@@ -292,28 +284,34 @@ module Alexandria
|
|
|
292
284
|
}
|
|
293
285
|
message = messages[status] % provider
|
|
294
286
|
log.debug { "update message : #{message}" }
|
|
295
|
-
|
|
287
|
+
ui_manager.set_status_label(message)
|
|
296
288
|
false
|
|
297
289
|
end
|
|
298
290
|
end
|
|
299
291
|
|
|
292
|
+
def destroyed?
|
|
293
|
+
@acquire_dialog.destroyed?
|
|
294
|
+
end
|
|
295
|
+
|
|
300
296
|
# end copy-n-paste
|
|
301
297
|
|
|
298
|
+
attr_reader :ui_manager
|
|
299
|
+
|
|
302
300
|
private
|
|
303
301
|
|
|
304
302
|
def start_search
|
|
305
|
-
@
|
|
306
|
-
first_search = @
|
|
303
|
+
@search_thread_monitor.synchronize do
|
|
304
|
+
first_search = @search_thread_monitor.none?
|
|
307
305
|
|
|
308
|
-
@
|
|
306
|
+
@search_thread_monitor.new_search
|
|
309
307
|
|
|
310
308
|
if first_search
|
|
311
309
|
@progress_bar_thread = Thread.new do
|
|
312
310
|
notify_start_add_by_isbn
|
|
313
311
|
Alexandria::BookProviders.instance.add_observer(self)
|
|
314
|
-
@
|
|
312
|
+
@search_thread_monitor.synchronize do
|
|
315
313
|
@search_threads_running.wait_while do
|
|
316
|
-
@
|
|
314
|
+
@search_thread_monitor.any?
|
|
317
315
|
end
|
|
318
316
|
end
|
|
319
317
|
notify_end_add_by_isbn
|
|
@@ -324,8 +322,8 @@ module Alexandria
|
|
|
324
322
|
end
|
|
325
323
|
|
|
326
324
|
def stop_search
|
|
327
|
-
@
|
|
328
|
-
@
|
|
325
|
+
@search_thread_monitor.synchronize do
|
|
326
|
+
@search_thread_monitor.end_search
|
|
329
327
|
@search_threads_running.signal
|
|
330
328
|
end
|
|
331
329
|
end
|
|
@@ -386,7 +384,7 @@ module Alexandria
|
|
|
386
384
|
end
|
|
387
385
|
|
|
388
386
|
def on_destroy
|
|
389
|
-
|
|
387
|
+
ui_manager.set_status_label("")
|
|
390
388
|
notify_end_add_by_isbn
|
|
391
389
|
# TODO: possibly make sure all threads have stopped running
|
|
392
390
|
@animation.destroy
|
|
@@ -401,7 +399,7 @@ module Alexandria
|
|
|
401
399
|
|
|
402
400
|
log.debug { "Using #{@scanner.name} scanner" }
|
|
403
401
|
message = _("Ready to use %s barcode scanner") % @scanner.name
|
|
404
|
-
|
|
402
|
+
ui_manager.set_status_label(message)
|
|
405
403
|
|
|
406
404
|
@prev_time = 0
|
|
407
405
|
@interval = 0
|
|
@@ -497,11 +495,6 @@ module Alexandria
|
|
|
497
495
|
end
|
|
498
496
|
end
|
|
499
497
|
|
|
500
|
-
# @sound_player = SoundEffectsPlayer.new
|
|
501
|
-
@sound_players = {}
|
|
502
|
-
@sound_players["scanning"] = SoundEffectsPlayer.new
|
|
503
|
-
@sound_players["good_scan"] = SoundEffectsPlayer.new
|
|
504
|
-
@sound_players["bad_scan"] = SoundEffectsPlayer.new
|
|
505
498
|
@test_scan = false
|
|
506
499
|
end
|
|
507
500
|
|
|
@@ -510,16 +503,20 @@ module Alexandria
|
|
|
510
503
|
log.debug { "Effect: #{effect}, playing: #{@prefs.play_scanning_sound}" }
|
|
511
504
|
return unless @prefs.play_scanning_sound
|
|
512
505
|
|
|
513
|
-
|
|
506
|
+
sound_player.play("scanning")
|
|
514
507
|
else
|
|
515
508
|
log.debug { "Effect: #{effect}, playing: #{@prefs.play_scan_sound}" }
|
|
516
509
|
return unless @prefs.play_scan_sound
|
|
517
510
|
|
|
518
511
|
# sleep(0.5) # "scanning" effect lasts 0.5 seconds, wait for it to end
|
|
519
|
-
|
|
512
|
+
sound_player.play(effect)
|
|
520
513
|
end
|
|
521
514
|
end
|
|
522
515
|
|
|
516
|
+
def sound_player
|
|
517
|
+
@sound_player ||= SoundEffectsPlayer.new
|
|
518
|
+
end
|
|
519
|
+
|
|
523
520
|
def developer_test_scan
|
|
524
521
|
log.info { "Developer test scan" }
|
|
525
522
|
scans = [".C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7C3j3C3f1Dxj3Dq.",
|
|
@@ -143,9 +143,9 @@ module Alexandria
|
|
|
143
143
|
def scan_animation
|
|
144
144
|
if @index < @barcode_bars.size
|
|
145
145
|
@index = 0 if @index < 0
|
|
146
|
-
alpha =
|
|
146
|
+
alpha = (@index + 1) * 7
|
|
147
147
|
@barcode_bars.each_with_index do |rect, i|
|
|
148
|
-
rect.set_property(:fill_color_rgba,
|
|
148
|
+
rect.set_property(:fill_color_rgba, alpha + 0xFF000000)
|
|
149
149
|
break if i >= @index
|
|
150
150
|
end
|
|
151
151
|
@index += 1
|
|
@@ -166,7 +166,7 @@ module Alexandria
|
|
|
166
166
|
def fade_animation
|
|
167
167
|
@fade_opacity = 255 if @fade_opacity == -1
|
|
168
168
|
if @fade_opacity >= 0
|
|
169
|
-
grey =
|
|
169
|
+
grey = @fade_opacity + 0x00000000
|
|
170
170
|
@barcode_bars.each { |rect| rect.set_property(:fill_color_rgba, grey) }
|
|
171
171
|
@fade_opacity -= 5
|
|
172
172
|
else
|
|
@@ -11,6 +11,7 @@ module Alexandria
|
|
|
11
11
|
class BookPropertiesDialog < BookPropertiesDialogBase
|
|
12
12
|
include GetText
|
|
13
13
|
extend GetText
|
|
14
|
+
|
|
14
15
|
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
|
15
16
|
|
|
16
17
|
def initialize(parent, library, book)
|
|
@@ -82,17 +83,16 @@ module Alexandria
|
|
|
82
83
|
end
|
|
83
84
|
|
|
84
85
|
@checkbutton_own.active = book.own?
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
@redd_date.text = format_date(book.redd_when)
|
|
91
|
-
end
|
|
92
|
-
# self.redd_when = (book.redd_when or Time.now)
|
|
86
|
+
|
|
87
|
+
@block_calendar_popup = true
|
|
88
|
+
if book.redd?
|
|
89
|
+
@redd_date.text = format_date(book.redd_when) unless book.redd_when.nil?
|
|
90
|
+
@checkbutton_redd.active = true
|
|
93
91
|
else
|
|
94
|
-
@
|
|
92
|
+
@checkbutton_redd.active = false
|
|
95
93
|
end
|
|
94
|
+
@block_calendar_popup = false
|
|
95
|
+
|
|
96
96
|
@checkbutton_want.active = book.want?
|
|
97
97
|
|
|
98
98
|
@checkbutton_want.inconsistent = true if (@checkbutton_own.active = book.own?)
|
|
@@ -15,6 +15,7 @@ module Alexandria
|
|
|
15
15
|
include Logging
|
|
16
16
|
include GetText
|
|
17
17
|
extend GetText
|
|
18
|
+
|
|
18
19
|
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
|
19
20
|
|
|
20
21
|
COVER_MAXWIDTH = 140 # pixels
|
|
@@ -55,11 +56,7 @@ module Alexandria
|
|
|
55
56
|
@treeview_authors.append_column(col)
|
|
56
57
|
|
|
57
58
|
setup_date_widgets
|
|
58
|
-
|
|
59
|
-
@setup_finished = true
|
|
60
|
-
|
|
61
|
-
false
|
|
62
|
-
end
|
|
59
|
+
@block_calendar_popup = false
|
|
63
60
|
end
|
|
64
61
|
|
|
65
62
|
def show
|
|
@@ -242,13 +239,15 @@ module Alexandria
|
|
|
242
239
|
end
|
|
243
240
|
|
|
244
241
|
def redd_toggled
|
|
245
|
-
|
|
246
|
-
|
|
242
|
+
if @checkbutton_redd.active?
|
|
243
|
+
@redd_date.sensitive = true
|
|
247
244
|
|
|
248
|
-
|
|
245
|
+
return if @block_calendar_popup
|
|
249
246
|
|
|
250
|
-
|
|
251
|
-
|
|
247
|
+
display_calendar_popup(@redd_date) if @redd_date.text.strip.empty?
|
|
248
|
+
else
|
|
249
|
+
@redd_date.sensitive = false
|
|
250
|
+
end
|
|
252
251
|
end
|
|
253
252
|
|
|
254
253
|
private
|
|
@@ -263,7 +262,7 @@ module Alexandria
|
|
|
263
262
|
]
|
|
264
263
|
raise _("out of range") if rating < 0 || rating > images.length
|
|
265
264
|
|
|
266
|
-
images[0..rating - 1].each { |x| x.pixbuf = Icons::STAR_SET }
|
|
265
|
+
images[0..(rating - 1)].each { |x| x.pixbuf = Icons::STAR_SET }
|
|
267
266
|
images[rating..].each { |x| x.pixbuf = Icons::STAR_UNSET }
|
|
268
267
|
@current_rating = rating
|
|
269
268
|
end
|
|
@@ -31,7 +31,8 @@ module Alexandria
|
|
|
31
31
|
|
|
32
32
|
def on_add_book(*)
|
|
33
33
|
log.info { "on_add_book" }
|
|
34
|
-
dialog = NewBookDialog.new(@main_app, selected_library) do
|
|
34
|
+
dialog = NewBookDialog.new(@main_app, self, selected_library) do
|
|
35
|
+
|_books, library, is_new|
|
|
35
36
|
if is_new
|
|
36
37
|
append_library(library, true)
|
|
37
38
|
setup_move_actions
|
|
@@ -115,7 +116,7 @@ module Alexandria
|
|
|
115
116
|
|
|
116
117
|
def on_acquire(*)
|
|
117
118
|
dialog =
|
|
118
|
-
AcquireDialog.new(@main_app, selected_library) do |_books, library, is_new|
|
|
119
|
+
AcquireDialog.new(@main_app, self, selected_library) do |_books, library, is_new|
|
|
119
120
|
if is_new
|
|
120
121
|
append_library(library, true)
|
|
121
122
|
setup_move_actions
|
|
@@ -313,11 +314,11 @@ module Alexandria
|
|
|
313
314
|
def connect_toggle_actions
|
|
314
315
|
toggle_actions
|
|
315
316
|
.each do |name, stock_id, label, accelerator, tooltip, callback, is_active|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
317
|
+
action = Gtk::ToggleAction.new(name, label: label, tooltip: tooltip,
|
|
318
|
+
stock_id: stock_id)
|
|
319
|
+
action.set_active is_active
|
|
320
|
+
@actiongroup.add_action_with_accel(action, accelerator)
|
|
321
|
+
action.signal_connect("toggled", &callback) if callback
|
|
321
322
|
end
|
|
322
323
|
end
|
|
323
324
|
|
|
@@ -10,11 +10,13 @@ module Alexandria
|
|
|
10
10
|
module UI
|
|
11
11
|
include Logging
|
|
12
12
|
include GetText
|
|
13
|
+
|
|
13
14
|
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
|
14
15
|
class ListViewManager
|
|
15
16
|
include Logging
|
|
16
17
|
include GetText
|
|
17
18
|
include DragAndDropable
|
|
19
|
+
|
|
18
20
|
BOOKS_TARGET_TABLE = [["ALEXANDRIA_BOOKS", :same_app, 0]].freeze
|
|
19
21
|
|
|
20
22
|
def initialize(_listview, parent)
|
|
@@ -37,19 +37,21 @@ require "alexandria/ui/dndable"
|
|
|
37
37
|
require "alexandria/ui/init"
|
|
38
38
|
require "alexandria/ui/ui_manager"
|
|
39
39
|
require "alexandria/ui/listview"
|
|
40
|
-
require "alexandria/ui/
|
|
40
|
+
require "alexandria/ui/icon_view_manager"
|
|
41
41
|
require "alexandria/ui/sidepane_manager"
|
|
42
42
|
|
|
43
43
|
module Alexandria
|
|
44
44
|
module UI
|
|
45
45
|
include Logging
|
|
46
46
|
include GetText
|
|
47
|
+
|
|
47
48
|
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
|
48
49
|
|
|
49
50
|
class MainApp
|
|
50
51
|
include Logging
|
|
51
52
|
include GetText
|
|
52
53
|
include Singleton
|
|
54
|
+
|
|
53
55
|
attr_accessor :main_app, :libraries, :actiongroup, :appbar, :prefs, :ui_manager
|
|
54
56
|
|
|
55
57
|
def initialize
|
|
@@ -79,8 +79,6 @@ module Alexandria
|
|
|
79
79
|
def motion_notify_event(event)
|
|
80
80
|
if drag_check_threshold(@context.x, @context.y, event.x, event.y)
|
|
81
81
|
stop_drag_check
|
|
82
|
-
paths = []
|
|
83
|
-
selection.each { |_model, path, _iter| paths << path }
|
|
84
82
|
@context.drag_context = drag_begin(@context.source_targets,
|
|
85
83
|
@context.source_actions,
|
|
86
84
|
@context.pressed_button,
|
|
@@ -20,13 +20,15 @@ module Alexandria
|
|
|
20
20
|
include ImageFetcher
|
|
21
21
|
include GetText
|
|
22
22
|
extend GetText
|
|
23
|
+
|
|
23
24
|
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
|
24
25
|
@@last_criterion_was_not_isbn = false
|
|
25
26
|
|
|
26
|
-
def initialize(
|
|
27
|
+
def initialize(parent_window, ui_manager, selected_library, &block)
|
|
27
28
|
super("new_book_dialog__builder.glade", widget_names)
|
|
28
29
|
log.info { "New Book Dialog" }
|
|
29
|
-
@new_book_dialog.transient_for = @parent =
|
|
30
|
+
@new_book_dialog.transient_for = @parent = parent_window
|
|
31
|
+
@ui_manager = ui_manager
|
|
30
32
|
@block = block
|
|
31
33
|
@destroyed = false
|
|
32
34
|
@selected_library = selected_library
|
|
@@ -317,7 +319,7 @@ module Alexandria
|
|
|
317
319
|
return unless entry.text =~ /^\..*?\..*?\.(.*?)\.$/
|
|
318
320
|
|
|
319
321
|
tmp = Regexp.last_match[1].tr("a-zA-Z0-9+-", " -_")
|
|
320
|
-
tmp = ((
|
|
322
|
+
tmp = ((tmp.length * 3 / 4 + 32).to_i.chr << tmp).unpack1("u")
|
|
321
323
|
tmp.chomp!("\000")
|
|
322
324
|
entry.text = tmp.gsub!(/./) { |c| (c[0] ^ 67).chr }
|
|
323
325
|
entry.text = "Bad scan result" if entry.text.count("^ -~") > 0
|
|
@@ -426,7 +428,7 @@ module Alexandria
|
|
|
426
428
|
@treeview_results.model.clear
|
|
427
429
|
@entry_search.grab_focus
|
|
428
430
|
else
|
|
429
|
-
@button_add.sensitive = true
|
|
431
|
+
@button_add.sensitive = true
|
|
430
432
|
@entry_isbn.text = "" # blank ISBN field
|
|
431
433
|
@entry_isbn.grab_focus
|
|
432
434
|
end
|
|
@@ -473,24 +475,11 @@ module Alexandria
|
|
|
473
475
|
end
|
|
474
476
|
|
|
475
477
|
def notify_start_add_by_isbn
|
|
476
|
-
|
|
477
|
-
main_progress_bar.visible = true
|
|
478
|
-
@progress_pulsing = GLib::Timeout.add(100) do
|
|
479
|
-
if @destroyed
|
|
480
|
-
false
|
|
481
|
-
else
|
|
482
|
-
main_progress_bar.pulse
|
|
483
|
-
true
|
|
484
|
-
end
|
|
485
|
-
end
|
|
478
|
+
ui_manager.start_progress_bar_pulsing(self)
|
|
486
479
|
end
|
|
487
480
|
|
|
488
481
|
def notify_end_add_by_isbn
|
|
489
|
-
|
|
490
|
-
return unless @progress_pulsing
|
|
491
|
-
|
|
492
|
-
GLib::Source.remove(@progress_pulsing)
|
|
493
|
-
@progress_pulsing = nil
|
|
482
|
+
ui_manager.stop_progress_bar_pulsing
|
|
494
483
|
end
|
|
495
484
|
|
|
496
485
|
def update(status, provider)
|
|
@@ -502,7 +491,7 @@ module Alexandria
|
|
|
502
491
|
}
|
|
503
492
|
message = messages[status] % provider
|
|
504
493
|
log.debug { "update message : #{message}" }
|
|
505
|
-
|
|
494
|
+
ui_manager.set_status_label(message)
|
|
506
495
|
end
|
|
507
496
|
|
|
508
497
|
def on_focus
|
|
@@ -556,6 +545,12 @@ module Alexandria
|
|
|
556
545
|
Alexandria::UI.display_help(@preferences_dialog, "add-book-by-isbn")
|
|
557
546
|
end
|
|
558
547
|
|
|
548
|
+
def destroyed?
|
|
549
|
+
@new_book_dialog.destroyed?
|
|
550
|
+
end
|
|
551
|
+
|
|
552
|
+
attr_reader :ui_manager
|
|
553
|
+
|
|
559
554
|
private
|
|
560
555
|
|
|
561
556
|
def assert_not_exist(library, isbn)
|
|
@@ -12,15 +12,16 @@ module Alexandria
|
|
|
12
12
|
class NewBookDialogManual < BookPropertiesDialogBase
|
|
13
13
|
include GetText
|
|
14
14
|
extend GetText
|
|
15
|
+
|
|
15
16
|
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
|
16
17
|
|
|
17
|
-
TMP_COVER_FILE = File.join(Dir.tmpdir, "tmp_cover")
|
|
18
18
|
def initialize(parent, library, &on_add_cb)
|
|
19
|
-
|
|
19
|
+
tmp_cover_file = File.join(Dir.mktmpdir("cover"), "tmp_cover")
|
|
20
|
+
super(parent, tmp_cover_file)
|
|
20
21
|
|
|
21
22
|
@library = library
|
|
22
23
|
@on_add_cb = on_add_cb
|
|
23
|
-
FileUtils.rm_f(
|
|
24
|
+
FileUtils.rm_f(@cover_file)
|
|
24
25
|
|
|
25
26
|
cancel_button = Gtk::Button.new(stock_id: Gtk::Stock::CANCEL)
|
|
26
27
|
cancel_button.signal_connect("clicked") { on_cancel }
|
|
@@ -89,8 +90,7 @@ module Alexandria
|
|
|
89
90
|
raise AddError, _("A binding must be provided.")
|
|
90
91
|
end
|
|
91
92
|
|
|
92
|
-
authors = []
|
|
93
|
-
@treeview_authors.model.each { |_m, _p, i| authors << i[0] }
|
|
93
|
+
authors = @treeview_authors.model.map { |_m, _p, i| i[0] }
|
|
94
94
|
if authors.empty?
|
|
95
95
|
raise AddError, _("At least one author must be " \
|
|
96
96
|
"provided.")
|
|
@@ -110,8 +110,8 @@ module Alexandria
|
|
|
110
110
|
book.tags = @entry_tags.text.split
|
|
111
111
|
@library << book
|
|
112
112
|
@library.save(book)
|
|
113
|
-
if File.exist?(
|
|
114
|
-
FileUtils.cp(
|
|
113
|
+
if File.exist?(@cover_file) && !@delete_cover_file
|
|
114
|
+
FileUtils.cp(@cover_file, @library.cover(book))
|
|
115
115
|
end
|
|
116
116
|
@on_add_cb.call(book)
|
|
117
117
|
@book_properties_dialog.destroy
|
|
@@ -8,10 +8,11 @@ module Alexandria
|
|
|
8
8
|
module UI
|
|
9
9
|
class NewSmartLibraryDialog < SmartLibraryPropertiesDialogBase
|
|
10
10
|
include GetText
|
|
11
|
+
|
|
11
12
|
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
|
12
13
|
|
|
13
14
|
def initialize(parent)
|
|
14
|
-
super
|
|
15
|
+
super
|
|
15
16
|
|
|
16
17
|
dialog.add_buttons([Gtk::Stock::CANCEL, :cancel],
|
|
17
18
|
[Gtk::Stock::NEW, :ok])
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# See the file README.md for authorship and licensing information.
|
|
6
6
|
|
|
7
7
|
require "alexandria/scanners/cue_cat"
|
|
8
|
-
require "alexandria/scanners/
|
|
8
|
+
require "alexandria/scanners/keyboard_wedge"
|
|
9
9
|
require "alexandria/ui/builder_base"
|
|
10
10
|
require "alexandria/ui/provider_preferences_dialog"
|
|
11
11
|
require "alexandria/ui/new_provider_dialog"
|
|
@@ -15,6 +15,7 @@ module Alexandria
|
|
|
15
15
|
class PreferencesDialog < BuilderBase
|
|
16
16
|
include Logging
|
|
17
17
|
include GetText
|
|
18
|
+
|
|
18
19
|
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
|
19
20
|
|
|
20
21
|
def initialize(parent, &changed_block)
|
|
@@ -301,9 +302,8 @@ module Alexandria
|
|
|
301
302
|
end
|
|
302
303
|
|
|
303
304
|
def update_priority
|
|
304
|
-
priority =
|
|
305
|
-
|
|
306
|
-
priority << iter[1]
|
|
305
|
+
priority = @treeview_providers.model.map do |_model, _path, iter|
|
|
306
|
+
iter[1]
|
|
307
307
|
end
|
|
308
308
|
Preferences.instance.providers_priority = priority
|
|
309
309
|
BookProviders.instance.update_priority
|