alexandria-book-collection-manager 0.7.5 → 0.7.6
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/.gitignore +4 -1
- data/.rubocop.yml +51 -29
- data/.rubocop_todo.yml +33 -155
- data/.simplecov +5 -2
- data/.travis.yml +10 -4
- data/CHANGELOG.md +19 -0
- data/INSTALL.md +23 -11
- data/README.md +36 -35
- data/Rakefile +7 -5
- data/alexandria-book-collection-manager.gemspec +8 -3
- data/doc/dependency_decisions.yml +22 -3
- data/lib/alexandria.rb +2 -2
- data/lib/alexandria/book_providers.rb +47 -49
- data/lib/alexandria/book_providers/adlibris.rb +8 -13
- data/lib/alexandria/book_providers/amazon_aws.rb +47 -60
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +283 -298
- data/lib/alexandria/book_providers/barnes_and_noble.rb +8 -8
- data/lib/alexandria/book_providers/douban.rb +2 -2
- data/lib/alexandria/book_providers/proxis.rb +12 -11
- data/lib/alexandria/book_providers/pseudomarc.rb +60 -70
- data/lib/alexandria/book_providers/siciliano.rb +5 -6
- data/lib/alexandria/book_providers/thalia.rb +8 -9
- data/lib/alexandria/book_providers/worldcat.rb +25 -31
- data/lib/alexandria/book_providers/z3950.rb +62 -69
- data/lib/alexandria/default_preferences.rb +37 -0
- data/lib/alexandria/execution_queue.rb +13 -12
- data/lib/alexandria/export_library.rb +4 -8
- data/lib/alexandria/import_library.rb +38 -62
- data/lib/alexandria/import_library_csv.rb +16 -16
- data/lib/alexandria/library_sort_order.rb +3 -1
- data/lib/alexandria/library_store.rb +16 -16
- data/lib/alexandria/logging.rb +4 -8
- data/lib/alexandria/models/book.rb +2 -2
- data/lib/alexandria/models/library.rb +18 -14
- data/lib/alexandria/net.rb +1 -2
- data/lib/alexandria/preferences.rb +27 -31
- data/lib/alexandria/scanners.rb +2 -2
- data/lib/alexandria/scanners/cue_cat.rb +5 -5
- data/lib/alexandria/scanners/keyboard.rb +1 -1
- data/lib/alexandria/smart_library.rb +22 -26
- data/lib/alexandria/ui.rb +7 -7
- data/lib/alexandria/ui/about_dialog.rb +1 -1
- data/lib/alexandria/ui/acquire_dialog.rb +9 -10
- data/lib/alexandria/ui/alert_dialog.rb +34 -19
- data/lib/alexandria/ui/bad_isbns_dialog.rb +13 -9
- data/lib/alexandria/ui/barcode_animation.rb +5 -5
- data/lib/alexandria/ui/book_properties_dialog.rb +2 -2
- data/lib/alexandria/ui/book_properties_dialog_base.rb +23 -17
- data/lib/alexandria/ui/callbacks.rb +141 -120
- data/lib/alexandria/ui/completion_models.rb +1 -1
- data/lib/alexandria/ui/confirm_erase_dialog.rb +1 -1
- data/lib/alexandria/ui/conflict_while_copying_dialog.rb +1 -1
- data/lib/alexandria/ui/error_dialog.rb +1 -1
- data/lib/alexandria/ui/export_dialog.rb +13 -15
- data/lib/alexandria/ui/icons.rb +34 -40
- data/lib/alexandria/ui/iconview_tooltips.rb +40 -53
- data/lib/alexandria/ui/import_dialog.rb +48 -47
- data/lib/alexandria/ui/init.rb +3 -2
- data/lib/alexandria/ui/keep_bad_isbn_dialog.rb +2 -2
- data/lib/alexandria/ui/libraries_combo.rb +10 -9
- data/lib/alexandria/ui/listview.rb +5 -6
- data/lib/alexandria/ui/main_app.rb +2 -2
- data/lib/alexandria/ui/multi_drag_treeview.rb +4 -6
- data/lib/alexandria/ui/new_book_dialog.rb +52 -52
- data/lib/alexandria/ui/new_provider_dialog.rb +12 -11
- data/lib/alexandria/ui/new_smart_library_dialog.rb +39 -27
- data/lib/alexandria/ui/preferences_dialog.rb +23 -82
- data/lib/alexandria/ui/provider_preferences_base_dialog.rb +9 -5
- data/lib/alexandria/ui/provider_preferences_dialog.rb +5 -5
- data/lib/alexandria/ui/really_delete_dialog.rb +1 -1
- data/lib/alexandria/ui/sidepane_manager.rb +35 -37
- data/lib/alexandria/ui/skip_entry_dialog.rb +3 -2
- data/lib/alexandria/ui/smart_library_properties_dialog.rb +35 -36
- data/lib/alexandria/ui/smart_library_properties_dialog_base.rb +59 -138
- data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
- data/lib/alexandria/ui/sound.rb +4 -6
- data/lib/alexandria/ui/ui_manager.rb +62 -64
- data/lib/alexandria/version.rb +2 -2
- data/lib/alexandria/web_themes.rb +15 -15
- data/po/cs.po +991 -874
- data/po/cy.po +957 -870
- data/po/de.po +991 -866
- data/po/el.po +987 -863
- data/po/es.po +986 -862
- data/po/fr.po +988 -868
- data/po/ga.po +910 -822
- data/po/gl.po +983 -863
- data/po/it.po +984 -862
- data/po/ja.po +969 -849
- data/po/mk.po +983 -859
- data/po/nb.po +982 -862
- data/po/nl.po +992 -869
- data/po/pl.po +1018 -963
- data/po/pt.po +983 -852
- data/po/pt_BR.po +983 -863
- data/po/ru.po +992 -869
- data/po/sk.po +986 -864
- data/po/sv.po +980 -860
- data/po/uk.po +975 -861
- data/po/zh_TW.po +974 -854
- data/share/alexandria/glade/main_app__builder.glade +6 -21
- 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/smart-libraries.xml +1 -1
- data/spec/alexandria/book_providers/world_cat_provider_spec.rb +160 -0
- data/spec/alexandria/book_providers_spec.rb +73 -129
- data/spec/alexandria/console_spec.rb +0 -5
- data/spec/alexandria/export_library_spec.rb +27 -38
- data/spec/alexandria/library_spec.rb +56 -44
- data/spec/alexandria/preferences_spec.rb +29 -3
- data/spec/alexandria/scanners/cue_cat_spec.rb +1 -1
- data/spec/alexandria/ui/about_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/acquire_dialog_spec.rb +1 -1
- 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 +1 -1
- data/spec/alexandria/ui/icons_spec.rb +26 -0
- data/spec/alexandria/ui/iconview_spec.rb +1 -1
- data/spec/alexandria/ui/import_dialog_spec.rb +30 -3
- data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/main_app_spec.rb +1 -1
- data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +1 -1
- data/spec/alexandria/ui/new_provider_dialog_spec.rb +19 -3
- data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +28 -3
- data/spec/alexandria/ui/preferences_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +23 -8
- data/spec/alexandria/ui/really_delete_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/sidepane_manager_spec.rb +2 -2
- data/spec/alexandria/ui/skip_entry_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +21 -7
- data/spec/alexandria/ui/ui_manager_spec.rb +39 -2
- data/spec/spec_helper.rb +46 -3
- data/tasks/spec.rake +3 -5
- data/util/rake/fileinstall.rb +12 -11
- metadata +82 -10
- data/spec/alexandria/ui/ui_utilities_spec.rb +0 -62
- data/spec/alexandria/utilities_spec.rb +0 -52
data/lib/alexandria/scanners.rb
CHANGED
@@ -23,7 +23,7 @@ require "alexandria/scanners"
|
|
23
23
|
module Alexandria
|
24
24
|
module Scanners
|
25
25
|
class CueCat
|
26
|
-
include
|
26
|
+
include Logging
|
27
27
|
|
28
28
|
def name
|
29
29
|
"CueCat"
|
@@ -72,7 +72,8 @@ module Alexandria
|
|
72
72
|
|
73
73
|
return code if type == "IBN"
|
74
74
|
|
75
|
-
raise "Don't know how to handle type
|
75
|
+
raise format(_("Don't know how to handle type %<type>s (barcode: %<code>s)"),
|
76
|
+
type: type, code: code)
|
76
77
|
end
|
77
78
|
|
78
79
|
private
|
@@ -85,8 +86,7 @@ module Alexandria
|
|
85
86
|
|
86
87
|
padding = pad(values)
|
87
88
|
result = calc(values)
|
88
|
-
result
|
89
|
-
result
|
89
|
+
result[0, result.length - padding]
|
90
90
|
end
|
91
91
|
|
92
92
|
def calc(values)
|
@@ -106,7 +106,7 @@ module Alexandria
|
|
106
106
|
length = array.length % 4
|
107
107
|
|
108
108
|
if length.nonzero?
|
109
|
-
raise "Error parsing CueCat input" if length == 1
|
109
|
+
raise _("Error parsing CueCat input") if length == 1
|
110
110
|
|
111
111
|
length = 4 - length
|
112
112
|
length.times { array.push(0) }
|
@@ -16,7 +16,7 @@ module Alexandria
|
|
16
16
|
|
17
17
|
ALL_RULES = 1
|
18
18
|
ANY_RULE = 2
|
19
|
-
attr_reader :name
|
19
|
+
attr_reader :name, :n_rated
|
20
20
|
attr_accessor :rules, :predicate_operator_rule, :deleted_books
|
21
21
|
|
22
22
|
EXT = ".yaml"
|
@@ -94,22 +94,23 @@ module Alexandria
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def name=(new_name)
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
97
|
+
return unless @name != new_name
|
98
|
+
|
99
|
+
old_yaml = yaml
|
100
|
+
@name = new_name
|
101
|
+
FileUtils.mv(old_yaml, yaml)
|
102
|
+
save
|
103
103
|
end
|
104
104
|
|
105
105
|
def update(*params)
|
106
|
-
|
106
|
+
case params.first
|
107
|
+
when LibraryCollection
|
107
108
|
libraries, _, library = params
|
108
109
|
unless library.is_a?(self.class)
|
109
110
|
self.libraries = libraries.all_libraries
|
110
111
|
refilter
|
111
112
|
end
|
112
|
-
|
113
|
+
when Library
|
113
114
|
refilter
|
114
115
|
end
|
115
116
|
end
|
@@ -172,14 +173,12 @@ module Alexandria
|
|
172
173
|
end
|
173
174
|
end
|
174
175
|
|
175
|
-
attr_reader :n_rated
|
176
|
-
|
177
176
|
def n_unrated
|
178
177
|
length - n_rated
|
179
178
|
end
|
180
179
|
|
181
|
-
def ==(
|
182
|
-
|
180
|
+
def ==(other)
|
181
|
+
other.is_a?(self.class) && other.name == name
|
183
182
|
end
|
184
183
|
|
185
184
|
@@deleted_libraries = []
|
@@ -190,15 +189,16 @@ module Alexandria
|
|
190
189
|
|
191
190
|
def self.really_delete_deleted_libraries
|
192
191
|
@@deleted_libraries.each do |library|
|
193
|
-
|
192
|
+
log.debug { "Deleting smart library file (#{yaml})" }
|
194
193
|
FileUtils.rm_rf(library.yaml)
|
195
194
|
end
|
196
195
|
end
|
197
196
|
|
198
197
|
def delete
|
199
198
|
if @@deleted_libraries.include?(self)
|
200
|
-
|
201
|
-
|
199
|
+
log.info do
|
200
|
+
"Already deleted a SmartLibrary with this name (this might mess up undeletes)"
|
201
|
+
end
|
202
202
|
FileUtils.rm_rf(yaml)
|
203
203
|
# so we just delete the old smart library, and
|
204
204
|
# 'pending' delete the new one of the same name...
|
@@ -265,8 +265,8 @@ module Alexandria
|
|
265
265
|
|
266
266
|
Operand = Struct.new(:name, :klass)
|
267
267
|
class Operand
|
268
|
-
def <=>(
|
269
|
-
name <=>
|
268
|
+
def <=>(other)
|
269
|
+
name <=> other.name
|
270
270
|
end
|
271
271
|
end
|
272
272
|
|
@@ -281,8 +281,8 @@ module Alexandria
|
|
281
281
|
|
282
282
|
Operator = Struct.new(:sym, :name, :proc)
|
283
283
|
class Operator
|
284
|
-
def <=>(
|
285
|
-
name <=>
|
284
|
+
def <=>(other)
|
285
|
+
name <=> other.name
|
286
286
|
end
|
287
287
|
end
|
288
288
|
|
@@ -462,17 +462,13 @@ module Alexandria
|
|
462
462
|
end
|
463
463
|
end
|
464
464
|
else
|
465
|
-
raise "invalid operand klass
|
465
|
+
raise format(_("invalid operand klass %<klass>s"), klass: operand.klass)
|
466
466
|
end
|
467
467
|
end
|
468
468
|
|
469
469
|
def filter_proc
|
470
470
|
proc do |book|
|
471
|
-
|
472
|
-
left_value = book.send(@operand.book_selector)
|
473
|
-
rescue StandardError => ex
|
474
|
-
puts ex.message
|
475
|
-
end
|
471
|
+
left_value = book.send(@operand.book_selector)
|
476
472
|
right_value = @value
|
477
473
|
if right_value.is_a?(String)
|
478
474
|
left_value = left_value.to_s.downcase
|
data/lib/alexandria/ui.rb
CHANGED
@@ -31,21 +31,21 @@ 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
|
-
|
40
|
-
log.info { "Starting MainApp
|
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 { "Starting Gtk
|
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
|
@@ -64,6 +64,10 @@ module Alexandria
|
|
64
64
|
@search_threads_running = @search_thread_counter.new_cond
|
65
65
|
end
|
66
66
|
|
67
|
+
def show
|
68
|
+
@acquire_dialog.show
|
69
|
+
end
|
70
|
+
|
67
71
|
def widget_names
|
68
72
|
[:acquire_dialog, :add_button, :barcodes_treeview, :barcode_label,
|
69
73
|
:scan_area, :scan_frame, :combo_libraries]
|
@@ -71,14 +75,9 @@ module Alexandria
|
|
71
75
|
|
72
76
|
def book_in_library(isbn10, library)
|
73
77
|
isbn13 = Library.canonicalise_ean(isbn10)
|
74
|
-
# puts "new book #{isbn10} (or #{isbn13})"
|
75
78
|
match = library.find do |book|
|
76
|
-
# puts "testing #{book.isbn}"
|
77
79
|
(book.isbn == isbn10 || book.isbn == isbn13)
|
78
|
-
# puts "book #{book.isbn}"
|
79
|
-
# book == new_book
|
80
80
|
end
|
81
|
-
# puts "book_in_library match #{match.inspect}"
|
82
81
|
!match.nil?
|
83
82
|
rescue StandardError
|
84
83
|
log.warn { "Failed to check for book #{isbn10} in library #{library}" }
|
@@ -472,7 +471,7 @@ module Alexandria
|
|
472
471
|
if @scanner.match? @scanner_buffer
|
473
472
|
|
474
473
|
Thread.new(@interval, @scanner_buffer) do |interval, buffer|
|
475
|
-
log.debug { "Waiting for more scanner input
|
474
|
+
log.debug { "Waiting for more scanner input" }
|
476
475
|
GLib::Idle.add do
|
477
476
|
@animation.manual_input
|
478
477
|
false
|
@@ -492,7 +491,7 @@ module Alexandria
|
|
492
491
|
|
493
492
|
else
|
494
493
|
log.debug do
|
495
|
-
"Buffer has changed while waiting
|
494
|
+
"Buffer has changed while waiting; reading more characters"
|
496
495
|
end
|
497
496
|
end
|
498
497
|
end
|
@@ -511,12 +510,12 @@ module Alexandria
|
|
511
510
|
|
512
511
|
def play_sound(effect)
|
513
512
|
if effect == "scanning"
|
514
|
-
|
513
|
+
log.debug { "Effect: #{effect}, playing: #{@prefs.play_scanning_sound}" }
|
515
514
|
return unless @prefs.play_scanning_sound
|
516
515
|
|
517
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,7 +524,7 @@ module Alexandria
|
|
525
524
|
end
|
526
525
|
|
527
526
|
def developer_test_scan
|
528
|
-
log.info { "Developer test scan
|
527
|
+
log.info { "Developer test scan" }
|
529
528
|
scans = [".C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7C3j3C3f1Dxj3Dq.",
|
530
529
|
".C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7C3z0CNj3Dhj1EW.",
|
531
530
|
".C3nZC3nZC3n2ChnWENz7DxnY.cGen.ENr7C3r2DNbXCxTZCW.",
|
@@ -6,20 +6,17 @@
|
|
6
6
|
|
7
7
|
module Alexandria
|
8
8
|
module UI
|
9
|
-
class AlertDialog
|
9
|
+
class AlertDialog
|
10
10
|
def initialize(parent, title, stock_icon, buttons, message = nil)
|
11
|
-
dialog = Gtk::Dialog.new(title: "", parent: parent, flags: :destroy_with_parent,
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
self.resizable = false
|
17
|
-
child.spacing = 12
|
11
|
+
@dialog = Gtk::Dialog.new(title: "", parent: parent, flags: :destroy_with_parent,
|
12
|
+
buttons: buttons)
|
13
|
+
@dialog.border_width = 6
|
14
|
+
@dialog.resizable = false
|
15
|
+
@dialog.child.spacing = 12
|
18
16
|
|
19
17
|
hbox = Gtk::Box.new(:horizontal, 12)
|
20
18
|
hbox.homogeneous = false
|
21
19
|
hbox.border_width = 6
|
22
|
-
child.pack_start(hbox)
|
23
20
|
|
24
21
|
image = Gtk::Image.new(stock: stock_icon,
|
25
22
|
size: Gtk::IconSize::DIALOG)
|
@@ -28,21 +25,39 @@ module Alexandria
|
|
28
25
|
|
29
26
|
vbox = Gtk::Box.new(:vertical, 6)
|
30
27
|
vbox.homogeneous = false
|
28
|
+
vbox.pack_start make_label("<b><big>#{title}</big></b>")
|
29
|
+
vbox.pack_start make_label(message.strip) unless message
|
31
30
|
hbox.pack_start(vbox)
|
32
31
|
|
32
|
+
@dialog.child.pack_start(hbox)
|
33
|
+
end
|
34
|
+
|
35
|
+
def show_all
|
36
|
+
dialog.show_all
|
37
|
+
end
|
38
|
+
|
39
|
+
def run
|
40
|
+
dialog.run
|
41
|
+
end
|
42
|
+
|
43
|
+
def destroy
|
44
|
+
dialog.destroy
|
45
|
+
end
|
46
|
+
|
47
|
+
def default_response=(response)
|
48
|
+
dialog.default_response = response
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
attr_reader :dialog
|
54
|
+
|
55
|
+
def make_label(markup)
|
33
56
|
label = Gtk::Label.new
|
34
57
|
label.set_alignment(0, 0)
|
35
58
|
label.wrap = label.selectable = true
|
36
|
-
label.markup =
|
37
|
-
|
38
|
-
|
39
|
-
if message
|
40
|
-
label = Gtk::Label.new
|
41
|
-
label.set_alignment(0, 0)
|
42
|
-
label.wrap = label.selectable = true
|
43
|
-
label.markup = message.strip
|
44
|
-
vbox.pack_start(label)
|
45
|
-
end
|
59
|
+
label.markup = markup
|
60
|
+
label
|
46
61
|
end
|
47
62
|
end
|
48
63
|
end
|
@@ -8,17 +8,16 @@ module Alexandria
|
|
8
8
|
module UI
|
9
9
|
# Generalized Dialog for lists of bad isbns. Used for on_import. Can also
|
10
10
|
# be used for on_load library conversions.
|
11
|
-
class BadIsbnsDialog
|
11
|
+
class BadIsbnsDialog
|
12
12
|
def initialize(parent, message, list)
|
13
|
-
dialog = Gtk::MessageDialog.new(parent: parent,
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
@dialog = Gtk::MessageDialog.new(parent: parent,
|
14
|
+
flags: :modal,
|
15
|
+
type: :warning,
|
16
|
+
buttons: :close,
|
17
|
+
message: message)
|
18
|
+
the_vbox = @dialog.children.first
|
19
19
|
|
20
20
|
isbn_container = Gtk::Box.new :horizontal
|
21
|
-
the_vbox = children.first
|
22
21
|
the_vbox.pack_start(isbn_container)
|
23
22
|
the_vbox.reorder_child(isbn_container, 3)
|
24
23
|
scrolley = Gtk::ScrolledWindow.new
|
@@ -30,7 +29,12 @@ module Alexandria
|
|
30
29
|
list.each do |li|
|
31
30
|
textview.buffer.insert_at_cursor("#{li}\n")
|
32
31
|
end
|
33
|
-
|
32
|
+
|
33
|
+
@dialog.signal_connect("response") { @dialog.destroy }
|
34
|
+
end
|
35
|
+
|
36
|
+
def show
|
37
|
+
@dialog.show_all
|
34
38
|
end
|
35
39
|
end
|
36
40
|
end
|
@@ -96,11 +96,11 @@ module Alexandria
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def set_passive
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
99
|
+
@canvas or return
|
100
|
+
|
101
|
+
passive_bg = "#F4F4F4"
|
102
|
+
@canvas.set_property(:background_color, passive_bg)
|
103
|
+
@barcode_bars.each { |rect| rect.set_property(:fill_color, passive_bg) }
|
104
104
|
end
|
105
105
|
|
106
106
|
def manual_input
|
@@ -16,7 +16,7 @@ module Alexandria
|
|
16
16
|
|
17
17
|
def initialize(parent, library, book)
|
18
18
|
super(parent, library.cover(book))
|
19
|
-
|
19
|
+
log.debug { "Initializing Book Properties Dialog" }
|
20
20
|
|
21
21
|
cancel_button = Gtk::Button.new(stock_id: Gtk::Stock::CANCEL)
|
22
22
|
cancel_button.signal_connect("clicked") { on_cancel }
|
@@ -86,7 +86,7 @@ module Alexandria
|
|
86
86
|
if (@checkbutton_redd.active = book.redd?)
|
87
87
|
@redd_date.sensitive = true
|
88
88
|
if book.redd_when.nil?
|
89
|
-
|
89
|
+
log.debug { "no redd_when" }
|
90
90
|
else
|
91
91
|
@redd_date.text = format_date(book.redd_when)
|
92
92
|
end
|
@@ -59,6 +59,10 @@ module Alexandria
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
+
def show
|
63
|
+
@book_properties_dialog.show
|
64
|
+
end
|
65
|
+
|
62
66
|
def setup_calendar_widgets
|
63
67
|
@popup_displayed = false
|
64
68
|
@calendar_popup = Gtk::Window.new # Gtk::Window::POPUP)
|
@@ -107,17 +111,19 @@ module Alexandria
|
|
107
111
|
end
|
108
112
|
|
109
113
|
@redd_date.signal_connect("icon-press") do |entry, primary, _icon|
|
110
|
-
|
114
|
+
case primary.nick
|
115
|
+
when "primary"
|
111
116
|
display_calendar_popup(entry)
|
112
|
-
|
117
|
+
when "secondary"
|
113
118
|
clear_date_entry(entry)
|
114
119
|
end
|
115
120
|
end
|
116
121
|
|
117
122
|
@date_loaned_since.signal_connect("icon-press") do |entry, primary, _icon|
|
118
|
-
|
123
|
+
case primary.nick
|
124
|
+
when "primary"
|
119
125
|
display_calendar_popup(entry)
|
120
|
-
|
126
|
+
when "secondary"
|
121
127
|
clear_date_entry(entry)
|
122
128
|
@label_loaning_duration.label = ""
|
123
129
|
end
|
@@ -263,18 +269,17 @@ module Alexandria
|
|
263
269
|
[Gtk::Stock::OPEN, Gtk::ResponseType::ACCEPT])
|
264
270
|
dialog.current_folder = @@latest_filechooser_directory
|
265
271
|
response = dialog.run
|
266
|
-
|
272
|
+
case response
|
273
|
+
when Gtk::ResponseType::ACCEPT
|
267
274
|
begin
|
268
275
|
@delete_cover_file = false
|
269
276
|
cover = GdkPixbuf::Pixbuf.new(file: dialog.filename)
|
270
277
|
# At this stage the file format is recognized.
|
271
278
|
|
272
|
-
if File.exist?(@cover_file)
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
FileUtils.cp(@cover_file, @original_cover_file)
|
277
|
-
end
|
279
|
+
if File.exist?(@cover_file) && !@original_cover_file
|
280
|
+
# make a back up, but only of the original
|
281
|
+
@original_cover_file = "#{@cover_file}~"
|
282
|
+
FileUtils.cp(@cover_file, @original_cover_file)
|
278
283
|
end
|
279
284
|
if cover.height > COVER_ABSOLUTE_MAXHEIGHT
|
280
285
|
FileUtils.cp(dialog.filename, "#{@cover_file}.orig")
|
@@ -294,7 +299,7 @@ module Alexandria
|
|
294
299
|
rescue RuntimeError => ex
|
295
300
|
ErrorDialog.new(@book_properties_dialog, ex.message).display
|
296
301
|
end
|
297
|
-
|
302
|
+
when Gtk::ResponseType::REJECT
|
298
303
|
## FileUtils.rm_f(@cover_file) # fixing bug #16707
|
299
304
|
@delete_cover_file = true
|
300
305
|
|
@@ -347,10 +352,11 @@ module Alexandria
|
|
347
352
|
def redd_toggled
|
348
353
|
redd_yes = @checkbutton_redd.active?
|
349
354
|
@redd_date.sensitive = redd_yes
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
355
|
+
|
356
|
+
return unless redd_yes && @redd_date.text.strip.empty?
|
357
|
+
|
358
|
+
# don't do this when popping up the dialog for the first time
|
359
|
+
display_calendar_popup(@redd_date) if @setup_finished
|
354
360
|
end
|
355
361
|
|
356
362
|
private
|
@@ -363,7 +369,7 @@ module Alexandria
|
|
363
369
|
@image_rating4,
|
364
370
|
@image_rating5
|
365
371
|
]
|
366
|
-
raise "out of range" if rating < 0 || rating > images.length
|
372
|
+
raise _("out of range") if rating < 0 || rating > images.length
|
367
373
|
|
368
374
|
images[0..rating - 1].each { |x| x.pixbuf = Icons::STAR_SET }
|
369
375
|
images[rating..-1].each { |x| x.pixbuf = Icons::STAR_UNSET }
|