alexandria-book-collection-manager 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +28 -25
  3. data/.rubocop_todo.yml +87 -67
  4. data/CHANGELOG.md +12 -1
  5. data/Gemfile +4 -3
  6. data/README.md +16 -6
  7. data/Rakefile +71 -72
  8. data/alexandria-book-collection-manager.gemspec +44 -44
  9. data/bin/alexandria +12 -12
  10. data/lib/alexandria.rb +22 -22
  11. data/lib/alexandria/about.rb +50 -50
  12. data/lib/alexandria/book_providers.rb +50 -50
  13. data/lib/alexandria/book_providers/adlibris.rb +28 -44
  14. data/lib/alexandria/book_providers/amazon_aws.rb +64 -64
  15. data/lib/alexandria/book_providers/amazon_ecs_util.rb +52 -78
  16. data/lib/alexandria/book_providers/barnes_and_noble.rb +34 -34
  17. data/lib/alexandria/book_providers/douban.rb +21 -37
  18. data/lib/alexandria/book_providers/proxis.rb +24 -24
  19. data/lib/alexandria/book_providers/pseudomarc.rb +19 -19
  20. data/lib/alexandria/book_providers/renaud.rb +44 -57
  21. data/lib/alexandria/book_providers/siciliano.rb +39 -39
  22. data/lib/alexandria/book_providers/thalia.rb +33 -33
  23. data/lib/alexandria/book_providers/web.rb +5 -5
  24. data/lib/alexandria/book_providers/worldcat.rb +44 -69
  25. data/lib/alexandria/book_providers/z3950.rb +94 -109
  26. data/lib/alexandria/config.rb +1 -1
  27. data/lib/alexandria/console.rb +3 -3
  28. data/lib/alexandria/export_format.rb +8 -8
  29. data/lib/alexandria/export_library.rb +112 -113
  30. data/lib/alexandria/import_library.rb +45 -45
  31. data/lib/alexandria/import_library_csv.rb +30 -30
  32. data/lib/alexandria/library_collection.rb +4 -4
  33. data/lib/alexandria/library_sort_order.rb +1 -1
  34. data/lib/alexandria/library_store.rb +14 -14
  35. data/lib/alexandria/logging.rb +5 -5
  36. data/lib/alexandria/models/book.rb +1 -1
  37. data/lib/alexandria/models/library.rb +36 -36
  38. data/lib/alexandria/net.rb +5 -5
  39. data/lib/alexandria/preferences.rb +32 -32
  40. data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +13 -13
  41. data/lib/alexandria/scanners/keyboard.rb +5 -5
  42. data/lib/alexandria/smart_library.rb +53 -53
  43. data/lib/alexandria/ui.rb +15 -15
  44. data/lib/alexandria/ui/{dialogs/about_dialog.rb → about_dialog.rb} +1 -1
  45. data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +66 -65
  46. data/lib/alexandria/ui/{dialogs/alert_dialog.rb → alert_dialog.rb} +1 -16
  47. data/lib/alexandria/ui/{dialogs/bad_isbns_dialog.rb → bad_isbns_dialog.rb} +0 -0
  48. data/lib/alexandria/ui/{dialogs/barcode_animation.rb → barcode_animation.rb} +7 -7
  49. data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +25 -37
  50. data/lib/alexandria/ui/{dialogs/book_properties_dialog_base.rb → book_properties_dialog_base.rb} +38 -37
  51. data/lib/alexandria/ui/builder_base.rb +1 -1
  52. data/lib/alexandria/ui/callbacks.rb +95 -91
  53. data/lib/alexandria/ui/completion_models.rb +7 -21
  54. data/lib/alexandria/ui/confirm_erase_dialog.rb +33 -0
  55. data/lib/alexandria/ui/conflict_while_copying_dialog.rb +34 -0
  56. data/lib/alexandria/ui/dndable.rb +7 -7
  57. data/lib/alexandria/ui/error_dialog.rb +25 -0
  58. data/lib/alexandria/ui/{dialogs/export_dialog.rb → export_dialog.rb} +22 -42
  59. data/lib/alexandria/ui/icons.rb +6 -6
  60. data/lib/alexandria/ui/iconview.rb +7 -7
  61. data/lib/alexandria/ui/iconview_tooltips.rb +6 -6
  62. data/lib/alexandria/ui/{dialogs/import_dialog.rb → import_dialog.rb} +14 -32
  63. data/lib/alexandria/ui/init.rb +16 -29
  64. data/lib/alexandria/ui/{dialogs/keep_bad_isbn_dialog.rb → keep_bad_isbn_dialog.rb} +6 -4
  65. data/lib/alexandria/ui/libraries_combo.rb +7 -7
  66. data/lib/alexandria/ui/listview.rb +40 -40
  67. data/lib/alexandria/ui/main_app.rb +22 -24
  68. data/lib/alexandria/ui/misc_dialogs.rb +10 -0
  69. data/lib/alexandria/ui/multi_drag_treeview.rb +4 -4
  70. data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +46 -45
  71. data/lib/alexandria/ui/{dialogs/new_book_dialog_manual.rb → new_book_dialog_manual.rb} +20 -19
  72. data/lib/alexandria/ui/new_provider_dialog.rb +99 -0
  73. data/lib/alexandria/ui/{dialogs/new_smart_library_dialog.rb → new_smart_library_dialog.rb} +4 -4
  74. data/lib/alexandria/ui/{dialogs/preferences_dialog.rb → preferences_dialog.rb} +44 -235
  75. data/lib/alexandria/ui/provider_preferences_base_dialog.rb +90 -0
  76. data/lib/alexandria/ui/provider_preferences_dialog.rb +35 -0
  77. data/lib/alexandria/ui/{dialogs/misc_dialogs.rb → really_delete_dialog.rb} +6 -27
  78. data/lib/alexandria/ui/{sidepane.rb → sidepane_manager.rb} +27 -25
  79. data/lib/alexandria/ui/skip_entry_dialog.rb +32 -0
  80. data/lib/alexandria/ui/{dialogs/smart_library_properties_dialog.rb → smart_library_properties_dialog.rb} +2 -2
  81. data/lib/alexandria/ui/{dialogs/smart_library_properties_dialog_base.rb → smart_library_properties_dialog_base.rb} +30 -30
  82. data/lib/alexandria/ui/sound.rb +8 -8
  83. data/lib/alexandria/ui/ui_manager.rb +136 -135
  84. data/lib/alexandria/version.rb +4 -19
  85. data/lib/alexandria/web_themes.rb +8 -8
  86. data/po/cs.po +97 -97
  87. data/po/cy.po +97 -97
  88. data/po/de.po +97 -97
  89. data/po/el.po +97 -97
  90. data/po/es.po +97 -97
  91. data/po/fr.po +97 -97
  92. data/po/ga.po +97 -97
  93. data/po/gl.po +97 -97
  94. data/po/it.po +97 -97
  95. data/po/ja.po +97 -97
  96. data/po/mk.po +97 -97
  97. data/po/nb.po +97 -97
  98. data/po/nl.po +97 -97
  99. data/po/pl.po +97 -97
  100. data/po/pt.po +97 -97
  101. data/po/pt_BR.po +97 -97
  102. data/po/ru.po +97 -97
  103. data/po/sk.po +97 -97
  104. data/po/sv.po +97 -97
  105. data/po/uk.po +97 -97
  106. data/po/zh_TW.po +97 -97
  107. data/schemas/alexandria.schemas +24 -2
  108. data/spec/alexandria/book_providers_spec.rb +65 -82
  109. data/spec/alexandria/book_spec.rb +12 -10
  110. data/spec/alexandria/console_spec.rb +9 -9
  111. data/spec/alexandria/export_library_spec.rb +31 -31
  112. data/spec/alexandria/library_spec.rb +86 -86
  113. data/spec/alexandria/library_store_spec.rb +8 -8
  114. data/spec/alexandria/preferences_spec.rb +18 -17
  115. data/spec/alexandria/scanners/cue_cat_spec.rb +52 -0
  116. data/spec/alexandria/smart_library_spec.rb +15 -15
  117. data/spec/alexandria/ui/about_dialog_spec.rb +14 -0
  118. data/spec/alexandria/ui/acquire_dialog_spec.rb +14 -0
  119. data/spec/alexandria/ui/alert_dialog_spec.rb +16 -0
  120. data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +14 -0
  121. data/spec/alexandria/ui/book_properties_dialog_spec.rb +17 -0
  122. data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +14 -0
  123. data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +16 -0
  124. data/spec/alexandria/ui/error_dialog_spec.rb +14 -0
  125. data/spec/alexandria/ui/export_dialog_spec.rb +15 -0
  126. data/spec/alexandria/ui/iconview_spec.rb +7 -21
  127. data/spec/alexandria/ui/import_dialog_spec.rb +14 -0
  128. data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +17 -0
  129. data/spec/alexandria/ui/main_app_spec.rb +6 -6
  130. data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +15 -0
  131. data/spec/alexandria/ui/{dialogs/new_book_dialog_spec.rb → new_book_dialog_spec.rb} +4 -4
  132. data/spec/alexandria/ui/new_provider_dialog_spec.rb +14 -0
  133. data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +14 -0
  134. data/spec/alexandria/ui/preferences_dialog_spec.rb +14 -0
  135. data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +19 -0
  136. data/spec/alexandria/ui/really_delete_dialog_spec.rb +15 -0
  137. data/spec/alexandria/ui/sidepane_manager_spec.rb +15 -0
  138. data/spec/alexandria/ui/skip_entry_dialog_spec.rb +14 -0
  139. data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +18 -0
  140. data/spec/alexandria/ui/sound_spec.rb +2 -2
  141. data/spec/alexandria/ui/ui_manager_spec.rb +6 -20
  142. data/spec/alexandria/ui/ui_utilities_spec.rb +9 -9
  143. data/spec/alexandria/utilities_spec.rb +6 -6
  144. data/spec/end_to_end/basic_run_spec.rb +24 -36
  145. data/spec/spec_helper.rb +9 -9
  146. data/tasks/dogtail.rake +1 -1
  147. data/tasks/setup.rb +2 -2
  148. data/tasks/spec.rake +11 -11
  149. data/util/rake/fileinstall.rb +25 -25
  150. data/util/rake/gettextgenerate.rb +7 -7
  151. data/util/rake/omfgenerate.rb +7 -7
  152. metadata +59 -33
  153. data/spec/alexandria/scanners/cuecat_spec.rb +0 -67
  154. data/spec/alexandria/ui/dialogs_spec.rb +0 -162
  155. data/spec/alexandria/ui/sidepane_spec.rb +0 -29
@@ -4,12 +4,11 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- # HIG compliant error dialog boxes
8
7
  module Alexandria
9
8
  module UI
10
9
  class AlertDialog < SimpleDelegator
11
10
  def initialize(parent, title, stock_icon, buttons, message = nil)
12
- dialog = Gtk::Dialog.new(title: '', parent: parent, flags: :destroy_with_parent, buttons: buttons)
11
+ dialog = Gtk::Dialog.new(title: "", parent: parent, flags: :destroy_with_parent, buttons: buttons)
13
12
  super(dialog)
14
13
 
15
14
  self.border_width = 6
@@ -45,19 +44,5 @@ module Alexandria
45
44
  end
46
45
  end
47
46
  end
48
-
49
- class ErrorDialog < AlertDialog
50
- def initialize(parent, title, message = nil)
51
- super(parent, title, Gtk::Stock::DIALOG_ERROR,
52
- [[Gtk::Stock::OK, :ok]], message)
53
- # FIXME: Should accept just :ok
54
- self.default_response = Gtk::ResponseType::OK
55
- end
56
-
57
- def display
58
- show_all && run
59
- destroy
60
- end
61
- end
62
47
  end
63
48
  end
@@ -23,7 +23,7 @@
23
23
  # Boston, MA 02110-1301 USA.
24
24
  #++
25
25
 
26
- require 'gobject-introspection'
26
+ require "gobject-introspection"
27
27
 
28
28
  module GooCanvas
29
29
  class << self
@@ -42,7 +42,7 @@ module GooCanvas
42
42
  remove_method(:const_missing)
43
43
  end
44
44
  loader = GObjectIntrospection::Loader.new(self)
45
- loader.load('GooCanvas')
45
+ loader.load("GooCanvas")
46
46
  end
47
47
  end
48
48
  end
@@ -91,13 +91,13 @@ module Alexandria
91
91
  end
92
92
 
93
93
  def set_active
94
- @canvas.set_property(:background_color, 'white')
95
- @barcode_bars.each { |rect| rect.set_property(:fill_color, 'white') }
94
+ @canvas.set_property(:background_color, "white")
95
+ @barcode_bars.each { |rect| rect.set_property(:fill_color, "white") }
96
96
  end
97
97
 
98
98
  def set_passive
99
99
  if @canvas
100
- passive_bg = '#F4F4F4'
100
+ passive_bg = "#F4F4F4"
101
101
  @canvas.set_property(:background_color, passive_bg)
102
102
  @barcode_bars.each { |rect| rect.set_property(:fill_color, passive_bg) }
103
103
  end
@@ -116,7 +116,7 @@ module Alexandria
116
116
  private
117
117
 
118
118
  def create_ean_barcode_data
119
- d = '211113123121112331122131113211111123122211132321112311231111'
119
+ d = "211113123121112331122131113211111123122211132321112311231111"
120
120
  # ####911113... but that's too much padding on the left...
121
121
  until d.empty?
122
122
  space_width = d[0].chr.to_i
@@ -133,7 +133,7 @@ module Alexandria
133
133
  x: @bar_left_edge + @scale * @hpos, y: @bar_top,
134
134
  width: @scale * bar_width, height: @bar_height,
135
135
  line_width: 0,
136
- fill_color: 'white')
136
+ fill_color: "white")
137
137
  @hpos += bar_width
138
138
  @barcode_bars << rect_item
139
139
  end
@@ -1,22 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2004-2006 Laurent Sansonetti
4
- # Copyright (C) 2016 Matijs van Zuijlen
3
+ # This file is part of Alexandria.
5
4
  #
6
- # Alexandria is free software; you can redistribute it and/or
7
- # modify it under the terms of the GNU General Public License as
8
- # published by the Free Software Foundation; either version 2 of the
9
- # License, or (at your option) any later version.
10
- #
11
- # Alexandria is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- # General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public
17
- # License along with Alexandria; see the file COPYING. If not,
18
- # write to the Free Software Foundation, Inc., 51 Franklin Street,
19
- # Fifth Floor, Boston, MA 02110-1301 USA.
5
+ # See the file README.md for authorship and licensing information.
6
+
7
+ require "alexandria/ui/error_dialog"
20
8
 
21
9
  module Alexandria
22
10
  module UI
@@ -24,51 +12,51 @@ module Alexandria
24
12
  include Logging
25
13
  include GetText
26
14
  extend GetText
27
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
15
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
28
16
 
29
17
  def initialize(parent, library, book)
30
18
  super(parent, library.cover(book))
31
- puts 'Initializing Book Properties Dialog...' if $DEBUG
19
+ puts "Initializing Book Properties Dialog..." if $DEBUG
32
20
 
33
21
  cancel_button = Gtk::Button.new(stock_id: Gtk::Stock::CANCEL)
34
- cancel_button.signal_connect('clicked') { on_cancel }
22
+ cancel_button.signal_connect("clicked") { on_cancel }
35
23
  cancel_button.show
36
24
  @button_box << cancel_button
37
25
 
38
26
  close_button = Gtk::Button.new(stock_id: Gtk::Stock::SAVE)
39
- close_button.signal_connect('clicked') { on_close }
27
+ close_button.signal_connect("clicked") { on_close }
40
28
  close_button.show
41
29
  @button_box << close_button
42
30
 
43
31
  help_button = Gtk::Button.new(stock_id: Gtk::Stock::HELP)
44
- help_button.signal_connect('clicked') { on_help }
32
+ help_button.signal_connect("clicked") { on_help }
45
33
  help_button.show
46
34
  @button_box << help_button
47
35
  @button_box.set_child_secondary(help_button, true)
48
36
 
49
37
  @entry_title.text = @book_properties_dialog.title = book.title
50
- @entry_isbn.text = (book.isbn || '')
38
+ @entry_isbn.text = (book.isbn || "")
51
39
  @entry_publisher.text = book.publisher
52
40
  @entry_publish_date.text = book.publishing_year.to_s
53
- @entry_publish_date.signal_connect('focus-out-event') do
41
+ @entry_publish_date.signal_connect("focus-out-event") do
54
42
  text = @entry_publish_date.text
55
43
  if text.empty?
56
44
  false
57
45
  else
58
46
  year = text.to_i
59
47
  if year.zero? || year > (Time.now.year + 10) || year < 10
60
- @entry_publish_date.text = ''
48
+ @entry_publish_date.text = ""
61
49
  @entry_publish_date.grab_focus
62
50
  true
63
51
  elsif year < 100
64
- @entry_publish_date.text = '19' + year.to_s
52
+ @entry_publish_date.text = "19" + year.to_s
65
53
  false
66
54
  end
67
55
  end
68
56
  end
69
57
  @entry_edition.text = book.edition
70
58
  if book.tags
71
- @entry_tags.text = book.tags.join(',') # tags are comma-separated
59
+ @entry_tags.text = book.tags.join(",") # tags are comma-separated
72
60
  end
73
61
 
74
62
  book.authors.each do |author|
@@ -78,7 +66,7 @@ module Alexandria
78
66
  end
79
67
 
80
68
  buffer = Gtk::TextBuffer.new
81
- buffer.text = (book.notes || '')
69
+ buffer.text = (book.notes || "")
82
70
  @textview_notes.buffer = buffer
83
71
 
84
72
  @library = library
@@ -87,7 +75,7 @@ module Alexandria
87
75
  self.rating = (book.rating || Book::DEFAULT_RATING)
88
76
 
89
77
  if (@checkbutton_loaned.active = book.loaned?)
90
- @entry_loaned_to.text = (book.loaned_to || '')
78
+ @entry_loaned_to.text = (book.loaned_to || "")
91
79
  self.loaned_since = book.loaned_since
92
80
  @date_loaned_since.sensitive = true
93
81
  else
@@ -98,7 +86,7 @@ module Alexandria
98
86
  if (@checkbutton_redd.active = book.redd?)
99
87
  @redd_date.sensitive = true
100
88
  if book.redd_when.nil?
101
- puts 'no redd_when'
89
+ puts "no redd_when"
102
90
  else
103
91
  @redd_date.text = format_date(book.redd_when)
104
92
  end
@@ -114,17 +102,17 @@ module Alexandria
114
102
  private
115
103
 
116
104
  def on_close
117
- if @entry_isbn.text == ''
105
+ if @entry_isbn.text == ""
118
106
  # If set to nil .to_yaml in library.save causes crash
119
- @book.isbn = ''
107
+ @book.isbn = ""
120
108
  else
121
109
  isbn = Library.canonicalise_ean(@entry_isbn.text)
122
110
  unless isbn
123
111
  ErrorDialog.new(@book_properties_dialog,
124
112
  _("Couldn't modify the book"),
125
113
  _("Couldn't validate the EAN/ISBN you " \
126
- 'provided. Make sure it is written ' \
127
- 'correcty, and try again.')).display
114
+ "provided. Make sure it is written " \
115
+ "correcty, and try again.")).display
128
116
  return
129
117
  end
130
118
 
@@ -132,8 +120,8 @@ module Alexandria
132
120
  unless ary.empty? || ((ary.length == 1) && (ary.first == @book))
133
121
  ErrorDialog.new(@book_properties_dialog,
134
122
  _("Couldn't modify the book"),
135
- _('The EAN/ISBN you provided is already ' \
136
- 'used in this library.')).display
123
+ _("The EAN/ISBN you provided is already " \
124
+ "used in this library.")).display
137
125
  return
138
126
  end
139
127
 
@@ -173,7 +161,7 @@ module Alexandria
173
161
  end
174
162
  @book.own = @checkbutton_own.active?
175
163
  @book.want = @checkbutton_want.active?
176
- @book.tags = @entry_tags.text.split(',') # tags are comma separated
164
+ @book.tags = @entry_tags.text.split(",") # tags are comma separated
177
165
 
178
166
  FileUtils.rm_f(@cover_file) if @delete_cover_file
179
167
 
@@ -191,7 +179,7 @@ module Alexandria
191
179
 
192
180
  def on_help
193
181
  Alexandria::UI.display_help(@preferences_dialog,
194
- 'editing-book-properties')
182
+ "editing-book-properties")
195
183
  end
196
184
  end
197
185
  end
@@ -4,21 +4,22 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require 'alexandria/ui/builder_base'
7
+ require "alexandria/ui/builder_base"
8
+ require "alexandria/ui/error_dialog"
8
9
 
9
10
  module Alexandria
10
11
  module UI
11
12
  class BookPropertiesDialogBase < BuilderBase
12
13
  include GetText
13
14
  extend GetText
14
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
15
+ GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
15
16
 
16
17
  COVER_MAXWIDTH = 140 # pixels
17
18
 
18
19
  COVER_ABSOLUTE_MAXHEIGHT = 250 # pixels, above this we scale down...
19
20
 
20
21
  def initialize(parent, cover_file)
21
- super('book_properties_dialog__builder.glade', widget_names)
22
+ super("book_properties_dialog__builder.glade", widget_names)
22
23
  @setup_finished = false
23
24
  @book_properties_dialog.transient_for = parent
24
25
  @parent = parent
@@ -37,15 +38,15 @@ module Alexandria
37
38
  @treeview_authors.model = Gtk::ListStore.new(String, TrueClass)
38
39
  @treeview_authors.selection.mode = :single
39
40
  renderer = Gtk::CellRendererText.new
40
- renderer.signal_connect('edited') do |_cell, path_string, new_text|
41
+ renderer.signal_connect("edited") do |_cell, path_string, new_text|
41
42
  path = Gtk::TreePath.new(path_string)
42
43
  iter = @treeview_authors.model.get_iter(path)
43
44
  iter[0] = new_text
44
45
  end
45
- renderer.signal_connect('editing_started') do |_cell, entry, _path_string|
46
+ renderer.signal_connect("editing_started") do |_cell, entry, _path_string|
46
47
  entry.complete_authors
47
48
  end
48
- col = Gtk::TreeViewColumn.new('', renderer,
49
+ col = Gtk::TreeViewColumn.new("", renderer,
49
50
  text: 0,
50
51
  editable: 1)
51
52
  @treeview_authors.append_column(col)
@@ -69,12 +70,12 @@ module Alexandria
69
70
 
70
71
  @calendar_popup.set_transient_for(@book_properties_dialog)
71
72
  @calendar_popup.set_type_hint :dialog
72
- @calendar_popup.name = 'calendar-popup'
73
+ @calendar_popup.name = "calendar-popup"
73
74
  @calendar_popup.resizable = false
74
75
  # @calendar_popup.border_width = 4
75
76
  # @calendar_popup.app_paintable = true
76
77
 
77
- @calendar_popup.signal_connect('focus-out-event') do |_popup, _event|
78
+ @calendar_popup.signal_connect("focus-out-event") do |_popup, _event|
78
79
  hide_calendar_popup
79
80
  false
80
81
  end
@@ -82,7 +83,7 @@ module Alexandria
82
83
  @calendar = Gtk::Calendar.new
83
84
  @calendar_popup.add(@calendar)
84
85
 
85
- @calendar.signal_connect('day-selected') do
86
+ @calendar.signal_connect("day-selected") do
86
87
  date_arr = @calendar.date
87
88
  year = date_arr[0]
88
89
  month = date_arr[1] # + 1 # gtk : months 0-indexed, Time.gm : 1-index
@@ -93,7 +94,7 @@ module Alexandria
93
94
  end
94
95
  end
95
96
 
96
- @calendar.signal_connect('day-selected-double-click') do
97
+ @calendar.signal_connect("day-selected-double-click") do
97
98
  date_arr = @calendar.date
98
99
  year = date_arr[0]
99
100
  month = date_arr[1] # + 1 # gtk : months 0-indexed, Time.gm : 1-index
@@ -105,26 +106,26 @@ module Alexandria
105
106
  hide_calendar_popup
106
107
  end
107
108
 
108
- @redd_date.signal_connect('icon-press') do |entry, primary, _icon|
109
- if primary.nick == 'primary'
109
+ @redd_date.signal_connect("icon-press") do |entry, primary, _icon|
110
+ if primary.nick == "primary"
110
111
  display_calendar_popup(entry)
111
- elsif primary.nick == 'secondary'
112
+ elsif primary.nick == "secondary"
112
113
  clear_date_entry(entry)
113
114
  end
114
115
  end
115
116
 
116
- @date_loaned_since.signal_connect('icon-press') do |entry, primary, _icon|
117
- if primary.nick == 'primary'
117
+ @date_loaned_since.signal_connect("icon-press") do |entry, primary, _icon|
118
+ if primary.nick == "primary"
118
119
  display_calendar_popup(entry)
119
- elsif primary.nick == 'secondary'
120
+ elsif primary.nick == "secondary"
120
121
  clear_date_entry(entry)
121
- @label_loaning_duration.label = ''
122
+ @label_loaning_duration.label = ""
122
123
  end
123
124
  end
124
125
  end
125
126
 
126
127
  def clear_date_entry(entry)
127
- entry.text = ''
128
+ entry.text = ""
128
129
  end
129
130
 
130
131
  def hide_calendar_popup
@@ -196,7 +197,7 @@ module Alexandria
196
197
  def on_title_changed
197
198
  title = @entry_title.text.strip
198
199
  @book_properties_dialog.title = if title.empty?
199
- _('Properties')
200
+ _("Properties")
200
201
  else
201
202
  _("Properties for '%s'") % title
202
203
  end
@@ -204,7 +205,7 @@ module Alexandria
204
205
 
205
206
  def on_add_author
206
207
  iter = @treeview_authors.model.append
207
- iter[0] = _('Author')
208
+ iter[0] = _("Author")
208
209
  iter[1] = true
209
210
  @treeview_authors.set_cursor(iter.path,
210
211
  @treeview_authors.get_column(0),
@@ -250,14 +251,14 @@ module Alexandria
250
251
 
251
252
  def want_toggled; end
252
253
 
253
- @@latest_filechooser_directory = ENV['HOME']
254
+ @@latest_filechooser_directory = ENV["HOME"]
254
255
  def on_change_cover
255
- backend = `uname`.chomp == 'FreeBSD' ? 'neant' : 'gnome-vfs'
256
- dialog = Gtk::FileChooserDialog.new(_('Select a cover image'),
256
+ backend = `uname`.chomp == "FreeBSD" ? "neant" : "gnome-vfs"
257
+ dialog = Gtk::FileChooserDialog.new(_("Select a cover image"),
257
258
  @book_properties_dialog,
258
259
  Gtk::FileChooser::ACTION_OPEN,
259
260
  backend,
260
- [_('No Cover'), Gtk::ResponseType::REJECT],
261
+ [_("No Cover"), Gtk::ResponseType::REJECT],
261
262
  [Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL],
262
263
  [Gtk::Stock::OPEN, Gtk::ResponseType::ACCEPT])
263
264
  dialog.current_folder = @@latest_filechooser_directory
@@ -280,15 +281,15 @@ module Alexandria
280
281
  new_width = cover.width / (cover.height / COVER_ABSOLUTE_MAXHEIGHT.to_f)
281
282
  puts "Scaling large cover image to #{new_width.to_i} x #{COVER_ABSOLUTE_MAXHEIGHT}"
282
283
  cover = cover.scale(new_width.to_i, COVER_ABSOLUTE_MAXHEIGHT)
283
- cover.save(@cover_file, 'jpeg')
284
+ cover.save(@cover_file, "jpeg")
284
285
  else
285
286
  FileUtils.cp(dialog.filename, @cover_file)
286
287
  end
287
288
 
288
289
  self.cover = cover
289
290
  @@latest_filechooser_directory = dialog.current_folder
290
- rescue RuntimeError => e
291
- ErrorDialog.new(@book_properties_dialog, e.message).display
291
+ rescue RuntimeError => ex
292
+ ErrorDialog.new(@book_properties_dialog, ex.message).display
292
293
  end
293
294
  elsif response == Gtk::ResponseType::REJECT
294
295
  ## FileUtils.rm_f(@cover_file) # fixing bug #16707
@@ -313,7 +314,7 @@ module Alexandria
313
314
  end
314
315
 
315
316
  def on_loaned_date_changed
316
- date_regexes = [/[0123]?[0-9]\/[0123]?[0-9]\/[0-9]{4}/,
317
+ date_regexes = [%r{[0123]?[0-9]/[0123]?[0-9]/[0-9]{4}},
317
318
  /[0-9]{4}-[0123]?[0-9]-[0123]?[0-9]/]
318
319
  matches_regex = false
319
320
  date_regexes.each do |regex|
@@ -324,19 +325,19 @@ module Alexandria
324
325
 
325
326
  t = parse_date(@date_loaned_since.text)
326
327
  if t.nil?
327
- @label_loaning_duration.label = ''
328
+ @label_loaning_duration.label = ""
328
329
  return
329
330
  end
330
331
  loaned_time = Time.at(t)
331
332
  n_days = ((Time.now - loaned_time) / (3600 * 24)).to_i
332
333
  if n_days > 365_250 # 1,000 years
333
- @label_loaning_duration.label = ''
334
+ @label_loaning_duration.label = ""
334
335
  return
335
336
  end
336
337
  @label_loaning_duration.label = if n_days > 0
337
- n_('%d day', '%d days', n_days) % n_days
338
+ n_("%d day", "%d days", n_days) % n_days
338
339
  else
339
- ''
340
+ ""
340
341
  end
341
342
  end
342
343
 
@@ -359,7 +360,7 @@ module Alexandria
359
360
  @image_rating4,
360
361
  @image_rating5
361
362
  ]
362
- raise 'out of range' if rating < 0 || rating > images.length
363
+ raise "out of range" if rating < 0 || rating > images.length
363
364
 
364
365
  images[0..rating - 1].each { |x| x.pixbuf = Icons::STAR_SET }
365
366
  images[rating..-1].each { |x| x.pixbuf = Icons::STAR_UNSET }
@@ -378,8 +379,8 @@ module Alexandria
378
379
 
379
380
  def loaned_since=(time)
380
381
  if time.nil?
381
- @date_loaned_since.text = ''
382
- @label_loaning_duration.label = ''
382
+ @date_loaned_since.text = ""
383
+ @label_loaning_duration.label = ""
383
384
  else
384
385
  @date_loaned_since.text = format_date(time)
385
386
  on_loaned_date_changed
@@ -392,7 +393,7 @@ module Alexandria
392
393
  end
393
394
 
394
395
  def parse_date(datestring)
395
- date_format = '%d/%m/%Y' # or '%m/%d/%Y' for USA and Canada ; or '%Y-%m-%d' for most of Asia
396
+ date_format = "%d/%m/%Y" # or '%m/%d/%Y' for USA and Canada ; or '%Y-%m-%d' for most of Asia
396
397
  ## http://en.wikipedia.org/wiki/Calendar_date#Middle_endian_forms.2C_starting_with_the_month
397
398
  begin
398
399
  d = Date.strptime(datestring, date_format)
@@ -403,7 +404,7 @@ module Alexandria
403
404
  end
404
405
 
405
406
  def format_date(datetime)
406
- datetime.strftime('%d/%m/%Y')
407
+ datetime.strftime("%d/%m/%Y")
407
408
  end
408
409
  end
409
410
  end