alexandria-book-collection-manager 0.7.8 → 0.7.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +45 -50
- data/.rubocop.yml +18 -5
- data/.rubocop_todo.yml +29 -22
- data/CHANGELOG.md +29 -0
- data/ChangeLog.0 +19 -19
- data/INSTALL.md +3 -5
- data/README.md +0 -5
- data/Rakefile +11 -11
- data/alexandria-book-collection-manager.gemspec +35 -34
- data/doc/FAQ +2 -2
- data/lib/alexandria/about.rb +1 -1
- data/lib/alexandria/book_providers/bl_provider.rb +88 -0
- data/lib/alexandria/book_providers/loc_provider.rb +38 -0
- data/lib/alexandria/book_providers/pseudomarc.rb +1 -1
- data/lib/alexandria/book_providers/sbn_provider.rb +108 -0
- data/lib/alexandria/book_providers/thalia_provider.rb +1 -1
- data/lib/alexandria/book_providers/web.rb +2 -2
- data/lib/alexandria/book_providers/worldcat.rb +9 -7
- data/lib/alexandria/book_providers/z3950_provider.rb +199 -0
- data/lib/alexandria/book_providers.rb +10 -25
- data/lib/alexandria/default_preferences.rb +1 -1
- data/lib/alexandria/export_library.rb +10 -10
- data/lib/alexandria/image_fetcher.rb +25 -0
- data/lib/alexandria/import_library.rb +9 -9
- data/lib/alexandria/library_store.rb +3 -4
- data/lib/alexandria/models/book.rb +13 -0
- data/lib/alexandria/models/library.rb +13 -21
- data/lib/alexandria/preferences.rb +4 -6
- data/lib/alexandria/scanners/cue_cat.rb +1 -1
- data/lib/alexandria/ui/about_dialog.rb +1 -1
- data/lib/alexandria/ui/acquire_dialog.rb +6 -9
- data/lib/alexandria/ui/barcode_animation.rb +1 -1
- data/lib/alexandria/ui/book_properties_dialog_base.rb +2 -6
- data/lib/alexandria/ui/completion_models.rb +1 -5
- data/lib/alexandria/ui/conflict_while_copying_dialog.rb +1 -1
- data/lib/alexandria/ui/listview.rb +1 -1
- data/lib/alexandria/ui/multi_drag_treeview.rb +1 -1
- data/lib/alexandria/ui/new_book_dialog.rb +11 -13
- data/lib/alexandria/ui/new_book_dialog_manual.rb +1 -1
- data/lib/alexandria/ui/preferences_dialog.rb +2 -2
- data/lib/alexandria/ui/provider_preferences_base_dialog.rb +1 -1
- data/lib/alexandria/ui/really_delete_dialog.rb +1 -1
- data/lib/alexandria/ui/ui_manager.rb +14 -22
- data/lib/alexandria/version.rb +1 -1
- data/po/cs.po +90 -125
- data/po/cy.po +87 -125
- data/po/de.po +96 -125
- data/po/el.po +96 -125
- data/po/es.po +96 -125
- data/po/fr.po +90 -125
- data/po/ga.po +83 -124
- data/po/gl.po +90 -125
- data/po/it.po +90 -125
- data/po/ja.po +90 -125
- data/po/mk.po +96 -125
- data/po/nb.po +90 -125
- data/po/nl.po +107 -124
- data/po/pl.po +113 -124
- data/po/pt.po +90 -125
- data/po/pt_BR.po +90 -125
- data/po/ru.po +92 -124
- data/po/sk.po +90 -125
- data/po/sv.po +90 -125
- data/po/uk.po +90 -125
- data/po/zh_TW.po +90 -125
- data/schemas/alexandria.schemas +1 -1
- data/share/gnome/help/alexandria/C/adding-books.xml +3 -4
- data/share/gnome/help/alexandria/C/introduction.xml +0 -16
- data/share/gnome/help/alexandria/C/searching.xml +1 -4
- data/share/gnome/help/alexandria/C/settings.xml +0 -30
- data/share/gnome/help/alexandria/fr/alexandria.xml +4 -159
- data/share/gnome/help/alexandria/ja/adding-books.xml +1 -1
- data/share/gnome/help/alexandria/ja/introduction.xml +0 -15
- data/share/gnome/help/alexandria/ja/searching.xml +3 -7
- data/share/gnome/help/alexandria/ja/settings.xml +0 -27
- data/spec/alexandria/book_providers/bl_provider_spec.rb +13 -0
- data/spec/alexandria/book_providers/loc_provider_spec.rb +17 -0
- data/spec/alexandria/book_providers/sbn_provider_spec.rb +13 -0
- data/spec/alexandria/book_providers_spec.rb +0 -81
- data/spec/alexandria/library_spec.rb +20 -2
- data/spec/alexandria/ui/import_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/preferences_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/ui_manager_spec.rb +78 -2
- data/spec/data/libraries/0.6.2/My Library/9780571147168.yaml +2 -0
- data/util/rake/fileinstall.rb +4 -4
- data/util/rake/omfgenerate.rb +1 -1
- metadata +69 -55
- data/lib/alexandria/book_providers/adlibris.rb +0 -191
- data/lib/alexandria/book_providers/amazon_aws.rb +0 -239
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +0 -373
- data/lib/alexandria/book_providers/barnes_and_noble.rb +0 -209
- data/lib/alexandria/book_providers/proxis.rb +0 -176
- data/lib/alexandria/book_providers/siciliano.rb +0 -256
- data/lib/alexandria/book_providers/z3950.rb +0 -408
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file is part of Alexandria.
|
4
|
+
#
|
5
|
+
# See the file README.md for authorship and licensing information.
|
6
|
+
|
7
|
+
require "alexandria/net"
|
8
|
+
|
9
|
+
module Alexandria
|
10
|
+
module ImageFetcher
|
11
|
+
def fetch_image(uri)
|
12
|
+
result = nil
|
13
|
+
if URI.parse(uri).scheme.nil?
|
14
|
+
File.open(uri, "r") do |io|
|
15
|
+
result = io.read
|
16
|
+
end
|
17
|
+
else
|
18
|
+
result = WWWAgent.new.get(uri)
|
19
|
+
end
|
20
|
+
result
|
21
|
+
rescue Errno::ECONNRESET
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -53,13 +53,13 @@ module Alexandria
|
|
53
53
|
def self.import_autodetect(*args)
|
54
54
|
log.debug { args.inspect }
|
55
55
|
filename = args[1]
|
56
|
-
log.debug { "Filename is #{filename} and ext is #{filename[-4
|
56
|
+
log.debug { "Filename is #{filename} and ext is #{filename[-4..]}" }
|
57
57
|
log.debug { "Beginning import: #{args[0]}, #{args[1]}" }
|
58
|
-
if filename[-4
|
58
|
+
if filename[-4..] == ".txt"
|
59
59
|
import_as_isbn_list(*args)
|
60
|
-
elsif [".tc", ".bc"].include? filename[-3
|
60
|
+
elsif [".tc", ".bc"].include? filename[-3..]
|
61
61
|
import_as_tellico_xml_archive(*args)
|
62
|
-
elsif [".csv"].include? filename[-4
|
62
|
+
elsif [".csv"].include? filename[-4..]
|
63
63
|
import_as_csv_file(*args)
|
64
64
|
else
|
65
65
|
raise _("Unsupported type")
|
@@ -97,11 +97,11 @@ module Alexandria
|
|
97
97
|
keys = ["isbn", "publisher", "pub_year", "binding"]
|
98
98
|
|
99
99
|
book_elements = [neaten(elements["title"].text)]
|
100
|
-
book_elements += if
|
100
|
+
book_elements += if elements["authors"].nil?
|
101
|
+
[[]]
|
102
|
+
else
|
101
103
|
[elements["authors"].elements.to_a.map \
|
102
104
|
{ |x| neaten(x.text) }]
|
103
|
-
else
|
104
|
-
[[]]
|
105
105
|
end
|
106
106
|
book_elements += keys.map do |key|
|
107
107
|
neaten(elements[key].text) if elements[key]
|
@@ -139,7 +139,7 @@ module Alexandria
|
|
139
139
|
def self.import_as_csv_file(name, filename, on_iterate_cb, _on_error_cb)
|
140
140
|
require "alexandria/import_library_csv"
|
141
141
|
books_and_covers = []
|
142
|
-
line_count =
|
142
|
+
line_count = File.readlines(filename).reduce(0) { |count, _line| count + 1 }
|
143
143
|
|
144
144
|
import_count = 0
|
145
145
|
max_import = line_count - 1
|
@@ -210,7 +210,7 @@ module Alexandria
|
|
210
210
|
def self.import_as_isbn_list(name, filename, on_iterate_cb,
|
211
211
|
on_error_cb)
|
212
212
|
log.debug { "Starting import_as_isbn_list... " }
|
213
|
-
isbn_list =
|
213
|
+
isbn_list = File.readlines(filename).map do |line|
|
214
214
|
log.debug { "Trying line #{line}" }
|
215
215
|
[line.chomp, canonicalise_isbn(line.chomp)] unless line == "\n"
|
216
216
|
end
|
@@ -152,7 +152,7 @@ module Alexandria
|
|
152
152
|
# Skip non-regular files.
|
153
153
|
next unless File.stat(filename).file?
|
154
154
|
|
155
|
-
text =
|
155
|
+
text = File.read(filename)
|
156
156
|
hash = YAML.safe_load(text, permitted_classes: [Symbol])
|
157
157
|
smart_library = SmartLibrary.from_hash(hash, self)
|
158
158
|
a << smart_library
|
@@ -181,7 +181,7 @@ module Alexandria
|
|
181
181
|
private
|
182
182
|
|
183
183
|
def regularize_book_from_yaml(name)
|
184
|
-
text =
|
184
|
+
text = File.read(name)
|
185
185
|
|
186
186
|
# Code to remove the mystery string in books imported from Amazon
|
187
187
|
# (In the past, still?) To allow ruby-amazon to be removed.
|
@@ -202,8 +202,7 @@ module Alexandria
|
|
202
202
|
text.sub!(md[0], "loaned_since: #{new_yaml}\n")
|
203
203
|
end
|
204
204
|
|
205
|
-
|
206
|
-
book = YAML.safe_load(text, permitted_classes: [Book, Time])
|
205
|
+
book = Book.from_yaml(text)
|
207
206
|
|
208
207
|
unless book.isbn.instance_of? String
|
209
208
|
# HACK
|
@@ -71,5 +71,18 @@ module Alexandria
|
|
71
71
|
def inspect
|
72
72
|
"#<Alexandria::Book title: #{@title}>"
|
73
73
|
end
|
74
|
+
|
75
|
+
def self.from_yaml(text)
|
76
|
+
node = YAML.parse_stream text
|
77
|
+
doc = node.children.first
|
78
|
+
mapping = doc.children.first
|
79
|
+
mapping.children.each_slice(2) do |_k, v|
|
80
|
+
v.tag = nil if v.tag == "!ruby/array:Alexandria:Library"
|
81
|
+
end
|
82
|
+
yaml = node.to_yaml
|
83
|
+
|
84
|
+
# TODO: Ensure book loading passes through Book#initialize
|
85
|
+
YAML.safe_load(yaml, permitted_classes: [Book, Time])
|
86
|
+
end
|
74
87
|
end
|
75
88
|
end
|
@@ -10,10 +10,12 @@ require "rexml/document"
|
|
10
10
|
require "tempfile"
|
11
11
|
require "etc"
|
12
12
|
require "alexandria/library_store"
|
13
|
+
require "alexandria/image_fetcher"
|
13
14
|
|
14
15
|
module Alexandria
|
15
16
|
class Library < Array
|
16
17
|
include Logging
|
18
|
+
include ImageFetcher
|
17
19
|
|
18
20
|
attr_reader :name
|
19
21
|
attr_accessor :ruined_books, :updating, :deleted_books
|
@@ -77,7 +79,7 @@ module Alexandria
|
|
77
79
|
normalized = entry.delete("- ").upcase
|
78
80
|
return [] unless /\A[\dX]*\Z/.match?(normalized)
|
79
81
|
|
80
|
-
normalized.
|
82
|
+
normalized.chars.map do |char|
|
81
83
|
char == "X" ? 10 : char.to_i
|
82
84
|
end
|
83
85
|
end
|
@@ -238,19 +240,13 @@ module Alexandria
|
|
238
240
|
Dir.chdir(path) do
|
239
241
|
# Fetch the cover picture.
|
240
242
|
cover_file = cover(book)
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
# Regular filename.
|
245
|
-
File.open(cover_uri) { |io2| io.puts io2.read }
|
246
|
-
else
|
247
|
-
# Try open-uri.
|
248
|
-
io.puts transport.get(uri)
|
249
|
-
end
|
250
|
-
end
|
243
|
+
data = fetch_image(cover_uri)
|
244
|
+
if data
|
245
|
+
File.write(cover_file, data)
|
251
246
|
|
252
|
-
|
253
|
-
|
247
|
+
# Remove the file if its blank.
|
248
|
+
File.delete(cover_file) if Alexandria::UI::Icons.blank?(cover_file)
|
249
|
+
end
|
254
250
|
end
|
255
251
|
end
|
256
252
|
|
@@ -345,9 +341,7 @@ module Alexandria
|
|
345
341
|
else
|
346
342
|
"g#{something.ident}" # g is for generated id...
|
347
343
|
end
|
348
|
-
when String
|
349
|
-
something
|
350
|
-
when Integer
|
344
|
+
when String, Integer
|
351
345
|
something
|
352
346
|
else
|
353
347
|
raise NotImplementedError
|
@@ -359,9 +353,7 @@ module Alexandria
|
|
359
353
|
ident = case something
|
360
354
|
when Book
|
361
355
|
something.ident
|
362
|
-
when String
|
363
|
-
something
|
364
|
-
when Integer
|
356
|
+
when String, Integer
|
365
357
|
something
|
366
358
|
else
|
367
359
|
raise NotImplementedError
|
@@ -370,7 +362,7 @@ module Alexandria
|
|
370
362
|
end
|
371
363
|
|
372
364
|
def name=(name)
|
373
|
-
File.rename(path, File.join(
|
365
|
+
File.rename(path, File.join(@store.library_dir, name))
|
374
366
|
@name = name
|
375
367
|
end
|
376
368
|
|
@@ -398,7 +390,7 @@ module Alexandria
|
|
398
390
|
end
|
399
391
|
|
400
392
|
def self.jpeg?(file)
|
401
|
-
|
393
|
+
File.read(file, 10)[6..9] == "JFIF"
|
402
394
|
end
|
403
395
|
|
404
396
|
def final_cover(book)
|
@@ -135,8 +135,6 @@ module Alexandria
|
|
135
135
|
|
136
136
|
def get_gconf_type(value)
|
137
137
|
case value
|
138
|
-
when String
|
139
|
-
"string"
|
140
138
|
when Integer
|
141
139
|
"int"
|
142
140
|
when TrueClass, FalseClass
|
@@ -147,7 +145,7 @@ module Alexandria
|
|
147
145
|
end
|
148
146
|
|
149
147
|
def exec_gconf_set_list(var_path, new_list)
|
150
|
-
# NOTE we must check between list and pair...
|
148
|
+
# NOTE: we must check between list and pair...
|
151
149
|
|
152
150
|
list_type = get_gconf_type(new_list.first)
|
153
151
|
if list_type == "int" && new_list.size == 2
|
@@ -238,11 +236,11 @@ module Alexandria
|
|
238
236
|
# range of values used by Alexandria.
|
239
237
|
def discriminate(value)
|
240
238
|
case value
|
241
|
-
when "true"
|
239
|
+
when "true" # bool
|
242
240
|
true
|
243
|
-
when "false"
|
241
|
+
when "false" # bool
|
244
242
|
false
|
245
|
-
when
|
243
|
+
when /^-?[0-9]+$/ # int
|
246
244
|
value.to_i
|
247
245
|
when /^\[(.*)\]$/ # list (assume of type String)
|
248
246
|
Regexp.last_match[1].split(",")
|
@@ -7,7 +7,7 @@
|
|
7
7
|
module Alexandria
|
8
8
|
module UI
|
9
9
|
class AboutDialog
|
10
|
-
GPL = <<~EOL # rubocop:disable GetText/DecorateString
|
10
|
+
GPL = <<~EOL # rubocop:disable I18n/GetText/DecorateString
|
11
11
|
Alexandria is free software; you can redistribute it and/or
|
12
12
|
modify it under the terms of the GNU General Public License as
|
13
13
|
published by the Free Software Foundation; either version 2 of the
|
@@ -5,6 +5,9 @@
|
|
5
5
|
# See the file README.md for authorship and licensing information.
|
6
6
|
|
7
7
|
require "monitor"
|
8
|
+
|
9
|
+
require "alexandria/image_fetcher"
|
10
|
+
|
8
11
|
require "alexandria/scanners/cue_cat"
|
9
12
|
require "alexandria/scanners/keyboard"
|
10
13
|
|
@@ -40,6 +43,7 @@ module Alexandria
|
|
40
43
|
|
41
44
|
class AcquireDialog < BuilderBase
|
42
45
|
include GetText
|
46
|
+
include ImageFetcher
|
43
47
|
include Logging
|
44
48
|
extend GetText
|
45
49
|
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
@@ -91,7 +95,7 @@ module Alexandria
|
|
91
95
|
library, is_new_library =
|
92
96
|
@combo_libraries.selection_from_libraries(libraries)
|
93
97
|
|
94
|
-
# NOTE at this stage, the ISBN is 10-digit...
|
98
|
+
# NOTE: at this stage, the ISBN is 10-digit...
|
95
99
|
#
|
96
100
|
|
97
101
|
selection = @barcodes_treeview.selection
|
@@ -357,14 +361,7 @@ module Alexandria
|
|
357
361
|
Thread.new do
|
358
362
|
pixbuf = nil
|
359
363
|
if cover_uri
|
360
|
-
image_data =
|
361
|
-
if URI.parse(cover_uri).scheme.nil?
|
362
|
-
File.open(cover_uri, "r") do |io|
|
363
|
-
image_data = io.read
|
364
|
-
end
|
365
|
-
else
|
366
|
-
image_data = URI.parse(cover_uri).read
|
367
|
-
end
|
364
|
+
image_data = fetch_image(cover_uri)
|
368
365
|
loader = GdkPixbuf::PixbufLoader.new
|
369
366
|
loader.last_write(image_data)
|
370
367
|
pixbuf = loader.pixbuf
|
@@ -146,11 +146,7 @@ module Alexandria
|
|
146
146
|
end
|
147
147
|
|
148
148
|
def own_toggled
|
149
|
-
@checkbutton_want.inconsistent =
|
150
|
-
true
|
151
|
-
else
|
152
|
-
false
|
153
|
-
end
|
149
|
+
@checkbutton_want.inconsistent = @checkbutton_own.active?
|
154
150
|
end
|
155
151
|
|
156
152
|
def want_toggled; end
|
@@ -268,7 +264,7 @@ module Alexandria
|
|
268
264
|
raise _("out of range") if rating < 0 || rating > images.length
|
269
265
|
|
270
266
|
images[0..rating - 1].each { |x| x.pixbuf = Icons::STAR_SET }
|
271
|
-
images[rating
|
267
|
+
images[rating..].each { |x| x.pixbuf = Icons::STAR_UNSET }
|
272
268
|
@current_rating = rating
|
273
269
|
end
|
274
270
|
|
@@ -15,7 +15,7 @@ module Alexandria
|
|
15
15
|
def initialize(parent, library, book)
|
16
16
|
super(parent,
|
17
17
|
format(_("The book '%s' already exists in '%s'. Would you like " \
|
18
|
-
|
18
|
+
"to replace it?"), book.title, library.name),
|
19
19
|
Gtk::Stock::DIALOG_QUESTION,
|
20
20
|
[[_("_Skip"), Gtk::ResponseType::CANCEL],
|
21
21
|
[_("_Replace"), Gtk::ResponseType::OK]],
|
@@ -201,7 +201,7 @@ module Alexandria
|
|
201
201
|
@prefs.col_rating_visible,
|
202
202
|
@prefs.col_tags_visible
|
203
203
|
]
|
204
|
-
cols = @listview.columns[1
|
204
|
+
cols = @listview.columns[1..] # skip "Title"
|
205
205
|
cols.each_index do |i|
|
206
206
|
cols[i].visible = cols_visibility[i]
|
207
207
|
end
|
@@ -99,7 +99,7 @@ module Alexandria
|
|
99
99
|
return true
|
100
100
|
end
|
101
101
|
|
102
|
-
return false if event.event_type == :
|
102
|
+
return false if event.event_type == :"2button_press"
|
103
103
|
|
104
104
|
path, _, cell_x, cell_y = get_path_at_pos(event.x, event.y)
|
105
105
|
return false if path.nil?
|
@@ -8,6 +8,7 @@ require "gdk_pixbuf2"
|
|
8
8
|
require "alexandria/ui/builder_base"
|
9
9
|
require "alexandria/ui/error_dialog"
|
10
10
|
require "alexandria/ui/keep_bad_isbn_dialog"
|
11
|
+
require "alexandria/image_fetcher"
|
11
12
|
|
12
13
|
module Alexandria
|
13
14
|
class DuplicateBookException < NameError
|
@@ -16,6 +17,7 @@ module Alexandria
|
|
16
17
|
module UI
|
17
18
|
class NewBookDialog < BuilderBase
|
18
19
|
include Logging
|
20
|
+
include ImageFetcher
|
19
21
|
include GetText
|
20
22
|
extend GetText
|
21
23
|
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
@@ -163,17 +165,11 @@ module Alexandria
|
|
163
165
|
begin
|
164
166
|
@results.each_with_index do |result, i|
|
165
167
|
uri = result[1]
|
166
|
-
if uri
|
167
|
-
if URI.parse(uri).scheme.nil?
|
168
|
-
File.open(uri, "r") do |io|
|
169
|
-
@images[i] = io.read
|
170
|
-
end
|
171
|
-
else
|
172
|
-
@images[i] = URI.parse(uri).read
|
173
|
-
end
|
174
|
-
end
|
168
|
+
@images[i] = fetch_image(uri) if uri
|
175
169
|
end
|
176
170
|
rescue StandardError => ex
|
171
|
+
log.error { "Couldn't download image: #{ex.class} #{ex}" }
|
172
|
+
log.error { ex.backtrace.join("\n") }
|
177
173
|
@image_error = ex.message
|
178
174
|
end
|
179
175
|
end
|
@@ -181,8 +177,13 @@ module Alexandria
|
|
181
177
|
GLib::Timeout.add(100) do
|
182
178
|
if @image_error
|
183
179
|
image_error_dialog(@image_error).display
|
180
|
+
@image_error = nil
|
184
181
|
else
|
185
182
|
@images.each_pair do |key, value|
|
183
|
+
@images.delete(key)
|
184
|
+
|
185
|
+
next unless value
|
186
|
+
|
186
187
|
loader = GdkPixbuf::PixbufLoader.new
|
187
188
|
loader.last_write(value)
|
188
189
|
pixbuf = loader.pixbuf
|
@@ -195,8 +196,6 @@ module Alexandria
|
|
195
196
|
|
196
197
|
iter[2] = pixbuf # I bet you this is it!
|
197
198
|
end
|
198
|
-
|
199
|
-
@images.delete(key)
|
200
199
|
rescue StandardError => ex
|
201
200
|
image_error_dialog(ex.message).display
|
202
201
|
end
|
@@ -326,7 +325,7 @@ module Alexandria
|
|
326
325
|
|
327
326
|
def on_results_button_press_event(_widget, event)
|
328
327
|
# double left click
|
329
|
-
on_add if (event.event_type == :
|
328
|
+
on_add if (event.event_type == :"2button_press") && (event.button == 1)
|
330
329
|
end
|
331
330
|
|
332
331
|
def add_single_book_by_isbn(library, is_new)
|
@@ -462,7 +461,6 @@ module Alexandria
|
|
462
461
|
# Do not destroy if there is no addition.
|
463
462
|
# return unless book_was_added
|
464
463
|
rescue StandardError => ex
|
465
|
-
# FIXME: Message containing <> should be displayed correctly.
|
466
464
|
ErrorDialog.new(@new_book_dialog, _("Couldn't add the book"), ex.message).display
|
467
465
|
end
|
468
466
|
# books_to_add
|
@@ -93,7 +93,7 @@ module Alexandria
|
|
93
93
|
@treeview_authors.model.each { |_m, _p, i| authors << i[0] }
|
94
94
|
if authors.empty?
|
95
95
|
raise AddError, _("At least one author must be " \
|
96
|
-
|
96
|
+
"provided.")
|
97
97
|
end
|
98
98
|
book = Book.new(title, authors, isbn, publisher,
|
99
99
|
publishing_year.zero? ? nil : publishing_year,
|
@@ -41,7 +41,7 @@ module Alexandria
|
|
41
41
|
else
|
42
42
|
log.warn do
|
43
43
|
"no CheckButton for property #{pref_name} " \
|
44
|
-
|
44
|
+
"(probably conflicting versions of GUI and lib code)"
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -235,7 +235,7 @@ module Alexandria
|
|
235
235
|
|
236
236
|
def on_providers_button_press_event(_widget, event)
|
237
237
|
# double left click
|
238
|
-
on_provider_setup if (event.event_type == :
|
238
|
+
on_provider_setup if (event.event_type == :"2button_press") && (event.button == 1)
|
239
239
|
end
|
240
240
|
|
241
241
|
def on_close
|
@@ -27,7 +27,7 @@ module Alexandria
|
|
27
27
|
else
|
28
28
|
message = if books.length == 1
|
29
29
|
format(_("Are you sure you want to delete '%s' " \
|
30
|
-
|
30
|
+
"from '%s'?"), books.first.title, library.name)
|
31
31
|
else
|
32
32
|
_("Are you sure you want to delete the " \
|
33
33
|
"selected books from '%s'?") % library.name
|
@@ -418,7 +418,7 @@ module Alexandria
|
|
418
418
|
library.length), library.name, library.length)
|
419
419
|
else
|
420
420
|
format(n_("Library '%s' selected, %d book, " \
|
421
|
-
|
421
|
+
"%d unrated",
|
422
422
|
"Library '%s' selected, %d books, " \
|
423
423
|
"%d unrated",
|
424
424
|
library.length), library.name, library.length, n_unrated)
|
@@ -455,7 +455,7 @@ module Alexandria
|
|
455
455
|
log.debug { "#{@library_listview} : #{@library_popup} : #{@listview}" }
|
456
456
|
log.debug do
|
457
457
|
"@library_listview: #{@library_listview.has_focus?} " \
|
458
|
-
|
458
|
+
"or @library_popup:#{@library_popup.has_focus?}"
|
459
459
|
end
|
460
460
|
log.debug { "@library_listview does *NOT* have focus" }
|
461
461
|
log.debug { "Books are empty: #{books.empty?}" }
|
@@ -531,11 +531,8 @@ module Alexandria
|
|
531
531
|
@actiongroup["Sidepane"].active = false
|
532
532
|
end
|
533
533
|
|
534
|
-
# TODO: Figure out why this frequently selects the wrong book!
|
535
534
|
def select_a_book(book)
|
536
|
-
log.debug { "select_a_book: listview" }
|
537
535
|
select_book_in_view(book, @listview)
|
538
|
-
log.debug { "select_a_book: iconview" }
|
539
536
|
select_book_in_view(book, @iconview)
|
540
537
|
end
|
541
538
|
|
@@ -658,7 +655,7 @@ module Alexandria
|
|
658
655
|
|
659
656
|
log.debug do
|
660
657
|
"Trying to add #{book.title}, #{cover_uri}" \
|
661
|
-
|
658
|
+
" in library ''#{library.name}'"
|
662
659
|
end
|
663
660
|
library.save_cover(book, cover_uri) unless cover_uri.nil?
|
664
661
|
library << book
|
@@ -878,7 +875,6 @@ module Alexandria
|
|
878
875
|
end
|
879
876
|
|
880
877
|
def iter_from_ident(ident)
|
881
|
-
log.debug { ident.to_s }
|
882
878
|
iter = @model.iter_first
|
883
879
|
ok = true if iter
|
884
880
|
while ok
|
@@ -890,7 +886,6 @@ module Alexandria
|
|
890
886
|
end
|
891
887
|
|
892
888
|
def iter_from_book(book)
|
893
|
-
log.debug { book.to_s }
|
894
889
|
iter_from_ident(book.ident)
|
895
890
|
end
|
896
891
|
|
@@ -1074,7 +1069,7 @@ module Alexandria
|
|
1074
1069
|
# added by Cathal Mc Ginley, 23 Oct 2007
|
1075
1070
|
log.debug do
|
1076
1071
|
"library_sort_order #{@notebook.page}: " \
|
1077
|
-
|
1072
|
+
"#{@iconview.model.inspect} #{@listview.model.inspect}"
|
1078
1073
|
end
|
1079
1074
|
result, sort_column, sort_order = current_view.model.sort_column_id
|
1080
1075
|
if result
|
@@ -1100,10 +1095,10 @@ module Alexandria
|
|
1100
1095
|
def get_previous_selected_library(library)
|
1101
1096
|
log.debug { "get_previous_selected_library: #{library}" }
|
1102
1097
|
@previous_selected_library = selected_library
|
1103
|
-
if @previous_selected_library
|
1104
|
-
select_library(library)
|
1105
|
-
else
|
1098
|
+
if @previous_selected_library == library
|
1106
1099
|
@previous_selected_library = nil
|
1100
|
+
else
|
1101
|
+
select_library(library)
|
1107
1102
|
end
|
1108
1103
|
end
|
1109
1104
|
|
@@ -1181,23 +1176,20 @@ module Alexandria
|
|
1181
1176
|
private
|
1182
1177
|
|
1183
1178
|
def select_book_in_view(book, view)
|
1184
|
-
@filtered_model.refilter
|
1185
|
-
iter = iter_from_book book
|
1186
|
-
return unless iter
|
1187
|
-
|
1188
|
-
path = iter.path
|
1189
1179
|
return unless view.model
|
1190
1180
|
|
1181
|
+
@filtered_model.refilter
|
1182
|
+
iter = iter_from_book(book) or return
|
1183
|
+
path = iter.path
|
1191
1184
|
path = view_path_to_model_path(view, path)
|
1192
|
-
log.debug { "Path for #{book.ident} is #{path}" }
|
1193
1185
|
selection = view.respond_to?(:selection) ? view.selection : view
|
1194
1186
|
selection.unselect_all
|
1195
|
-
selection.select_path(path)
|
1187
|
+
selection.select_path(path) if path
|
1196
1188
|
end
|
1197
1189
|
|
1198
|
-
def view_path_to_model_path(view,
|
1199
|
-
|
1200
|
-
@filtered_model.convert_path_to_child_path(
|
1190
|
+
def view_path_to_model_path(view, view_path)
|
1191
|
+
filter_path = view.model.convert_path_to_child_path(view_path)
|
1192
|
+
@filtered_model.convert_path_to_child_path(filter_path) if filter_path
|
1201
1193
|
end
|
1202
1194
|
end
|
1203
1195
|
end
|