alexandria-book-collection-manager 0.7.2 → 0.7.7
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/.github/workflows/ruby.yml +77 -0
- data/.gitignore +5 -1
- data/.hound.yml +2 -0
- data/.rubocop.yml +87 -37
- data/.rubocop_todo.yml +62 -191
- data/.simplecov +5 -2
- data/CHANGELOG.md +63 -0
- data/Gemfile +4 -3
- data/INSTALL.md +26 -14
- data/README.md +52 -42
- data/Rakefile +93 -109
- data/TODO.md +9 -1
- data/alexandria-book-collection-manager.gemspec +50 -43
- data/bin/alexandria +30 -53
- data/doc/FAQ +2 -6
- data/doc/dependency_decisions.yml +27 -8
- data/lib/alexandria.rb +27 -37
- data/lib/alexandria/about.rb +50 -50
- data/lib/alexandria/book_providers.rb +90 -97
- data/lib/alexandria/book_providers/adlibris.rb +41 -76
- data/lib/alexandria/book_providers/amazon_aws.rb +96 -100
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +295 -322
- data/lib/alexandria/book_providers/barnes_and_noble.rb +48 -45
- data/lib/alexandria/book_providers/douban.rb +26 -42
- data/lib/alexandria/book_providers/proxis.rb +44 -55
- data/lib/alexandria/book_providers/pseudomarc.rb +77 -85
- data/lib/alexandria/book_providers/siciliano.rb +64 -65
- data/lib/alexandria/book_providers/thalia.rb +42 -41
- data/lib/alexandria/book_providers/web.rb +15 -33
- data/lib/alexandria/book_providers/worldcat.rb +70 -97
- data/lib/alexandria/book_providers/z3950.rb +160 -173
- data/lib/alexandria/config.rb +1 -1
- data/lib/alexandria/console.rb +8 -21
- data/lib/alexandria/default_preferences.rb +37 -0
- data/lib/alexandria/execution_queue.rb +15 -13
- data/lib/alexandria/export_format.rb +47 -0
- data/lib/alexandria/export_library.rb +193 -300
- data/lib/alexandria/import_library.rb +108 -141
- data/lib/alexandria/import_library_csv.rb +43 -46
- data/lib/alexandria/library_collection.rb +79 -0
- data/lib/alexandria/library_sort_order.rb +45 -0
- data/lib/alexandria/library_store.rb +233 -0
- data/lib/alexandria/logging.rb +11 -13
- data/lib/alexandria/models/book.rb +13 -20
- data/lib/alexandria/models/library.rb +81 -353
- data/lib/alexandria/net.rb +5 -6
- data/lib/alexandria/preferences.rb +73 -87
- data/lib/alexandria/scanners.rb +2 -2
- data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +20 -18
- data/lib/alexandria/scanners/keyboard.rb +8 -8
- data/lib/alexandria/smart_library.rb +133 -170
- data/lib/alexandria/ui.rb +15 -15
- data/lib/alexandria/ui/about_dialog.rb +49 -0
- data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +119 -136
- data/lib/alexandria/ui/alert_dialog.rb +64 -0
- data/lib/alexandria/ui/bad_isbns_dialog.rb +41 -0
- data/lib/alexandria/ui/{dialogs/barcode_animation.rb → barcode_animation.rb} +16 -15
- data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +39 -52
- data/lib/alexandria/ui/book_properties_dialog_base.rb +318 -0
- data/lib/alexandria/ui/builder_base.rb +7 -27
- data/lib/alexandria/ui/calendar_popup.rb +58 -0
- data/lib/alexandria/ui/callbacks.rb +189 -183
- data/lib/alexandria/ui/completion_models.rb +10 -23
- data/lib/alexandria/ui/confirm_erase_dialog.rb +33 -0
- data/lib/alexandria/ui/conflict_while_copying_dialog.rb +34 -0
- data/lib/alexandria/ui/dndable.rb +7 -7
- data/lib/alexandria/ui/error_dialog.rb +25 -0
- data/lib/alexandria/ui/export_dialog.rb +142 -0
- data/lib/alexandria/ui/icons.rb +47 -63
- data/lib/alexandria/ui/iconview.rb +12 -10
- data/lib/alexandria/ui/iconview_tooltips.rb +41 -54
- data/lib/alexandria/ui/import_dialog.rb +157 -0
- data/lib/alexandria/ui/init.rb +21 -33
- data/lib/alexandria/ui/keep_bad_isbn_dialog.rb +36 -0
- data/lib/alexandria/ui/libraries_combo.rb +16 -14
- data/lib/alexandria/ui/listview.rb +73 -87
- data/lib/alexandria/ui/main_app.rb +24 -26
- data/lib/alexandria/ui/misc_dialogs.rb +10 -0
- data/lib/alexandria/ui/multi_drag_treeview.rb +28 -41
- data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +156 -194
- data/lib/alexandria/ui/new_book_dialog_manual.rb +139 -0
- data/lib/alexandria/ui/new_provider_dialog.rb +100 -0
- data/lib/alexandria/ui/new_smart_library_dialog.rb +74 -0
- data/lib/alexandria/ui/preferences_dialog.rb +313 -0
- data/lib/alexandria/ui/provider_preferences_base_dialog.rb +95 -0
- data/lib/alexandria/ui/provider_preferences_dialog.rb +35 -0
- data/lib/alexandria/ui/really_delete_dialog.rb +53 -0
- data/lib/alexandria/ui/{sidepane.rb → sidepane_manager.rb} +56 -68
- data/lib/alexandria/ui/skip_entry_dialog.rb +33 -0
- data/lib/alexandria/ui/smart_library_properties_dialog.rb +60 -0
- data/lib/alexandria/ui/smart_library_properties_dialog_base.rb +242 -0
- data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
- data/lib/alexandria/ui/sound.rb +11 -13
- data/lib/alexandria/ui/ui_manager.rb +236 -251
- data/lib/alexandria/undo_manager.rb +1 -0
- data/lib/alexandria/version.rb +4 -19
- data/lib/alexandria/web_themes.rb +22 -21
- data/po/Makefile +2 -2
- data/po/cs.po +993 -880
- data/po/cy.po +957 -874
- data/po/de.po +990 -869
- data/po/el.po +989 -869
- data/po/es.po +985 -865
- data/po/fr.po +986 -870
- data/po/ga.po +907 -823
- data/po/gl.po +981 -865
- data/po/it.po +986 -868
- data/po/ja.po +969 -853
- data/po/mk.po +983 -863
- data/po/nb.po +979 -863
- data/po/nl.po +983 -864
- data/po/pl.po +1017 -974
- data/po/pt.po +988 -861
- data/po/pt_BR.po +984 -868
- data/po/ru.po +992 -873
- data/po/sk.po +987 -869
- data/po/sv.po +977 -861
- data/po/uk.po +975 -865
- data/po/zh_TW.po +976 -860
- data/schemas/alexandria.schemas +25 -3
- data/share/alexandria/glade/acquire_dialog__builder.glade +15 -12
- data/share/alexandria/glade/book_properties_dialog__builder.glade +171 -299
- data/share/alexandria/glade/main_app__builder.glade +24 -33
- data/share/alexandria/glade/new_book_dialog__builder.glade +27 -59
- data/share/alexandria/glade/preferences_dialog__builder.glade +250 -290
- data/share/gnome/help/alexandria/C/introduction.xml +0 -8
- data/share/gnome/help/alexandria/C/searching.xml +1 -1
- 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/introduction.xml +0 -8
- 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 +75 -171
- data/spec/alexandria/book_spec.rb +12 -10
- data/spec/alexandria/console_spec.rb +27 -0
- data/spec/alexandria/export_library_spec.rb +130 -0
- data/spec/alexandria/library_spec.rb +128 -172
- data/spec/alexandria/library_store_spec.rb +37 -0
- data/spec/alexandria/preferences_spec.rb +44 -17
- data/spec/alexandria/scanners/cue_cat_spec.rb +52 -0
- data/spec/alexandria/smart_library_spec.rb +30 -25
- data/spec/alexandria/ui/about_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/acquire_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/alert_dialog_spec.rb +16 -0
- data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/book_properties_dialog_spec.rb +17 -0
- data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +16 -0
- data/spec/alexandria/ui/error_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/export_dialog_spec.rb +36 -0
- data/spec/alexandria/ui/icons_spec.rb +26 -0
- data/spec/alexandria/ui/iconview_spec.rb +7 -21
- data/spec/alexandria/ui/import_dialog_spec.rb +46 -0
- data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +17 -0
- data/spec/alexandria/ui/main_app_spec.rb +7 -34
- data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +15 -0
- data/spec/alexandria/ui/new_book_dialog_spec.rb +22 -0
- data/spec/alexandria/ui/new_provider_dialog_spec.rb +30 -0
- data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +39 -0
- data/spec/alexandria/ui/preferences_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +34 -0
- data/spec/alexandria/ui/really_delete_dialog_spec.rb +16 -0
- data/spec/alexandria/ui/sidepane_manager_spec.rb +15 -0
- data/spec/alexandria/ui/skip_entry_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +49 -0
- data/spec/alexandria/ui/sound_spec.rb +2 -2
- data/spec/alexandria/ui/ui_manager_spec.rb +43 -20
- data/spec/end_to_end/basic_run_spec.rb +52 -0
- data/spec/spec_helper.rb +65 -33
- data/tasks/setup.rb +2 -2
- data/tasks/spec.rake +16 -3
- data/util/rake/fileinstall.rb +39 -35
- data/util/rake/gettextgenerate.rb +7 -7
- data/util/rake/omfgenerate.rb +7 -7
- metadata +178 -45
- data/dogtail/basic_run_test.py +0 -9
- data/lib/alexandria/book_providers/deastore.rb +0 -265
- data/lib/alexandria/book_providers/mcu.rb +0 -182
- data/lib/alexandria/book_providers/renaud.rb +0 -149
- data/lib/alexandria/ui/dialogs/about_dialog.rb +0 -61
- data/lib/alexandria/ui/dialogs/alert_dialog.rb +0 -72
- data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +0 -51
- data/lib/alexandria/ui/dialogs/book_properties_dialog_base.rb +0 -426
- data/lib/alexandria/ui/dialogs/export_dialog.rb +0 -171
- data/lib/alexandria/ui/dialogs/import_dialog.rb +0 -196
- data/lib/alexandria/ui/dialogs/misc_dialogs.rb +0 -87
- data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +0 -154
- data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +0 -74
- data/lib/alexandria/ui/dialogs/preferences_dialog.rb +0 -568
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +0 -59
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +0 -420
- data/spec/alexandria/scanners/cuecat_spec.rb +0 -67
- data/spec/alexandria/ui/dialogs_spec.rb +0 -96
- data/spec/alexandria/ui/sidepane_spec.rb +0 -29
- data/spec/alexandria/ui/ui_utilities_spec.rb +0 -62
- data/spec/alexandria/utilities_spec.rb +0 -52
- data/tasks/dogtail.rake +0 -6
@@ -19,8 +19,8 @@
|
|
19
19
|
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
20
20
|
# Fifth Floor, Boston, MA 02110-1301 USA.
|
21
21
|
|
22
|
-
require
|
23
|
-
require
|
22
|
+
require "alexandria/ui/columns"
|
23
|
+
require "alexandria/ui/iconview_tooltips"
|
24
24
|
|
25
25
|
module Alexandria
|
26
26
|
module UI
|
@@ -51,14 +51,14 @@ module Alexandria
|
|
51
51
|
@iconview.column_spacing = 16
|
52
52
|
@iconview.item_width = ICON_WIDTH + 16
|
53
53
|
|
54
|
-
@iconview.signal_connect(
|
55
|
-
log.debug {
|
54
|
+
@iconview.signal_connect("selection-changed") do
|
55
|
+
log.debug { "selection-changed" }
|
56
56
|
@parent.on_books_selection_changed
|
57
57
|
end
|
58
58
|
|
59
|
-
@iconview.signal_connect(
|
60
|
-
log.debug {
|
61
|
-
@actiongroup[
|
59
|
+
@iconview.signal_connect("item-activated") do
|
60
|
+
log.debug { "item-activated" }
|
61
|
+
@actiongroup["Properties"].activate
|
62
62
|
false
|
63
63
|
end
|
64
64
|
|
@@ -68,12 +68,14 @@ module Alexandria
|
|
68
68
|
|
69
69
|
ICONS_SORTS = [
|
70
70
|
Columns::TITLE, Columns::AUTHORS, Columns::ISBN,
|
71
|
-
Columns::PUBLISHER, Columns::EDITION, Columns::RATING,
|
71
|
+
Columns::PUBLISHER, Columns::EDITION, Columns::RATING,
|
72
|
+
Columns::REDD, Columns::OWN, Columns::WANT
|
72
73
|
].freeze
|
74
|
+
|
73
75
|
def setup_books_iconview_sorting
|
74
76
|
mode = ICONS_SORTS[@prefs.arrange_icons_mode]
|
75
|
-
@
|
76
|
-
|
77
|
+
sort = @prefs.reverse_icons ? Gtk::SORT_DESCENDING : Gtk::SORT_ASCENDING
|
78
|
+
@iconview_model.set_sort_column_id(mode, sort)
|
77
79
|
@filtered_model.refilter # force redraw
|
78
80
|
end
|
79
81
|
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
|
#
|
@@ -29,49 +12,53 @@
|
|
29
12
|
#
|
30
13
|
# Ported to ruby-gtk2 (and modified for IconView) by Cathal Mc Ginley
|
31
14
|
|
32
|
-
require
|
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
|
@@ -0,0 +1,157 @@
|
|
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/ui/error_dialog"
|
8
|
+
require "alexandria/ui/skip_entry_dialog"
|
9
|
+
|
10
|
+
module Alexandria
|
11
|
+
module UI
|
12
|
+
class ImportDialog
|
13
|
+
include GetText
|
14
|
+
include Logging
|
15
|
+
|
16
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
17
|
+
|
18
|
+
FILTERS = Alexandria::ImportFilter.all
|
19
|
+
|
20
|
+
attr_reader :dialog
|
21
|
+
|
22
|
+
def initialize(parent)
|
23
|
+
title = _("Import a Library")
|
24
|
+
@dialog = Gtk::FileChooserDialog.new title: title, parent: parent, action: :open
|
25
|
+
log.debug { "ImportDialog opened" }
|
26
|
+
@destroyed = false
|
27
|
+
@running = false
|
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)
|
32
|
+
import_button.sensitive = false
|
33
|
+
|
34
|
+
dialog.signal_connect("destroy") do
|
35
|
+
if @running
|
36
|
+
@destroyed = true
|
37
|
+
else
|
38
|
+
dialog.destroy
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
@filters = {}
|
43
|
+
FILTERS.each do |filter|
|
44
|
+
filefilter = make_filefilter filter
|
45
|
+
dialog.add_filter(filefilter)
|
46
|
+
log.debug { "Added ImportFilter #{filefilter} -- #{filefilter.name}" }
|
47
|
+
@filters[filefilter] = filter
|
48
|
+
end
|
49
|
+
|
50
|
+
dialog.signal_connect("selection_changed") do
|
51
|
+
import_button.sensitive = dialog.filename && File.file?(dialog.filename)
|
52
|
+
end
|
53
|
+
|
54
|
+
# before adding the (hidden) progress bar, we must re-set the
|
55
|
+
# packing of the button box (currently packed at the end),
|
56
|
+
# because the progressbar will be *after* the button box.
|
57
|
+
buttonbox = dialog.child.children.last
|
58
|
+
dialog.child.set_child_packing(buttonbox, pack_type: :start)
|
59
|
+
dialog.child.reorder_child(buttonbox, 1)
|
60
|
+
|
61
|
+
@pbar = Gtk::ProgressBar.new
|
62
|
+
@pbar.show_text = true
|
63
|
+
dialog.child.pack_start(@pbar, expand: false)
|
64
|
+
end
|
65
|
+
|
66
|
+
def acquire
|
67
|
+
on_progress = proc do |fraction|
|
68
|
+
@pbar.show unless @pbar.visible?
|
69
|
+
@pbar.fraction = fraction
|
70
|
+
end
|
71
|
+
|
72
|
+
on_error = proc do |message|
|
73
|
+
SkipEntryDialog.new(self, message).continue?
|
74
|
+
end
|
75
|
+
|
76
|
+
exec_queue = ExecutionQueue.new
|
77
|
+
|
78
|
+
while !@destroyed &&
|
79
|
+
((response = dialog.run) != Gtk::ResponseType::CANCEL) &&
|
80
|
+
response != Gtk::ResponseType::DELETE_EVENT
|
81
|
+
|
82
|
+
if response == Gtk::ResponseType::HELP
|
83
|
+
Alexandria::UI.display_help(self, "import-library")
|
84
|
+
next
|
85
|
+
end
|
86
|
+
file = File.basename(dialog.filename, ".*")
|
87
|
+
base = GLib.locale_to_utf8(file)
|
88
|
+
new_library_name = Library.generate_new_name(
|
89
|
+
LibraryCollection.instance.all_libraries,
|
90
|
+
base)
|
91
|
+
|
92
|
+
filter = @filters[dialog.filter]
|
93
|
+
log.debug { "Going forward with filter: #{filter.name}" }
|
94
|
+
dialog.sensitive = false
|
95
|
+
|
96
|
+
filter.on_iterate do |n, total|
|
97
|
+
unless @destroyed
|
98
|
+
fraction = n * 1.0 / total
|
99
|
+
log.debug { "#{inspect} fraction: #{fraction}" }
|
100
|
+
exec_queue.call(on_progress, fraction)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
not_cancelled = true
|
105
|
+
filter.on_error do |message|
|
106
|
+
not_cancelled = exec_queue.sync_call(on_error, message)
|
107
|
+
log.debug { "#{inspect} cancel state: #{not_cancelled}" }
|
108
|
+
end
|
109
|
+
|
110
|
+
library = nil
|
111
|
+
@bad_isbns = nil
|
112
|
+
@failed_isbns = nil
|
113
|
+
thread = Thread.start do
|
114
|
+
library, @bad_isbns, @failed_isbns =
|
115
|
+
filter.invoke(new_library_name, dialog.filename)
|
116
|
+
rescue StandardError => ex
|
117
|
+
trace = ex.backtrace.join("\n> ")
|
118
|
+
log.error { "Import failed: #{ex.message} #{trace}" }
|
119
|
+
end
|
120
|
+
|
121
|
+
while thread.alive? && !@destroyed
|
122
|
+
@running = true
|
123
|
+
exec_queue.iterate
|
124
|
+
Gtk.main_iteration_do(false)
|
125
|
+
end
|
126
|
+
|
127
|
+
unless @destroyed
|
128
|
+
if library
|
129
|
+
yield(library, @bad_isbns, @failed_isbns)
|
130
|
+
break
|
131
|
+
elsif not_cancelled
|
132
|
+
log.debug { "Raising ErrorDialog because not_cancelled is #{not_cancelled}" }
|
133
|
+
ErrorDialog.new(dialog,
|
134
|
+
_("Couldn't import the library"),
|
135
|
+
_("The format of the file you " \
|
136
|
+
"provided is unknown. Please " \
|
137
|
+
"retry with another file.")).display
|
138
|
+
end
|
139
|
+
@pbar.hide
|
140
|
+
self.sensitive = true
|
141
|
+
end
|
142
|
+
end
|
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
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
data/lib/alexandria/ui/init.rb
CHANGED
@@ -1,38 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
# Copyright (C) 2008 Joseph Method
|
5
|
-
# Copyright (C) 2011, 2016 Matijs van Zuijlen
|
3
|
+
# This file is part of Alexandria.
|
6
4
|
#
|
7
|
-
#
|
8
|
-
|
9
|
-
|
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.
|
6
|
+
|
7
|
+
require "alexandria/ui/error_dialog"
|
21
8
|
|
22
9
|
class CellRendererToggle < Gtk::CellRendererToggle
|
23
10
|
attr_accessor :text
|
11
|
+
|
24
12
|
type_register
|
25
13
|
install_property(GLib::Param::String.new(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
14
|
+
"text",
|
15
|
+
"text",
|
16
|
+
"Some damn value",
|
17
|
+
"",
|
30
18
|
GLib::Param::READABLE | GLib::Param::WRITABLE))
|
31
19
|
end
|
32
20
|
|
33
21
|
class Gtk::ActionGroup
|
34
|
-
def [](
|
35
|
-
get_action(
|
22
|
+
def [](index)
|
23
|
+
get_action(index)
|
36
24
|
end
|
37
25
|
end
|
38
26
|
|
@@ -60,28 +48,28 @@ end
|
|
60
48
|
|
61
49
|
class Alexandria::Library
|
62
50
|
def action_name
|
63
|
-
|
51
|
+
"MoveIn" + name.gsub(/\s/, "")
|
64
52
|
end
|
65
53
|
end
|
66
54
|
|
67
55
|
class Alexandria::BookProviders::AbstractProvider
|
68
56
|
def action_name
|
69
|
-
|
57
|
+
"At" + name
|
70
58
|
end
|
71
59
|
end
|
72
60
|
|
73
61
|
module Alexandria
|
74
62
|
module UI
|
75
|
-
def self.display_help(parent
|
76
|
-
section_index =
|
63
|
+
def self.display_help(parent, section = nil)
|
64
|
+
section_index = ""
|
77
65
|
section_index = "##{section}" if section
|
78
66
|
exec("gnome-help ghelp:alexandria#{section_index}") if fork.nil?
|
79
|
-
rescue
|
80
|
-
log.error(self) {
|
81
|
-
ErrorDialog.new(parent, _(
|
82
|
-
_(
|
83
|
-
|
84
|
-
|
67
|
+
rescue StandardError
|
68
|
+
log.error(self) { "Unable to load help browser" }
|
69
|
+
ErrorDialog.new(parent, _("Unable to launch the help browser"),
|
70
|
+
_("Could not display help for Alexandria. " \
|
71
|
+
"There was an error launching the system " \
|
72
|
+
"help browser.")).display
|
85
73
|
end
|
86
74
|
end
|
87
75
|
end
|
@@ -0,0 +1,36 @@
|
|
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/ui/alert_dialog"
|
8
|
+
|
9
|
+
module Alexandria
|
10
|
+
module UI
|
11
|
+
class KeepBadISBNDialog < AlertDialog
|
12
|
+
include GetText
|
13
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
14
|
+
|
15
|
+
def initialize(parent, book)
|
16
|
+
title = _("Invalid ISBN '%s'") % book.isbn
|
17
|
+
message =
|
18
|
+
_("The book titled '%s' has an invalid ISBN, but still " \
|
19
|
+
"exists in the providers libraries. Do you want to " \
|
20
|
+
"keep the book but change the ISBN or cancel the addition?") % book.title
|
21
|
+
super(parent, title,
|
22
|
+
Gtk::Stock::DIALOG_QUESTION,
|
23
|
+
[[Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL],
|
24
|
+
[_("_Keep"), Gtk::ResponseType::OK]], message)
|
25
|
+
dialog.default_response = Gtk::ResponseType::OK
|
26
|
+
end
|
27
|
+
|
28
|
+
def keep?
|
29
|
+
show_all
|
30
|
+
@response = run
|
31
|
+
destroy
|
32
|
+
@response == Gtk::ResponseType::OK
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -24,7 +24,7 @@ module Alexandria
|
|
24
24
|
module ComboBoxOverrides
|
25
25
|
include GetText
|
26
26
|
extend GetText
|
27
|
-
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset:
|
27
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
28
28
|
|
29
29
|
def populate_with_libraries(libraries, selected_library)
|
30
30
|
libraries_names = libraries.map(&:name)
|
@@ -33,28 +33,22 @@ module Alexandria
|
|
33
33
|
libraries_names.unshift selected_library.name
|
34
34
|
end
|
35
35
|
clear
|
36
|
-
set_row_separator_func do |model, iter|
|
37
|
-
# TODO: Replace with iter[1] if possible
|
38
|
-
model.get_value(iter, 1) == '-'
|
39
|
-
end
|
40
36
|
self.model = Gtk::ListStore.new(GdkPixbuf::Pixbuf, String, TrueClass)
|
41
37
|
libraries_names.each do |library_name|
|
42
|
-
|
43
|
-
iter[0] = Alexandria::UI::Icons::LIBRARY_SMALL
|
44
|
-
iter[1] = library_name
|
45
|
-
iter[2] = false
|
38
|
+
append_entry(Alexandria::UI::Icons::LIBRARY_SMALL, library_name, false)
|
46
39
|
end
|
47
|
-
|
48
|
-
|
49
|
-
iter[0] = Alexandria::UI::Icons::LIBRARY_SMALL
|
50
|
-
iter[1] = _('New Library')
|
51
|
-
iter[2] = true
|
40
|
+
append_entry(nil, "-", nil)
|
41
|
+
append_entry(Alexandria::UI::Icons::LIBRARY_SMALL, _("New Library"), true)
|
52
42
|
renderer = Gtk::CellRendererPixbuf.new
|
53
43
|
pack_start(renderer, false)
|
54
44
|
set_attributes(renderer, pixbuf: 0)
|
55
45
|
renderer = Gtk::CellRendererText.new
|
56
46
|
pack_start(renderer, true)
|
57
47
|
set_attributes(renderer, text: 1)
|
48
|
+
set_row_separator_func do |model, iter|
|
49
|
+
# TODO: Replace with iter[1] if possible
|
50
|
+
model.get_value(iter, 1) == "-"
|
51
|
+
end
|
58
52
|
self.active = 0
|
59
53
|
# self.sensitive = libraries.length > 1
|
60
54
|
# This prohibits us from adding a "New Library" from this combo
|
@@ -76,8 +70,16 @@ module Alexandria
|
|
76
70
|
end
|
77
71
|
end
|
78
72
|
raise unless library
|
73
|
+
|
79
74
|
[library, is_new]
|
80
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
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|