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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +34 -30
- data/.rubocop_todo.yml +139 -54
- data/CHANGELOG.md +10 -0
- data/Gemfile +1 -0
- data/Rakefile +10 -11
- data/alexandria-book-collection-manager.gemspec +3 -2
- data/bin/alexandria +1 -1
- data/lib/alexandria.rb +3 -6
- data/lib/alexandria/about.rb +9 -9
- data/lib/alexandria/book_providers.rb +12 -12
- data/lib/alexandria/book_providers/adlibris.rb +14 -18
- data/lib/alexandria/book_providers/amazon_aws.rb +17 -31
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +5 -6
- data/lib/alexandria/book_providers/barnes_and_noble.rb +51 -76
- data/lib/alexandria/book_providers/bol_it.rb +12 -12
- data/lib/alexandria/book_providers/deastore.rb +27 -31
- data/lib/alexandria/book_providers/douban.rb +9 -13
- data/lib/alexandria/book_providers/ibs_it.rb +10 -10
- data/lib/alexandria/book_providers/mcu.rb +12 -18
- data/lib/alexandria/book_providers/proxis.rb +14 -22
- data/lib/alexandria/book_providers/pseudomarc.rb +8 -18
- data/lib/alexandria/book_providers/renaud.rb +16 -16
- data/lib/alexandria/book_providers/siciliano.rb +25 -38
- data/lib/alexandria/book_providers/thalia.rb +13 -16
- data/lib/alexandria/book_providers/webster_it.rb +14 -18
- data/lib/alexandria/book_providers/worldcat.rb +21 -25
- data/lib/alexandria/book_providers/z3950.rb +19 -23
- data/lib/alexandria/config.rb +2 -2
- data/lib/alexandria/execution_queue.rb +3 -1
- data/lib/alexandria/export_library.rb +19 -22
- data/lib/alexandria/import_library.rb +14 -18
- data/lib/alexandria/import_library_csv.rb +12 -30
- data/lib/alexandria/models/book.rb +7 -9
- data/lib/alexandria/models/library.rb +44 -44
- data/lib/alexandria/net.rb +1 -1
- data/lib/alexandria/preferences.rb +12 -57
- data/lib/alexandria/scanners.rb +10 -6
- data/lib/alexandria/scanners/cuecat.rb +2 -2
- data/lib/alexandria/smart_library.rb +12 -12
- data/lib/alexandria/ui.rb +5 -2
- data/lib/alexandria/ui/callbacks.rb +106 -65
- data/lib/alexandria/ui/completion_models.rb +55 -51
- data/lib/alexandria/ui/dialogs/about_dialog.rb +1 -1
- data/lib/alexandria/ui/dialogs/acquire_dialog.rb +25 -51
- data/lib/alexandria/ui/dialogs/alert_dialog.rb +13 -11
- data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +2 -2
- data/lib/alexandria/ui/dialogs/barcode_animation.rb +39 -23
- data/lib/alexandria/ui/dialogs/book_properties_dialog.rb +16 -21
- data/lib/alexandria/ui/dialogs/book_properties_dialog_base.rb +23 -24
- data/lib/alexandria/ui/dialogs/export_dialog.rb +46 -45
- data/lib/alexandria/ui/dialogs/import_dialog.rb +26 -35
- data/lib/alexandria/ui/dialogs/misc_dialogs.rb +11 -11
- data/lib/alexandria/ui/dialogs/new_book_dialog.rb +47 -59
- data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +14 -13
- data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +12 -11
- data/lib/alexandria/ui/dialogs/preferences_dialog.rb +37 -43
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +9 -8
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +47 -53
- data/lib/alexandria/ui/dndable.rb +5 -4
- data/lib/alexandria/ui/icons.rb +19 -19
- data/lib/alexandria/ui/iconview.rb +7 -12
- data/lib/alexandria/ui/iconview_tooltips.rb +22 -109
- data/lib/alexandria/ui/init.rb +7 -15
- data/lib/alexandria/ui/libraries_combo.rb +54 -48
- data/lib/alexandria/ui/listview.rb +30 -85
- data/lib/alexandria/ui/multi_drag_treeview.rb +110 -107
- data/lib/alexandria/ui/sidepane.rb +23 -25
- data/lib/alexandria/ui/sound.rb +18 -27
- data/lib/alexandria/ui/ui_manager.rb +126 -204
- data/lib/alexandria/undo_manager.rb +2 -2
- data/lib/alexandria/version.rb +4 -4
- data/spec/alexandria/book_providers_spec.rb +7 -4
- data/spec/alexandria/library_spec.rb +13 -16
- data/spec/alexandria/scanners/cuecat_spec.rb +1 -2
- data/spec/alexandria/ui/dialogs_spec.rb +5 -1
- data/spec/alexandria/ui/main_app_spec.rb +3 -3
- data/{lib/alexandria/utils.rb → spec/alexandria/ui/sound_spec.rb} +6 -11
- data/spec/alexandria/ui/ui_utilities_spec.rb +3 -3
- data/spec/spec_helper.rb +2 -2
- data/util/rake/fileinstall.rb +17 -33
- data/util/rake/gettextgenerate.rb +2 -4
- data/util/rake/omfgenerate.rb +1 -3
- metadata +23 -11
- 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'),
|
30
|
-
[_('_Replace'),
|
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::
|
34
|
-
show_all
|
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 ==
|
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)
|
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,
|
72
|
-
[Gtk::Stock::DELETE,
|
71
|
+
[[Gtk::Stock::CANCEL, :cancel],
|
72
|
+
[Gtk::Stock::DELETE, :ok]],
|
73
73
|
description)
|
74
74
|
|
75
|
-
self.default_response = Gtk::
|
76
|
-
show_all
|
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 ==
|
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,
|
34
|
-
[_('_Keep'),
|
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
|
38
|
-
self.default_response = Gtk::
|
39
|
-
show_all
|
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 ==
|
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
|
-
|
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
|
-
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
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 =
|
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 =
|
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
|
-
|
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
|
-
|
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
|
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
|
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
|
-
#
|
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
|
-
#
|
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 #
|
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 ==
|
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
|
-
|
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 =
|
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
|
-
|
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
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
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?
|
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)
|
563
|
+
if Library.valid_isbn?(text) || Library.valid_ean?(text) ||
|
576
564
|
Library.valid_upc?(text)
|
577
|
-
|
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 ==
|
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
|
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
|
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
|
87
|
-
'already used in this library.')
|
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
|
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
|
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
|
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
|
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
|
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)
|
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
|
25
|
+
def initialize(parent)
|
26
26
|
super(parent)
|
27
27
|
|
28
|
-
add_buttons([Gtk::Stock::CANCEL,
|
29
|
-
[Gtk::Stock::NEW,
|
28
|
+
add_buttons([Gtk::Stock::CANCEL, :cancel],
|
29
|
+
[Gtk::Stock::NEW, :ok])
|
30
30
|
|
31
31
|
self.title = _('New Smart Library')
|
32
|
-
|
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) !=
|
38
|
-
response !=
|
38
|
+
while ((response = run) != :cancel) &&
|
39
|
+
(response != :delete_event)
|
39
40
|
|
40
|
-
if response ==
|
41
|
+
if response == :help
|
41
42
|
Alexandria::UI.display_help(self, 'new-smart-library')
|
42
|
-
elsif response ==
|
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
|
-
|
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)
|
67
|
+
if value.is_a?(String) && !value.strip.empty?
|
67
68
|
return value
|
68
69
|
end
|
69
70
|
end
|