alexandria-book-collection-manager 0.6.9 → 0.7.0
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/.rubocop.yml +34 -30
- data/.rubocop_todo.yml +139 -54
- data/CHANGELOG.md +10 -0
- data/Gemfile +1 -0
- data/Rakefile +10 -11
- data/alexandria-book-collection-manager.gemspec +3 -2
- data/bin/alexandria +1 -1
- data/lib/alexandria.rb +3 -6
- data/lib/alexandria/about.rb +9 -9
- data/lib/alexandria/book_providers.rb +12 -12
- data/lib/alexandria/book_providers/adlibris.rb +14 -18
- data/lib/alexandria/book_providers/amazon_aws.rb +17 -31
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +5 -6
- data/lib/alexandria/book_providers/barnes_and_noble.rb +51 -76
- data/lib/alexandria/book_providers/bol_it.rb +12 -12
- data/lib/alexandria/book_providers/deastore.rb +27 -31
- data/lib/alexandria/book_providers/douban.rb +9 -13
- data/lib/alexandria/book_providers/ibs_it.rb +10 -10
- data/lib/alexandria/book_providers/mcu.rb +12 -18
- data/lib/alexandria/book_providers/proxis.rb +14 -22
- data/lib/alexandria/book_providers/pseudomarc.rb +8 -18
- data/lib/alexandria/book_providers/renaud.rb +16 -16
- data/lib/alexandria/book_providers/siciliano.rb +25 -38
- data/lib/alexandria/book_providers/thalia.rb +13 -16
- data/lib/alexandria/book_providers/webster_it.rb +14 -18
- data/lib/alexandria/book_providers/worldcat.rb +21 -25
- data/lib/alexandria/book_providers/z3950.rb +19 -23
- data/lib/alexandria/config.rb +2 -2
- data/lib/alexandria/execution_queue.rb +3 -1
- data/lib/alexandria/export_library.rb +19 -22
- data/lib/alexandria/import_library.rb +14 -18
- data/lib/alexandria/import_library_csv.rb +12 -30
- data/lib/alexandria/models/book.rb +7 -9
- data/lib/alexandria/models/library.rb +44 -44
- data/lib/alexandria/net.rb +1 -1
- data/lib/alexandria/preferences.rb +12 -57
- data/lib/alexandria/scanners.rb +10 -6
- data/lib/alexandria/scanners/cuecat.rb +2 -2
- data/lib/alexandria/smart_library.rb +12 -12
- data/lib/alexandria/ui.rb +5 -2
- data/lib/alexandria/ui/callbacks.rb +106 -65
- data/lib/alexandria/ui/completion_models.rb +55 -51
- data/lib/alexandria/ui/dialogs/about_dialog.rb +1 -1
- data/lib/alexandria/ui/dialogs/acquire_dialog.rb +25 -51
- data/lib/alexandria/ui/dialogs/alert_dialog.rb +13 -11
- data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +2 -2
- data/lib/alexandria/ui/dialogs/barcode_animation.rb +39 -23
- data/lib/alexandria/ui/dialogs/book_properties_dialog.rb +16 -21
- data/lib/alexandria/ui/dialogs/book_properties_dialog_base.rb +23 -24
- data/lib/alexandria/ui/dialogs/export_dialog.rb +46 -45
- data/lib/alexandria/ui/dialogs/import_dialog.rb +26 -35
- data/lib/alexandria/ui/dialogs/misc_dialogs.rb +11 -11
- data/lib/alexandria/ui/dialogs/new_book_dialog.rb +47 -59
- data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +14 -13
- data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +12 -11
- data/lib/alexandria/ui/dialogs/preferences_dialog.rb +37 -43
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +9 -8
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +47 -53
- data/lib/alexandria/ui/dndable.rb +5 -4
- data/lib/alexandria/ui/icons.rb +19 -19
- data/lib/alexandria/ui/iconview.rb +7 -12
- data/lib/alexandria/ui/iconview_tooltips.rb +22 -109
- data/lib/alexandria/ui/init.rb +7 -15
- data/lib/alexandria/ui/libraries_combo.rb +54 -48
- data/lib/alexandria/ui/listview.rb +30 -85
- data/lib/alexandria/ui/multi_drag_treeview.rb +110 -107
- data/lib/alexandria/ui/sidepane.rb +23 -25
- data/lib/alexandria/ui/sound.rb +18 -27
- data/lib/alexandria/ui/ui_manager.rb +126 -204
- data/lib/alexandria/undo_manager.rb +2 -2
- data/lib/alexandria/version.rb +4 -4
- data/spec/alexandria/book_providers_spec.rb +7 -4
- data/spec/alexandria/library_spec.rb +13 -16
- data/spec/alexandria/scanners/cuecat_spec.rb +1 -2
- data/spec/alexandria/ui/dialogs_spec.rb +5 -1
- data/spec/alexandria/ui/main_app_spec.rb +3 -3
- data/{lib/alexandria/utils.rb → spec/alexandria/ui/sound_spec.rb} +6 -11
- data/spec/alexandria/ui/ui_utilities_spec.rb +3 -3
- data/spec/spec_helper.rb +2 -2
- data/util/rake/fileinstall.rb +17 -33
- data/util/rake/gettextgenerate.rb +2 -4
- data/util/rake/omfgenerate.rb +1 -3
- metadata +23 -11
- data/lib/alexandria/ui/gtk_thread_help.rb +0 -89
data/lib/alexandria/scanners.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (C) 2005-2006 Christopher Cyll
|
2
|
-
# Copyright (C) 2014
|
2
|
+
# Copyright (C) 2014-2016 Matijs van Zuijlen
|
3
3
|
#
|
4
4
|
# Alexandria is free software; you can redistribute it and/or
|
5
5
|
# modify it under the terms of the GNU General Public License as
|
@@ -22,22 +22,26 @@
|
|
22
22
|
|
23
23
|
module Alexandria
|
24
24
|
module Scanners
|
25
|
-
|
25
|
+
def self.registry
|
26
|
+
@registry ||= []
|
27
|
+
end
|
26
28
|
|
27
29
|
def self.register(scanner)
|
28
|
-
|
30
|
+
registry.push(scanner)
|
29
31
|
end
|
30
32
|
|
31
33
|
def self.default_scanner
|
32
|
-
|
34
|
+
registry.first
|
33
35
|
end
|
34
36
|
|
35
37
|
def self.find_scanner(name)
|
36
|
-
|
38
|
+
registry.find { |scanner| scanner.name == name }
|
37
39
|
end
|
38
40
|
|
39
41
|
def self.each_scanner
|
40
|
-
|
42
|
+
registry.each { |scanner| yield scanner }
|
41
43
|
end
|
44
|
+
|
45
|
+
private_class_method :registry
|
42
46
|
end
|
43
47
|
end
|
@@ -87,7 +87,7 @@ module Alexandria
|
|
87
87
|
|
88
88
|
def calc(values)
|
89
89
|
result = ''
|
90
|
-
|
90
|
+
until values.empty?
|
91
91
|
num = ((values[0] << 6 | values[1]) << 6 | values[2]) << 6 | values[3]
|
92
92
|
result += ((num >> 16) ^ 67).chr
|
93
93
|
result += ((num >> 8 & 255) ^ 67).chr
|
@@ -101,7 +101,7 @@ module Alexandria
|
|
101
101
|
def pad(array)
|
102
102
|
length = array.length % 4
|
103
103
|
|
104
|
-
if length
|
104
|
+
if length.nonzero?
|
105
105
|
raise 'Error parsing CueCat input' if length == 1
|
106
106
|
|
107
107
|
length = 4 - length
|
@@ -32,11 +32,11 @@ module Alexandria
|
|
32
32
|
attr_accessor :rules, :predicate_operator_rule, :deleted_books
|
33
33
|
|
34
34
|
DIR = File.join(ENV['HOME'], '.alexandria', '.smart_libraries')
|
35
|
-
EXT = '.yaml'
|
35
|
+
EXT = '.yaml'.freeze
|
36
36
|
|
37
37
|
def initialize(name, rules, predicate_operator_rule)
|
38
38
|
super()
|
39
|
-
raise if name.nil?
|
39
|
+
raise if name.nil? || rules.nil? || predicate_operator_rule.nil?
|
40
40
|
@name = name
|
41
41
|
@rules = rules
|
42
42
|
@predicate_operator_rule = predicate_operator_rule
|
@@ -162,7 +162,7 @@ module Alexandria
|
|
162
162
|
raise 'need libraries' if @libraries.nil?
|
163
163
|
raise 'no libraries' if @libraries.empty?
|
164
164
|
raise 'need predicate operator' if @predicate_operator_rule.nil?
|
165
|
-
raise 'need rule' if @rules.nil?
|
165
|
+
raise 'need rule' if @rules.nil? || @rules.empty?
|
166
166
|
|
167
167
|
filters = @rules.map(&:filter_proc)
|
168
168
|
selector = @predicate_operator_rule == ALL_RULES ? :all? : :any?
|
@@ -177,7 +177,7 @@ module Alexandria
|
|
177
177
|
filtered_library.each { |x| @cache[x] = library }
|
178
178
|
concat(filtered_library)
|
179
179
|
end
|
180
|
-
@n_rated = count { |x| !x.rating.nil?
|
180
|
+
@n_rated = count { |x| !x.rating.nil? && x.rating > 0 }
|
181
181
|
end
|
182
182
|
|
183
183
|
def cover(book)
|
@@ -196,7 +196,7 @@ module Alexandria
|
|
196
196
|
if book
|
197
197
|
@cache[book].save(book)
|
198
198
|
else
|
199
|
-
FileUtils.mkdir_p(DIR)
|
199
|
+
FileUtils.mkdir_p(DIR) unless File.exist? DIR
|
200
200
|
File.open(yaml, 'w') { |io| io.puts to_hash.to_yaml }
|
201
201
|
end
|
202
202
|
end
|
@@ -281,7 +281,7 @@ module Alexandria
|
|
281
281
|
attr_accessor :operand, :operation, :value
|
282
282
|
|
283
283
|
def initialize(operand, operation, value)
|
284
|
-
raise if operand.nil?
|
284
|
+
raise if operand.nil? || operation.nil? # value can be nil
|
285
285
|
@operand = operand
|
286
286
|
@operation = operation
|
287
287
|
@value = value
|
@@ -395,15 +395,15 @@ module Alexandria
|
|
395
395
|
proc { |x, y| x < y })
|
396
396
|
IS_AFTER = Operator.new(:is_after,
|
397
397
|
_('is after'),
|
398
|
-
proc { |x, y| x.to_i > y.to_i
|
398
|
+
proc { |x, y| x.to_i > y.to_i && !x.nil? })
|
399
399
|
IS_BEFORE = Operator.new(:is_before,
|
400
400
|
_('is before'),
|
401
|
-
proc { |x, y| x.to_i < y.to_i
|
401
|
+
proc { |x, y| x.to_i < y.to_i && !x.nil? })
|
402
402
|
IS_IN_LAST = Operator.new(:is_in_last_days,
|
403
403
|
_('is in last'),
|
404
404
|
proc { |x, y|
|
405
405
|
begin
|
406
|
-
if x.nil?
|
406
|
+
if x.nil? || x.empty?
|
407
407
|
false
|
408
408
|
else
|
409
409
|
log.debug { "Given Date: #{x.inspect} #{x.class}" }
|
@@ -422,7 +422,7 @@ module Alexandria
|
|
422
422
|
_('is not in last'),
|
423
423
|
proc { |x, y|
|
424
424
|
begin
|
425
|
-
if x.nil?
|
425
|
+
if x.nil? || x.empty?
|
426
426
|
false
|
427
427
|
else
|
428
428
|
log.debug { "Given Date: #{x.inspect} #{x.class}" }
|
@@ -491,8 +491,8 @@ module Alexandria
|
|
491
491
|
BOOLEAN_OPERATORS.map { |x| [x, nil] }
|
492
492
|
when 'Time'
|
493
493
|
TIME_OPERATORS.map do |x|
|
494
|
-
if x == Operators::IS_IN_LAST
|
495
|
-
x == Operators::IS_NOT_IN_LAST
|
494
|
+
if (x == Operators::IS_IN_LAST) ||
|
495
|
+
(x == Operators::IS_NOT_IN_LAST)
|
496
496
|
|
497
497
|
[x, Operands::DAYS]
|
498
498
|
else
|
data/lib/alexandria/ui.rb
CHANGED
@@ -16,8 +16,8 @@
|
|
16
16
|
# Fifth Floor, Boston, MA 02110-1301 USA.
|
17
17
|
|
18
18
|
require 'gdk_pixbuf2'
|
19
|
+
require 'gtk3'
|
19
20
|
|
20
|
-
require 'alexandria/ui/gtk_thread_help'
|
21
21
|
require 'alexandria/ui/icons'
|
22
22
|
require 'alexandria/ui/builder_base'
|
23
23
|
require 'alexandria/ui/completion_models'
|
@@ -32,18 +32,21 @@ module Alexandria
|
|
32
32
|
log.info { 'Initializing Icons...' }
|
33
33
|
Icons.init
|
34
34
|
end
|
35
|
+
|
35
36
|
def self.start_main_app
|
36
37
|
puts '==========================' if $DEBUG
|
37
38
|
log.info { 'Starting MainApp...' }
|
38
39
|
puts '==========================' if $DEBUG
|
39
40
|
MainApp.instance
|
40
41
|
end
|
42
|
+
|
41
43
|
def self.start_gtk
|
42
44
|
puts '====================================' if $DEBUG
|
43
45
|
log.info { 'Starting Gtk...' }
|
44
46
|
puts '====================================' if $DEBUG
|
45
|
-
Gtk.
|
47
|
+
Gtk.main
|
46
48
|
end
|
49
|
+
|
47
50
|
def self.main
|
48
51
|
init_icons
|
49
52
|
start_main_app
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
2
|
# Copyright (C) 2008 Joseph Method
|
3
|
-
# Copyright (C) 2011, 2014 Matijs van Zuijlen
|
3
|
+
# Copyright (C) 2011, 2014, 2016 Matijs van Zuijlen
|
4
4
|
#
|
5
5
|
# Alexandria is free software; you can redistribute it and/or
|
6
6
|
# modify it under the terms of the GNU General Public License as
|
@@ -22,7 +22,7 @@ module Alexandria
|
|
22
22
|
module Callbacks
|
23
23
|
include Logging
|
24
24
|
|
25
|
-
def on_new(
|
25
|
+
def on_new(*)
|
26
26
|
name = Library.generate_new_name(@libraries.all_libraries)
|
27
27
|
library = Library.load(name)
|
28
28
|
@libraries.add_library(library)
|
@@ -31,7 +31,7 @@ module Alexandria
|
|
31
31
|
library.add_observer(self)
|
32
32
|
end
|
33
33
|
|
34
|
-
def on_new_smart(
|
34
|
+
def on_new_smart(*)
|
35
35
|
NewSmartLibraryDialog.new(@main_app) do |smart_library|
|
36
36
|
smart_library.refilter
|
37
37
|
@libraries.add_library(smart_library)
|
@@ -40,7 +40,7 @@ module Alexandria
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
def on_add_book(
|
43
|
+
def on_add_book(*)
|
44
44
|
log.info { 'on_add_book' }
|
45
45
|
NewBookDialog.new(@main_app, selected_library) do |_books, library, is_new|
|
46
46
|
if is_new
|
@@ -52,14 +52,14 @@ module Alexandria
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
def on_add_book_manual(
|
55
|
+
def on_add_book_manual(*)
|
56
56
|
library = selected_library
|
57
57
|
NewBookDialogManual.new(@main_app, library) { |_book|
|
58
58
|
refresh_books
|
59
59
|
}
|
60
60
|
end
|
61
61
|
|
62
|
-
def on_import(
|
62
|
+
def on_import(*)
|
63
63
|
ImportDialog.new(@main_app) do |library, bad_isbns, failed_isbns|
|
64
64
|
unless bad_isbns.empty?
|
65
65
|
log.debug { 'bad_isbn' }
|
@@ -82,7 +82,7 @@ module Alexandria
|
|
82
82
|
def on_window_state_event(_window, event)
|
83
83
|
log.debug { 'window-state-event' }
|
84
84
|
if event.is_a?(Gdk::EventWindowState)
|
85
|
-
@maximized = event.new_window_state ==
|
85
|
+
@maximized = event.new_window_state == :maximized
|
86
86
|
end
|
87
87
|
log.debug { 'end window-state-event' }
|
88
88
|
end
|
@@ -120,8 +120,9 @@ module Alexandria
|
|
120
120
|
@iconview.unfreeze
|
121
121
|
end
|
122
122
|
|
123
|
-
def on_export(
|
123
|
+
def on_export(*)
|
124
124
|
ExportDialog.new(@main_app, selected_library, library_sort_order)
|
125
|
+
# FIXME: Remove this hack and fix the underlying problem.
|
125
126
|
rescue => ex
|
126
127
|
log.error { "problem with immediate export #{ex} try again" }
|
127
128
|
ErrorDialog.new(@main_app, _('Export failed'),
|
@@ -129,7 +130,7 @@ module Alexandria
|
|
129
130
|
'completely before exporting.'))
|
130
131
|
end
|
131
132
|
|
132
|
-
def on_acquire(
|
133
|
+
def on_acquire(*)
|
133
134
|
AcquireDialog.new(@main_app,
|
134
135
|
selected_library) do |_books, library, is_new|
|
135
136
|
if is_new
|
@@ -141,8 +142,8 @@ module Alexandria
|
|
141
142
|
end
|
142
143
|
end
|
143
144
|
|
144
|
-
def on_properties(
|
145
|
-
if @library_listview.focus?
|
145
|
+
def on_properties(*)
|
146
|
+
if @library_listview.focus? || selected_books.empty?
|
146
147
|
library = selected_library
|
147
148
|
if library.is_a?(SmartLibrary)
|
148
149
|
SmartLibraryPropertiesDialog.new(@main_app, library) do
|
@@ -161,7 +162,7 @@ module Alexandria
|
|
161
162
|
end
|
162
163
|
end
|
163
164
|
|
164
|
-
def on_quit(
|
165
|
+
def on_quit(*)
|
165
166
|
save_preferences
|
166
167
|
Gtk.main_quit
|
167
168
|
# @libraries.really_save_all_books
|
@@ -169,15 +170,15 @@ module Alexandria
|
|
169
170
|
@libraries.all_regular_libraries.each(&:really_delete_deleted_books)
|
170
171
|
end
|
171
172
|
|
172
|
-
def on_undo(
|
173
|
+
def on_undo(*)
|
173
174
|
UndoManager.instance.undo!
|
174
175
|
end
|
175
176
|
|
176
|
-
def on_redo(
|
177
|
+
def on_redo(*)
|
177
178
|
UndoManager.instance.redo!
|
178
179
|
end
|
179
180
|
|
180
|
-
def on_select_all(
|
181
|
+
def on_select_all(*)
|
181
182
|
log.debug { 'on_select_all' }
|
182
183
|
case @notebook.page
|
183
184
|
when 0
|
@@ -187,7 +188,7 @@ module Alexandria
|
|
187
188
|
end
|
188
189
|
end
|
189
190
|
|
190
|
-
def on_deselect_all(
|
191
|
+
def on_deselect_all(*)
|
191
192
|
log.debug { 'on_deselect_all' }
|
192
193
|
case @notebook.page
|
193
194
|
when 0
|
@@ -211,21 +212,21 @@ module Alexandria
|
|
211
212
|
end
|
212
213
|
end
|
213
214
|
|
214
|
-
def on_rename(
|
215
|
+
def on_rename(*)
|
215
216
|
iter = @library_listview.selection.selected
|
216
217
|
@library_listview.set_cursor(iter.path,
|
217
218
|
@library_listview.get_column(0),
|
218
219
|
true)
|
219
220
|
end
|
220
221
|
|
221
|
-
def on_delete(
|
222
|
+
def on_delete(*)
|
222
223
|
library = selected_library
|
223
224
|
|
224
|
-
if selected_books.empty?
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
225
|
+
books = if selected_books.empty?
|
226
|
+
nil
|
227
|
+
else
|
228
|
+
selected_books
|
229
|
+
end
|
229
230
|
# books = @library_listview.focus? ? nil : selected_books
|
230
231
|
is_smart = library.is_a?(SmartLibrary)
|
231
232
|
last_library = (@libraries.all_regular_libraries.length == 1)
|
@@ -233,39 +234,39 @@ module Alexandria
|
|
233
234
|
log.warn { 'Attempted to delete last library, fix GUI' }
|
234
235
|
return
|
235
236
|
end
|
236
|
-
if library.empty?
|
237
|
+
if library.empty? || ReallyDeleteDialog.new(@main_app,
|
237
238
|
library,
|
238
239
|
books).ok?
|
239
240
|
undoable_delete(library, books)
|
240
241
|
end
|
241
242
|
end
|
242
243
|
|
243
|
-
def on_clear_search_results(
|
244
|
+
def on_clear_search_results(*)
|
244
245
|
@filter_entry.text = ''
|
245
246
|
@iconview.freeze
|
246
247
|
@filtered_model.refilter
|
247
248
|
@iconview.unfreeze
|
248
249
|
end
|
249
250
|
|
250
|
-
def on_search(
|
251
|
+
def on_search(*)
|
251
252
|
@filter_entry.grab_focus
|
252
253
|
end
|
253
254
|
|
254
|
-
def on_preferences(
|
255
|
+
def on_preferences(*)
|
255
256
|
PreferencesDialog.new(@main_app) do
|
256
257
|
@listview_manager.setup_listview_columns_visibility
|
257
258
|
end
|
258
259
|
end
|
259
260
|
|
260
|
-
def on_submit_bug_report(
|
261
|
+
def on_submit_bug_report(*)
|
261
262
|
open_web_browser(BUGREPORT_URL)
|
262
263
|
end
|
263
264
|
|
264
|
-
def on_help(
|
265
|
+
def on_help(*)
|
265
266
|
Alexandria::UI.display_help(@main_app)
|
266
267
|
end
|
267
268
|
|
268
|
-
def on_about(
|
269
|
+
def on_about(*)
|
269
270
|
ad = AboutDialog.new(@main_app)
|
270
271
|
ad.signal_connect('response') do
|
271
272
|
log.debug { 'destroy about' }
|
@@ -274,6 +275,28 @@ module Alexandria
|
|
274
275
|
ad.show
|
275
276
|
end
|
276
277
|
|
278
|
+
def on_view_sidepane(action)
|
279
|
+
log.debug { 'on_view_sidepane' }
|
280
|
+
@paned.child1.visible = action.active?
|
281
|
+
end
|
282
|
+
|
283
|
+
def on_view_toolbar(action)
|
284
|
+
log.debug { 'on_view_toolbar' }
|
285
|
+
@toolbar.visible = action.active?
|
286
|
+
end
|
287
|
+
|
288
|
+
def on_view_statusbar(action)
|
289
|
+
log.debug { 'on_view_statusbar' }
|
290
|
+
@appbar.visible = action.active?
|
291
|
+
end
|
292
|
+
|
293
|
+
def on_reverse_order(action)
|
294
|
+
log.debug { 'on_reverse_order' }
|
295
|
+
Preferences.instance.reverse_icons = action.active?
|
296
|
+
Preferences.instance.save!
|
297
|
+
setup_books_iconview_sorting
|
298
|
+
end
|
299
|
+
|
277
300
|
def connect_signals
|
278
301
|
standard_actions = [
|
279
302
|
['LibraryMenu', nil, _('_Library')],
|
@@ -314,37 +337,11 @@ module Alexandria
|
|
314
337
|
['About', Gtk::Stock::ABOUT, _('_About'), nil, _('Show information about Alexandria'), method(:on_about)],
|
315
338
|
]
|
316
339
|
|
317
|
-
on_view_sidepane = proc do |_actiongroup, action|
|
318
|
-
log.debug { 'on_view_sidepane' }
|
319
|
-
@paned.child1.visible = action.active?
|
320
|
-
end
|
321
|
-
|
322
|
-
on_view_toolbar = proc do |_actiongroup, action|
|
323
|
-
log.debug { 'on_view_toolbar' }
|
324
|
-
@toolbar.parent.visible = action.active?
|
325
|
-
end
|
326
|
-
|
327
|
-
on_view_statusbar = proc do |_actiongroup, action|
|
328
|
-
log.debug { 'on_view_statusbar' }
|
329
|
-
@appbar.visible = action.active?
|
330
|
-
end
|
331
|
-
|
332
|
-
on_reverse_order = proc do |_actiongroup, action|
|
333
|
-
log.debug { 'on_reverse_order' }
|
334
|
-
Preferences.instance.reverse_icons = action.active?
|
335
|
-
Preferences.instance.save!
|
336
|
-
setup_books_iconview_sorting
|
337
|
-
end
|
338
|
-
|
339
340
|
toggle_actions = [
|
340
|
-
['Sidepane', nil, _('Side _Pane'), 'F9', nil,
|
341
|
-
|
342
|
-
['
|
343
|
-
|
344
|
-
['Statusbar', nil, _('_Statusbar'), nil, nil,
|
345
|
-
on_view_statusbar, true],
|
346
|
-
['ReversedOrder', nil, _('Re_versed Order'), nil, nil,
|
347
|
-
on_reverse_order],
|
341
|
+
['Sidepane', nil, _('Side _Pane'), 'F9', nil, method(:on_view_sidepane), true],
|
342
|
+
['Toolbar', nil, _('_Toolbar'), nil, nil, method(:on_view_toolbar), true],
|
343
|
+
['Statusbar', nil, _('_Statusbar'), nil, nil, method(:on_view_statusbar), true],
|
344
|
+
['ReversedOrder', nil, _('Re_versed Order'), nil, nil, method(:on_reverse_order)],
|
348
345
|
]
|
349
346
|
|
350
347
|
view_as_actions = [
|
@@ -369,17 +366,61 @@ module Alexandria
|
|
369
366
|
log.debug { 'Adding actions to @actiongroup' }
|
370
367
|
|
371
368
|
@actiongroup = Gtk::ActionGroup.new('actions')
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
369
|
+
|
370
|
+
standard_actions.each do |name, stock_id, label, accelerator, tooltip, callback|
|
371
|
+
action = Gtk::Action.new(name, label: label, tooltip: tooltip, stock_id: stock_id)
|
372
|
+
@actiongroup.add_action_with_accel(action, accelerator)
|
373
|
+
if callback
|
374
|
+
action.signal_connect('activate', &callback)
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
providers_actions.each do |name, stock_id, label, accelerator, tooltip, callback|
|
379
|
+
action = Gtk::Action.new(name, label: label, tooltip: tooltip, stock_id: stock_id)
|
380
|
+
@actiongroup.add_action_with_accel(action, accelerator)
|
381
|
+
if callback
|
382
|
+
action.signal_connect('activate', &callback)
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
toggle_actions.each do |name, stock_id, label, accelerator, tooltip, callback, is_active|
|
387
|
+
action = Gtk::ToggleAction.new(name, label: label, tooltip: tooltip, stock_id: stock_id)
|
388
|
+
action.set_active is_active
|
389
|
+
@actiongroup.add_action_with_accel(action, accelerator)
|
390
|
+
if callback
|
391
|
+
action.signal_connect('toggled', &callback)
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
group = nil
|
396
|
+
first_action = nil
|
397
|
+
view_as_actions.each do |name, stock_id, label, accelerator, tooltip, value|
|
398
|
+
action = Gtk::RadioAction.new(name, value, label: label, tooltip: tooltip, stock_id: stock_id)
|
399
|
+
first_action = action unless group
|
400
|
+
action.set_group group
|
401
|
+
group = action.group
|
402
|
+
@actiongroup.add_action_with_accel(action, accelerator)
|
403
|
+
end
|
404
|
+
|
405
|
+
first_action.signal_connect 'changed' do |_action, current, _user_data|
|
376
406
|
@notebook.page = current.current_value
|
377
407
|
hid = @toolbar_view_as_signal_hid
|
378
408
|
@toolbar_view_as.signal_handler_block(hid) do
|
379
409
|
@toolbar_view_as.active = current.current_value
|
380
410
|
end
|
381
411
|
end
|
382
|
-
|
412
|
+
|
413
|
+
group = nil
|
414
|
+
first_action = nil
|
415
|
+
arrange_icons_actions.each do |name, stock_id, label, accelerator, tooltip, value|
|
416
|
+
action = Gtk::RadioAction.new(name, value, label: label, tooltip: tooltip, stock_id: stock_id)
|
417
|
+
first_action = action unless group
|
418
|
+
action.set_group group
|
419
|
+
group = action.group
|
420
|
+
@actiongroup.add_action_with_accel(action, accelerator)
|
421
|
+
end
|
422
|
+
|
423
|
+
first_action.signal_connect 'changed' do |_action, current, _user_data|
|
383
424
|
@prefs.arrange_icons_mode = current.current_value
|
384
425
|
setup_books_iconview_sorting
|
385
426
|
end
|