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
@@ -83,9 +83,8 @@ module Alexandria
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def setup_tags_column
|
86
|
-
# adding tags column...
|
87
86
|
title = _("Tags")
|
88
|
-
log.debug { "Create listview column for tags
|
87
|
+
log.debug { "Create listview column for tags" }
|
89
88
|
renderer = Gtk::CellRendererText.new
|
90
89
|
renderer.ellipsize = :end
|
91
90
|
column = Gtk::TreeViewColumn.new(title, renderer,
|
@@ -105,7 +104,7 @@ module Alexandria
|
|
105
104
|
|
106
105
|
def setup_rating_column
|
107
106
|
title = _("Rating")
|
108
|
-
log.debug { format("Create listview column for %s
|
107
|
+
log.debug { format("Create listview column for %s", title) }
|
109
108
|
column = Gtk::TreeViewColumn.new(title)
|
110
109
|
column.sizing = :fixed
|
111
110
|
width = (Icons::STAR_SET.width + 1) * Book::MAX_RATING_STARS
|
@@ -164,7 +163,7 @@ module Alexandria
|
|
164
163
|
column = Gtk::TreeViewColumn.new(title, renderer, text: iterid)
|
165
164
|
column.sort_column_id = iterid
|
166
165
|
column.resizable = true
|
167
|
-
log.debug { format("Create listview column for %s
|
166
|
+
log.debug { format("Create listview column for %s", title) }
|
168
167
|
|
169
168
|
column.add_attribute(renderer, "active", iterid)
|
170
169
|
if iterid == Columns::WANT
|
@@ -176,7 +175,7 @@ module Alexandria
|
|
176
175
|
end
|
177
176
|
|
178
177
|
def setup_text_column(title, iterid)
|
179
|
-
log.debug { format("Create listview column for %s
|
178
|
+
log.debug { format("Create listview column for %s", title) }
|
180
179
|
renderer = Gtk::CellRendererText.new
|
181
180
|
renderer.ellipsize = :end
|
182
181
|
column = Gtk::TreeViewColumn.new(title, renderer,
|
@@ -204,7 +203,7 @@ module Alexandria
|
|
204
203
|
]
|
205
204
|
cols = @listview.columns[1..-1] # skip "Title"
|
206
205
|
cols.each_index do |i|
|
207
|
-
cols[i].visible =
|
206
|
+
cols[i].visible = cols_visibility[i]
|
208
207
|
end
|
209
208
|
log.debug do
|
210
209
|
"Columns visibility: " +
|
@@ -50,8 +50,8 @@ module Alexandria
|
|
50
50
|
include Logging
|
51
51
|
include GetText
|
52
52
|
include Singleton
|
53
|
-
attr_accessor :main_app, :libraries, :actiongroup, :appbar, :prefs
|
54
|
-
|
53
|
+
attr_accessor :main_app, :libraries, :actiongroup, :appbar, :prefs, :ui_manager
|
54
|
+
|
55
55
|
def initialize
|
56
56
|
log.info { "Starting MainApp" }
|
57
57
|
@ui_manager = UIManager.new self
|
@@ -6,16 +6,14 @@
|
|
6
6
|
|
7
7
|
module Alexandria
|
8
8
|
module EventOverrides
|
9
|
-
def ==(
|
10
|
-
|
11
|
-
(time ==
|
12
|
-
(button ==
|
9
|
+
def ==(other)
|
10
|
+
other.is_a?(self.class) &&
|
11
|
+
(time == other.time) && (x == other.x) && (y == other.y) &&
|
12
|
+
(button == other.button)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
module TreeViewOverrides
|
17
|
-
# include Alexandria::Logging
|
18
|
-
|
19
17
|
Context = Struct.new(:pressed_button,
|
20
18
|
:x,
|
21
19
|
:y,
|
@@ -32,6 +32,10 @@ module Alexandria
|
|
32
32
|
@progressbar.hide
|
33
33
|
end
|
34
34
|
|
35
|
+
def show
|
36
|
+
@new_book_dialog.show
|
37
|
+
end
|
38
|
+
|
35
39
|
def widget_names
|
36
40
|
[:new_book_dialog, :button_add, :button_cancel, :button_find,
|
37
41
|
:button_help, :combo_libraries, :combo_search, :entry_isbn,
|
@@ -139,7 +143,7 @@ module Alexandria
|
|
139
143
|
|
140
144
|
def on_changed(entry)
|
141
145
|
ok = !entry.text.strip.empty?
|
142
|
-
decode_cuecat
|
146
|
+
decode_cuecat(@entry_isbn) if entry == @entry_isbn
|
143
147
|
(entry == @entry_isbn ? @button_add : @button_find).sensitive = ok
|
144
148
|
end
|
145
149
|
|
@@ -186,7 +190,7 @@ module Alexandria
|
|
186
190
|
if pixbuf.width > 1
|
187
191
|
iter = @treeview_results.model.get_iter(key.to_s)
|
188
192
|
unless @treeview_results.model.iter_is_valid?(iter)
|
189
|
-
raise format("Iter is invalid! %s", iter)
|
193
|
+
raise format(_("Iter is invalid! %s"), iter)
|
190
194
|
end
|
191
195
|
|
192
196
|
iter[2] = pixbuf # I bet you this is it!
|
@@ -284,15 +288,10 @@ module Alexandria
|
|
284
288
|
# continue == false if @find_error OR if results are returned
|
285
289
|
# timeout ends if continue is false!
|
286
290
|
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
# @progressbar.hide
|
292
|
-
notify_end_add_by_isbn
|
293
|
-
@button_add.sensitive = false
|
294
|
-
end
|
295
|
-
end
|
291
|
+
# @find_thread.alive? happens after find_thread is done
|
292
|
+
unless continue || @find_thread.alive? || @destroyed
|
293
|
+
notify_end_add_by_isbn
|
294
|
+
@button_add.sensitive = false
|
296
295
|
end
|
297
296
|
|
298
297
|
continue # timeout loop condition
|
@@ -307,7 +306,7 @@ module Alexandria
|
|
307
306
|
(book.authors == book2.authors)
|
308
307
|
end
|
309
308
|
s += " (#{book.edition}, #{book.publisher})" if similar_books.length > 1
|
310
|
-
log.info { format("Copying %s into tree view.", book.title) }
|
309
|
+
log.info { format(_("Copying %s into tree view."), book.title) }
|
311
310
|
iter = model.append
|
312
311
|
iter[0] = s
|
313
312
|
iter[1] = book.ident
|
@@ -315,14 +314,14 @@ module Alexandria
|
|
315
314
|
end
|
316
315
|
end
|
317
316
|
|
318
|
-
def decode_cuecat
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
317
|
+
def decode_cuecat(entry)
|
318
|
+
return unless entry.text =~ /^\..*?\..*?\.(.*?)\.$/
|
319
|
+
|
320
|
+
tmp = Regexp.last_match[1].tr("a-zA-Z0-9+-", " -_")
|
321
|
+
tmp = ((32 + tmp.length * 3 / 4).to_i.chr << tmp).unpack1("u")
|
322
|
+
tmp.chomp!("\000")
|
323
|
+
entry.text = tmp.gsub!(/./) { |c| (c[0] ^ 67).chr }
|
324
|
+
entry.text = "Bad scan result" if entry.text.count("^ -~") > 0
|
326
325
|
end
|
327
326
|
|
328
327
|
def on_results_button_press_event(_widget, event)
|
@@ -353,8 +352,7 @@ module Alexandria
|
|
353
352
|
notify_end_add_by_isbn
|
354
353
|
|
355
354
|
if book
|
356
|
-
|
357
|
-
puts "adding book #{book} to library"
|
355
|
+
log.debug { "adding book #{book} to library" }
|
358
356
|
add_book_to_library(library, book, cover_url)
|
359
357
|
@entry_isbn.text = ""
|
360
358
|
|
@@ -384,7 +382,7 @@ module Alexandria
|
|
384
382
|
|
385
383
|
isbn = book.isbn
|
386
384
|
if isbn.nil? || isbn.empty?
|
387
|
-
|
385
|
+
log.debug { "noisbn" }
|
388
386
|
book.isbn = book.saved_ident = nil
|
389
387
|
books_to_add << [book, cover]
|
390
388
|
next
|
@@ -392,7 +390,7 @@ module Alexandria
|
|
392
390
|
|
393
391
|
isbn = Library.canonicalise_ean(isbn)
|
394
392
|
unless isbn
|
395
|
-
|
393
|
+
log.debug { "invalidisbn #{book.isbn}" }
|
396
394
|
next unless KeepBadISBNDialog.new(@new_book_dialog, book).keep?
|
397
395
|
|
398
396
|
book.isbn = book.saved_ident = nil
|
@@ -416,7 +414,7 @@ module Alexandria
|
|
416
414
|
end
|
417
415
|
|
418
416
|
def post_addition(books, library, is_new_library)
|
419
|
-
|
417
|
+
log.debug { "post_addition #{books.size}" }
|
420
418
|
return if books.empty?
|
421
419
|
|
422
420
|
# books, a 1d array of Alexandria::Book
|
@@ -491,10 +489,10 @@ module Alexandria
|
|
491
489
|
|
492
490
|
def notify_end_add_by_isbn
|
493
491
|
MainApp.instance.appbar.children.first.visible = false
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
492
|
+
return unless @progress_pulsing
|
493
|
+
|
494
|
+
GLib::Source.remove(@progress_pulsing)
|
495
|
+
@progress_pulsing = nil
|
498
496
|
end
|
499
497
|
|
500
498
|
def update(status, provider)
|
@@ -510,25 +508,26 @@ module Alexandria
|
|
510
508
|
end
|
511
509
|
|
512
510
|
def on_focus
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
puts text # required, strangely, to prevent GUI strangeness
|
527
|
-
# above last checked with ruby-gnome2 0.17.1 2009-12-09
|
528
|
-
# if this puts is commented out, the cursor disappears
|
529
|
-
# from the @entry_isbn box... weird, ne? - CathalMagus
|
530
|
-
end
|
511
|
+
return unless @isbn_radiobutton.active? && @entry_isbn.text.strip.empty?
|
512
|
+
|
513
|
+
clipboard = Gtk::Clipboard.get(Gdk::Selection::CLIPBOARD)
|
514
|
+
text = clipboard.wait_for_text or return
|
515
|
+
|
516
|
+
if Library.valid_isbn?(text) || Library.valid_ean?(text) ||
|
517
|
+
Library.valid_upc?(text)
|
518
|
+
GLib::Idle.add do
|
519
|
+
@entry_isbn.text = text
|
520
|
+
@entry_isbn.grab_focus
|
521
|
+
@entry_isbn.select_region(0, -1) # select all...
|
522
|
+
# @button_add.grab_focus
|
523
|
+
false
|
531
524
|
end
|
525
|
+
log.debug { "Setting ISBN field to #{text}" }
|
526
|
+
# FIXME: Get rid of this puts!
|
527
|
+
puts text # required, strangely, to prevent GUI strangeness
|
528
|
+
# above last checked with ruby-gnome2 0.17.1 2009-12-09
|
529
|
+
# if this puts is commented out, the cursor disappears
|
530
|
+
# from the @entry_isbn box... weird, ne? - CathalMagus
|
532
531
|
end
|
533
532
|
end
|
534
533
|
|
@@ -566,11 +565,12 @@ module Alexandria
|
|
566
565
|
isbn13 = Library.canonicalise_ean(isbn)
|
567
566
|
return unless isbn13
|
568
567
|
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
568
|
+
book = library.find { |bk| bk.isbn == isbn13 }
|
569
|
+
return unless book
|
570
|
+
|
571
|
+
raise DuplicateBookException,
|
572
|
+
format(_("'%s' already exists in '%s' (titled '%s')."),
|
573
|
+
isbn, library.name, book.title.sub("&", "&"))
|
574
574
|
end
|
575
575
|
end
|
576
576
|
end
|
@@ -17,14 +17,14 @@ module Alexandria
|
|
17
17
|
parent: parent,
|
18
18
|
flags: :modal,
|
19
19
|
buttons: [[Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL]])
|
20
|
-
@add_button = add_button(Gtk::Stock::ADD,
|
21
|
-
|
20
|
+
@add_button = dialog.add_button(Gtk::Stock::ADD,
|
21
|
+
Gtk::ResponseType::ACCEPT)
|
22
22
|
|
23
23
|
instances = BookProviders.abstract_classes.map(&:new)
|
24
24
|
@selected_instance = nil
|
25
25
|
|
26
26
|
@table = Gtk::Table.new(2, 2)
|
27
|
-
child.pack_start(@table)
|
27
|
+
dialog.child.pack_start(@table)
|
28
28
|
|
29
29
|
# Name.
|
30
30
|
|
@@ -33,10 +33,10 @@ module Alexandria
|
|
33
33
|
label_name.xalign = 0
|
34
34
|
@table.attach_defaults(label_name, 0, 1, 0, 1)
|
35
35
|
|
36
|
-
entry_name = Gtk::Entry.new
|
37
|
-
entry_name.mandatory = true
|
38
|
-
label_name.mnemonic_widget = entry_name
|
39
|
-
@table.attach_defaults(entry_name, 1, 2, 0, 1)
|
36
|
+
@entry_name = Gtk::Entry.new
|
37
|
+
@entry_name.mandatory = true
|
38
|
+
label_name.mnemonic_widget = @entry_name
|
39
|
+
@table.attach_defaults(@entry_name, 1, 2, 0, 1)
|
40
40
|
|
41
41
|
# Type.
|
42
42
|
|
@@ -62,14 +62,15 @@ module Alexandria
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def acquire
|
65
|
-
show_all
|
66
|
-
if run == Gtk::ResponseType::ACCEPT
|
67
|
-
@selected_instance.reinitialize(entry_name.text)
|
65
|
+
dialog.show_all
|
66
|
+
if dialog.run == Gtk::ResponseType::ACCEPT
|
67
|
+
@selected_instance.reinitialize(@entry_name.text)
|
68
68
|
sync_variables
|
69
69
|
else
|
70
70
|
@selected_instance = nil
|
71
71
|
end
|
72
|
-
destroy
|
72
|
+
dialog.destroy
|
73
|
+
instance
|
73
74
|
end
|
74
75
|
|
75
76
|
def instance
|
@@ -13,49 +13,61 @@ module Alexandria
|
|
13
13
|
def initialize(parent)
|
14
14
|
super(parent)
|
15
15
|
|
16
|
-
add_buttons([Gtk::Stock::CANCEL, :cancel],
|
17
|
-
|
16
|
+
dialog.add_buttons([Gtk::Stock::CANCEL, :cancel],
|
17
|
+
[Gtk::Stock::NEW, :ok])
|
18
18
|
|
19
|
-
|
19
|
+
dialog.title = _("New Smart Library")
|
20
20
|
# FIXME: Should accept just :cancel
|
21
|
-
|
21
|
+
dialog.default_response = Gtk::ResponseType::CANCEL
|
22
|
+
insert_new_rule
|
22
23
|
end
|
23
24
|
|
24
25
|
def acquire
|
25
|
-
show_all
|
26
|
-
insert_new_rule
|
26
|
+
dialog.show_all
|
27
27
|
|
28
|
-
|
28
|
+
result = nil
|
29
|
+
while ((response = dialog.run) != Gtk::ResponseType::CANCEL) &&
|
29
30
|
(response != Gtk::ResponseType::DELETE_EVENT)
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
name = Library.generate_new_name(
|
38
|
-
LibraryCollection.instance.all_libraries,
|
39
|
-
basename)
|
40
|
-
library = SmartLibrary.new(name,
|
41
|
-
rules,
|
42
|
-
predicate_operator_rule)
|
43
|
-
yield(library)
|
44
|
-
break
|
45
|
-
end
|
32
|
+
case response
|
33
|
+
when Gtk::ResponseType::HELP
|
34
|
+
handle_help_response
|
35
|
+
when Gtk::ResponseType::OK
|
36
|
+
result = handle_ok_response
|
37
|
+
break if result
|
46
38
|
end
|
47
39
|
end
|
48
40
|
|
49
|
-
destroy
|
41
|
+
dialog.destroy
|
42
|
+
result
|
50
43
|
end
|
51
44
|
|
52
45
|
private
|
53
46
|
|
47
|
+
def handle_help_response
|
48
|
+
Alexandria::UI.display_help(self, "new-smart-library")
|
49
|
+
end
|
50
|
+
|
51
|
+
def handle_ok_response
|
52
|
+
user_confirms_possible_weirdnesses_before_saving? or return
|
53
|
+
|
54
|
+
rules = smart_library_rules
|
55
|
+
basename = smart_library_base_name(rules) || _("Smart Library")
|
56
|
+
name = Library.generate_new_name(
|
57
|
+
LibraryCollection.instance.all_libraries,
|
58
|
+
basename)
|
59
|
+
library_store = LibraryCollection.instance.library_store
|
60
|
+
SmartLibrary.new(name,
|
61
|
+
rules,
|
62
|
+
predicate_operator_rule,
|
63
|
+
library_store)
|
64
|
+
end
|
65
|
+
|
54
66
|
def smart_library_base_name(rules)
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
67
|
+
return unless rules.length == 1
|
68
|
+
|
69
|
+
value = rules.first.value
|
70
|
+
value if value.is_a?(String) && !value.strip.empty?
|
59
71
|
end
|
60
72
|
end
|
61
73
|
end
|
@@ -13,7 +13,7 @@ require "alexandria/ui/new_provider_dialog"
|
|
13
13
|
module Alexandria
|
14
14
|
module UI
|
15
15
|
class PreferencesDialog < BuilderBase
|
16
|
-
include
|
16
|
+
include Logging
|
17
17
|
include GetText
|
18
18
|
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
19
19
|
|
@@ -37,7 +37,7 @@ module Alexandria
|
|
37
37
|
}
|
38
38
|
@cols.each_pair do |checkbutton, pref_name|
|
39
39
|
if checkbutton
|
40
|
-
checkbutton.active = Preferences.instance.
|
40
|
+
checkbutton.active = Preferences.instance.get_variable(pref_name)
|
41
41
|
else
|
42
42
|
log.warn do
|
43
43
|
"no CheckButton for property #{pref_name} " \
|
@@ -76,21 +76,17 @@ module Alexandria
|
|
76
76
|
renderer = Gtk::CellRendererText.new
|
77
77
|
column = Gtk::TreeViewColumn.new("Providers",
|
78
78
|
renderer)
|
79
|
-
# :text => 0)
|
80
79
|
column.set_cell_data_func(renderer) do |_col, rndr, _mod, iter|
|
81
80
|
rndr.markup = iter[0]
|
82
|
-
# enabled = iter[2]
|
83
|
-
# unless enabled
|
84
|
-
# rndr.foreground = "gray"
|
85
|
-
# end
|
86
|
-
# rndr.active = value
|
87
81
|
end
|
88
82
|
@treeview_providers.append_column(column)
|
89
|
-
@treeview_providers.selection
|
90
|
-
|
83
|
+
@treeview_providers.selection
|
84
|
+
.signal_connect("changed") { sensitize_providers }
|
91
85
|
|
92
86
|
@button_prov_setup.sensitive = false
|
93
|
-
|
87
|
+
|
88
|
+
@button_prov_up.sensitive =
|
89
|
+
@button_prov_down.sensitive = BookProviders.list.length > 1
|
94
90
|
|
95
91
|
@buttonbox_prov.set_child_secondary(@button_prov_add, true)
|
96
92
|
@buttonbox_prov.set_child_secondary(@button_prov_remove, true)
|
@@ -102,11 +98,14 @@ module Alexandria
|
|
102
98
|
@checkbutton_prov_advanced.active = true if view_advanced
|
103
99
|
end
|
104
100
|
|
105
|
-
setup_enable_disable_popup
|
106
101
|
sensitize_providers
|
107
102
|
setup_barcode_scanner_tab
|
108
103
|
end
|
109
104
|
|
105
|
+
def show
|
106
|
+
@preferences_dialog.show
|
107
|
+
end
|
108
|
+
|
110
109
|
def widget_names
|
111
110
|
[:button_prov_add, :button_prov_down, :button_prov_remove,
|
112
111
|
:button_prov_setup, :button_prov_up, :buttonbox_prov,
|
@@ -141,63 +140,6 @@ module Alexandria
|
|
141
140
|
@use_scan_sound.active = Preferences.instance.play_scan_sound
|
142
141
|
end
|
143
142
|
|
144
|
-
def setup_enable_disable_popup
|
145
|
-
# New Enable/Disable pop-up menu...
|
146
|
-
@enable_disable_providers_menu = Gtk::Menu.new
|
147
|
-
@enable_item = Gtk::MenuItem.new(label: _("Disable Provider"))
|
148
|
-
@enable_item.signal_connect("activate") do
|
149
|
-
prov = selected_provider
|
150
|
-
prov.toggle_enabled
|
151
|
-
adjust_selected_provider(prov)
|
152
|
-
end
|
153
|
-
@enable_disable_providers_menu.append(@enable_item)
|
154
|
-
@enable_disable_providers_menu.show_all
|
155
|
-
|
156
|
-
@treeview_providers.signal_connect("button_press_event") do |widget, event|
|
157
|
-
if event_is_right_click(event)
|
158
|
-
if (path = widget.get_path_at_pos(event.x, event.y))
|
159
|
-
widget.grab_focus
|
160
|
-
obj = widget.selection
|
161
|
-
path = path.first
|
162
|
-
unless obj.path_is_selected?(path)
|
163
|
-
widget.unselect_all
|
164
|
-
obj.select_path(path)
|
165
|
-
end
|
166
|
-
sel = widget.selection.selected
|
167
|
-
if sel
|
168
|
-
already_enabled = sel[2]
|
169
|
-
message = already_enabled ? _("Disable Provider") : _("Enable Provider")
|
170
|
-
@enable_item.label = message
|
171
|
-
GLib::Idle.add do
|
172
|
-
@enable_disable_providers_menu.popup(nil, nil, event.button, event.time)
|
173
|
-
false
|
174
|
-
end
|
175
|
-
end
|
176
|
-
else
|
177
|
-
puts "not on a path"
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
# Popup the menu on Shift-F10
|
183
|
-
@treeview_providers.signal_connect("popup_menu") do
|
184
|
-
selected_prov = @treeview_providers.selection.selected
|
185
|
-
puts selected_prov.inspect
|
186
|
-
if selected_prov
|
187
|
-
GLib::Idle.add do
|
188
|
-
already_enabled = selected_prov[2]
|
189
|
-
message = already_enabled ? _("Disable Provider") : _("Enable Provider")
|
190
|
-
@enable_item.label = message
|
191
|
-
|
192
|
-
@enable_disable_providers_menu.popup(nil, nil, 0, :current_time)
|
193
|
-
false
|
194
|
-
end
|
195
|
-
else
|
196
|
-
puts "no action"
|
197
|
-
end
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
143
|
def event_is_right_click(event)
|
202
144
|
(event.event_type == :button_press) && (event.button == 3)
|
203
145
|
end
|
@@ -239,11 +181,11 @@ module Alexandria
|
|
239
181
|
end
|
240
182
|
|
241
183
|
def on_provider_add
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
184
|
+
provider = NewProviderDialog.new(@preferences_dialog).acquire
|
185
|
+
return unless provider
|
186
|
+
|
187
|
+
BookProviders.instance.update_priority
|
188
|
+
reload_providers
|
247
189
|
end
|
248
190
|
|
249
191
|
def on_scanner_device_type(_combo)
|
@@ -277,7 +219,7 @@ module Alexandria
|
|
277
219
|
dialog.show_all
|
278
220
|
if dialog.run == Gtk::ResponseType::OK
|
279
221
|
provider.remove
|
280
|
-
BookProviders.update_priority
|
222
|
+
BookProviders.instance.update_priority
|
281
223
|
reload_providers
|
282
224
|
end
|
283
225
|
dialog.destroy
|
@@ -286,8 +228,7 @@ module Alexandria
|
|
286
228
|
def on_column_toggled(checkbutton)
|
287
229
|
raise if @cols[checkbutton].nil?
|
288
230
|
|
289
|
-
Preferences.instance.
|
290
|
-
checkbutton.active?)
|
231
|
+
Preferences.instance.set_variable(@cols[checkbutton], checkbutton.active?)
|
291
232
|
|
292
233
|
@changed_block.call
|
293
234
|
end
|
@@ -312,7 +253,7 @@ module Alexandria
|
|
312
253
|
def reload_providers
|
313
254
|
model = @treeview_providers.model
|
314
255
|
model.clear
|
315
|
-
BookProviders.each_with_index do |x, index|
|
256
|
+
BookProviders.list.each_with_index do |x, index|
|
316
257
|
iter = model.append
|
317
258
|
iter[0] = if x.enabled
|
318
259
|
x.fullname
|
@@ -327,7 +268,7 @@ module Alexandria
|
|
327
268
|
|
328
269
|
def selected_provider
|
329
270
|
iter = @treeview_providers.selection.selected
|
330
|
-
BookProviders.find { |x| x.name == iter[1] } unless iter.nil?
|
271
|
+
BookProviders.list.find { |x| x.name == iter[1] } unless iter.nil?
|
331
272
|
end
|
332
273
|
|
333
274
|
def adjust_selected_provider(prov)
|
@@ -350,10 +291,10 @@ module Alexandria
|
|
350
291
|
@button_prov_setup.sensitive = false
|
351
292
|
@button_prov_remove.sensitive = false
|
352
293
|
else
|
353
|
-
last_iter = model.get_iter((BookProviders.length - 1).to_s)
|
294
|
+
last_iter = model.get_iter((BookProviders.list.length - 1).to_s)
|
354
295
|
@button_prov_up.sensitive = sel_iter != model.iter_first
|
355
296
|
@button_prov_down.sensitive = sel_iter != last_iter
|
356
|
-
provider = BookProviders.find { |x| x.name == sel_iter[1] }
|
297
|
+
provider = BookProviders.list.find { |x| x.name == sel_iter[1] }
|
357
298
|
@button_prov_setup.sensitive = !prefs_empty(provider.prefs)
|
358
299
|
@button_prov_remove.sensitive = provider.abstract?
|
359
300
|
end
|
@@ -365,7 +306,7 @@ module Alexandria
|
|
365
306
|
priority << iter[1]
|
366
307
|
end
|
367
308
|
Preferences.instance.providers_priority = priority
|
368
|
-
BookProviders.update_priority
|
309
|
+
BookProviders.instance.update_priority
|
369
310
|
end
|
370
311
|
end
|
371
312
|
end
|