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,22 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
# Copyright (C) 2014, 2016 Matijs van Zuijlen
|
3
|
+
# This file is part of Alexandria.
|
5
4
|
#
|
6
|
-
#
|
7
|
-
|
8
|
-
|
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.
|
6
|
+
|
7
|
+
require 'alexandria/export_format'
|
20
8
|
|
21
9
|
module Alexandria
|
22
10
|
module UI
|
@@ -33,16 +21,16 @@ module Alexandria
|
|
33
21
|
'to replace it with the one you are generating?') % filename)
|
34
22
|
# FIXME: Should accept just :cancel
|
35
23
|
self.default_response = Gtk::ResponseType::CANCEL
|
36
|
-
show_all && (@response = run)
|
37
|
-
destroy
|
38
24
|
end
|
39
25
|
|
40
26
|
def erase?
|
41
|
-
@response
|
27
|
+
show_all && (@response = run)
|
28
|
+
destroy
|
29
|
+
@response == Gtk::ResponseType::OK
|
42
30
|
end
|
43
31
|
end
|
44
32
|
|
45
|
-
class ExportDialog <
|
33
|
+
class ExportDialog < SimpleDelegator
|
46
34
|
include GetText
|
47
35
|
extend GetText
|
48
36
|
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
|
@@ -51,13 +39,14 @@ module Alexandria
|
|
51
39
|
THEMES = Alexandria::WebTheme.all
|
52
40
|
|
53
41
|
def initialize(parent, library, sort_order)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
42
|
+
@export_dialog = Gtk::FileChooserDialog.new(title: _("Export '%s'") % library.name,
|
43
|
+
parent: parent,
|
44
|
+
action: :save,
|
45
|
+
buttons: [[Gtk::Stock::HELP, :help],
|
46
|
+
[Gtk::Stock::CANCEL, :cancel],
|
47
|
+
[_('_Export'), :accept]])
|
48
|
+
super(@export_dialog)
|
59
49
|
|
60
|
-
self.transient_for = parent
|
61
50
|
self.current_name = library.name
|
62
51
|
signal_connect('destroy') { hide }
|
63
52
|
|
@@ -67,24 +56,24 @@ module Alexandria
|
|
67
56
|
|
68
57
|
preview_image = Gtk::Image.new
|
69
58
|
|
70
|
-
theme_combo = Gtk::ComboBoxText.new
|
71
|
-
theme_combo.valign = :center
|
72
|
-
theme_combo.vexpand = false
|
59
|
+
@theme_combo = Gtk::ComboBoxText.new
|
60
|
+
@theme_combo.valign = :center
|
61
|
+
@theme_combo.vexpand = false
|
73
62
|
THEMES.each do |theme|
|
74
|
-
theme_combo.append_text(theme.name)
|
63
|
+
@theme_combo.append_text(theme.name)
|
75
64
|
end
|
76
|
-
theme_combo.signal_connect('changed') do
|
77
|
-
file = THEMES[theme_combo.active].preview_file
|
65
|
+
@theme_combo.signal_connect('changed') do
|
66
|
+
file = THEMES[@theme_combo.active].preview_file
|
78
67
|
preview_image.pixbuf = GdkPixbuf::Pixbuf.new(file: file)
|
79
68
|
end
|
80
|
-
theme_combo.active = 0
|
69
|
+
@theme_combo.active = 0
|
81
70
|
theme_label = Gtk::Label.new(_('_Theme:'), use_underline: true)
|
82
71
|
theme_label.xalign = 0
|
83
|
-
theme_label.mnemonic_widget = theme_combo
|
72
|
+
theme_label.mnemonic_widget = @theme_combo
|
84
73
|
|
85
|
-
types_combo = Gtk::ComboBoxText.new
|
86
|
-
types_combo.vexpand = false
|
87
|
-
types_combo.valign = :center
|
74
|
+
@types_combo = Gtk::ComboBoxText.new
|
75
|
+
@types_combo.vexpand = false
|
76
|
+
@types_combo.valign = :center
|
88
77
|
FORMATS.each do |format|
|
89
78
|
text = format.name + ' ('
|
90
79
|
text += if format.ext
|
@@ -93,42 +82,43 @@ module Alexandria
|
|
93
82
|
_('directory')
|
94
83
|
end
|
95
84
|
text += ')'
|
96
|
-
types_combo.append_text(text)
|
85
|
+
@types_combo.append_text(text)
|
97
86
|
end
|
98
|
-
types_combo.active = 0
|
99
|
-
types_combo.signal_connect('changed') do
|
100
|
-
visible = FORMATS[types_combo.active].needs_preview?
|
101
|
-
theme_label.visible = theme_combo.visible = preview_image.visible = visible
|
87
|
+
@types_combo.active = 0
|
88
|
+
@types_combo.signal_connect('changed') do
|
89
|
+
visible = FORMATS[@types_combo.active].needs_preview?
|
90
|
+
theme_label.visible = @theme_combo.visible = preview_image.visible = visible
|
102
91
|
end
|
103
|
-
types_combo.show
|
92
|
+
@types_combo.show
|
104
93
|
|
105
94
|
types_label = Gtk::Label.new(_('Export for_mat:'), use_underline: true)
|
106
95
|
types_label.xalign = 0
|
107
|
-
types_label.mnemonic_widget = types_combo
|
96
|
+
types_label.mnemonic_widget = @types_combo
|
108
97
|
types_label.show
|
109
98
|
|
110
99
|
# TODO: Re-design extra widget layout
|
111
100
|
grid = Gtk::Grid.new
|
112
101
|
grid.column_spacing = 6
|
113
102
|
grid.attach types_label, 0, 0, 1, 1
|
114
|
-
grid.attach types_combo, 1, 0, 1, 1
|
103
|
+
grid.attach @types_combo, 1, 0, 1, 1
|
115
104
|
grid.attach theme_label, 0, 1, 1, 1
|
116
|
-
grid.attach theme_combo, 1, 1, 1, 1
|
105
|
+
grid.attach @theme_combo, 1, 1, 1, 1
|
117
106
|
grid.attach preview_image, 2, 0, 1, 3
|
118
107
|
set_extra_widget grid
|
108
|
+
end
|
119
109
|
|
120
|
-
|
121
|
-
|
110
|
+
def perform
|
111
|
+
while ((response = run) != Gtk::ResponseType::CANCEL) &&
|
112
|
+
(response != Gtk::ResponseType::DELETE_EVENT)
|
122
113
|
|
123
|
-
if response ==
|
114
|
+
if response == Gtk::ResponseType::HELP
|
124
115
|
Alexandria::UI.display_help(self, 'exporting')
|
125
116
|
else
|
126
117
|
begin
|
127
|
-
break if on_export(FORMATS[types_combo.active],
|
128
|
-
THEMES[theme_combo.active])
|
129
|
-
rescue => e
|
130
|
-
|
131
|
-
ErrorDialog.new(self, _('Export failed'), e.message)
|
118
|
+
break if on_export(FORMATS[@types_combo.active],
|
119
|
+
THEMES[@theme_combo.active])
|
120
|
+
rescue StandardError => e
|
121
|
+
ErrorDialog.new(@export_dialog, _('Export failed'), e.message).display
|
132
122
|
end
|
133
123
|
end
|
134
124
|
end
|
@@ -139,12 +129,14 @@ module Alexandria
|
|
139
129
|
|
140
130
|
def on_export(format, theme)
|
141
131
|
raise NotImplementedError unless @library.respond_to?(format.message)
|
132
|
+
|
142
133
|
filename = self.filename
|
143
134
|
if format.ext
|
144
135
|
filename += '.' + format.ext if File.extname(filename).empty?
|
145
136
|
if File.exist?(filename)
|
146
|
-
dialog = ConfirmEraseDialog.new(@
|
137
|
+
dialog = ConfirmEraseDialog.new(@export_dialog, filename)
|
147
138
|
return unless dialog.erase?
|
139
|
+
|
148
140
|
FileUtils.rm(filename)
|
149
141
|
end
|
150
142
|
args = []
|
@@ -155,7 +147,7 @@ module Alexandria
|
|
155
147
|
'file. A directory is needed for this ' \
|
156
148
|
'operation. Please select a directory and ' \
|
157
149
|
'try again.') % filename
|
158
|
-
ErrorDialog.new(@
|
150
|
+
ErrorDialog.new(@export_dialog, _('Not a directory'), msg).display
|
159
151
|
return
|
160
152
|
end
|
161
153
|
else
|
@@ -1,22 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
# Copyright (C) 2011, 2016 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
|
class Alexandria::ImportFilter
|
22
8
|
def to_filefilter
|
@@ -36,21 +22,21 @@ module Alexandria
|
|
36
22
|
def initialize(parent, message)
|
37
23
|
super(parent, _('Error while importing'),
|
38
24
|
Gtk::Stock::DIALOG_QUESTION,
|
39
|
-
[[Gtk::Stock::CANCEL,
|
40
|
-
[_('_Continue'),
|
25
|
+
[[Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL],
|
26
|
+
[_('_Continue'), Gtk::ResponseType::OK]],
|
41
27
|
message)
|
42
28
|
puts "Opened SkipEntryDialog #{inspect}" if $DEBUG
|
43
29
|
self.default_response = Gtk::ResponseType::CANCEL
|
44
|
-
show_all && (@response = run)
|
45
|
-
destroy
|
46
30
|
end
|
47
31
|
|
48
32
|
def continue?
|
49
|
-
@response
|
33
|
+
show_all && (@response = run)
|
34
|
+
destroy
|
35
|
+
@response == Gtk::ResponseType::OK
|
50
36
|
end
|
51
37
|
end
|
52
38
|
|
53
|
-
class ImportDialog <
|
39
|
+
class ImportDialog < SimpleDelegator
|
54
40
|
include GetText
|
55
41
|
include Logging
|
56
42
|
|
@@ -59,29 +45,25 @@ module Alexandria
|
|
59
45
|
FILTERS = Alexandria::ImportFilter.all
|
60
46
|
|
61
47
|
def initialize(parent)
|
62
|
-
|
48
|
+
title = _('Import a Library')
|
49
|
+
dialog = Gtk::FileChooserDialog.new title: title, parent: parent, action: :open
|
50
|
+
super(dialog)
|
63
51
|
puts 'ImportDialog opened.' if $DEBUG
|
64
52
|
@destroyed = false
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
# self.deletable = false
|
69
|
-
running = false
|
70
|
-
add_button(Gtk::Stock::HELP, :help)
|
71
|
-
add_button(Gtk::Stock::CANCEL, :cancel)
|
53
|
+
@running = false
|
54
|
+
add_button(Gtk::Stock::HELP, Gtk::ResponseType::HELP)
|
55
|
+
add_button(Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL)
|
72
56
|
import_button = add_button(_('_Import'),
|
73
|
-
|
57
|
+
Gtk::ResponseType::ACCEPT)
|
74
58
|
import_button.sensitive = false
|
75
59
|
|
76
|
-
signal_connect('destroy')
|
77
|
-
if running
|
60
|
+
signal_connect('destroy') do
|
61
|
+
if @running
|
78
62
|
@destroyed = true
|
79
|
-
|
80
63
|
else
|
81
64
|
destroy
|
82
65
|
end
|
83
|
-
|
84
|
-
}
|
66
|
+
end
|
85
67
|
|
86
68
|
filters = {}
|
87
69
|
FILTERS.each do |filter|
|
@@ -105,34 +87,32 @@ module Alexandria
|
|
105
87
|
pbar = Gtk::ProgressBar.new
|
106
88
|
pbar.show_text = true
|
107
89
|
child.pack_start(pbar, expand: false)
|
90
|
+
end
|
108
91
|
|
92
|
+
def acquire
|
109
93
|
on_progress = proc do |fraction|
|
110
|
-
|
111
|
-
|
112
|
-
pbar.fraction = fraction
|
113
|
-
rescue
|
114
|
-
# TODO: check if destroyed instead...
|
115
|
-
end
|
94
|
+
pbar.show unless pbar.visible?
|
95
|
+
pbar.fraction = fraction
|
116
96
|
end
|
117
97
|
|
118
98
|
on_error = proc do |message|
|
119
|
-
SkipEntryDialog.new(
|
99
|
+
SkipEntryDialog.new(self, message).continue?
|
120
100
|
end
|
121
101
|
|
122
102
|
exec_queue = ExecutionQueue.new
|
123
103
|
|
124
104
|
while !@destroyed &&
|
125
|
-
((response = run) !=
|
126
|
-
|
105
|
+
((response = run) != Gtk::ResponseType::CANCEL) &&
|
106
|
+
response != Gtk::ResponseType::DELETE_EVENT
|
127
107
|
|
128
|
-
if response ==
|
108
|
+
if response == Gtk::ResponseType::HELP
|
129
109
|
Alexandria::UI.display_help(self, 'import-library')
|
130
110
|
next
|
131
111
|
end
|
132
112
|
file = File.basename(filename, '.*')
|
133
113
|
base = GLib.locale_to_utf8(file)
|
134
114
|
new_library_name = Library.generate_new_name(
|
135
|
-
|
115
|
+
LibraryCollection.instance.all_libraries,
|
136
116
|
base)
|
137
117
|
|
138
118
|
filter = filters[self.filter]
|
@@ -160,7 +140,7 @@ module Alexandria
|
|
160
140
|
begin
|
161
141
|
library, @bad_isbns, @failed_isbns = filter.invoke(new_library_name,
|
162
142
|
filename)
|
163
|
-
rescue => ex
|
143
|
+
rescue StandardError => ex
|
164
144
|
trace = ex.backtrace.join("\n> ")
|
165
145
|
log.error { "Import failed: #{ex.message} #{trace}" }
|
166
146
|
end
|
@@ -168,7 +148,7 @@ module Alexandria
|
|
168
148
|
|
169
149
|
while thread.alive? && !@destroyed
|
170
150
|
# puts "Thread #{thread} still alive."
|
171
|
-
running = true
|
151
|
+
@running = true
|
172
152
|
exec_queue.iterate
|
173
153
|
Gtk.main_iteration_do(false)
|
174
154
|
end
|
@@ -179,11 +159,11 @@ module Alexandria
|
|
179
159
|
break
|
180
160
|
elsif not_cancelled
|
181
161
|
puts "Raising ErrorDialog because not_cancelled is #{not_cancelled}" if $DEBUG
|
182
|
-
ErrorDialog.new(
|
162
|
+
ErrorDialog.new(self,
|
183
163
|
_("Couldn't import the library"),
|
184
164
|
_('The format of the file you ' \
|
185
165
|
'provided is unknown. Please ' \
|
186
|
-
'retry with another file.'))
|
166
|
+
'retry with another file.')).display
|
187
167
|
end
|
188
168
|
pbar.hide
|
189
169
|
self.sensitive = true
|
@@ -0,0 +1,33 @@
|
|
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
|
+
module Alexandria
|
8
|
+
module UI
|
9
|
+
class KeepBadISBNDialog < AlertDialog
|
10
|
+
include GetText
|
11
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
|
12
|
+
|
13
|
+
def initialize(parent, book)
|
14
|
+
title = _("Invalid ISBN '%s'") % book.isbn
|
15
|
+
message = _("The book titled '%s' has an invalid ISBN, but still " \
|
16
|
+
'exists in the providers libraries. Do you want to ' \
|
17
|
+
'keep the book but change the ISBN or cancel the addition?') % book.title
|
18
|
+
super(parent, title,
|
19
|
+
Gtk::Stock::DIALOG_QUESTION,
|
20
|
+
[[Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL],
|
21
|
+
[_('_Keep'), Gtk::ResponseType::OK]], message)
|
22
|
+
self.default_response = Gtk::ResponseType::OK
|
23
|
+
end
|
24
|
+
|
25
|
+
def keep?
|
26
|
+
show_all
|
27
|
+
@response = run
|
28
|
+
destroy
|
29
|
+
@response == Gtk::ResponseType::OK
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -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
|
@@ -28,17 +15,17 @@ module Alexandria
|
|
28
15
|
format(_("The book '%s' already exists in '%s'. Would you like " \
|
29
16
|
'to replace it?'), book.title, library.name),
|
30
17
|
Gtk::Stock::DIALOG_QUESTION,
|
31
|
-
[[_('_Skip'),
|
32
|
-
[_('_Replace'),
|
18
|
+
[[_('_Skip'), Gtk::ResponseType::CANCEL],
|
19
|
+
[_('_Replace'), Gtk::ResponseType::OK]],
|
33
20
|
_('If you replace the existing book, its contents will ' \
|
34
21
|
'be overwritten.'))
|
35
22
|
self.default_response = Gtk::ResponseType::CANCEL
|
36
|
-
show_all && (@response = run)
|
37
|
-
destroy
|
38
23
|
end
|
39
24
|
|
40
25
|
def replace?
|
41
|
-
@response
|
26
|
+
show_all && (@response = run)
|
27
|
+
destroy
|
28
|
+
@response == Gtk::ResponseType::OK
|
42
29
|
end
|
43
30
|
end
|
44
31
|
|
@@ -70,17 +57,17 @@ module Alexandria
|
|
70
57
|
end
|
71
58
|
|
72
59
|
super(parent, message, Gtk::Stock::DIALOG_QUESTION,
|
73
|
-
[[Gtk::Stock::CANCEL,
|
74
|
-
[Gtk::Stock::DELETE,
|
60
|
+
[[Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL],
|
61
|
+
[Gtk::Stock::DELETE, Gtk::ResponseType::OK]],
|
75
62
|
description)
|
76
63
|
|
77
64
|
self.default_response = Gtk::ResponseType::CANCEL
|
78
|
-
show_all && (@response = run)
|
79
|
-
destroy
|
80
65
|
end
|
81
66
|
|
82
67
|
def ok?
|
83
|
-
@response
|
68
|
+
show_all && (@response = run)
|
69
|
+
destroy
|
70
|
+
@response == Gtk::ResponseType::OK
|
84
71
|
end
|
85
72
|
end
|
86
73
|
end
|