alexandria-book-collection-manager 0.7.5 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.gitignore +4 -1
- data/.rubocop.yml +51 -29
- data/.rubocop_todo.yml +33 -155
- data/.simplecov +5 -2
- data/.travis.yml +10 -4
- data/CHANGELOG.md +19 -0
- data/INSTALL.md +23 -11
- data/README.md +36 -35
- data/Rakefile +7 -5
- data/alexandria-book-collection-manager.gemspec +8 -3
- data/doc/dependency_decisions.yml +22 -3
- data/lib/alexandria.rb +2 -2
- data/lib/alexandria/book_providers.rb +47 -49
- data/lib/alexandria/book_providers/adlibris.rb +8 -13
- data/lib/alexandria/book_providers/amazon_aws.rb +47 -60
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +283 -298
- data/lib/alexandria/book_providers/barnes_and_noble.rb +8 -8
- data/lib/alexandria/book_providers/douban.rb +2 -2
- data/lib/alexandria/book_providers/proxis.rb +12 -11
- data/lib/alexandria/book_providers/pseudomarc.rb +60 -70
- data/lib/alexandria/book_providers/siciliano.rb +5 -6
- data/lib/alexandria/book_providers/thalia.rb +8 -9
- data/lib/alexandria/book_providers/worldcat.rb +25 -31
- data/lib/alexandria/book_providers/z3950.rb +62 -69
- data/lib/alexandria/default_preferences.rb +37 -0
- data/lib/alexandria/execution_queue.rb +13 -12
- data/lib/alexandria/export_library.rb +4 -8
- data/lib/alexandria/import_library.rb +38 -62
- data/lib/alexandria/import_library_csv.rb +16 -16
- data/lib/alexandria/library_sort_order.rb +3 -1
- data/lib/alexandria/library_store.rb +16 -16
- data/lib/alexandria/logging.rb +4 -8
- data/lib/alexandria/models/book.rb +2 -2
- data/lib/alexandria/models/library.rb +18 -14
- data/lib/alexandria/net.rb +1 -2
- data/lib/alexandria/preferences.rb +27 -31
- data/lib/alexandria/scanners.rb +2 -2
- data/lib/alexandria/scanners/cue_cat.rb +5 -5
- data/lib/alexandria/scanners/keyboard.rb +1 -1
- data/lib/alexandria/smart_library.rb +22 -26
- data/lib/alexandria/ui.rb +7 -7
- data/lib/alexandria/ui/about_dialog.rb +1 -1
- data/lib/alexandria/ui/acquire_dialog.rb +9 -10
- data/lib/alexandria/ui/alert_dialog.rb +34 -19
- data/lib/alexandria/ui/bad_isbns_dialog.rb +13 -9
- data/lib/alexandria/ui/barcode_animation.rb +5 -5
- data/lib/alexandria/ui/book_properties_dialog.rb +2 -2
- data/lib/alexandria/ui/book_properties_dialog_base.rb +23 -17
- data/lib/alexandria/ui/callbacks.rb +141 -120
- data/lib/alexandria/ui/completion_models.rb +1 -1
- data/lib/alexandria/ui/confirm_erase_dialog.rb +1 -1
- data/lib/alexandria/ui/conflict_while_copying_dialog.rb +1 -1
- data/lib/alexandria/ui/error_dialog.rb +1 -1
- data/lib/alexandria/ui/export_dialog.rb +13 -15
- data/lib/alexandria/ui/icons.rb +34 -40
- data/lib/alexandria/ui/iconview_tooltips.rb +40 -53
- data/lib/alexandria/ui/import_dialog.rb +48 -47
- data/lib/alexandria/ui/init.rb +3 -2
- data/lib/alexandria/ui/keep_bad_isbn_dialog.rb +2 -2
- data/lib/alexandria/ui/libraries_combo.rb +10 -9
- data/lib/alexandria/ui/listview.rb +5 -6
- data/lib/alexandria/ui/main_app.rb +2 -2
- data/lib/alexandria/ui/multi_drag_treeview.rb +4 -6
- data/lib/alexandria/ui/new_book_dialog.rb +52 -52
- data/lib/alexandria/ui/new_provider_dialog.rb +12 -11
- data/lib/alexandria/ui/new_smart_library_dialog.rb +39 -27
- data/lib/alexandria/ui/preferences_dialog.rb +23 -82
- data/lib/alexandria/ui/provider_preferences_base_dialog.rb +9 -5
- data/lib/alexandria/ui/provider_preferences_dialog.rb +5 -5
- data/lib/alexandria/ui/really_delete_dialog.rb +1 -1
- data/lib/alexandria/ui/sidepane_manager.rb +35 -37
- data/lib/alexandria/ui/skip_entry_dialog.rb +3 -2
- data/lib/alexandria/ui/smart_library_properties_dialog.rb +35 -36
- data/lib/alexandria/ui/smart_library_properties_dialog_base.rb +59 -138
- data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
- data/lib/alexandria/ui/sound.rb +4 -6
- data/lib/alexandria/ui/ui_manager.rb +62 -64
- data/lib/alexandria/version.rb +2 -2
- data/lib/alexandria/web_themes.rb +15 -15
- data/po/cs.po +991 -874
- data/po/cy.po +957 -870
- data/po/de.po +991 -866
- data/po/el.po +987 -863
- data/po/es.po +986 -862
- data/po/fr.po +988 -868
- data/po/ga.po +910 -822
- data/po/gl.po +983 -863
- data/po/it.po +984 -862
- data/po/ja.po +969 -849
- data/po/mk.po +983 -859
- data/po/nb.po +982 -862
- data/po/nl.po +992 -869
- data/po/pl.po +1018 -963
- data/po/pt.po +983 -852
- data/po/pt_BR.po +983 -863
- data/po/ru.po +992 -869
- data/po/sk.po +986 -864
- data/po/sv.po +980 -860
- data/po/uk.po +975 -861
- data/po/zh_TW.po +974 -854
- data/share/alexandria/glade/main_app__builder.glade +6 -21
- data/share/gnome/help/alexandria/C/smart-libraries.xml +2 -2
- data/share/gnome/help/alexandria/C/working-with-libraries.xml +1 -1
- data/share/gnome/help/alexandria/fr/alexandria.xml +1 -1
- data/share/gnome/help/alexandria/ja/smart-libraries.xml +1 -1
- data/spec/alexandria/book_providers/world_cat_provider_spec.rb +160 -0
- data/spec/alexandria/book_providers_spec.rb +73 -129
- data/spec/alexandria/console_spec.rb +0 -5
- data/spec/alexandria/export_library_spec.rb +27 -38
- data/spec/alexandria/library_spec.rb +56 -44
- data/spec/alexandria/preferences_spec.rb +29 -3
- data/spec/alexandria/scanners/cue_cat_spec.rb +1 -1
- data/spec/alexandria/ui/about_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/acquire_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/alert_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/book_properties_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/error_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/export_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/icons_spec.rb +26 -0
- data/spec/alexandria/ui/iconview_spec.rb +1 -1
- data/spec/alexandria/ui/import_dialog_spec.rb +30 -3
- data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/main_app_spec.rb +1 -1
- data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +1 -1
- data/spec/alexandria/ui/new_provider_dialog_spec.rb +19 -3
- data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +28 -3
- data/spec/alexandria/ui/preferences_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +23 -8
- data/spec/alexandria/ui/really_delete_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/sidepane_manager_spec.rb +2 -2
- data/spec/alexandria/ui/skip_entry_dialog_spec.rb +1 -1
- data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +21 -7
- data/spec/alexandria/ui/ui_manager_spec.rb +39 -2
- data/spec/spec_helper.rb +46 -3
- data/tasks/spec.rake +3 -5
- data/util/rake/fileinstall.rb +12 -11
- metadata +82 -10
- data/spec/alexandria/ui/ui_utilities_spec.rb +0 -62
- data/spec/alexandria/utilities_spec.rb +0 -52
data/lib/alexandria/ui/icons.rb
CHANGED
@@ -4,41 +4,6 @@
|
|
4
4
|
#
|
5
5
|
# See the file README.md for authorship and licensing information.
|
6
6
|
|
7
|
-
class GdkPixbuf::Pixbuf
|
8
|
-
def tag(tag_pixbuf)
|
9
|
-
# Computes some tweaks.
|
10
|
-
tweak_x = tag_pixbuf.width / 3
|
11
|
-
tweak_y = tag_pixbuf.height / 3
|
12
|
-
|
13
|
-
# Creates the destination pixbuf.
|
14
|
-
new_pixbuf = GdkPixbuf::Pixbuf.new(colorspace: :rgb,
|
15
|
-
has_alpha: true,
|
16
|
-
bits_per_sample: 8,
|
17
|
-
width: width + tweak_x,
|
18
|
-
height: height + tweak_y)
|
19
|
-
|
20
|
-
# Fills with blank.
|
21
|
-
new_pixbuf.fill!(0)
|
22
|
-
|
23
|
-
# Copies the current pixbuf there (south-west).
|
24
|
-
copy_area(0, 0,
|
25
|
-
width, height,
|
26
|
-
new_pixbuf,
|
27
|
-
0, tweak_y)
|
28
|
-
|
29
|
-
# Copies the tag pixbuf there (north-est).
|
30
|
-
tag_pixbuf_x = width - (tweak_x * 2)
|
31
|
-
new_pixbuf.composite!(tag_pixbuf,
|
32
|
-
dest_x: 0, dest_y: 0,
|
33
|
-
dest_width: tag_pixbuf.width + tag_pixbuf_x,
|
34
|
-
dest_height: tag_pixbuf.height,
|
35
|
-
offset_x: tag_pixbuf_x, offset_y: 0,
|
36
|
-
scale_x: 1, scale_y: 1,
|
37
|
-
interpolation_type: :hyper, overall_alpha: 255)
|
38
|
-
new_pixbuf
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
7
|
module Alexandria
|
43
8
|
module UI
|
44
9
|
module Icons
|
@@ -53,7 +18,7 @@ module Alexandria
|
|
53
18
|
# Alexandria::UI::Icons namespace, e.g., Icons::STAR_SET
|
54
19
|
def self.load_icon_images
|
55
20
|
Dir.entries(ICONS_DIR).each do |file|
|
56
|
-
next unless
|
21
|
+
next unless file.end_with?(".png") # skip non '.png' files
|
57
22
|
|
58
23
|
# Don't use upcase and use tr instead
|
59
24
|
# For example in Turkish the upper case of 'i' is still 'i'.
|
@@ -77,13 +42,42 @@ module Alexandria
|
|
77
42
|
BOOK_ICON
|
78
43
|
end
|
79
44
|
|
45
|
+
def self.tag_icon(icon_pixbuf, tag_pixbuf)
|
46
|
+
# Computes some tweaks.
|
47
|
+
tweak_x = tag_pixbuf.width / 3
|
48
|
+
tweak_y = tag_pixbuf.height / 3
|
49
|
+
|
50
|
+
# Creates the destination pixbuf.
|
51
|
+
new_pixbuf = GdkPixbuf::Pixbuf.new(colorspace: :rgb,
|
52
|
+
has_alpha: true,
|
53
|
+
bits_per_sample: 8,
|
54
|
+
width: icon_pixbuf.width + tweak_x,
|
55
|
+
height: icon_pixbuf.height + tweak_y)
|
56
|
+
|
57
|
+
# Fills with blank.
|
58
|
+
new_pixbuf.fill!(0)
|
59
|
+
|
60
|
+
# Copies the current pixbuf there (south-west).
|
61
|
+
icon_pixbuf.copy_area(0, 0,
|
62
|
+
icon_pixbuf.width, icon_pixbuf.height,
|
63
|
+
new_pixbuf,
|
64
|
+
0, tweak_y)
|
65
|
+
|
66
|
+
# Copies the tag pixbuf there (north-est).
|
67
|
+
tag_pixbuf_x = icon_pixbuf.width - (tweak_x * 2)
|
68
|
+
new_pixbuf.composite!(tag_pixbuf,
|
69
|
+
dest_x: 0, dest_y: 0,
|
70
|
+
dest_width: tag_pixbuf.width + tag_pixbuf_x,
|
71
|
+
dest_height: tag_pixbuf.height,
|
72
|
+
offset_x: tag_pixbuf_x, offset_y: 0,
|
73
|
+
scale_x: 1, scale_y: 1,
|
74
|
+
interpolation_type: :hyper, overall_alpha: 255)
|
75
|
+
new_pixbuf
|
76
|
+
end
|
77
|
+
|
80
78
|
def self.blank?(filename)
|
81
79
|
pixbuf = GdkPixbuf::Pixbuf.new(file: filename)
|
82
80
|
(pixbuf.width == 1) && (pixbuf.height == 1)
|
83
|
-
rescue StandardError => ex
|
84
|
-
puts ex.message
|
85
|
-
puts ex.backtrace.join("\n> ")
|
86
|
-
true
|
87
81
|
end
|
88
82
|
end
|
89
83
|
end
|
@@ -1,25 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# This file is part of Alexandria.
|
4
4
|
#
|
5
|
-
#
|
6
|
-
# Copyright (C) 2008,2009 Cathal Mc Ginley
|
7
|
-
# Copyright (C) 2011, 2014, 2016 Matijs van Zuijlen
|
8
|
-
#
|
9
|
-
# Alexandria is free software; you can redistribute it and/or
|
10
|
-
# modify it under the terms of the GNU General Public License as
|
11
|
-
# published by the Free Software Foundation; either version 2 of the
|
12
|
-
# License, or (at your option) any later version.
|
13
|
-
#
|
14
|
-
# Alexandria is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17
|
-
# General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU General Public
|
20
|
-
# License along with Alexandria; see the file COPYING. If not,
|
21
|
-
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
22
|
-
# Fifth Floor, Boston, MA 02110-1301 USA.
|
5
|
+
# See the file README.md for authorship and licensing information.
|
23
6
|
|
24
7
|
# Please retain the following note:
|
25
8
|
#
|
@@ -31,47 +14,51 @@
|
|
31
14
|
|
32
15
|
require "cgi"
|
33
16
|
|
34
|
-
|
35
|
-
|
17
|
+
module Alexandria
|
18
|
+
module UI
|
19
|
+
class IconViewTooltips
|
20
|
+
include Logging
|
36
21
|
|
37
|
-
|
38
|
-
|
39
|
-
|
22
|
+
def initialize(view)
|
23
|
+
set_view(view)
|
24
|
+
end
|
40
25
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
26
|
+
def set_view(view)
|
27
|
+
view.has_tooltip = true
|
28
|
+
view.signal_connect("query-tooltip") do |_widget, x, y, _keyboard_mode, tooltip|
|
29
|
+
tree_path = view.get_path_at_pos(x, y)
|
30
|
+
if tree_path
|
31
|
+
iter = view.model.get_iter(tree_path)
|
47
32
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
33
|
+
title = iter[2] # HACK: hardcoded, should use column names...
|
34
|
+
authors = iter[4]
|
35
|
+
publisher = iter[6]
|
36
|
+
year = iter[7]
|
37
|
+
tooltip.set_markup label_for_book(title, authors, publisher, year)
|
38
|
+
end
|
39
|
+
end
|
53
40
|
end
|
54
|
-
end
|
55
|
-
end
|
56
41
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
42
|
+
def label_for_book(title, authors, publisher, year)
|
43
|
+
# This is much too complex... but it works for now!
|
44
|
+
html = ""
|
45
|
+
unless title.empty?
|
46
|
+
html += "<b>#{CGI.escapeHTML(title)}</b>"
|
47
|
+
html += "\n" unless authors.empty?
|
48
|
+
end
|
49
|
+
html += "<i>#{CGI.escapeHTML(authors)}</i>" unless authors.empty?
|
50
|
+
html += "\n" if !title.empty? || !authors.empty?
|
66
51
|
|
67
|
-
|
68
|
-
|
52
|
+
html += "<small>"
|
53
|
+
html += CGI.escapeHTML(publisher).to_s if publisher && !publisher.empty?
|
69
54
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
55
|
+
if year && !year.empty?
|
56
|
+
html += " " if publisher && !publisher.empty?
|
57
|
+
html += "(#{year})"
|
58
|
+
end
|
74
59
|
|
75
|
-
|
60
|
+
html + "</small>"
|
61
|
+
end
|
62
|
+
end
|
76
63
|
end
|
77
64
|
end
|
@@ -7,18 +7,9 @@
|
|
7
7
|
require "alexandria/ui/error_dialog"
|
8
8
|
require "alexandria/ui/skip_entry_dialog"
|
9
9
|
|
10
|
-
class Alexandria::ImportFilter
|
11
|
-
def to_filefilter
|
12
|
-
filefilter = Gtk::FileFilter.new
|
13
|
-
filefilter.name = name
|
14
|
-
patterns.each { |x| filefilter.add_pattern(x) }
|
15
|
-
filefilter
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
10
|
module Alexandria
|
20
11
|
module UI
|
21
|
-
class ImportDialog
|
12
|
+
class ImportDialog
|
22
13
|
include GetText
|
23
14
|
include Logging
|
24
15
|
|
@@ -26,55 +17,56 @@ module Alexandria
|
|
26
17
|
|
27
18
|
FILTERS = Alexandria::ImportFilter.all
|
28
19
|
|
20
|
+
attr_reader :dialog
|
21
|
+
|
29
22
|
def initialize(parent)
|
30
23
|
title = _("Import a Library")
|
31
|
-
dialog = Gtk::FileChooserDialog.new title: title, parent: parent, action: :open
|
32
|
-
|
33
|
-
puts "ImportDialog opened." if $DEBUG
|
24
|
+
@dialog = Gtk::FileChooserDialog.new title: title, parent: parent, action: :open
|
25
|
+
log.debug { "ImportDialog opened" }
|
34
26
|
@destroyed = false
|
35
27
|
@running = false
|
36
|
-
add_button(Gtk::Stock::HELP, Gtk::ResponseType::HELP)
|
37
|
-
add_button(Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL)
|
38
|
-
import_button = add_button(_("_Import"),
|
39
|
-
|
28
|
+
dialog.add_button(Gtk::Stock::HELP, Gtk::ResponseType::HELP)
|
29
|
+
dialog.add_button(Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL)
|
30
|
+
import_button = dialog.add_button(_("_Import"),
|
31
|
+
Gtk::ResponseType::ACCEPT)
|
40
32
|
import_button.sensitive = false
|
41
33
|
|
42
|
-
signal_connect("destroy") do
|
34
|
+
dialog.signal_connect("destroy") do
|
43
35
|
if @running
|
44
36
|
@destroyed = true
|
45
37
|
else
|
46
|
-
destroy
|
38
|
+
dialog.destroy
|
47
39
|
end
|
48
40
|
end
|
49
41
|
|
50
|
-
filters = {}
|
42
|
+
@filters = {}
|
51
43
|
FILTERS.each do |filter|
|
52
|
-
filefilter = filter
|
53
|
-
add_filter(filefilter)
|
54
|
-
|
55
|
-
filters[filefilter] = filter
|
44
|
+
filefilter = make_filefilter filter
|
45
|
+
dialog.add_filter(filefilter)
|
46
|
+
log.debug { "Added ImportFilter #{filefilter} -- #{filefilter.name}" }
|
47
|
+
@filters[filefilter] = filter
|
56
48
|
end
|
57
49
|
|
58
|
-
signal_connect("selection_changed") do
|
59
|
-
import_button.sensitive =
|
50
|
+
dialog.signal_connect("selection_changed") do
|
51
|
+
import_button.sensitive = filename && File.file?(filename)
|
60
52
|
end
|
61
53
|
|
62
54
|
# before adding the (hidden) progress bar, we must re-set the
|
63
55
|
# packing of the button box (currently packed at the end),
|
64
56
|
# because the progressbar will be *after* the button box.
|
65
|
-
buttonbox = child.children.last
|
66
|
-
child.set_child_packing(buttonbox, pack_type: :start)
|
67
|
-
child.reorder_child(buttonbox, 1)
|
57
|
+
buttonbox = dialog.child.children.last
|
58
|
+
dialog.child.set_child_packing(buttonbox, pack_type: :start)
|
59
|
+
dialog.child.reorder_child(buttonbox, 1)
|
68
60
|
|
69
|
-
pbar = Gtk::ProgressBar.new
|
70
|
-
pbar.show_text = true
|
71
|
-
child.pack_start(pbar, expand: false)
|
61
|
+
@pbar = Gtk::ProgressBar.new
|
62
|
+
@pbar.show_text = true
|
63
|
+
dialog.child.pack_start(@pbar, expand: false)
|
72
64
|
end
|
73
65
|
|
74
66
|
def acquire
|
75
67
|
on_progress = proc do |fraction|
|
76
|
-
pbar.show unless pbar.visible?
|
77
|
-
pbar.fraction = fraction
|
68
|
+
@pbar.show unless @pbar.visible?
|
69
|
+
@pbar.fraction = fraction
|
78
70
|
end
|
79
71
|
|
80
72
|
on_error = proc do |message|
|
@@ -84,27 +76,27 @@ module Alexandria
|
|
84
76
|
exec_queue = ExecutionQueue.new
|
85
77
|
|
86
78
|
while !@destroyed &&
|
87
|
-
((response = run) != Gtk::ResponseType::CANCEL) &&
|
79
|
+
((response = dialog.run) != Gtk::ResponseType::CANCEL) &&
|
88
80
|
response != Gtk::ResponseType::DELETE_EVENT
|
89
81
|
|
90
82
|
if response == Gtk::ResponseType::HELP
|
91
83
|
Alexandria::UI.display_help(self, "import-library")
|
92
84
|
next
|
93
85
|
end
|
94
|
-
file = File.basename(filename, ".*")
|
86
|
+
file = File.basename(dialog.filename, ".*")
|
95
87
|
base = GLib.locale_to_utf8(file)
|
96
88
|
new_library_name = Library.generate_new_name(
|
97
89
|
LibraryCollection.instance.all_libraries,
|
98
90
|
base)
|
99
91
|
|
100
|
-
filter = filters[
|
101
|
-
|
102
|
-
|
92
|
+
filter = @filters[dialog.filter]
|
93
|
+
log.debug { "Going forward with filter: #{filter.name}" }
|
94
|
+
dialog.sensitive = false
|
103
95
|
|
104
96
|
filter.on_iterate do |n, total|
|
105
97
|
unless @destroyed
|
106
98
|
fraction = n * 1.0 / total
|
107
|
-
|
99
|
+
log.debug { "#{inspect} fraction: #{fraction}" }
|
108
100
|
exec_queue.call(on_progress, fraction)
|
109
101
|
end
|
110
102
|
end
|
@@ -112,22 +104,21 @@ module Alexandria
|
|
112
104
|
not_cancelled = true
|
113
105
|
filter.on_error do |message|
|
114
106
|
not_cancelled = exec_queue.sync_call(on_error, message)
|
115
|
-
|
107
|
+
log.debug { "#{inspect} cancel state: #{not_cancelled}" }
|
116
108
|
end
|
117
109
|
|
118
110
|
library = nil
|
119
111
|
@bad_isbns = nil
|
120
112
|
@failed_isbns = nil
|
121
113
|
thread = Thread.start do
|
122
|
-
library, @bad_isbns, @failed_isbns =
|
123
|
-
|
114
|
+
library, @bad_isbns, @failed_isbns =
|
115
|
+
filter.invoke(new_library_name, dialog.filename)
|
124
116
|
rescue StandardError => ex
|
125
117
|
trace = ex.backtrace.join("\n> ")
|
126
118
|
log.error { "Import failed: #{ex.message} #{trace}" }
|
127
119
|
end
|
128
120
|
|
129
121
|
while thread.alive? && !@destroyed
|
130
|
-
# puts "Thread #{thread} still alive."
|
131
122
|
@running = true
|
132
123
|
exec_queue.iterate
|
133
124
|
Gtk.main_iteration_do(false)
|
@@ -138,8 +129,8 @@ module Alexandria
|
|
138
129
|
yield(library, @bad_isbns, @failed_isbns)
|
139
130
|
break
|
140
131
|
elsif not_cancelled
|
141
|
-
|
142
|
-
ErrorDialog.new(
|
132
|
+
log.debug { "Raising ErrorDialog because not_cancelled is #{not_cancelled}" }
|
133
|
+
ErrorDialog.new(dialog,
|
143
134
|
_("Couldn't import the library"),
|
144
135
|
_("The format of the file you " \
|
145
136
|
"provided is unknown. Please " \
|
@@ -149,7 +140,17 @@ module Alexandria
|
|
149
140
|
self.sensitive = true
|
150
141
|
end
|
151
142
|
end
|
152
|
-
|
143
|
+
|
144
|
+
dialog.destroy unless @destroyed
|
145
|
+
end
|
146
|
+
|
147
|
+
private
|
148
|
+
|
149
|
+
def make_filefilter(import_filter)
|
150
|
+
filefilter = Gtk::FileFilter.new
|
151
|
+
filefilter.name = import_filter.name
|
152
|
+
import_filter.patterns.each { |x| filefilter.add_pattern(x) }
|
153
|
+
filefilter
|
153
154
|
end
|
154
155
|
end
|
155
156
|
end
|
data/lib/alexandria/ui/init.rb
CHANGED
@@ -8,6 +8,7 @@ require "alexandria/ui/error_dialog"
|
|
8
8
|
|
9
9
|
class CellRendererToggle < Gtk::CellRendererToggle
|
10
10
|
attr_accessor :text
|
11
|
+
|
11
12
|
type_register
|
12
13
|
install_property(GLib::Param::String.new(
|
13
14
|
"text",
|
@@ -18,8 +19,8 @@ class CellRendererToggle < Gtk::CellRendererToggle
|
|
18
19
|
end
|
19
20
|
|
20
21
|
class Gtk::ActionGroup
|
21
|
-
def [](
|
22
|
-
get_action(
|
22
|
+
def [](index)
|
23
|
+
get_action(index)
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
@@ -16,13 +16,13 @@ module Alexandria
|
|
16
16
|
title = _("Invalid ISBN '%s'") % book.isbn
|
17
17
|
message =
|
18
18
|
_("The book titled '%s' has an invalid ISBN, but still " \
|
19
|
-
"exists in the providers libraries.
|
19
|
+
"exists in the providers libraries. Do you want to " \
|
20
20
|
"keep the book but change the ISBN or cancel the addition?") % book.title
|
21
21
|
super(parent, title,
|
22
22
|
Gtk::Stock::DIALOG_QUESTION,
|
23
23
|
[[Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL],
|
24
24
|
[_("_Keep"), Gtk::ResponseType::OK]], message)
|
25
|
-
|
25
|
+
dialog.default_response = Gtk::ResponseType::OK
|
26
26
|
end
|
27
27
|
|
28
28
|
def keep?
|
@@ -35,16 +35,10 @@ module Alexandria
|
|
35
35
|
clear
|
36
36
|
self.model = Gtk::ListStore.new(GdkPixbuf::Pixbuf, String, TrueClass)
|
37
37
|
libraries_names.each do |library_name|
|
38
|
-
|
39
|
-
iter[0] = Alexandria::UI::Icons::LIBRARY_SMALL
|
40
|
-
iter[1] = library_name
|
41
|
-
iter[2] = false
|
38
|
+
append_entry(Alexandria::UI::Icons::LIBRARY_SMALL, library_name, false)
|
42
39
|
end
|
43
|
-
|
44
|
-
|
45
|
-
iter[0] = Alexandria::UI::Icons::LIBRARY_SMALL
|
46
|
-
iter[1] = _("New Library")
|
47
|
-
iter[2] = true
|
40
|
+
append_entry(nil, "-", nil)
|
41
|
+
append_entry(Alexandria::UI::Icons::LIBRARY_SMALL, _("New Library"), true)
|
48
42
|
renderer = Gtk::CellRendererPixbuf.new
|
49
43
|
pack_start(renderer, false)
|
50
44
|
set_attributes(renderer, pixbuf: 0)
|
@@ -79,6 +73,13 @@ module Alexandria
|
|
79
73
|
|
80
74
|
[library, is_new]
|
81
75
|
end
|
76
|
+
|
77
|
+
def append_entry(icon, label, is_new)
|
78
|
+
iter = model.append
|
79
|
+
iter[0] = icon
|
80
|
+
iter[1] = label
|
81
|
+
iter[2] = is_new
|
82
|
+
end
|
82
83
|
end
|
83
84
|
end
|
84
85
|
|