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.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.gitignore +4 -1
  4. data/.rubocop.yml +51 -29
  5. data/.rubocop_todo.yml +33 -155
  6. data/.simplecov +5 -2
  7. data/.travis.yml +10 -4
  8. data/CHANGELOG.md +19 -0
  9. data/INSTALL.md +23 -11
  10. data/README.md +36 -35
  11. data/Rakefile +7 -5
  12. data/alexandria-book-collection-manager.gemspec +8 -3
  13. data/doc/dependency_decisions.yml +22 -3
  14. data/lib/alexandria.rb +2 -2
  15. data/lib/alexandria/book_providers.rb +47 -49
  16. data/lib/alexandria/book_providers/adlibris.rb +8 -13
  17. data/lib/alexandria/book_providers/amazon_aws.rb +47 -60
  18. data/lib/alexandria/book_providers/amazon_ecs_util.rb +283 -298
  19. data/lib/alexandria/book_providers/barnes_and_noble.rb +8 -8
  20. data/lib/alexandria/book_providers/douban.rb +2 -2
  21. data/lib/alexandria/book_providers/proxis.rb +12 -11
  22. data/lib/alexandria/book_providers/pseudomarc.rb +60 -70
  23. data/lib/alexandria/book_providers/siciliano.rb +5 -6
  24. data/lib/alexandria/book_providers/thalia.rb +8 -9
  25. data/lib/alexandria/book_providers/worldcat.rb +25 -31
  26. data/lib/alexandria/book_providers/z3950.rb +62 -69
  27. data/lib/alexandria/default_preferences.rb +37 -0
  28. data/lib/alexandria/execution_queue.rb +13 -12
  29. data/lib/alexandria/export_library.rb +4 -8
  30. data/lib/alexandria/import_library.rb +38 -62
  31. data/lib/alexandria/import_library_csv.rb +16 -16
  32. data/lib/alexandria/library_sort_order.rb +3 -1
  33. data/lib/alexandria/library_store.rb +16 -16
  34. data/lib/alexandria/logging.rb +4 -8
  35. data/lib/alexandria/models/book.rb +2 -2
  36. data/lib/alexandria/models/library.rb +18 -14
  37. data/lib/alexandria/net.rb +1 -2
  38. data/lib/alexandria/preferences.rb +27 -31
  39. data/lib/alexandria/scanners.rb +2 -2
  40. data/lib/alexandria/scanners/cue_cat.rb +5 -5
  41. data/lib/alexandria/scanners/keyboard.rb +1 -1
  42. data/lib/alexandria/smart_library.rb +22 -26
  43. data/lib/alexandria/ui.rb +7 -7
  44. data/lib/alexandria/ui/about_dialog.rb +1 -1
  45. data/lib/alexandria/ui/acquire_dialog.rb +9 -10
  46. data/lib/alexandria/ui/alert_dialog.rb +34 -19
  47. data/lib/alexandria/ui/bad_isbns_dialog.rb +13 -9
  48. data/lib/alexandria/ui/barcode_animation.rb +5 -5
  49. data/lib/alexandria/ui/book_properties_dialog.rb +2 -2
  50. data/lib/alexandria/ui/book_properties_dialog_base.rb +23 -17
  51. data/lib/alexandria/ui/callbacks.rb +141 -120
  52. data/lib/alexandria/ui/completion_models.rb +1 -1
  53. data/lib/alexandria/ui/confirm_erase_dialog.rb +1 -1
  54. data/lib/alexandria/ui/conflict_while_copying_dialog.rb +1 -1
  55. data/lib/alexandria/ui/error_dialog.rb +1 -1
  56. data/lib/alexandria/ui/export_dialog.rb +13 -15
  57. data/lib/alexandria/ui/icons.rb +34 -40
  58. data/lib/alexandria/ui/iconview_tooltips.rb +40 -53
  59. data/lib/alexandria/ui/import_dialog.rb +48 -47
  60. data/lib/alexandria/ui/init.rb +3 -2
  61. data/lib/alexandria/ui/keep_bad_isbn_dialog.rb +2 -2
  62. data/lib/alexandria/ui/libraries_combo.rb +10 -9
  63. data/lib/alexandria/ui/listview.rb +5 -6
  64. data/lib/alexandria/ui/main_app.rb +2 -2
  65. data/lib/alexandria/ui/multi_drag_treeview.rb +4 -6
  66. data/lib/alexandria/ui/new_book_dialog.rb +52 -52
  67. data/lib/alexandria/ui/new_provider_dialog.rb +12 -11
  68. data/lib/alexandria/ui/new_smart_library_dialog.rb +39 -27
  69. data/lib/alexandria/ui/preferences_dialog.rb +23 -82
  70. data/lib/alexandria/ui/provider_preferences_base_dialog.rb +9 -5
  71. data/lib/alexandria/ui/provider_preferences_dialog.rb +5 -5
  72. data/lib/alexandria/ui/really_delete_dialog.rb +1 -1
  73. data/lib/alexandria/ui/sidepane_manager.rb +35 -37
  74. data/lib/alexandria/ui/skip_entry_dialog.rb +3 -2
  75. data/lib/alexandria/ui/smart_library_properties_dialog.rb +35 -36
  76. data/lib/alexandria/ui/smart_library_properties_dialog_base.rb +59 -138
  77. data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
  78. data/lib/alexandria/ui/sound.rb +4 -6
  79. data/lib/alexandria/ui/ui_manager.rb +62 -64
  80. data/lib/alexandria/version.rb +2 -2
  81. data/lib/alexandria/web_themes.rb +15 -15
  82. data/po/cs.po +991 -874
  83. data/po/cy.po +957 -870
  84. data/po/de.po +991 -866
  85. data/po/el.po +987 -863
  86. data/po/es.po +986 -862
  87. data/po/fr.po +988 -868
  88. data/po/ga.po +910 -822
  89. data/po/gl.po +983 -863
  90. data/po/it.po +984 -862
  91. data/po/ja.po +969 -849
  92. data/po/mk.po +983 -859
  93. data/po/nb.po +982 -862
  94. data/po/nl.po +992 -869
  95. data/po/pl.po +1018 -963
  96. data/po/pt.po +983 -852
  97. data/po/pt_BR.po +983 -863
  98. data/po/ru.po +992 -869
  99. data/po/sk.po +986 -864
  100. data/po/sv.po +980 -860
  101. data/po/uk.po +975 -861
  102. data/po/zh_TW.po +974 -854
  103. data/share/alexandria/glade/main_app__builder.glade +6 -21
  104. data/share/gnome/help/alexandria/C/smart-libraries.xml +2 -2
  105. data/share/gnome/help/alexandria/C/working-with-libraries.xml +1 -1
  106. data/share/gnome/help/alexandria/fr/alexandria.xml +1 -1
  107. data/share/gnome/help/alexandria/ja/smart-libraries.xml +1 -1
  108. data/spec/alexandria/book_providers/world_cat_provider_spec.rb +160 -0
  109. data/spec/alexandria/book_providers_spec.rb +73 -129
  110. data/spec/alexandria/console_spec.rb +0 -5
  111. data/spec/alexandria/export_library_spec.rb +27 -38
  112. data/spec/alexandria/library_spec.rb +56 -44
  113. data/spec/alexandria/preferences_spec.rb +29 -3
  114. data/spec/alexandria/scanners/cue_cat_spec.rb +1 -1
  115. data/spec/alexandria/ui/about_dialog_spec.rb +1 -1
  116. data/spec/alexandria/ui/acquire_dialog_spec.rb +1 -1
  117. data/spec/alexandria/ui/alert_dialog_spec.rb +1 -1
  118. data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +1 -1
  119. data/spec/alexandria/ui/book_properties_dialog_spec.rb +1 -1
  120. data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +1 -1
  121. data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +1 -1
  122. data/spec/alexandria/ui/error_dialog_spec.rb +1 -1
  123. data/spec/alexandria/ui/export_dialog_spec.rb +1 -1
  124. data/spec/alexandria/ui/icons_spec.rb +26 -0
  125. data/spec/alexandria/ui/iconview_spec.rb +1 -1
  126. data/spec/alexandria/ui/import_dialog_spec.rb +30 -3
  127. data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +1 -1
  128. data/spec/alexandria/ui/main_app_spec.rb +1 -1
  129. data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +1 -1
  130. data/spec/alexandria/ui/new_provider_dialog_spec.rb +19 -3
  131. data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +28 -3
  132. data/spec/alexandria/ui/preferences_dialog_spec.rb +1 -1
  133. data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +23 -8
  134. data/spec/alexandria/ui/really_delete_dialog_spec.rb +1 -1
  135. data/spec/alexandria/ui/sidepane_manager_spec.rb +2 -2
  136. data/spec/alexandria/ui/skip_entry_dialog_spec.rb +1 -1
  137. data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +21 -7
  138. data/spec/alexandria/ui/ui_manager_spec.rb +39 -2
  139. data/spec/spec_helper.rb +46 -3
  140. data/tasks/spec.rake +3 -5
  141. data/util/rake/fileinstall.rb +12 -11
  142. metadata +82 -10
  143. data/spec/alexandria/ui/ui_utilities_spec.rb +0 -62
  144. data/spec/alexandria/utilities_spec.rb +0 -52
@@ -40,8 +40,8 @@ module Alexandria
40
40
  registry.find { |scanner| scanner.name == name }
41
41
  end
42
42
 
43
- def self.each_scanner
44
- registry.each { |scanner| yield scanner }
43
+ def self.each_scanner(&block)
44
+ registry.each(&block)
45
45
  end
46
46
 
47
47
  private_class_method :registry
@@ -23,7 +23,7 @@ require "alexandria/scanners"
23
23
  module Alexandria
24
24
  module Scanners
25
25
  class CueCat
26
- include Alexandria::Logging
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 #{type} (barcode: #{code})"
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 = result[0, result.length - padding]
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) }
@@ -48,7 +48,7 @@ module Alexandria
48
48
  elsif data.length >= 13
49
49
  data[0, 13]
50
50
  else
51
- raise "Unknown scan data #{data}"
51
+ raise format(_("Unknown scan data %s<data>"), data: data)
52
52
  end
53
53
  end
54
54
  end
@@ -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
- if @name != new_name
98
- old_yaml = yaml
99
- @name = new_name
100
- FileUtils.mv(old_yaml, yaml)
101
- save
102
- end
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
- if params.first.is_a?(LibraryCollection)
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
- elsif params.first.is_a?(Library)
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 ==(object)
182
- object.is_a?(self.class) && object.name == name
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
- puts "Deleting smart library file (#{yaml})" if $DEBUG
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
- puts "Already deleted a SmartLibrary with this name"
201
- puts "(this might mess up undeletes...)"
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 <=>(x)
269
- name <=> x.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 <=>(x)
285
- name <=> x.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 #{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
- begin
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
@@ -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
- puts "==========================" if $DEBUG
40
- log.info { "Starting MainApp..." }
41
- puts "==========================" if $DEBUG
39
+ log.debug { "==========================" }
40
+ log.info { "Starting MainApp" }
41
+ log.debug { "==========================" }
42
42
  MainApp.instance
43
43
  end
44
44
 
45
45
  def self.start_gtk
46
- puts "====================================" if $DEBUG
47
- log.info { "Starting Gtk..." }
48
- puts "====================================" if $DEBUG
46
+ log.debug { "====================================" }
47
+ log.info { "Starting Gtk" }
48
+ log.debug { "====================================" }
49
49
  Gtk.main
50
50
  end
51
51
 
@@ -7,7 +7,7 @@
7
7
  module Alexandria
8
8
  module UI
9
9
  class AboutDialog
10
- GPL = <<~EOL
10
+ GPL = <<~EOL # rubocop:disable GetText/DecorateString
11
11
  Alexandria is free software; you can redistribute it and/or
12
12
  modify it under the terms of the GNU General Public License as
13
13
  published by the Free Software Foundation; either version 2 of the
@@ -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, reading more characters..."
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
- puts "Effect: #{effect}, playing: #{@prefs.play_scanning_sound}" if $DEBUG
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
- puts "Effect: #{effect}, playing: #{@prefs.play_scan_sound}" if $DEBUG
518
+ log.debug { "Effect: #{effect}, playing: #{@prefs.play_scan_sound}" }
520
519
  return unless @prefs.play_scan_sound
521
520
 
522
521
  # sleep(0.5) # "scanning" effect lasts 0.5 seconds, wait for it to end
@@ -525,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 < SimpleDelegator
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
- buttons: buttons)
13
- super(dialog)
14
-
15
- self.border_width = 6
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 = "<b><big>#{title}</big></b>"
37
- vbox.pack_start(label)
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 < SimpleDelegator
11
+ class BadIsbnsDialog
12
12
  def initialize(parent, message, list)
13
- dialog = Gtk::MessageDialog.new(parent: parent,
14
- flags: :modal,
15
- type: :warning,
16
- buttons: :close,
17
- message: message)
18
- super(dialog)
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
- show_all
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
- if @canvas
100
- passive_bg = "#F4F4F4"
101
- @canvas.set_property(:background_color, passive_bg)
102
- @barcode_bars.each { |rect| rect.set_property(:fill_color, passive_bg) }
103
- end
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
- puts "Initializing Book Properties Dialog..." if $DEBUG
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
- puts "no redd_when"
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
- if primary.nick == "primary"
114
+ case primary.nick
115
+ when "primary"
111
116
  display_calendar_popup(entry)
112
- elsif primary.nick == "secondary"
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
- if primary.nick == "primary"
123
+ case primary.nick
124
+ when "primary"
119
125
  display_calendar_popup(entry)
120
- elsif primary.nick == "secondary"
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
- if response == Gtk::ResponseType::ACCEPT
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
- unless @original_cover_file
274
- # make a back up, but only of the original
275
- @original_cover_file = "#{@cover_file}~"
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
- elsif response == Gtk::ResponseType::REJECT
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
- if @setup_finished
351
- # don't do this when popping up the dialog for the first time
352
- display_calendar_popup(@redd_date) if redd_yes && @redd_date.text.strip.empty?
353
- end
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 }