alexandria-book-collection-manager 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.hound.yml +2 -0
  4. data/.rubocop.yml +4 -4
  5. data/.rubocop_todo.yml +55 -82
  6. data/CHANGELOG.md +17 -0
  7. data/INSTALL.md +3 -3
  8. data/README.md +1 -2
  9. data/Rakefile +14 -33
  10. data/TODO.md +9 -1
  11. data/alexandria-book-collection-manager.gemspec +4 -3
  12. data/bin/alexandria +21 -34
  13. data/doc/FAQ +2 -5
  14. data/lib/alexandria.rb +4 -16
  15. data/lib/alexandria/book_providers.rb +5 -7
  16. data/lib/alexandria/book_providers/adlibris.rb +5 -3
  17. data/lib/alexandria/book_providers/amazon_aws.rb +3 -1
  18. data/lib/alexandria/book_providers/amazon_ecs_util.rb +8 -0
  19. data/lib/alexandria/book_providers/barnes_and_noble.rb +7 -4
  20. data/lib/alexandria/book_providers/douban.rb +1 -1
  21. data/lib/alexandria/book_providers/proxis.rb +11 -27
  22. data/lib/alexandria/book_providers/renaud.rb +9 -3
  23. data/lib/alexandria/book_providers/siciliano.rb +7 -4
  24. data/lib/alexandria/book_providers/thalia.rb +5 -3
  25. data/lib/alexandria/book_providers/web.rb +11 -29
  26. data/lib/alexandria/book_providers/worldcat.rb +7 -5
  27. data/lib/alexandria/book_providers/z3950.rb +10 -7
  28. data/lib/alexandria/console.rb +5 -18
  29. data/lib/alexandria/execution_queue.rb +2 -1
  30. data/lib/alexandria/export_format.rb +47 -0
  31. data/lib/alexandria/export_library.rb +72 -180
  32. data/lib/alexandria/import_library.rb +14 -23
  33. data/lib/alexandria/import_library_csv.rb +3 -6
  34. data/lib/alexandria/library_collection.rb +78 -0
  35. data/lib/alexandria/library_sort_order.rb +43 -0
  36. data/lib/alexandria/library_store.rb +222 -0
  37. data/lib/alexandria/logging.rb +2 -0
  38. data/lib/alexandria/models/book.rb +8 -16
  39. data/lib/alexandria/models/library.rb +26 -308
  40. data/lib/alexandria/preferences.rb +7 -24
  41. data/lib/alexandria/scanners/cuecat.rb +3 -1
  42. data/lib/alexandria/smart_library.rb +32 -67
  43. data/lib/alexandria/ui/builder_base.rb +6 -26
  44. data/lib/alexandria/ui/callbacks.rb +8 -34
  45. data/lib/alexandria/ui/completion_models.rb +2 -1
  46. data/lib/alexandria/ui/dialogs/about_dialog.rb +35 -47
  47. data/lib/alexandria/ui/dialogs/acquire_dialog.rb +14 -30
  48. data/lib/alexandria/ui/dialogs/alert_dialog.rb +8 -17
  49. data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +10 -24
  50. data/lib/alexandria/ui/dialogs/book_properties_dialog.rb +17 -18
  51. data/lib/alexandria/ui/dialogs/book_properties_dialog_base.rb +25 -41
  52. data/lib/alexandria/ui/dialogs/export_dialog.rb +48 -56
  53. data/lib/alexandria/ui/dialogs/import_dialog.rb +31 -51
  54. data/lib/alexandria/ui/dialogs/keep_bad_isbn_dialog.rb +33 -0
  55. data/lib/alexandria/ui/dialogs/misc_dialogs.rb +12 -25
  56. data/lib/alexandria/ui/dialogs/new_book_dialog.rb +57 -94
  57. data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +24 -42
  58. data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +9 -21
  59. data/lib/alexandria/ui/dialogs/preferences_dialog.rb +27 -32
  60. data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +5 -3
  61. data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +15 -12
  62. data/lib/alexandria/ui/icons.rb +11 -22
  63. data/lib/alexandria/ui/init.rb +3 -3
  64. data/lib/alexandria/ui/libraries_combo.rb +1 -0
  65. data/lib/alexandria/ui/listview.rb +5 -21
  66. data/lib/alexandria/ui/multi_drag_treeview.rb +20 -32
  67. data/lib/alexandria/ui/sidepane.rb +9 -24
  68. data/lib/alexandria/ui/ui_manager.rb +36 -60
  69. data/lib/alexandria/undo_manager.rb +1 -0
  70. data/lib/alexandria/version.rb +2 -2
  71. data/lib/alexandria/web_themes.rb +1 -0
  72. data/po/cs.po +0 -4
  73. data/po/cy.po +0 -4
  74. data/po/de.po +0 -4
  75. data/po/el.po +0 -4
  76. data/po/es.po +0 -4
  77. data/po/fr.po +0 -4
  78. data/po/ga.po +0 -4
  79. data/po/gl.po +0 -4
  80. data/po/it.po +0 -4
  81. data/po/ja.po +0 -4
  82. data/po/mk.po +0 -4
  83. data/po/nb.po +0 -4
  84. data/po/nl.po +0 -4
  85. data/po/pl.po +0 -4
  86. data/po/pt.po +0 -4
  87. data/po/pt_BR.po +0 -4
  88. data/po/ru.po +0 -4
  89. data/po/sk.po +0 -4
  90. data/po/sv.po +0 -4
  91. data/po/uk.po +0 -4
  92. data/po/zh_TW.po +0 -4
  93. data/schemas/alexandria.schemas +1 -1
  94. data/share/alexandria/glade/acquire_dialog__builder.glade +14 -11
  95. data/share/alexandria/glade/book_properties_dialog__builder.glade +170 -298
  96. data/share/alexandria/glade/main_app__builder.glade +22 -16
  97. data/share/alexandria/glade/new_book_dialog__builder.glade +26 -58
  98. data/share/alexandria/glade/preferences_dialog__builder.glade +249 -289
  99. data/share/gnome/help/alexandria/C/introduction.xml +0 -4
  100. data/share/gnome/help/alexandria/ja/introduction.xml +0 -4
  101. data/spec/alexandria/book_providers_spec.rb +1 -20
  102. data/spec/alexandria/console_spec.rb +32 -0
  103. data/spec/alexandria/export_library_spec.rb +141 -0
  104. data/spec/alexandria/library_spec.rb +24 -80
  105. data/spec/alexandria/library_store_spec.rb +37 -0
  106. data/spec/alexandria/smart_library_spec.rb +27 -22
  107. data/spec/alexandria/ui/dialogs/new_book_dialog_spec.rb +22 -0
  108. data/spec/alexandria/ui/dialogs_spec.rb +104 -38
  109. data/spec/end_to_end/basic_run_spec.rb +69 -0
  110. data/spec/spec_helper.rb +13 -25
  111. data/tasks/spec.rake +15 -2
  112. data/util/rake/fileinstall.rb +1 -0
  113. metadata +38 -16
  114. data/lib/alexandria/book_providers/deastore.rb +0 -265
  115. data/lib/alexandria/book_providers/mcu.rb +0 -182
@@ -1,52 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2004-2006 Laurent Sansonetti
4
- # Copyright (C) 2011, 2015, 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.
20
6
 
21
7
  require 'gdk_pixbuf2'
8
+ require 'alexandria/ui/builder_base'
9
+ require 'alexandria/ui/dialogs/keep_bad_isbn_dialog'
22
10
 
23
11
  module Alexandria
24
12
  class DuplicateBookException < NameError
25
13
  end
26
14
 
27
15
  module UI
28
- class KeepBadISBNDialog < AlertDialog
29
- include GetText
30
- GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
31
-
32
- def initialize(parent, book)
33
- super(parent, _("Invalid ISBN '%s'") % book.isbn,
34
- Gtk::Stock::DIALOG_QUESTION,
35
- [[Gtk::Stock::CANCEL, :cancel],
36
- [_('_Keep'), :ok]],
37
- _("The book titled '%s' has an invalid ISBN, but still " \
38
- 'exists in the providers libraries. Do you want to ' \
39
- 'keep the book but change the ISBN or cancel the addition?') % book.title)
40
- self.default_response = Gtk::ResponseType::OK
41
- show_all && (@response = run)
42
- destroy
43
- end
44
-
45
- def keep?
46
- @response == :ok
47
- end
48
- end
49
-
50
16
  class NewBookDialog < BuilderBase
51
17
  include Logging
52
18
  include GetText
@@ -66,25 +32,22 @@ module Alexandria
66
32
  end
67
33
 
68
34
  def widget_names
69
- [:liststore1, :liststore2, :new_book_dialog, :dialog_vbox1,
70
- :dialog_action_area1, :button_help, :button_cancel,
71
- :button_add, :table1, :keep_open, :combo_libraries,
72
- :cellrenderertext1, :eventbox_entry_isbn, :entry_isbn,
73
- :label3, :hbox2, :eventbox_combo_search, :combo_search,
74
- :cellrenderertext2, :eventbox_entry_search, :entry_search,
75
- :button_find, :scrolledwindow, :treeview_results,
76
- :title_radiobutton, :isbn_radiobutton, :progressbar]
35
+ [:new_book_dialog, :button_add, :button_cancel, :button_find,
36
+ :button_help, :combo_libraries, :combo_search, :entry_isbn,
37
+ :entry_search, :eventbox_combo_search, :eventbox_entry_isbn,
38
+ :eventbox_entry_search, :isbn_radiobutton, :keep_open, :progressbar,
39
+ :scrolledwindow, :title_radiobutton, :treeview_results]
77
40
  end
78
41
 
79
42
  def setup_dialog_gui
80
- libraries = Libraries.instance.all_regular_libraries
43
+ libraries = LibraryCollection.instance.all_regular_libraries
81
44
  @selected_library = libraries.first if @selected_library.is_a?(SmartLibrary)
82
45
  @combo_libraries.populate_with_libraries(libraries,
83
46
  @selected_library)
84
47
 
85
48
  @treeview_results.model = Gtk::ListStore.new(String, String,
86
49
  GdkPixbuf::Pixbuf)
87
- @treeview_results.selection.mode = Gtk::SELECTION_MULTIPLE
50
+ @treeview_results.selection.mode = :multiple
88
51
  @treeview_results.selection.signal_connect('changed') do
89
52
  @button_add.sensitive = true
90
53
  end
@@ -205,14 +168,14 @@ module Alexandria
205
168
  end
206
169
  end
207
170
  end
208
- rescue => e
171
+ rescue StandardError => e
209
172
  @image_error = e.message
210
173
  end
211
174
  end
212
175
 
213
176
  GLib::Timeout.add(100) do
214
177
  if @image_error
215
- image_error_dialog(@image_error)
178
+ image_error_dialog(@image_error).display
216
179
  else
217
180
  @images.each_pair do |key, value|
218
181
  begin
@@ -225,12 +188,13 @@ module Alexandria
225
188
  unless @treeview_results.model.iter_is_valid?(iter)
226
189
  raise format('Iter is invalid! %s', iter)
227
190
  end
191
+
228
192
  iter[2] = pixbuf # I bet you this is it!
229
193
  end
230
194
 
231
195
  @images.delete(key)
232
- rescue => e
233
- image_error_dialog(e.message)
196
+ rescue StandardError => e
197
+ image_error_dialog(e.message).display
234
198
  end
235
199
  end
236
200
  end
@@ -257,16 +221,6 @@ module Alexandria
257
221
  BookProviders::SEARCH_BY_KEYWORD
258
222
  end
259
223
 
260
- # @progressbar.show
261
- # progress_pulsing = GLib::Timeout.add(100) do
262
- # if @destroyed
263
- # false
264
- # else
265
- # @progressbar.pulse
266
- # true
267
- # end
268
- # end
269
-
270
224
  criterion = @entry_search.text.strip
271
225
  @treeview_results.model.clear
272
226
  log.info {
@@ -290,7 +244,7 @@ module Alexandria
290
244
  @results = Alexandria::BookProviders.search(criterion, mode)
291
245
 
292
246
  log.info { "got #{@results.length} results" }
293
- rescue => e
247
+ rescue StandardError => e
294
248
  @find_error = e.message
295
249
  ensure
296
250
  Alexandria::BookProviders.instance.delete_observer(self)
@@ -306,25 +260,13 @@ module Alexandria
306
260
 
307
261
  # Err... continue == false if @find_error
308
262
  continue = if @find_error
309
- ErrorDialog.new(@parent,
263
+ ErrorDialog.new(@new_book_dialog,
310
264
  _('Unable to find matches for your search'),
311
- @find_error)
265
+ @find_error).display
312
266
  false
313
267
  elsif @results
314
268
  log.info { "Got results: #{@results[0]}..." }
315
- @results.each_key do |book|
316
- s = format(_('%s, by %s'), book.title, book.authors.join(', '))
317
- similar_books = @results.find { |book2, _cover2|
318
- (book.title == book2.title) &&
319
- (book.authors == book2.authors)
320
- }
321
- s += " (#{book.edition}, #{book.publisher})" if similar_books.length > 1
322
- log.info { format('Copying %s into tree view.', book.title) }
323
- iter = @treeview_results.model.append
324
- iter[0] = s
325
- iter[1] = book.ident
326
- iter[2] = Icons::BOOK
327
- end
269
+ copy_results_to_treeview_model(@results, @treeview_results.model)
328
270
 
329
271
  # Kick off the image download thread.
330
272
  if @find_thread.alive?
@@ -358,6 +300,22 @@ module Alexandria
358
300
  end
359
301
  end
360
302
 
303
+ def copy_results_to_treeview_model(results, model)
304
+ results.each do |book, _cover_url|
305
+ s = format(_('%s, by %s'), book.title, book.authors.join(', '))
306
+ similar_books = results.find { |book2, _cover2|
307
+ (book.title == book2.title) &&
308
+ (book.authors == book2.authors)
309
+ }
310
+ s += " (#{book.edition}, #{book.publisher})" if similar_books.length > 1
311
+ log.info { format('Copying %s into tree view.', book.title) }
312
+ iter = model.append
313
+ iter[0] = s
314
+ iter[1] = book.ident
315
+ iter[2] = Icons::BOOK
316
+ end
317
+ end
318
+
361
319
  def decode_cuecat?(entry) # srsly?
362
320
  if entry.text =~ /^\..*?\..*?\.(.*?)\.$/
363
321
  tmp = Regexp.last_match[1].tr('a-zA-Z0-9+-', ' -_')
@@ -377,7 +335,7 @@ module Alexandria
377
335
  # Perform the ISBN search via the providers.
378
336
  isbn = begin
379
337
  Library.canonicalise_isbn(@entry_isbn.text)
380
- rescue
338
+ rescue StandardError
381
339
  raise _("Couldn't validate the EAN/ISBN you " \
382
340
  'provided. Make sure it is written ' \
383
341
  'correctly, and try again.')
@@ -392,9 +350,6 @@ module Alexandria
392
350
  # MAJOR HACK, add this again...
393
351
  Alexandria::BookProviders.instance.add_observer(self)
394
352
  book, cover_url = Alexandria::BookProviders.isbn_search(isbn)
395
- # prov = FakeBookProviders.new()
396
- # prov.add_observer(self)
397
- # book, cover_url = prov.isbn_search(isbn)
398
353
 
399
354
  notify_end_add_by_isbn
400
355
 
@@ -424,22 +379,28 @@ module Alexandria
424
379
 
425
380
  def add_selected_books(library, _is_new)
426
381
  books_to_add = []
427
- @treeview_results.selection.selected_each do |_model, _path, iter|
382
+ @treeview_results.selection.each do |_model, _path, iter|
428
383
  @results.each do |book, cover|
429
384
  next unless book.ident == iter[1]
430
- begin
431
- next unless assert_not_exist(library, book.isbn)
432
- rescue Alexandria::Library::NoISBNError
385
+
386
+ isbn = book.isbn
387
+ if isbn.nil? || isbn.empty?
433
388
  puts 'noisbn'
434
389
  book.isbn = book.saved_ident = nil
435
390
  books_to_add << [book, cover]
436
391
  next
437
- rescue Alexandria::Library::InvalidISBNError
392
+ end
393
+
394
+ isbn = Library.canonicalise_ean(isbn)
395
+ unless isbn
438
396
  puts "invalidisbn #{book.isbn}"
439
- next unless
440
- KeepBadISBNDialog.new(@parent, book).keep?
397
+ next unless KeepBadISBNDialog.new(@new_book_dialog, book).keep?
398
+
441
399
  book.isbn = book.saved_ident = nil
442
400
  end
401
+
402
+ book.isbn = isbn
403
+ assert_not_exist(library, isbn)
443
404
  books_to_add << [book, cover]
444
405
  end
445
406
  end
@@ -483,11 +444,12 @@ module Alexandria
483
444
 
484
445
  def on_add
485
446
  return unless @button_add.sensitive?
447
+
486
448
  @find_thread&.kill
487
449
  @image_thread&.kill
488
450
 
489
451
  begin
490
- libraries = Libraries.instance.all_libraries
452
+ libraries = LibraryCollection.instance.all_libraries
491
453
  library, is_new_library =
492
454
  @combo_libraries.selection_from_libraries(libraries)
493
455
 
@@ -502,8 +464,9 @@ module Alexandria
502
464
 
503
465
  # Do not destroy if there is no addition.
504
466
  # return unless book_was_added
505
- rescue => e
506
- ErrorDialog.new(@parent, _("Couldn't add the book"), e.message)
467
+ rescue StandardError => e
468
+ # FIXME: Message containing <> should be displayed correctly.
469
+ ErrorDialog.new(@new_book_dialog, _("Couldn't add the book"), e.message).display
507
470
  end
508
471
  # books_to_add
509
472
  end
@@ -603,12 +566,12 @@ module Alexandria
603
566
  def assert_not_exist(library, isbn)
604
567
  # Check that the book doesn't already exist in the library.
605
568
  isbn13 = Library.canonicalise_ean(isbn)
606
- puts isbn13
569
+ return unless isbn13
570
+
607
571
  if (book = library.find { |bk| bk.isbn == isbn13 })
608
572
  raise DuplicateBookException, format(_("'%s' already exists in '%s' (titled '%s')."),
609
573
  isbn, library.name, book.title.sub('&', '&amp;'))
610
574
  end
611
- true
612
575
  end
613
576
  end
614
577
  end
@@ -1,22 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2004-2006 Laurent Sansonetti
4
- # Copyright (C) 2011, 2014 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 'tmpdir'
20
8
 
21
9
  module Alexandria
22
10
  module UI
@@ -33,17 +21,17 @@ module Alexandria
33
21
  @on_add_cb = on_add_cb
34
22
  FileUtils.rm_f(TMP_COVER_FILE)
35
23
 
36
- cancel_button = Gtk::Button.new(Gtk::Stock::CANCEL)
24
+ cancel_button = Gtk::Button.new(stock_id: Gtk::Stock::CANCEL)
37
25
  cancel_button.signal_connect('clicked') { on_cancel }
38
26
  cancel_button.show
39
27
  @button_box << cancel_button
40
28
 
41
- add_button = Gtk::Button.new(Gtk::Stock::ADD)
29
+ add_button = Gtk::Button.new(stock_id: Gtk::Stock::ADD)
42
30
  add_button.signal_connect('clicked') { on_add }
43
31
  add_button.show
44
32
  @button_box << add_button
45
33
 
46
- help_button = Gtk::Button.new(Gtk::Stock::HELP)
34
+ help_button = Gtk::Button.new(stock_id: Gtk::Stock::HELP)
47
35
  help_button.signal_connect('clicked') { on_help }
48
36
  help_button.show
49
37
  @button_box << help_button
@@ -57,15 +45,11 @@ module Alexandria
57
45
 
58
46
  def on_title_changed
59
47
  title = @entry_title.text.strip
60
- begin
61
- @book_properties_dialog.title = if title.empty?
62
- _('Adding a Book')
63
- else
64
- _("Adding '%s'") % title
65
- end
66
- rescue
67
- raise "There's a problem with a book somewhere"
68
- end
48
+ @book_properties_dialog.title = if title.empty?
49
+ _('Adding a Book')
50
+ else
51
+ _("Adding '%s'") % title
52
+ end
69
53
  end
70
54
 
71
55
  private
@@ -81,29 +65,27 @@ module Alexandria
81
65
  if (title = @entry_title.text.strip).empty?
82
66
  raise AddError, _('A title must be provided.')
83
67
  end
68
+
84
69
  isbn = nil
85
70
  if @entry_isbn.text != ''
86
- ary = @library.select { |book|
87
- book.ident == @entry_isbn.text
88
- }
71
+ isbn = Library.canonicalise_ean(@entry_isbn.text)
72
+ unless isbn
73
+ raise AddError, _("Couldn't validate the EAN/ISBN you provided. Make " \
74
+ 'sure it is written correcty, and try again.')
75
+ end
76
+ ary = @library.select { |book| book.ident == isbn }
89
77
  raise AddError, _('The EAN/ISBN you provided is already used in this library.') unless ary.empty?
90
- isbn = begin
91
- Library.canonicalise_isbn(@entry_isbn.text)
92
- rescue Alexandria::Library::InvalidISBNError
93
- raise AddError, _("Couldn't validate the " \
94
- 'EAN/ISBN you provided. Make ' \
95
- 'sure it is written correcty, ' \
96
- 'and try again.')
97
- end
98
78
  end
99
79
  if (publisher = @entry_publisher.text.strip).empty?
100
80
  raise AddError, _('A publisher must be provided.')
101
81
  end
82
+
102
83
  publishing_year = @entry_publish_date.text.to_i
103
84
  # TODO: Get rid of this silly requirement
104
85
  if (edition = @entry_edition.text.strip).empty?
105
86
  raise AddError, _('A binding must be provided.')
106
87
  end
88
+
107
89
  authors = []
108
90
  @treeview_authors.model.each { |_m, _p, i| authors << i[0] }
109
91
  if authors.empty?
@@ -131,8 +113,8 @@ module Alexandria
131
113
  @on_add_cb.call(book)
132
114
  @book_properties_dialog.destroy
133
115
  rescue AddError => e
134
- ErrorDialog.new(@parent, _("Couldn't add the book"),
135
- e.message)
116
+ ErrorDialog.new(@book_properties_dialog, _("Couldn't add the book"),
117
+ e.message).display
136
118
  end
137
119
 
138
120
  # COPIED from book_properties_dialog_base
@@ -141,7 +123,7 @@ module Alexandria
141
123
  begin
142
124
  d = Date.strptime(datestring, date_format)
143
125
  Time.gm(d.year, d.month, d.day)
144
- rescue
126
+ rescue StandardError
145
127
  nil
146
128
  end
147
129
  end
@@ -1,22 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (C) 2004-2006 Laurent Sansonetti
4
- # Copyright (C) 2015, 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.
20
6
 
21
7
  module Alexandria
22
8
  module UI
@@ -33,21 +19,23 @@ module Alexandria
33
19
  self.title = _('New Smart Library')
34
20
  # FIXME: Should accept just :cancel
35
21
  self.default_response = Gtk::ResponseType::CANCEL
22
+ end
36
23
 
24
+ def acquire
37
25
  show_all
38
26
  insert_new_rule
39
27
 
40
- while ((response = run) != :cancel) &&
41
- (response != :delete_event)
28
+ while ((response = run) != Gtk::ResponseType::CANCEL) &&
29
+ (response != Gtk::ResponseType::DELETE_EVENT)
42
30
 
43
- if response == :help
31
+ if response == Gtk::ResponseType::HELP
44
32
  Alexandria::UI.display_help(self, 'new-smart-library')
45
- elsif response == :ok
33
+ elsif response == Gtk::ResponseType::OK
46
34
  if user_confirms_possible_weirdnesses_before_saving?
47
35
  rules = smart_library_rules
48
36
  basename = smart_library_base_name(rules) || _('Smart Library')
49
37
  name = Library.generate_new_name(
50
- Libraries.instance.all_libraries,
38
+ LibraryCollection.instance.all_libraries,
51
39
  basename)
52
40
  library = SmartLibrary.new(name,
53
41
  rules,