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
@@ -1,4 +1,5 @@
|
|
1
1
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
|
+
# Copyright (C) 2016 Matijs van Zuijlen
|
2
3
|
#
|
3
4
|
# Alexandria is free software; you can redistribute it and/or
|
4
5
|
# modify it under the terms of the GNU General Public License as
|
@@ -27,24 +28,24 @@ module Alexandria
|
|
27
28
|
super(parent, library.cover(book))
|
28
29
|
puts 'Initializing Book Properties Dialog...' if $DEBUG
|
29
30
|
|
30
|
-
cancel_button = Gtk::Button.new(Gtk::Stock::CANCEL)
|
31
|
+
cancel_button = Gtk::Button.new(stock_id: Gtk::Stock::CANCEL)
|
31
32
|
cancel_button.signal_connect('clicked') { on_cancel }
|
32
33
|
cancel_button.show
|
33
34
|
@button_box << cancel_button
|
34
35
|
|
35
|
-
close_button = Gtk::Button.new(Gtk::Stock::SAVE)
|
36
|
+
close_button = Gtk::Button.new(stock_id: Gtk::Stock::SAVE)
|
36
37
|
close_button.signal_connect('clicked') { on_close }
|
37
38
|
close_button.show
|
38
39
|
@button_box << close_button
|
39
40
|
|
40
|
-
help_button = Gtk::Button.new(Gtk::Stock::HELP)
|
41
|
+
help_button = Gtk::Button.new(stock_id: Gtk::Stock::HELP)
|
41
42
|
help_button.signal_connect('clicked') { on_help }
|
42
43
|
help_button.show
|
43
44
|
@button_box << help_button
|
44
45
|
@button_box.set_child_secondary(help_button, true)
|
45
46
|
|
46
47
|
@entry_title.text = @book_properties_dialog.title = book.title
|
47
|
-
@entry_isbn.text = (book.isbn
|
48
|
+
@entry_isbn.text = (book.isbn || '')
|
48
49
|
@entry_publisher.text = book.publisher
|
49
50
|
@entry_publish_date.text = book.publishing_year.to_s
|
50
51
|
@entry_publish_date.signal_connect('focus-out-event') do
|
@@ -53,7 +54,7 @@ module Alexandria
|
|
53
54
|
false
|
54
55
|
else
|
55
56
|
year = text.to_i
|
56
|
-
if year
|
57
|
+
if year.zero? || year > (Time.now.year + 10) || year < 10
|
57
58
|
@entry_publish_date.text = ''
|
58
59
|
@entry_publish_date.grab_focus
|
59
60
|
true
|
@@ -75,15 +76,16 @@ module Alexandria
|
|
75
76
|
end
|
76
77
|
|
77
78
|
buffer = Gtk::TextBuffer.new
|
78
|
-
buffer.text = (book.notes
|
79
|
+
buffer.text = (book.notes || '')
|
79
80
|
@textview_notes.buffer = buffer
|
80
81
|
|
81
|
-
@library
|
82
|
+
@library = library
|
83
|
+
@book = book
|
82
84
|
self.cover = Icons.cover(library, book)
|
83
|
-
self.rating = (book.rating
|
85
|
+
self.rating = (book.rating || Book::DEFAULT_RATING)
|
84
86
|
|
85
87
|
if (@checkbutton_loaned.active = book.loaned?)
|
86
|
-
@entry_loaned_to.text = (book.loaned_to
|
88
|
+
@entry_loaned_to.text = (book.loaned_to || '')
|
87
89
|
self.loaned_since = book.loaned_since
|
88
90
|
@date_loaned_since.sensitive = true
|
89
91
|
else
|
@@ -117,7 +119,7 @@ module Alexandria
|
|
117
119
|
@book.isbn = ''
|
118
120
|
else
|
119
121
|
ary = @library.select { |book| book.ident == @entry_isbn.text }
|
120
|
-
unless ary.empty?
|
122
|
+
unless ary.empty? || ((ary.length == 1) && (ary.first == @book))
|
121
123
|
ErrorDialog.new(@parent,
|
122
124
|
_("Couldn't modify the book"),
|
123
125
|
_('The EAN/ISBN you provided is already ' \
|
@@ -138,7 +140,7 @@ module Alexandria
|
|
138
140
|
@book.title = @entry_title.text
|
139
141
|
@book.publisher = @entry_publisher.text
|
140
142
|
year = @entry_publish_date.text.to_i
|
141
|
-
@book.publishing_year = year
|
143
|
+
@book.publishing_year = year.zero? ? nil : year
|
142
144
|
@book.edition = @entry_edition.text
|
143
145
|
@book.authors = []
|
144
146
|
@treeview_authors.model.each { |_m, _p, i| @book.authors << i[0] }
|
@@ -164,13 +166,8 @@ module Alexandria
|
|
164
166
|
if redd_date.strip.empty?
|
165
167
|
@book.redd_when = nil
|
166
168
|
else
|
167
|
-
|
168
|
-
|
169
|
-
@book.redd_when = t
|
170
|
-
rescue => err
|
171
|
-
puts err
|
172
|
-
puts err.backtrace
|
173
|
-
end
|
169
|
+
t = parse_date(redd_date)
|
170
|
+
@book.redd_when = t
|
174
171
|
end
|
175
172
|
else
|
176
173
|
@book.redd_when = nil
|
@@ -179,9 +176,7 @@ module Alexandria
|
|
179
176
|
@book.want = @checkbutton_want.active?
|
180
177
|
@book.tags = @entry_tags.text.split(',') # tags are comma separated
|
181
178
|
|
182
|
-
if @delete_cover_file
|
183
|
-
FileUtils.rm_f(@cover_file)
|
184
|
-
end
|
179
|
+
FileUtils.rm_f(@cover_file) if @delete_cover_file
|
185
180
|
|
186
181
|
if @original_cover_file
|
187
182
|
FileUtils.rm_f(@original_cover_file)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
|
-
# Copyright (C) 2011, 2014 Matijs van Zuijlen
|
2
|
+
# Copyright (C) 2011, 2014, 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
|
@@ -25,7 +25,7 @@ module Alexandria
|
|
25
25
|
extend GetText
|
26
26
|
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
|
27
27
|
|
28
|
-
COVER_MAXWIDTH = 140
|
28
|
+
COVER_MAXWIDTH = 140 # pixels
|
29
29
|
|
30
30
|
COVER_ABSOLUTE_MAXHEIGHT = 250 # pixels, above this we scale down...
|
31
31
|
|
@@ -33,7 +33,8 @@ module Alexandria
|
|
33
33
|
super('book_properties_dialog__builder.glade', widget_names)
|
34
34
|
@setup_finished = false
|
35
35
|
@book_properties_dialog.transient_for = parent
|
36
|
-
@parent
|
36
|
+
@parent = parent
|
37
|
+
@cover_file = cover_file
|
37
38
|
@original_cover_file = nil
|
38
39
|
@delete_cover_file = false # fixing bug #16707
|
39
40
|
|
@@ -46,7 +47,7 @@ module Alexandria
|
|
46
47
|
@entry_tags.complete_tags
|
47
48
|
|
48
49
|
@treeview_authors.model = Gtk::ListStore.new(String, TrueClass)
|
49
|
-
@treeview_authors.selection.mode =
|
50
|
+
@treeview_authors.selection.mode = :single
|
50
51
|
renderer = Gtk::CellRendererText.new
|
51
52
|
renderer.signal_connect('edited') do |_cell, path_string, new_text|
|
52
53
|
path = Gtk::TreePath.new(path_string)
|
@@ -62,7 +63,7 @@ module Alexandria
|
|
62
63
|
@treeview_authors.append_column(col)
|
63
64
|
|
64
65
|
setup_calendar_widgets
|
65
|
-
|
66
|
+
GLib::Timeout.add(150) do
|
66
67
|
@setup_finished = true
|
67
68
|
|
68
69
|
false
|
@@ -76,10 +77,10 @@ module Alexandria
|
|
76
77
|
@calendar_popup.decorated = false
|
77
78
|
@calendar_popup.skip_taskbar_hint = true
|
78
79
|
@calendar_popup.skip_pager_hint = true
|
79
|
-
@calendar_popup.events = [
|
80
|
+
@calendar_popup.events = [:focus_change_mask]
|
80
81
|
|
81
82
|
@calendar_popup.set_transient_for(@book_properties_dialog)
|
82
|
-
@calendar_popup.set_type_hint
|
83
|
+
@calendar_popup.set_type_hint :dialog
|
83
84
|
@calendar_popup.name = 'calendar-popup'
|
84
85
|
@calendar_popup.resizable = false
|
85
86
|
# @calendar_popup.border_width = 4
|
@@ -144,7 +145,7 @@ module Alexandria
|
|
144
145
|
@calendar_popup.hide_all
|
145
146
|
@book_properties_dialog.modal = true
|
146
147
|
|
147
|
-
|
148
|
+
GLib::Timeout.add(150) do
|
148
149
|
# If we set @popup_displayed=false immediately, then a click
|
149
150
|
# event on the primary icon of the Entry simultaneous with
|
150
151
|
# the focus-out-event of the Calendar causes the Calendar to
|
@@ -260,11 +261,11 @@ module Alexandria
|
|
260
261
|
end
|
261
262
|
|
262
263
|
def own_toggled
|
263
|
-
if @checkbutton_own.active?
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
264
|
+
@checkbutton_want.inconsistent = if @checkbutton_own.active?
|
265
|
+
true
|
266
|
+
else
|
267
|
+
false
|
268
|
+
end
|
268
269
|
end
|
269
270
|
|
270
271
|
def want_toggled
|
@@ -277,15 +278,15 @@ module Alexandria
|
|
277
278
|
@book_properties_dialog,
|
278
279
|
Gtk::FileChooser::ACTION_OPEN,
|
279
280
|
backend,
|
280
|
-
[_('No Cover'),
|
281
|
-
[Gtk::Stock::CANCEL,
|
282
|
-
[Gtk::Stock::OPEN,
|
281
|
+
[_('No Cover'), :reject],
|
282
|
+
[Gtk::Stock::CANCEL, :cancel],
|
283
|
+
[Gtk::Stock::OPEN, :accept])
|
283
284
|
dialog.current_folder = @@latest_filechooser_directory
|
284
285
|
response = dialog.run
|
285
|
-
if response ==
|
286
|
+
if response == :accept
|
286
287
|
begin
|
287
288
|
@delete_cover_file = false
|
288
|
-
cover =
|
289
|
+
cover = GdkPixbuf::Pixbuf.new(file: dialog.filename)
|
289
290
|
# At this stage the file format is recognized.
|
290
291
|
|
291
292
|
if File.exist?(@cover_file)
|
@@ -310,7 +311,7 @@ module Alexandria
|
|
310
311
|
rescue RuntimeError => e
|
311
312
|
ErrorDialog.new(@book_properties_dialog, e.message)
|
312
313
|
end
|
313
|
-
elsif response ==
|
314
|
+
elsif response == :reject
|
314
315
|
## FileUtils.rm_f(@cover_file) # fixing bug #16707
|
315
316
|
@delete_cover_file = true
|
316
317
|
|
@@ -319,7 +320,7 @@ module Alexandria
|
|
319
320
|
dialog.destroy
|
320
321
|
end
|
321
322
|
|
322
|
-
def on_destroy; end
|
323
|
+
def on_destroy; end # no action by default
|
323
324
|
|
324
325
|
def on_loaned
|
325
326
|
loaned = @checkbutton_loaned.active?
|
@@ -336,9 +337,7 @@ module Alexandria
|
|
336
337
|
matches_regex = regex.match(@date_loaned_since.text)
|
337
338
|
break if matches_regex
|
338
339
|
end
|
339
|
-
unless matches_regex
|
340
|
-
return
|
341
|
-
end
|
340
|
+
return unless matches_regex
|
342
341
|
t = parse_date(@date_loaned_since.text)
|
343
342
|
if t.nil?
|
344
343
|
@label_loaning_duration.label = ''
|
@@ -378,7 +377,7 @@ module Alexandria
|
|
378
377
|
@image_rating4,
|
379
378
|
@image_rating5
|
380
379
|
]
|
381
|
-
raise 'out of range' if rating < 0
|
380
|
+
raise 'out of range' if rating < 0 || rating > images.length
|
382
381
|
images[0..rating - 1].each { |x| x.pixbuf = Icons::STAR_SET }
|
383
382
|
images[rating..-1].each { |x| x.pixbuf = Icons::STAR_UNSET }
|
384
383
|
@current_rating = rating
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
|
-
# Copyright (C) 2014 Matijs van Zuijlen
|
2
|
+
# Copyright (C) 2014, 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
|
@@ -25,17 +25,18 @@ module Alexandria
|
|
25
25
|
def initialize(parent, filename)
|
26
26
|
super(parent, _('File already exists'),
|
27
27
|
Gtk::Stock::DIALOG_QUESTION,
|
28
|
-
[[Gtk::Stock::CANCEL,
|
29
|
-
[_('_Replace'),
|
28
|
+
[[Gtk::Stock::CANCEL, :cancel],
|
29
|
+
[_('_Replace'), :ok]],
|
30
30
|
_("A file named '%s' already exists. Do you want " \
|
31
31
|
'to replace it with the one you are generating?') % filename)
|
32
|
-
|
33
|
-
|
32
|
+
# FIXME: Should accept just :cancel
|
33
|
+
self.default_response = Gtk::ResponseType::CANCEL
|
34
|
+
show_all && (@response = run)
|
34
35
|
destroy
|
35
36
|
end
|
36
37
|
|
37
38
|
def erase?
|
38
|
-
@response ==
|
39
|
+
@response == :ok
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
@@ -48,83 +49,83 @@ module Alexandria
|
|
48
49
|
THEMES = Alexandria::WebTheme.all
|
49
50
|
|
50
51
|
def initialize(parent, library, sort_order)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
[Gtk::Stock::HELP, Gtk::Dialog::RESPONSE_HELP],
|
57
|
-
[Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
|
58
|
-
[_('_Export'), Gtk::Dialog::RESPONSE_ACCEPT])
|
52
|
+
super(title: _("Export '%s'") % library.name,
|
53
|
+
action: :save,
|
54
|
+
buttons: [[Gtk::Stock::HELP, :help],
|
55
|
+
[Gtk::Stock::CANCEL, :cancel],
|
56
|
+
[_('_Export'), :accept]])
|
59
57
|
|
60
58
|
self.transient_for = parent
|
61
59
|
self.current_name = library.name
|
62
60
|
signal_connect('destroy') { hide }
|
63
61
|
|
64
|
-
@parent
|
62
|
+
@parent = parent
|
63
|
+
@library = library
|
64
|
+
@sort_order = sort_order
|
65
65
|
|
66
66
|
preview_image = Gtk::Image.new
|
67
67
|
|
68
|
-
theme_combo = Gtk::
|
68
|
+
theme_combo = Gtk::ComboBoxText.new
|
69
|
+
theme_combo.valign = :center
|
70
|
+
theme_combo.vexpand = false
|
69
71
|
THEMES.each do |theme|
|
70
72
|
theme_combo.append_text(theme.name)
|
71
73
|
end
|
72
74
|
theme_combo.signal_connect('changed') do
|
73
75
|
file = THEMES[theme_combo.active].preview_file
|
74
|
-
preview_image.pixbuf =
|
76
|
+
preview_image.pixbuf = GdkPixbuf::Pixbuf.new(file: file)
|
75
77
|
end
|
76
78
|
theme_combo.active = 0
|
77
|
-
theme_label = Gtk::Label.new(_('_Theme:'), true)
|
79
|
+
theme_label = Gtk::Label.new(_('_Theme:'), use_underline: true)
|
78
80
|
theme_label.xalign = 0
|
79
81
|
theme_label.mnemonic_widget = theme_combo
|
80
82
|
|
81
|
-
types_combo = Gtk::
|
83
|
+
types_combo = Gtk::ComboBoxText.new
|
84
|
+
types_combo.vexpand = false
|
85
|
+
types_combo.valign = :center
|
82
86
|
FORMATS.each do |format|
|
83
87
|
text = format.name + ' ('
|
84
|
-
if format.ext
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
88
|
+
text += if format.ext
|
89
|
+
'*.' + format.ext
|
90
|
+
else
|
91
|
+
_('directory')
|
92
|
+
end
|
89
93
|
text += ')'
|
90
94
|
types_combo.append_text(text)
|
91
95
|
end
|
92
96
|
types_combo.active = 0
|
93
97
|
types_combo.signal_connect('changed') do
|
94
|
-
|
95
|
-
|
96
|
-
FORMATS[types_combo.active].needs_preview?
|
98
|
+
visible = FORMATS[types_combo.active].needs_preview?
|
99
|
+
theme_label.visible = theme_combo.visible = preview_image.visible = visible
|
97
100
|
end
|
98
101
|
types_combo.show
|
99
102
|
|
100
|
-
types_label = Gtk::Label.new(_('Export for_mat:'), true)
|
103
|
+
types_label = Gtk::Label.new(_('Export for_mat:'), use_underline: true)
|
101
104
|
types_label.xalign = 0
|
102
105
|
types_label.mnemonic_widget = types_combo
|
103
106
|
types_label.show
|
104
107
|
|
105
|
-
#
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
response != Gtk::Dialog::RESPONSE_DELETE_EVENT
|
120
|
-
|
121
|
-
if response == Gtk::Dialog::RESPONSE_HELP
|
108
|
+
# TODO: Re-design extra widget layout
|
109
|
+
grid = Gtk::Grid.new
|
110
|
+
grid.column_spacing = 6
|
111
|
+
grid.attach types_label, 0, 0, 1, 1
|
112
|
+
grid.attach types_combo, 1, 0, 1, 1
|
113
|
+
grid.attach theme_label, 0, 1, 1, 1
|
114
|
+
grid.attach theme_combo, 1, 1, 1, 1
|
115
|
+
grid.attach preview_image, 2, 0, 1, 3
|
116
|
+
set_extra_widget grid
|
117
|
+
|
118
|
+
while ((response = run) != :cancel) &&
|
119
|
+
(response != :delete_event)
|
120
|
+
|
121
|
+
if response == :help
|
122
122
|
Alexandria::UI.display_help(self, 'exporting')
|
123
123
|
else
|
124
124
|
begin
|
125
125
|
break if on_export(FORMATS[types_combo.active],
|
126
126
|
THEMES[theme_combo.active])
|
127
127
|
rescue => e
|
128
|
+
raise
|
128
129
|
ErrorDialog.new(self, _('Export failed'), e.message)
|
129
130
|
end
|
130
131
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
|
-
# Copyright (C) 2011 Matijs van Zuijlen
|
2
|
+
# Copyright (C) 2011, 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
|
@@ -36,17 +36,17 @@ module Alexandria
|
|
36
36
|
def initialize(parent, message)
|
37
37
|
super(parent, _('Error while importing'),
|
38
38
|
Gtk::Stock::DIALOG_QUESTION,
|
39
|
-
[[Gtk::Stock::CANCEL,
|
40
|
-
[_('_Continue'),
|
39
|
+
[[Gtk::Stock::CANCEL, :cancel],
|
40
|
+
[_('_Continue'), :ok]],
|
41
41
|
message)
|
42
42
|
puts "Opened SkipEntryDialog #{inspect}" if $DEBUG
|
43
|
-
self.default_response = Gtk::
|
44
|
-
show_all
|
43
|
+
self.default_response = Gtk::ResponseType::CANCEL
|
44
|
+
show_all && (@response = run)
|
45
45
|
destroy
|
46
46
|
end
|
47
47
|
|
48
48
|
def continue?
|
49
|
-
@response ==
|
49
|
+
@response == :ok
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -58,19 +58,19 @@ module Alexandria
|
|
58
58
|
|
59
59
|
FILTERS = Alexandria::ImportFilter.all
|
60
60
|
|
61
|
-
def initialize(parent
|
61
|
+
def initialize(parent)
|
62
62
|
super()
|
63
63
|
puts 'ImportDialog opened.' if $DEBUG
|
64
64
|
@destroyed = false
|
65
65
|
self.title = _('Import a Library')
|
66
|
-
self.action =
|
66
|
+
self.action = :open
|
67
67
|
self.transient_for = parent
|
68
68
|
# self.deletable = false
|
69
69
|
running = false
|
70
|
-
add_button(Gtk::Stock::HELP,
|
71
|
-
add_button(Gtk::Stock::CANCEL,
|
70
|
+
add_button(Gtk::Stock::HELP, :help)
|
71
|
+
add_button(Gtk::Stock::CANCEL, :cancel)
|
72
72
|
import_button = add_button(_('_Import'),
|
73
|
-
|
73
|
+
:accept)
|
74
74
|
import_button.sensitive = false
|
75
75
|
|
76
76
|
signal_connect('destroy') {
|
@@ -92,29 +92,26 @@ module Alexandria
|
|
92
92
|
end
|
93
93
|
|
94
94
|
signal_connect('selection_changed') do
|
95
|
-
import_button.sensitive =
|
96
|
-
filename and File.file?(filename)
|
95
|
+
import_button.sensitive = filename && File.file?(filename)
|
97
96
|
end
|
98
97
|
|
99
98
|
# before adding the (hidden) progress bar, we must re-set the
|
100
99
|
# packing of the button box (currently packed at the end),
|
101
100
|
# because the progressbar will be *after* the button box.
|
102
|
-
buttonbox =
|
103
|
-
|
104
|
-
|
105
|
-
vbox.set_child_packing(buttonbox, *options)
|
106
|
-
vbox.reorder_child(buttonbox, 1)
|
101
|
+
buttonbox = child.children.last
|
102
|
+
child.set_child_packing(buttonbox, pack_type: :start)
|
103
|
+
child.reorder_child(buttonbox, 1)
|
107
104
|
|
108
105
|
pbar = Gtk::ProgressBar.new
|
109
106
|
pbar.show_text = true
|
110
|
-
|
107
|
+
child.pack_start(pbar, expand: false)
|
111
108
|
|
112
109
|
on_progress = proc do |fraction|
|
113
110
|
begin
|
114
111
|
pbar.show unless pbar.visible?
|
115
112
|
pbar.fraction = fraction
|
116
113
|
rescue
|
117
|
-
# TODO check if destroyed instead...
|
114
|
+
# TODO: check if destroyed instead...
|
118
115
|
end
|
119
116
|
end
|
120
117
|
|
@@ -124,11 +121,11 @@ module Alexandria
|
|
124
121
|
|
125
122
|
exec_queue = ExecutionQueue.new
|
126
123
|
|
127
|
-
while !@destroyed
|
128
|
-
(response = run) !=
|
129
|
-
response !=
|
124
|
+
while !@destroyed &&
|
125
|
+
((response = run) != :cancel) &&
|
126
|
+
(response != :delete_event)
|
130
127
|
|
131
|
-
if response ==
|
128
|
+
if response == :help
|
132
129
|
Alexandria::UI.display_help(self, 'import-library')
|
133
130
|
next
|
134
131
|
end
|
@@ -144,12 +141,8 @@ module Alexandria
|
|
144
141
|
|
145
142
|
filter.on_iterate do |n, total|
|
146
143
|
unless @destroyed
|
147
|
-
|
148
|
-
|
149
|
-
percent = n / coeff
|
150
|
-
# fraction between 0 and 1
|
151
|
-
fraction = percent / 100
|
152
|
-
puts "#{inspect} Percentage: #{fraction}" if $DEBUG
|
144
|
+
fraction = n * 1.0 / total
|
145
|
+
puts "#{inspect} fraction: #{fraction}" if $DEBUG
|
153
146
|
exec_queue.call(on_progress, fraction)
|
154
147
|
end
|
155
148
|
end
|
@@ -173,7 +166,7 @@ module Alexandria
|
|
173
166
|
end
|
174
167
|
end
|
175
168
|
|
176
|
-
while thread.alive?
|
169
|
+
while thread.alive? && !@destroyed
|
177
170
|
# puts "Thread #{thread} still alive."
|
178
171
|
running = true
|
179
172
|
exec_queue.iterate
|
@@ -182,7 +175,7 @@ module Alexandria
|
|
182
175
|
|
183
176
|
unless @destroyed
|
184
177
|
if library
|
185
|
-
|
178
|
+
yield(library, @bad_isbns, @failed_isbns)
|
186
179
|
break
|
187
180
|
elsif not_cancelled
|
188
181
|
puts "Raising ErrorDialog because not_cancelled is #{not_cancelled}" if $DEBUG
|
@@ -196,9 +189,7 @@ module Alexandria
|
|
196
189
|
self.sensitive = true
|
197
190
|
end
|
198
191
|
end
|
199
|
-
unless @destroyed
|
200
|
-
destroy
|
201
|
-
end
|
192
|
+
destroy unless @destroyed
|
202
193
|
end
|
203
194
|
end
|
204
195
|
end
|