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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.hound.yml +2 -0
- data/.rubocop.yml +4 -4
- data/.rubocop_todo.yml +55 -82
- data/CHANGELOG.md +17 -0
- data/INSTALL.md +3 -3
- data/README.md +1 -2
- data/Rakefile +14 -33
- data/TODO.md +9 -1
- data/alexandria-book-collection-manager.gemspec +4 -3
- data/bin/alexandria +21 -34
- data/doc/FAQ +2 -5
- data/lib/alexandria.rb +4 -16
- data/lib/alexandria/book_providers.rb +5 -7
- data/lib/alexandria/book_providers/adlibris.rb +5 -3
- data/lib/alexandria/book_providers/amazon_aws.rb +3 -1
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +8 -0
- data/lib/alexandria/book_providers/barnes_and_noble.rb +7 -4
- data/lib/alexandria/book_providers/douban.rb +1 -1
- data/lib/alexandria/book_providers/proxis.rb +11 -27
- data/lib/alexandria/book_providers/renaud.rb +9 -3
- data/lib/alexandria/book_providers/siciliano.rb +7 -4
- data/lib/alexandria/book_providers/thalia.rb +5 -3
- data/lib/alexandria/book_providers/web.rb +11 -29
- data/lib/alexandria/book_providers/worldcat.rb +7 -5
- data/lib/alexandria/book_providers/z3950.rb +10 -7
- data/lib/alexandria/console.rb +5 -18
- data/lib/alexandria/execution_queue.rb +2 -1
- data/lib/alexandria/export_format.rb +47 -0
- data/lib/alexandria/export_library.rb +72 -180
- data/lib/alexandria/import_library.rb +14 -23
- data/lib/alexandria/import_library_csv.rb +3 -6
- data/lib/alexandria/library_collection.rb +78 -0
- data/lib/alexandria/library_sort_order.rb +43 -0
- data/lib/alexandria/library_store.rb +222 -0
- data/lib/alexandria/logging.rb +2 -0
- data/lib/alexandria/models/book.rb +8 -16
- data/lib/alexandria/models/library.rb +26 -308
- data/lib/alexandria/preferences.rb +7 -24
- data/lib/alexandria/scanners/cuecat.rb +3 -1
- data/lib/alexandria/smart_library.rb +32 -67
- data/lib/alexandria/ui/builder_base.rb +6 -26
- data/lib/alexandria/ui/callbacks.rb +8 -34
- data/lib/alexandria/ui/completion_models.rb +2 -1
- data/lib/alexandria/ui/dialogs/about_dialog.rb +35 -47
- data/lib/alexandria/ui/dialogs/acquire_dialog.rb +14 -30
- data/lib/alexandria/ui/dialogs/alert_dialog.rb +8 -17
- data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +10 -24
- data/lib/alexandria/ui/dialogs/book_properties_dialog.rb +17 -18
- data/lib/alexandria/ui/dialogs/book_properties_dialog_base.rb +25 -41
- data/lib/alexandria/ui/dialogs/export_dialog.rb +48 -56
- data/lib/alexandria/ui/dialogs/import_dialog.rb +31 -51
- data/lib/alexandria/ui/dialogs/keep_bad_isbn_dialog.rb +33 -0
- data/lib/alexandria/ui/dialogs/misc_dialogs.rb +12 -25
- data/lib/alexandria/ui/dialogs/new_book_dialog.rb +57 -94
- data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +24 -42
- data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +9 -21
- data/lib/alexandria/ui/dialogs/preferences_dialog.rb +27 -32
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +5 -3
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +15 -12
- data/lib/alexandria/ui/icons.rb +11 -22
- data/lib/alexandria/ui/init.rb +3 -3
- data/lib/alexandria/ui/libraries_combo.rb +1 -0
- data/lib/alexandria/ui/listview.rb +5 -21
- data/lib/alexandria/ui/multi_drag_treeview.rb +20 -32
- data/lib/alexandria/ui/sidepane.rb +9 -24
- data/lib/alexandria/ui/ui_manager.rb +36 -60
- data/lib/alexandria/undo_manager.rb +1 -0
- data/lib/alexandria/version.rb +2 -2
- data/lib/alexandria/web_themes.rb +1 -0
- data/po/cs.po +0 -4
- data/po/cy.po +0 -4
- data/po/de.po +0 -4
- data/po/el.po +0 -4
- data/po/es.po +0 -4
- data/po/fr.po +0 -4
- data/po/ga.po +0 -4
- data/po/gl.po +0 -4
- data/po/it.po +0 -4
- data/po/ja.po +0 -4
- data/po/mk.po +0 -4
- data/po/nb.po +0 -4
- data/po/nl.po +0 -4
- data/po/pl.po +0 -4
- data/po/pt.po +0 -4
- data/po/pt_BR.po +0 -4
- data/po/ru.po +0 -4
- data/po/sk.po +0 -4
- data/po/sv.po +0 -4
- data/po/uk.po +0 -4
- data/po/zh_TW.po +0 -4
- data/schemas/alexandria.schemas +1 -1
- data/share/alexandria/glade/acquire_dialog__builder.glade +14 -11
- data/share/alexandria/glade/book_properties_dialog__builder.glade +170 -298
- data/share/alexandria/glade/main_app__builder.glade +22 -16
- data/share/alexandria/glade/new_book_dialog__builder.glade +26 -58
- data/share/alexandria/glade/preferences_dialog__builder.glade +249 -289
- data/share/gnome/help/alexandria/C/introduction.xml +0 -4
- data/share/gnome/help/alexandria/ja/introduction.xml +0 -4
- data/spec/alexandria/book_providers_spec.rb +1 -20
- data/spec/alexandria/console_spec.rb +32 -0
- data/spec/alexandria/export_library_spec.rb +141 -0
- data/spec/alexandria/library_spec.rb +24 -80
- data/spec/alexandria/library_store_spec.rb +37 -0
- data/spec/alexandria/smart_library_spec.rb +27 -22
- data/spec/alexandria/ui/dialogs/new_book_dialog_spec.rb +22 -0
- data/spec/alexandria/ui/dialogs_spec.rb +104 -38
- data/spec/end_to_end/basic_run_spec.rb +69 -0
- data/spec/spec_helper.rb +13 -25
- data/tasks/spec.rake +15 -2
- data/util/rake/fileinstall.rb +1 -0
- metadata +38 -16
- data/lib/alexandria/book_providers/deastore.rb +0 -265
- data/lib/alexandria/book_providers/mcu.rb +0 -182
@@ -1,23 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
# Copyright (C) 2011 Cathal Mc Ginley
|
5
|
-
# Copyright (C) 2011, 2016 Matijs van Zuijlen
|
3
|
+
# This file is part of Alexandria.
|
6
4
|
#
|
7
|
-
#
|
8
|
-
# modify it under the terms of the GNU General Public License as
|
9
|
-
# published by the Free Software Foundation; either version 2 of the
|
10
|
-
# License, or (at your option) any later version.
|
11
|
-
#
|
12
|
-
# Alexandria is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
-
# General Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU General Public
|
18
|
-
# License along with Alexandria; see the file COPYING. If not,
|
19
|
-
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
20
|
-
# Fifth Floor, Boston, MA 02110-1301 USA.
|
5
|
+
# See the file README.md for authorship and licensing information.
|
21
6
|
|
22
7
|
require 'singleton'
|
23
8
|
require 'set'
|
@@ -132,15 +117,13 @@ module Alexandria
|
|
132
117
|
# set list value
|
133
118
|
exec_gconf_set_list(var_path, new_value)
|
134
119
|
end
|
120
|
+
elsif new_value.nil?
|
121
|
+
exec_gconf_unset(variable_name)
|
135
122
|
else
|
136
123
|
# set non-list value
|
137
|
-
|
138
|
-
exec_gconf_unset(variable_name)
|
139
|
-
else
|
140
|
-
exec_gconf_set(var_path, new_value)
|
141
|
-
end
|
124
|
+
exec_gconf_set(var_path, new_value)
|
142
125
|
end
|
143
|
-
rescue => ex
|
126
|
+
rescue StandardError => ex
|
144
127
|
log.debug { new_value.inspect }
|
145
128
|
log.error { "Could not set GConf setting #{variable_name} to value: #{new_value.inspect}" }
|
146
129
|
log << ex.message
|
@@ -264,7 +247,7 @@ module Alexandria
|
|
264
247
|
begin
|
265
248
|
pair = Regexp.last_match[1].split(',')
|
266
249
|
return [discriminate(pair.first), discriminate(pair.last)]
|
267
|
-
rescue
|
250
|
+
rescue StandardError
|
268
251
|
return [0, 0]
|
269
252
|
end
|
270
253
|
else
|
@@ -37,9 +37,11 @@ module Alexandria
|
|
37
37
|
def match?(data)
|
38
38
|
data = data.chomp
|
39
39
|
return false if data[-1] != '.'
|
40
|
+
|
40
41
|
fields = data.split('.')
|
41
42
|
return false if fields.size != 4
|
42
43
|
return false if fields[2].size != 4
|
44
|
+
|
43
45
|
true
|
44
46
|
end
|
45
47
|
|
@@ -64,7 +66,7 @@ module Alexandria
|
|
64
66
|
code = isbn13
|
65
67
|
type = 'IBN'
|
66
68
|
end
|
67
|
-
rescue
|
69
|
+
rescue StandardError
|
68
70
|
log.debug { "Cannot translate UPC (#{type}) code #{code} to ISBN" }
|
69
71
|
end
|
70
72
|
|
@@ -1,22 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
# Copyright (C) 2011, 2014 Matijs van Zuijlen
|
3
|
+
# This file is part of Alexandria.
|
5
4
|
#
|
6
|
-
#
|
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 'date'
|
22
8
|
require 'time'
|
@@ -33,16 +19,17 @@ module Alexandria
|
|
33
19
|
attr_reader :name
|
34
20
|
attr_accessor :rules, :predicate_operator_rule, :deleted_books
|
35
21
|
|
36
|
-
DIR = File.join(ENV['HOME'], '.alexandria', '.smart_libraries')
|
37
22
|
EXT = '.yaml'
|
38
23
|
|
39
|
-
def initialize(name, rules, predicate_operator_rule)
|
24
|
+
def initialize(name, rules, predicate_operator_rule, store = nil)
|
40
25
|
super()
|
41
26
|
raise if name.nil? || rules.nil? || predicate_operator_rule.nil?
|
27
|
+
|
42
28
|
@name = name.dup.force_encoding('UTF-8')
|
43
29
|
@rules = rules
|
44
30
|
@predicate_operator_rule = predicate_operator_rule
|
45
|
-
|
31
|
+
@store = store
|
32
|
+
libraries = LibraryCollection.instance
|
46
33
|
libraries.add_observer(self)
|
47
34
|
self.libraries = libraries.all_regular_libraries
|
48
35
|
# carry deleted books over from libraries that are part of the smart library
|
@@ -50,39 +37,7 @@ module Alexandria
|
|
50
37
|
@cache = {}
|
51
38
|
end
|
52
39
|
|
53
|
-
def self.
|
54
|
-
a = []
|
55
|
-
begin
|
56
|
-
# Deserialize smart libraries.
|
57
|
-
Dir.chdir(DIR) do
|
58
|
-
Dir['*' + EXT].each do |filename|
|
59
|
-
# Skip non-regular files.
|
60
|
-
next unless File.stat(filename).file?
|
61
|
-
|
62
|
-
text = IO.read(filename)
|
63
|
-
hash = YAML.safe_load(text, whitelist_classes = [Symbol])
|
64
|
-
begin
|
65
|
-
smart_library = from_hash(hash)
|
66
|
-
a << smart_library
|
67
|
-
rescue => e
|
68
|
-
puts "Cannot load serialized smart library: #{e}"
|
69
|
-
puts e.backtrace
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
rescue Errno::ENOENT
|
74
|
-
# First run and no smart libraries yet? Provide some default
|
75
|
-
# ones.
|
76
|
-
sample_smart_libraries.each do |smart_library|
|
77
|
-
smart_library.save
|
78
|
-
a << smart_library
|
79
|
-
end
|
80
|
-
end
|
81
|
-
a.each(&:refilter)
|
82
|
-
a
|
83
|
-
end
|
84
|
-
|
85
|
-
def self.sample_smart_libraries
|
40
|
+
def self.sample_smart_libraries(store)
|
86
41
|
a = []
|
87
42
|
|
88
43
|
operands = Rule::Operands::LEFT
|
@@ -91,25 +46,25 @@ module Alexandria
|
|
91
46
|
rule = Rule.new(operands.find { |x| x.book_selector == :rating },
|
92
47
|
Rule::Operators::IS,
|
93
48
|
Book::MAX_RATING_STARS.to_s)
|
94
|
-
a << new(_('Favorite'), [rule], ALL_RULES)
|
49
|
+
a << new(_('Favorite'), [rule], ALL_RULES, store)
|
95
50
|
|
96
51
|
# Loaned books.
|
97
52
|
rule = Rule.new(operands.find { |x| x.book_selector == :loaned },
|
98
53
|
Rule::Operators::IS_TRUE,
|
99
54
|
nil)
|
100
|
-
a << new(_('Loaned'), [rule], ALL_RULES)
|
55
|
+
a << new(_('Loaned'), [rule], ALL_RULES, store)
|
101
56
|
|
102
57
|
# Redd books.
|
103
58
|
rule = Rule.new(operands.find { |x| x.book_selector == :redd },
|
104
59
|
Rule::Operators::IS_TRUE,
|
105
60
|
nil)
|
106
|
-
a << new(_('Read'), [rule], ALL_RULES)
|
61
|
+
a << new(_('Read'), [rule], ALL_RULES, store)
|
107
62
|
|
108
63
|
# Own books.
|
109
64
|
rule = Rule.new(operands.find { |x| x.book_selector == :own },
|
110
65
|
Rule::Operators::IS_TRUE,
|
111
66
|
nil)
|
112
|
-
a << new(_('Owned'), [rule], ALL_RULES)
|
67
|
+
a << new(_('Owned'), [rule], ALL_RULES, store)
|
113
68
|
|
114
69
|
# Want books.
|
115
70
|
rule = Rule.new(operands.find { |x| x.book_selector == :want },
|
@@ -118,15 +73,16 @@ module Alexandria
|
|
118
73
|
rule2 = Rule.new(operands.find { |x| x.book_selector == :own },
|
119
74
|
Rule::Operators::IS_NOT_TRUE,
|
120
75
|
nil)
|
121
|
-
a << new(_('Wishlist'), [rule, rule2], ALL_RULES)
|
76
|
+
a << new(_('Wishlist'), [rule, rule2], ALL_RULES, store)
|
122
77
|
|
123
78
|
a
|
124
79
|
end
|
125
80
|
|
126
|
-
def self.from_hash(hash)
|
81
|
+
def self.from_hash(hash, store)
|
127
82
|
SmartLibrary.new(hash[:name],
|
128
83
|
hash[:rules].map { |x| Rule.from_hash(x) },
|
129
|
-
hash[:predicate_operator_rule] == :all ? ALL_RULES : ANY_RULE
|
84
|
+
hash[:predicate_operator_rule] == :all ? ALL_RULES : ANY_RULE,
|
85
|
+
store)
|
130
86
|
end
|
131
87
|
|
132
88
|
def to_hash
|
@@ -147,7 +103,7 @@ module Alexandria
|
|
147
103
|
end
|
148
104
|
|
149
105
|
def update(*params)
|
150
|
-
if params.first.is_a?(
|
106
|
+
if params.first.is_a?(LibraryCollection)
|
151
107
|
libraries, _, library = params
|
152
108
|
unless library.is_a?(self.class)
|
153
109
|
self.libraries = libraries.all_libraries
|
@@ -183,7 +139,7 @@ module Alexandria
|
|
183
139
|
if book
|
184
140
|
@cache[book].yaml(book)
|
185
141
|
else
|
186
|
-
File.join(
|
142
|
+
File.join(base_dir, @name + EXT)
|
187
143
|
end
|
188
144
|
end
|
189
145
|
|
@@ -191,7 +147,7 @@ module Alexandria
|
|
191
147
|
if book
|
192
148
|
@cache[book].save(book)
|
193
149
|
else
|
194
|
-
FileUtils.mkdir_p(
|
150
|
+
FileUtils.mkdir_p(base_dir) unless File.exist? base_dir
|
195
151
|
File.open(yaml, 'w') { |io| io.puts to_hash.to_yaml }
|
196
152
|
end
|
197
153
|
end
|
@@ -210,6 +166,7 @@ module Alexandria
|
|
210
166
|
each do |book|
|
211
167
|
library = @cache[book]
|
212
168
|
next unless File.exist?(library.cover(book))
|
169
|
+
|
213
170
|
FileUtils.cp(File.join(library.path, book.ident + Library::EXT[:cover]),
|
214
171
|
File.join(somewhere, library.final_cover(book)))
|
215
172
|
end
|
@@ -256,6 +213,7 @@ module Alexandria
|
|
256
213
|
|
257
214
|
def undelete
|
258
215
|
raise unless @@deleted_libraries.include?(self)
|
216
|
+
|
259
217
|
@@deleted_libraries.delete(self)
|
260
218
|
end
|
261
219
|
|
@@ -268,6 +226,10 @@ module Alexandria
|
|
268
226
|
@libraries.each { |x| x.add_observer(self) }
|
269
227
|
end
|
270
228
|
|
229
|
+
def base_dir
|
230
|
+
@store.smart_library_dir
|
231
|
+
end
|
232
|
+
|
271
233
|
class Rule
|
272
234
|
include GetText
|
273
235
|
extend GetText
|
@@ -277,6 +239,7 @@ module Alexandria
|
|
277
239
|
|
278
240
|
def initialize(operand, operation, value)
|
279
241
|
raise if operand.nil? || operation.nil? # value can be nil
|
242
|
+
|
280
243
|
@operand = operand
|
281
244
|
@operation = operation
|
282
245
|
@value = value
|
@@ -300,7 +263,8 @@ module Alexandria
|
|
300
263
|
}
|
301
264
|
end
|
302
265
|
|
303
|
-
|
266
|
+
Operand = Struct.new(:name, :klass)
|
267
|
+
class Operand
|
304
268
|
def <=>(x)
|
305
269
|
name <=> x.name
|
306
270
|
end
|
@@ -315,7 +279,8 @@ module Alexandria
|
|
315
279
|
end
|
316
280
|
end
|
317
281
|
|
318
|
-
|
282
|
+
Operator = Struct.new(:sym, :name, :proc)
|
283
|
+
class Operator
|
319
284
|
def <=>(x)
|
320
285
|
name <=> x.name
|
321
286
|
end
|
@@ -407,7 +372,7 @@ module Alexandria
|
|
407
372
|
|
408
373
|
Time.now - given_date <= days
|
409
374
|
end
|
410
|
-
rescue => ex
|
375
|
+
rescue StandardError => ex
|
411
376
|
trace = ex.backtrace.join("\n >")
|
412
377
|
log.warn { "Date matching failed #{ex} #{trace}" }
|
413
378
|
false
|
@@ -426,7 +391,7 @@ module Alexandria
|
|
426
391
|
|
427
392
|
Time.now - given_date > days
|
428
393
|
end
|
429
|
-
rescue => ex
|
394
|
+
rescue StandardError => ex
|
430
395
|
trace = ex.backtrace.join("\n >")
|
431
396
|
log.warn { "Date matching failed #{ex} #{trace}" }
|
432
397
|
false
|
@@ -503,7 +468,7 @@ module Alexandria
|
|
503
468
|
proc do |book|
|
504
469
|
begin
|
505
470
|
left_value = book.send(@operand.book_selector)
|
506
|
-
rescue => e
|
471
|
+
rescue StandardError => e
|
507
472
|
puts e.message
|
508
473
|
end
|
509
474
|
right_value = @value
|
@@ -1,21 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# This file is part of Alexandria.
|
4
4
|
#
|
5
|
-
#
|
6
|
-
# modify it under the terms of the GNU General Public License as
|
7
|
-
# published by the Free Software Foundation; either version 2 of the
|
8
|
-
# License, or (at your option) any later version.
|
9
|
-
#
|
10
|
-
# Alexandria is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
# General Public License for more details.
|
14
|
-
#
|
15
|
-
# You should have received a copy of the GNU General Public
|
16
|
-
# License along with Alexandria; see the file COPYING. If not,
|
17
|
-
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
18
|
-
# Fifth Floor, Boston, MA 02110-1301 USA.
|
5
|
+
# See the file README.md for authorship and licensing information.
|
19
6
|
|
20
7
|
module Alexandria
|
21
8
|
module UI
|
@@ -23,21 +10,14 @@ module Alexandria
|
|
23
10
|
def initialize(filename, widget_names)
|
24
11
|
file = File.join(Alexandria::Config::DATA_DIR, 'glade', filename)
|
25
12
|
builder = Gtk::Builder.new
|
13
|
+
# TODO: This emits the warning 'GtkDialog mapped without a transient
|
14
|
+
# parent. This is discouraged.'
|
26
15
|
builder.add_from_file(file)
|
27
16
|
builder.connect_signals do |handler|
|
28
|
-
|
29
|
-
method(handler)
|
30
|
-
rescue => ex
|
31
|
-
puts "Error: #{ex}" if $DEBUG
|
32
|
-
nil
|
33
|
-
end
|
17
|
+
method(handler)
|
34
18
|
end
|
35
19
|
widget_names.each do |name|
|
36
|
-
|
37
|
-
instance_variable_set("@#{name}".intern, builder[name.to_s])
|
38
|
-
rescue => err
|
39
|
-
puts "Error: #{err}" if $DEBUG
|
40
|
-
end
|
20
|
+
instance_variable_set("@#{name}".intern, builder[name.to_s])
|
41
21
|
end
|
42
22
|
end
|
43
23
|
end
|
@@ -1,23 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
# Copyright (C) 2008 Joseph Method
|
5
|
-
# Copyright (C) 2011, 2014, 2016 Matijs van Zuijlen
|
3
|
+
# This file is part of Alexandria.
|
6
4
|
#
|
7
|
-
#
|
8
|
-
# modify it under the terms of the GNU General Public License as
|
9
|
-
# published by the Free Software Foundation; either version 2 of the
|
10
|
-
# License, or (at your option) any later version.
|
11
|
-
#
|
12
|
-
# Alexandria is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
-
# General Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU General Public
|
18
|
-
# License along with Alexandria; see the file COPYING. If not,
|
19
|
-
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
20
|
-
# Fifth Floor, Boston, MA 02110-1301 USA.
|
5
|
+
# See the file README.md for authorship and licensing information.
|
21
6
|
|
22
7
|
module Alexandria
|
23
8
|
module UI
|
@@ -34,7 +19,7 @@ module Alexandria
|
|
34
19
|
end
|
35
20
|
|
36
21
|
def on_new_smart(*)
|
37
|
-
NewSmartLibraryDialog.new(@main_app) do |smart_library|
|
22
|
+
NewSmartLibraryDialog.new(@main_app).acquire do |smart_library|
|
38
23
|
smart_library.refilter
|
39
24
|
@libraries.add_library(smart_library)
|
40
25
|
append_library(smart_library, true)
|
@@ -62,7 +47,7 @@ module Alexandria
|
|
62
47
|
end
|
63
48
|
|
64
49
|
def on_import(*)
|
65
|
-
ImportDialog.new(@main_app) do |library, bad_isbns, failed_isbns|
|
50
|
+
ImportDialog.new(@main_app).acquire do |library, bad_isbns, failed_isbns|
|
66
51
|
unless bad_isbns.empty?
|
67
52
|
log.debug { 'bad_isbn' }
|
68
53
|
message = _('The following lines are not valid ISBNs and were not imported:')
|
@@ -121,13 +106,7 @@ module Alexandria
|
|
121
106
|
end
|
122
107
|
|
123
108
|
def on_export(*)
|
124
|
-
ExportDialog.new(@main_app, selected_library, library_sort_order)
|
125
|
-
# FIXME: Remove this hack and fix the underlying problem.
|
126
|
-
rescue => ex
|
127
|
-
log.error { "problem with immediate export #{ex} try again" }
|
128
|
-
ErrorDialog.new(@main_app, _('Export failed'),
|
129
|
-
_('Try letting this library load ' \
|
130
|
-
'completely before exporting.'))
|
109
|
+
ExportDialog.new(@main_app, selected_library, library_sort_order).perform
|
131
110
|
end
|
132
111
|
|
133
112
|
def on_acquire(*)
|
@@ -146,7 +125,7 @@ module Alexandria
|
|
146
125
|
if @library_listview.focus? || selected_books.empty?
|
147
126
|
library = selected_library
|
148
127
|
if library.is_a?(SmartLibrary)
|
149
|
-
SmartLibraryPropertiesDialog.new(@main_app, library) do
|
128
|
+
SmartLibraryPropertiesDialog.new(@main_app, library).acquire do
|
150
129
|
library.refilter
|
151
130
|
refresh_books
|
152
131
|
end
|
@@ -267,12 +246,7 @@ module Alexandria
|
|
267
246
|
end
|
268
247
|
|
269
248
|
def on_about(*)
|
270
|
-
|
271
|
-
ad.signal_connect('response') do
|
272
|
-
log.debug { 'destroy about' }
|
273
|
-
ad.destroy
|
274
|
-
end
|
275
|
-
ad.show
|
249
|
+
AboutDialog.new(@main_app).show
|
276
250
|
end
|
277
251
|
|
278
252
|
def on_view_sidepane(action)
|
@@ -343,7 +317,7 @@ module Alexandria
|
|
343
317
|
['Sidepane', nil, _('Side _Pane'), 'F9', nil, method(:on_view_sidepane), true],
|
344
318
|
['Toolbar', nil, _('_Toolbar'), nil, nil, method(:on_view_toolbar), true],
|
345
319
|
['Statusbar', nil, _('_Statusbar'), nil, nil, method(:on_view_statusbar), true],
|
346
|
-
['ReversedOrder', nil, _('Re_versed Order'), nil, nil, method(:on_reverse_order)],
|
320
|
+
['ReversedOrder', nil, _('Re_versed Order'), nil, nil, method(:on_reverse_order), false],
|
347
321
|
]
|
348
322
|
|
349
323
|
view_as_actions = [
|