alexandria-book-collection-manager 0.6.9 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +34 -30
  4. data/.rubocop_todo.yml +139 -54
  5. data/CHANGELOG.md +10 -0
  6. data/Gemfile +1 -0
  7. data/Rakefile +10 -11
  8. data/alexandria-book-collection-manager.gemspec +3 -2
  9. data/bin/alexandria +1 -1
  10. data/lib/alexandria.rb +3 -6
  11. data/lib/alexandria/about.rb +9 -9
  12. data/lib/alexandria/book_providers.rb +12 -12
  13. data/lib/alexandria/book_providers/adlibris.rb +14 -18
  14. data/lib/alexandria/book_providers/amazon_aws.rb +17 -31
  15. data/lib/alexandria/book_providers/amazon_ecs_util.rb +5 -6
  16. data/lib/alexandria/book_providers/barnes_and_noble.rb +51 -76
  17. data/lib/alexandria/book_providers/bol_it.rb +12 -12
  18. data/lib/alexandria/book_providers/deastore.rb +27 -31
  19. data/lib/alexandria/book_providers/douban.rb +9 -13
  20. data/lib/alexandria/book_providers/ibs_it.rb +10 -10
  21. data/lib/alexandria/book_providers/mcu.rb +12 -18
  22. data/lib/alexandria/book_providers/proxis.rb +14 -22
  23. data/lib/alexandria/book_providers/pseudomarc.rb +8 -18
  24. data/lib/alexandria/book_providers/renaud.rb +16 -16
  25. data/lib/alexandria/book_providers/siciliano.rb +25 -38
  26. data/lib/alexandria/book_providers/thalia.rb +13 -16
  27. data/lib/alexandria/book_providers/webster_it.rb +14 -18
  28. data/lib/alexandria/book_providers/worldcat.rb +21 -25
  29. data/lib/alexandria/book_providers/z3950.rb +19 -23
  30. data/lib/alexandria/config.rb +2 -2
  31. data/lib/alexandria/execution_queue.rb +3 -1
  32. data/lib/alexandria/export_library.rb +19 -22
  33. data/lib/alexandria/import_library.rb +14 -18
  34. data/lib/alexandria/import_library_csv.rb +12 -30
  35. data/lib/alexandria/models/book.rb +7 -9
  36. data/lib/alexandria/models/library.rb +44 -44
  37. data/lib/alexandria/net.rb +1 -1
  38. data/lib/alexandria/preferences.rb +12 -57
  39. data/lib/alexandria/scanners.rb +10 -6
  40. data/lib/alexandria/scanners/cuecat.rb +2 -2
  41. data/lib/alexandria/smart_library.rb +12 -12
  42. data/lib/alexandria/ui.rb +5 -2
  43. data/lib/alexandria/ui/callbacks.rb +106 -65
  44. data/lib/alexandria/ui/completion_models.rb +55 -51
  45. data/lib/alexandria/ui/dialogs/about_dialog.rb +1 -1
  46. data/lib/alexandria/ui/dialogs/acquire_dialog.rb +25 -51
  47. data/lib/alexandria/ui/dialogs/alert_dialog.rb +13 -11
  48. data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +2 -2
  49. data/lib/alexandria/ui/dialogs/barcode_animation.rb +39 -23
  50. data/lib/alexandria/ui/dialogs/book_properties_dialog.rb +16 -21
  51. data/lib/alexandria/ui/dialogs/book_properties_dialog_base.rb +23 -24
  52. data/lib/alexandria/ui/dialogs/export_dialog.rb +46 -45
  53. data/lib/alexandria/ui/dialogs/import_dialog.rb +26 -35
  54. data/lib/alexandria/ui/dialogs/misc_dialogs.rb +11 -11
  55. data/lib/alexandria/ui/dialogs/new_book_dialog.rb +47 -59
  56. data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +14 -13
  57. data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +12 -11
  58. data/lib/alexandria/ui/dialogs/preferences_dialog.rb +37 -43
  59. data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +9 -8
  60. data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +47 -53
  61. data/lib/alexandria/ui/dndable.rb +5 -4
  62. data/lib/alexandria/ui/icons.rb +19 -19
  63. data/lib/alexandria/ui/iconview.rb +7 -12
  64. data/lib/alexandria/ui/iconview_tooltips.rb +22 -109
  65. data/lib/alexandria/ui/init.rb +7 -15
  66. data/lib/alexandria/ui/libraries_combo.rb +54 -48
  67. data/lib/alexandria/ui/listview.rb +30 -85
  68. data/lib/alexandria/ui/multi_drag_treeview.rb +110 -107
  69. data/lib/alexandria/ui/sidepane.rb +23 -25
  70. data/lib/alexandria/ui/sound.rb +18 -27
  71. data/lib/alexandria/ui/ui_manager.rb +126 -204
  72. data/lib/alexandria/undo_manager.rb +2 -2
  73. data/lib/alexandria/version.rb +4 -4
  74. data/spec/alexandria/book_providers_spec.rb +7 -4
  75. data/spec/alexandria/library_spec.rb +13 -16
  76. data/spec/alexandria/scanners/cuecat_spec.rb +1 -2
  77. data/spec/alexandria/ui/dialogs_spec.rb +5 -1
  78. data/spec/alexandria/ui/main_app_spec.rb +3 -3
  79. data/{lib/alexandria/utils.rb → spec/alexandria/ui/sound_spec.rb} +6 -11
  80. data/spec/alexandria/ui/ui_utilities_spec.rb +3 -3
  81. data/spec/spec_helper.rb +2 -2
  82. data/util/rake/fileinstall.rb +17 -33
  83. data/util/rake/gettextgenerate.rb +2 -4
  84. data/util/rake/omfgenerate.rb +1 -3
  85. metadata +23 -11
  86. data/lib/alexandria/ui/gtk_thread_help.rb +0 -89
@@ -26,17 +26,17 @@ module Alexandria
26
26
  _("The book '%s' already exists in '%s'. Would you like " \
27
27
  'to replace it?') % [book.title, library.name],
28
28
  Gtk::Stock::DIALOG_QUESTION,
29
- [[_('_Skip'), Gtk::Dialog::RESPONSE_CANCEL],
30
- [_('_Replace'), Gtk::Dialog::RESPONSE_OK]],
29
+ [[_('_Skip'), :cancel],
30
+ [_('_Replace'), :ok]],
31
31
  _('If you replace the existing book, its contents will ' \
32
32
  'be overwritten.'))
33
- self.default_response = Gtk::Dialog::RESPONSE_CANCEL
34
- show_all and @response = run
33
+ self.default_response = Gtk::ResponseType::CANCEL
34
+ show_all && (@response = run)
35
35
  destroy
36
36
  end
37
37
 
38
38
  def replace?
39
- @response == Gtk::Dialog::RESPONSE_OK
39
+ @response == :ok
40
40
  end
41
41
  end
42
42
 
@@ -48,7 +48,7 @@ module Alexandria
48
48
  # Deleting a library.
49
49
  if books.nil?
50
50
  message = _("Are you sure you want to delete '%s'?") % library.name
51
- description = if library.is_a?(SmartLibrary) or library.empty?
51
+ description = if library.is_a?(SmartLibrary) || library.empty?
52
52
  nil
53
53
  else
54
54
  n_('If you continue, %d book will be deleted.',
@@ -68,17 +68,17 @@ module Alexandria
68
68
  end
69
69
 
70
70
  super(parent, message, Gtk::Stock::DIALOG_QUESTION,
71
- [[Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
72
- [Gtk::Stock::DELETE, Gtk::Dialog::RESPONSE_OK]],
71
+ [[Gtk::Stock::CANCEL, :cancel],
72
+ [Gtk::Stock::DELETE, :ok]],
73
73
  description)
74
74
 
75
- self.default_response = Gtk::Dialog::RESPONSE_CANCEL
76
- show_all and @response = run
75
+ self.default_response = Gtk::ResponseType::CANCEL
76
+ show_all && (@response = run)
77
77
  destroy
78
78
  end
79
79
 
80
80
  def ok?
81
- @response == Gtk::Dialog::RESPONSE_OK
81
+ @response == :ok
82
82
  end
83
83
  end
84
84
  end
@@ -1,5 +1,5 @@
1
1
  # Copyright (C) 2004-2006 Laurent Sansonetti
2
- # Copyright (C) 2011 Matijs van Zuijlen
2
+ # Copyright (C) 2011, 2015, 2016 Matijs van Zuijlen
3
3
  #
4
4
  # Alexandria is free software; you can redistribute it and/or
5
5
  # modify it under the terms of the GNU General Public License as
@@ -30,18 +30,18 @@ module Alexandria
30
30
  def initialize(parent, book)
31
31
  super(parent, _("Invalid ISBN '%s'") % book.isbn,
32
32
  Gtk::Stock::DIALOG_QUESTION,
33
- [[Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
34
- [_('_Keep'), Gtk::Dialog::RESPONSE_OK]],
33
+ [[Gtk::Stock::CANCEL, :cancel],
34
+ [_('_Keep'), :ok]],
35
35
  _("The book titled '%s' has an invalid ISBN, but still " \
36
36
  'exists in the providers libraries. Do you want to ' \
37
- 'keep the book but change the ISBN or cancel the add?') % book.title)
38
- self.default_response = Gtk::Dialog::RESPONSE_OK
39
- show_all and @response = run
37
+ 'keep the book but change the ISBN or cancel the addition?') % book.title)
38
+ self.default_response = Gtk::ResponseType::OK
39
+ show_all && (@response = run)
40
40
  destroy
41
41
  end
42
42
 
43
43
  def keep?
44
- @response == Gtk::Dialog::RESPONSE_OK
44
+ @response == :ok
45
45
  end
46
46
  end
47
47
 
@@ -50,6 +50,7 @@ module Alexandria
50
50
  include GetText
51
51
  extend GetText
52
52
  GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
53
+ @@last_criterion_was_not_isbn = false
53
54
 
54
55
  def initialize(parent, selected_library = nil, &block)
55
56
  super('new_book_dialog__builder.glade', widget_names)
@@ -82,7 +83,7 @@ module Alexandria
82
83
  @selected_library)
83
84
 
84
85
  @treeview_results.model = Gtk::ListStore.new(String, String,
85
- Gdk::Pixbuf)
86
+ GdkPixbuf::Pixbuf)
86
87
  @treeview_results.selection.mode = Gtk::SELECTION_MULTIPLE
87
88
  @treeview_results.selection.signal_connect('changed') do
88
89
  @button_add.sensitive = true
@@ -111,12 +112,7 @@ module Alexandria
111
112
 
112
113
  # Re-select the last selected criterion.
113
114
  # TODO let's do this from a Gconf setting instead, maybe?
114
- begin
115
- @title_radiobutton.active = @@last_criterion_was_not_isbn
116
- rescue NameError
117
- log.debug { 'initialize @@last_criterion_was_not_isbn as false' }
118
- @@last_criterion_was_not_isbn = false
119
- end
115
+ @title_radiobutton.active = @@last_criterion_was_not_isbn
120
116
 
121
117
  if @@last_criterion_was_not_isbn
122
118
  @entry_search.grab_focus
@@ -141,18 +137,18 @@ module Alexandria
141
137
  # When item is first toggled to "Search" the entry_search
142
138
  # field was unselectable. One used to have to click the dialog
143
139
  # title bar to be able to focus it again. Putting the GUI
144
- # modifications in an Gtk.idle_add block fixed the problem.
140
+ # modifications in an GLib::Idle.add block fixed the problem.
145
141
 
146
142
  is_isbn = item == @isbn_radiobutton
147
143
  if is_isbn
148
- Gtk.idle_add do
144
+ GLib::Idle.add do
149
145
  @latest_size = @new_book_dialog.size
150
146
  @new_book_dialog.resizable = false
151
147
  @entry_isbn.grab_focus
152
148
  false
153
149
  end
154
150
  else
155
- Gtk.idle_add do
151
+ GLib::Idle.add do
156
152
  @new_book_dialog.resizable = true
157
153
  @new_book_dialog.resize(*@latest_size) unless @latest_size.nil?
158
154
  @entry_search.grab_focus
@@ -214,13 +210,13 @@ module Alexandria
214
210
  end
215
211
  end
216
212
 
217
- Gtk.timeout_add(100) do
213
+ GLib::Timeout.add(100) do
218
214
  if @image_error
219
215
  image_error_dialog(@image_error)
220
216
  else
221
217
  @images.each_pair do |key, value|
222
218
  begin
223
- loader = Gdk::PixbufLoader.new
219
+ loader = GdkPixbuf::PixbufLoader.new
224
220
  loader.last_write(value)
225
221
  pixbuf = loader.pixbuf
226
222
 
@@ -262,7 +258,7 @@ module Alexandria
262
258
  end
263
259
 
264
260
  # @progressbar.show
265
- # progress_pulsing = Gtk.timeout_add(100) do
261
+ # progress_pulsing = GLib::Timeout.add(100) do
266
262
  # if @destroyed
267
263
  # false
268
264
  # else
@@ -285,7 +281,7 @@ module Alexandria
285
281
  @image_thread.kill if @image_thread
286
282
 
287
283
  notify_start_add_by_isbn
288
- Gtk.idle_add do
284
+ GLib::Idle.add do
289
285
  @find_thread = Thread.new do
290
286
  log.info { "New @find_thread #{Thread.current}" }
291
287
  begin
@@ -303,7 +299,7 @@ module Alexandria
303
299
  false
304
300
  end
305
301
 
306
- Gtk.timeout_add(100) do
302
+ GLib::Timeout.add(100) do
307
303
  # This block copies results into the tree view, or shows an
308
304
  # error if the search failed.
309
305
 
@@ -319,8 +315,8 @@ module Alexandria
319
315
  s = _('%s, by %s') % [book.title,
320
316
  book.authors.join(', ')]
321
317
  similar_books = @results.find { |book2, _cover2|
322
- book.title == book2.title and
323
- book.authors == book2.authors
318
+ (book.title == book2.title) &&
319
+ (book.authors == book2.authors)
324
320
  }
325
321
  if similar_books.length > 1
326
322
  s += " (#{book.edition}, #{book.publisher})"
@@ -340,19 +336,19 @@ module Alexandria
340
336
  log.info { "@find_thread (#{@find_thread}) asleep now." }
341
337
  # Not really async now.
342
338
  get_images_async
343
- false # continue == false if you get to here. Stop timeout_add.
339
+ false # continue == false if you get to here. Stop timeout.
344
340
  end
345
341
  else
346
342
  # Stop if the book find thread has stopped.
347
343
  @find_thread.alive?
348
344
  end
349
345
  # continue == false if @find_error OR if results are returned
350
- # timeout_add ends if continue is false!
346
+ # timeout ends if continue is false!
351
347
 
352
348
  unless continue
353
349
  unless @find_thread.alive? # This happens after find_thread is done
354
350
  unless @destroyed
355
- # Gtk.timeout_remove(progress_pulsing)
351
+ # GLib::Source.remove(progress_pulsing)
356
352
  # @progressbar.hide
357
353
  notify_end_add_by_isbn
358
354
  @button_add.sensitive = false
@@ -360,7 +356,7 @@ module Alexandria
360
356
  end
361
357
  end
362
358
 
363
- continue # timeout_add loop condition
359
+ continue # timeout loop condition
364
360
  end
365
361
  end
366
362
 
@@ -378,9 +374,7 @@ module Alexandria
378
374
 
379
375
  def on_results_button_press_event(_widget, event)
380
376
  # double left click
381
- if event.event_type == Gdk::Event::BUTTON2_PRESS and
382
- event.button == 1
383
-
377
+ if (event.event_type == :'2button_press') && (event.button == 1)
384
378
  on_add
385
379
  end
386
380
  end
@@ -397,7 +391,7 @@ module Alexandria
397
391
  assert_not_exist(library, @entry_isbn.text)
398
392
  @button_add.sensitive = false
399
393
  notify_start_add_by_isbn
400
- Gtk.idle_add do
394
+ GLib::Idle.add do
401
395
  @find_thread = Thread.new do
402
396
  log.info { "New @find_thread #{Thread.current}" }
403
397
  begin
@@ -420,11 +414,7 @@ module Alexandria
420
414
  else
421
415
  post_addition([], library, is_new)
422
416
  end
423
- rescue => e
424
- unless e.is_a? Alexandria::BookProviders::NoResultsError
425
- puts e.message
426
- puts e.backtrace.join("\n> ")
427
- end
417
+ rescue Alexandria::BookProviders::NoResultsError => e
428
418
  @find_error = e.message
429
419
  @button_add.sensitive = true
430
420
  notify_end_add_by_isbn
@@ -481,7 +471,7 @@ module Alexandria
481
471
  @block.call(books, library, is_new_library)
482
472
 
483
473
  if @keep_open.active?
484
- # TODO reset and clear fields
474
+ # TODO: reset and clear fields
485
475
  if @@last_criterion_was_not_isbn
486
476
  @entry_search.select_region(0, -1) # select all, ready to delete
487
477
  @treeview_results.model.clear
@@ -536,7 +526,7 @@ module Alexandria
536
526
  def notify_start_add_by_isbn
537
527
  main_progress_bar = MainApp.instance.appbar.children.first
538
528
  main_progress_bar.visible = true
539
- @progress_pulsing = Gtk.timeout_add(100) do
529
+ @progress_pulsing = GLib::Timeout.add(100) do
540
530
  if @destroyed
541
531
  false
542
532
  else
@@ -548,33 +538,31 @@ module Alexandria
548
538
 
549
539
  def notify_end_add_by_isbn
550
540
  MainApp.instance.appbar.children.first.visible = false
551
- Gtk.timeout_remove(@progress_pulsing)
541
+ if @progress_pulsing
542
+ GLib::Source.remove(@progress_pulsing)
543
+ @progress_pulsing = nil
544
+ end
552
545
  end
553
546
 
554
547
  def update(status, provider)
555
- Gtk.queue do
556
- messages = {
557
- searching: _("Searching Provider '%s'..."),
558
- error: _("Error while Searching Provider '%s'"),
559
- not_found: _("Not Found at Provider '%s'"),
560
- found: _("Found at Provider '%s'")
561
- }
562
- message = messages[status] % provider
563
- log.debug { "update message : #{message}" }
564
-
565
- # @parent.appbar.status = message
566
- MainApp.instance.appbar.status = message # HACKish
567
- # false
568
- end
548
+ messages = {
549
+ searching: _("Searching Provider '%s'..."),
550
+ error: _("Error while Searching Provider '%s'"),
551
+ not_found: _("Not Found at Provider '%s'"),
552
+ found: _("Found at Provider '%s'")
553
+ }
554
+ message = messages[status] % provider
555
+ log.debug { "update message : #{message}" }
556
+ MainApp.instance.ui_manager.set_status_label(message)
569
557
  end
570
558
 
571
559
  def on_focus
572
- if @isbn_radiobutton.active? and @entry_isbn.text.strip.empty?
560
+ if @isbn_radiobutton.active? && @entry_isbn.text.strip.empty?
573
561
  clipboard = Gtk::Clipboard.get(Gdk::Selection::CLIPBOARD)
574
562
  if (text = clipboard.wait_for_text)
575
- if Library.valid_isbn?(text) or Library.valid_ean?(text) or
563
+ if Library.valid_isbn?(text) || Library.valid_ean?(text) ||
576
564
  Library.valid_upc?(text)
577
- Gtk.idle_add do
565
+ GLib::Idle.add do
578
566
  @entry_isbn.text = text
579
567
  @entry_isbn.grab_focus
580
568
  @entry_isbn.select_region(0, -1) # select all...
@@ -592,8 +580,8 @@ module Alexandria
592
580
  end
593
581
 
594
582
  def on_clicked(widget, event)
595
- if event.event_type == Gdk::Event::BUTTON_PRESS and
596
- event.button == 1
583
+ if (event.event_type == :button_press) &&
584
+ (event.button == 1)
597
585
 
598
586
  radio, target_widget, box2, box3 = case widget
599
587
  when @eventbox_entry_search
@@ -27,7 +27,8 @@ module Alexandria
27
27
  def initialize(parent, library, &on_add_cb)
28
28
  super(parent, TMP_COVER_FILE)
29
29
 
30
- @library, @on_add_cb = library, on_add_cb
30
+ @library = library
31
+ @on_add_cb = on_add_cb
31
32
  FileUtils.rm_f(TMP_COVER_FILE)
32
33
 
33
34
  cancel_button = Gtk::Button.new(Gtk::Stock::CANCEL)
@@ -76,40 +77,40 @@ module Alexandria
76
77
 
77
78
  def on_add
78
79
  if (title = @entry_title.text.strip).empty?
79
- raise AddError.new(_('A title must be provided.'))
80
+ raise AddError, _('A title must be provided.')
80
81
  end
81
82
  isbn = nil
82
83
  if @entry_isbn.text != ''
83
84
  ary = @library.select { |book|
84
85
  book.ident == @entry_isbn.text
85
86
  }
86
- raise AddError.new(_('The EAN/ISBN you provided is ' \
87
- 'already used in this library.')) unless ary.empty?
87
+ raise AddError, _('The EAN/ISBN you provided is ' \
88
+ 'already used in this library.') unless ary.empty?
88
89
  isbn = begin
89
90
  Library.canonicalise_isbn(@entry_isbn.text)
90
91
  rescue Alexandria::Library::InvalidISBNError
91
- raise AddError.new(_("Couldn't validate the " \
92
+ raise AddError, _("Couldn't validate the " \
92
93
  'EAN/ISBN you provided. Make ' \
93
94
  'sure it is written correcty, ' \
94
- 'and try again.'))
95
+ 'and try again.')
95
96
  end
96
97
  end
97
98
  if (publisher = @entry_publisher.text.strip).empty?
98
- raise AddError.new(_('A publisher must be provided.'))
99
+ raise AddError, _('A publisher must be provided.')
99
100
  end
100
101
  publishing_year = @entry_publish_date.text.to_i
101
- # TODO Get rid of this silly requirement
102
+ # TODO: Get rid of this silly requirement
102
103
  if (edition = @entry_edition.text.strip).empty?
103
- raise AddError.new(_('A binding must be provided.'))
104
+ raise AddError, _('A binding must be provided.')
104
105
  end
105
106
  authors = []
106
107
  @treeview_authors.model.each { |_m, _p, i| authors << i[0] }
107
108
  if authors.empty?
108
- raise AddError.new(_('At least one author must be ' \
109
- 'provided.'))
109
+ raise AddError, _('At least one author must be ' \
110
+ 'provided.')
110
111
  end
111
112
  book = Book.new(title, authors, isbn, publisher,
112
- publishing_year == 0 ? nil : publishing_year,
113
+ publishing_year.zero? ? nil : publishing_year,
113
114
  edition)
114
115
  book.rating = @current_rating
115
116
  book.notes = @textview_notes.buffer.text
@@ -123,7 +124,7 @@ module Alexandria
123
124
  book.tags = @entry_tags.text.split
124
125
  @library << book
125
126
  @library.save(book)
126
- if File.exist?(TMP_COVER_FILE) and (!@delete_cover_file)
127
+ if File.exist?(TMP_COVER_FILE) && !@delete_cover_file
127
128
  FileUtils.cp(TMP_COVER_FILE, @library.cover(book))
128
129
  end
129
130
  @on_add_cb.call(book)
@@ -1,5 +1,5 @@
1
1
  # Copyright (C) 2004-2006 Laurent Sansonetti
2
- # Copyright (C) 2015 Matijs van Zuijlen
2
+ # Copyright (C) 2015, 2016 Matijs van Zuijlen
3
3
  #
4
4
  # Alexandria is free software; you can redistribute it and/or
5
5
  # modify it under the terms of the GNU General Public License as
@@ -22,24 +22,25 @@ module Alexandria
22
22
  include GetText
23
23
  GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
24
24
 
25
- def initialize(parent, &block)
25
+ def initialize(parent)
26
26
  super(parent)
27
27
 
28
- add_buttons([Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
29
- [Gtk::Stock::NEW, Gtk::Dialog::RESPONSE_OK])
28
+ add_buttons([Gtk::Stock::CANCEL, :cancel],
29
+ [Gtk::Stock::NEW, :ok])
30
30
 
31
31
  self.title = _('New Smart Library')
32
- self.default_response = Gtk::Dialog::RESPONSE_CANCEL
32
+ # FIXME: Should accept just :cancel
33
+ self.default_response = Gtk::ResponseType::CANCEL
33
34
 
34
35
  show_all
35
36
  insert_new_rule
36
37
 
37
- while (response = run) != Gtk::Dialog::RESPONSE_CANCEL and
38
- response != Gtk::Dialog::RESPONSE_DELETE_EVENT
38
+ while ((response = run) != :cancel) &&
39
+ (response != :delete_event)
39
40
 
40
- if response == Gtk::Dialog::RESPONSE_HELP
41
+ if response == :help
41
42
  Alexandria::UI.display_help(self, 'new-smart-library')
42
- elsif response == Gtk::Dialog::RESPONSE_OK
43
+ elsif response == :ok
43
44
  if user_confirms_possible_weirdnesses_before_saving?
44
45
  rules = smart_library_rules
45
46
  basename = smart_library_base_name(rules) || _('Smart Library')
@@ -49,7 +50,7 @@ module Alexandria
49
50
  library = SmartLibrary.new(name,
50
51
  rules,
51
52
  predicate_operator_rule)
52
- block.call(library)
53
+ yield(library)
53
54
  break
54
55
  end
55
56
  end
@@ -63,7 +64,7 @@ module Alexandria
63
64
  def smart_library_base_name(rules)
64
65
  if rules.length == 1
65
66
  value = rules.first.value
66
- if value.is_a?(String) and !value.strip.empty?
67
+ if value.is_a?(String) && !value.strip.empty?
67
68
  return value
68
69
  end
69
70
  end