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
@@ -43,30 +43,28 @@ module Alexandria
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def ident
|
46
|
-
if
|
47
|
-
|
48
|
-
end
|
49
|
-
@isbn or @title.hash.to_s
|
46
|
+
@isbn = nil if !@isbn.nil? && @isbn.empty?
|
47
|
+
@isbn || @title.hash.to_s
|
50
48
|
end
|
51
49
|
|
52
50
|
def loaned?
|
53
|
-
loaned
|
51
|
+
loaned || false
|
54
52
|
end
|
55
53
|
|
56
54
|
def redd?
|
57
|
-
redd
|
55
|
+
redd || false
|
58
56
|
end
|
59
57
|
|
60
58
|
def want?
|
61
|
-
want
|
59
|
+
want || false
|
62
60
|
end
|
63
61
|
|
64
62
|
def own?
|
65
|
-
own
|
63
|
+
own || false
|
66
64
|
end
|
67
65
|
|
68
66
|
def ==(obj)
|
69
|
-
obj.is_a?(self.class)
|
67
|
+
obj.is_a?(self.class) && (ident == obj.ident)
|
70
68
|
end
|
71
69
|
end
|
72
70
|
end
|
@@ -38,7 +38,7 @@ module Alexandria
|
|
38
38
|
attr_reader :name
|
39
39
|
attr_accessor :ruined_books, :updating, :deleted_books
|
40
40
|
DIR = File.join(ENV['HOME'], '.alexandria')
|
41
|
-
EXT = { book: '.yaml', cover: '.cover' }
|
41
|
+
EXT = { book: '.yaml', cover: '.cover' }.freeze
|
42
42
|
|
43
43
|
include GetText
|
44
44
|
extend GetText
|
@@ -54,6 +54,7 @@ module Alexandria
|
|
54
54
|
def updating?
|
55
55
|
@updating
|
56
56
|
end
|
57
|
+
|
57
58
|
def self.generate_new_name(existing_libraries,
|
58
59
|
from_base = _('Untitled'))
|
59
60
|
i = 1
|
@@ -77,7 +78,7 @@ module Alexandria
|
|
77
78
|
FileUtils.mkdir_p(library.path) unless File.exist?(library.path)
|
78
79
|
Dir.chdir(library.path) do
|
79
80
|
Dir['*' + EXT[:book]].each do |filename|
|
80
|
-
test[1] = filename if test[0]
|
81
|
+
test[1] = filename if (test[0]).zero?
|
81
82
|
|
82
83
|
unless File.size? test[1]
|
83
84
|
log.warn { "Book file #{test[1]} was empty" }
|
@@ -87,7 +88,7 @@ module Alexandria
|
|
87
88
|
ruined_books << [nil, file_isbn, library]
|
88
89
|
else
|
89
90
|
log.warn { "Filename #{filename} does not contain an ISBN" }
|
90
|
-
# TODO delete this file...
|
91
|
+
# TODO: delete this file...
|
91
92
|
end
|
92
93
|
next
|
93
94
|
end
|
@@ -183,7 +184,7 @@ module Alexandria
|
|
183
184
|
|
184
185
|
# The string is removed on load, but can't make it stick, maybe has to do with cache
|
185
186
|
|
186
|
-
if /!str:Amazon::Search::Response
|
187
|
+
if text =~ /!str:Amazon::Search::Response/
|
187
188
|
log.debug { "Removing Ruby/Amazon strings from #{name}" }
|
188
189
|
text.gsub!('!str:Amazon::Search::Response', '')
|
189
190
|
end
|
@@ -219,7 +220,7 @@ module Alexandria
|
|
219
220
|
book.saved_ident = string_saved_ident
|
220
221
|
end
|
221
222
|
end
|
222
|
-
if book.isbn.class == String
|
223
|
+
if (book.isbn.class == String) && book.isbn.empty?
|
223
224
|
book.isbn = nil # save trouble later
|
224
225
|
end
|
225
226
|
book
|
@@ -230,7 +231,7 @@ module Alexandria
|
|
230
231
|
begin
|
231
232
|
Dir.entries(DIR).each do |file|
|
232
233
|
# Skip hidden files.
|
233
|
-
next if
|
234
|
+
next if file =~ /^\./
|
234
235
|
# Skip non-directory files.
|
235
236
|
next unless File.stat(File.join(DIR, file)).directory?
|
236
237
|
|
@@ -242,9 +243,7 @@ module Alexandria
|
|
242
243
|
end
|
243
244
|
# Create the default library if there is no library yet.
|
244
245
|
|
245
|
-
if a.empty?
|
246
|
-
a << load(_('My Library'))
|
247
|
-
end
|
246
|
+
a << load(_('My Library')) if a.empty?
|
248
247
|
|
249
248
|
a
|
250
249
|
end
|
@@ -285,10 +284,10 @@ module Alexandria
|
|
285
284
|
end
|
286
285
|
|
287
286
|
def self.extract_numbers(isbn)
|
288
|
-
raise NoISBNError
|
287
|
+
raise NoISBNError, 'Nil ISBN' if isbn.nil? || isbn.empty?
|
289
288
|
|
290
289
|
isbn.delete('- ').upcase.split('').map do |x|
|
291
|
-
raise InvalidISBNError
|
290
|
+
raise InvalidISBNError, isbn unless x =~ /[\dX]/
|
292
291
|
x == 'X' ? 10 : x.to_i
|
293
292
|
end
|
294
293
|
end
|
@@ -303,7 +302,7 @@ module Alexandria
|
|
303
302
|
|
304
303
|
def self.valid_isbn?(isbn)
|
305
304
|
numbers = extract_numbers(isbn)
|
306
|
-
numbers.length == 10
|
305
|
+
(numbers.length == 10) && isbn_checksum(numbers).zero?
|
307
306
|
rescue InvalidISBNError
|
308
307
|
false
|
309
308
|
end
|
@@ -315,10 +314,10 @@ module Alexandria
|
|
315
314
|
|
316
315
|
def self.valid_ean?(ean)
|
317
316
|
numbers = extract_numbers(ean)
|
318
|
-
(numbers.length == 13
|
319
|
-
ean_checksum(numbers[0..11]) == numbers[12])
|
320
|
-
(numbers.length == 18
|
321
|
-
ean_checksum(numbers[0..11]) == numbers[12])
|
317
|
+
((numbers.length == 13) &&
|
318
|
+
(ean_checksum(numbers[0..11]) == numbers[12])) ||
|
319
|
+
((numbers.length == 18) &&
|
320
|
+
(ean_checksum(numbers[0..11]) == numbers[12]))
|
322
321
|
rescue InvalidISBNError
|
323
322
|
false
|
324
323
|
end
|
@@ -330,8 +329,8 @@ module Alexandria
|
|
330
329
|
|
331
330
|
def self.valid_upc?(upc)
|
332
331
|
numbers = extract_numbers(upc)
|
333
|
-
(numbers.length == 17
|
334
|
-
upc_checksum(numbers[0..10]) == numbers[11])
|
332
|
+
((numbers.length == 17) &&
|
333
|
+
(upc_checksum(numbers[0..10]) == numbers[11]))
|
335
334
|
rescue InvalidISBNError
|
336
335
|
false
|
337
336
|
end
|
@@ -349,7 +348,7 @@ module Alexandria
|
|
349
348
|
'072742' => '0441', '076714' => '0671', '076783' => '0553',
|
350
349
|
'076814' => '0449', '078021' => '0872', '079808' => '0394',
|
351
350
|
'090129' => '0679', '099455' => '0061', '099769' => '0451'
|
352
|
-
}
|
351
|
+
}.freeze
|
353
352
|
|
354
353
|
def self.upc_convert(upc)
|
355
354
|
test_upc = upc.map(&:to_s).join
|
@@ -358,41 +357,41 @@ module Alexandria
|
|
358
357
|
|
359
358
|
def self.canonicalise_ean(code)
|
360
359
|
code = code.to_s.delete('- ')
|
361
|
-
if
|
360
|
+
if valid_ean?(code)
|
362
361
|
return code
|
363
|
-
elsif
|
362
|
+
elsif valid_isbn?(code)
|
364
363
|
code = '978' + code[0..8]
|
365
364
|
return code + String(ean_checksum(extract_numbers(code)))
|
366
|
-
elsif
|
367
|
-
isbn10 =
|
365
|
+
elsif valid_upc?(code)
|
366
|
+
isbn10 = canonicalise_isbn
|
368
367
|
code = '978' + isbn10[0..8]
|
369
368
|
return code + String(ean_checksum(extract_numbers(code)))
|
370
369
|
## raise "fix function Alexandria::Library.canonicalise_ean"
|
371
370
|
else
|
372
|
-
raise InvalidISBNError
|
371
|
+
raise InvalidISBNError, code
|
373
372
|
end
|
374
373
|
end
|
375
374
|
|
376
375
|
def self.canonicalise_isbn(isbn)
|
377
376
|
numbers = extract_numbers(isbn)
|
378
|
-
if
|
377
|
+
if valid_ean?(isbn) && (numbers[0..2] != [9, 7, 8])
|
379
378
|
return isbn
|
380
379
|
end
|
381
|
-
canonical = if
|
380
|
+
canonical = if valid_ean?(isbn)
|
382
381
|
# Looks like an EAN number -- extract the intersting part and
|
383
382
|
# calculate a checksum. It would be nice if we could validate
|
384
383
|
# the EAN number somehow.
|
385
384
|
numbers[3..11] + [isbn_checksum(numbers[3..11])]
|
386
|
-
elsif
|
385
|
+
elsif valid_upc?(isbn)
|
387
386
|
# Seems to be a valid UPC number.
|
388
387
|
prefix = upc_convert(numbers[0..5])
|
389
388
|
isbn_sans_chcksm = prefix + numbers[(8 + prefix.length)..17]
|
390
389
|
isbn_sans_chcksm + [isbn_checksum(isbn_sans_chcksm)]
|
391
|
-
elsif
|
390
|
+
elsif valid_isbn?(isbn)
|
392
391
|
# Seems to be a valid ISBN number.
|
393
392
|
numbers[0..-2] + [isbn_checksum(numbers[0..-2])]
|
394
393
|
else
|
395
|
-
raise InvalidISBNError
|
394
|
+
raise InvalidISBNError, isbn
|
396
395
|
end
|
397
396
|
|
398
397
|
canonical.map(&:to_s).join
|
@@ -402,7 +401,7 @@ module Alexandria
|
|
402
401
|
# Let's initialize the saved identifier if not already
|
403
402
|
# (backward compatibility from 0.4.0)
|
404
403
|
# book.saved_ident ||= book.ident
|
405
|
-
if book.saved_ident.nil?
|
404
|
+
if book.saved_ident.nil? || book.saved_ident.empty?
|
406
405
|
book.saved_ident = book.ident
|
407
406
|
end
|
408
407
|
if book.ident != book.saved_ident
|
@@ -441,7 +440,7 @@ module Alexandria
|
|
441
440
|
book.saved_ident = book.ident
|
442
441
|
end
|
443
442
|
# #was File.exist? but that returns true for empty files... CathalMagus
|
444
|
-
already_there = (File.size?(yaml(book))
|
443
|
+
already_there = (File.size?(yaml(book)) &&
|
445
444
|
!@deleted_books.include?(book))
|
446
445
|
|
447
446
|
temp_book = book.dup
|
@@ -503,7 +502,7 @@ module Alexandria
|
|
503
502
|
end
|
504
503
|
end
|
505
504
|
|
506
|
-
|
505
|
+
alias old_delete delete
|
507
506
|
def delete(book = nil)
|
508
507
|
if book.nil?
|
509
508
|
# Delete the whole library.
|
@@ -512,14 +511,14 @@ module Alexandria
|
|
512
511
|
else
|
513
512
|
if @deleted_books.include?(book)
|
514
513
|
doubles = @deleted_books.reject { |b| !b.equal?(book) }
|
515
|
-
raise "Book #{book.isbn} was already deleted" unless doubles.empty?
|
514
|
+
raise ArgumentError, "Book #{book.isbn} was already deleted" unless doubles.empty?
|
516
515
|
end
|
517
516
|
@deleted_books << book
|
518
517
|
i = index(book)
|
519
518
|
# We check object IDs there because the user could have added
|
520
519
|
# a book with the same identifier as another book he/she
|
521
520
|
# previously deleted and that he/she is trying to redo.
|
522
|
-
if i
|
521
|
+
if i && self[i].equal?(book)
|
523
522
|
changed
|
524
523
|
old_delete(book) # FIX this will old_delete all '==' books
|
525
524
|
notify_observers(self, BOOK_REMOVED, book)
|
@@ -539,7 +538,7 @@ module Alexandria
|
|
539
538
|
else
|
540
539
|
raise unless @deleted_books.include?(book)
|
541
540
|
@deleted_books.delete(book)
|
542
|
-
unless
|
541
|
+
unless include?(book)
|
543
542
|
changed
|
544
543
|
self << book
|
545
544
|
notify_observers(self, BOOK_ADDED, book)
|
@@ -547,7 +546,7 @@ module Alexandria
|
|
547
546
|
end
|
548
547
|
end
|
549
548
|
|
550
|
-
|
549
|
+
alias old_select select
|
551
550
|
def select
|
552
551
|
filtered_library = Library.new(@name)
|
553
552
|
each do |book|
|
@@ -570,9 +569,9 @@ module Alexandria
|
|
570
569
|
end
|
571
570
|
when String
|
572
571
|
something
|
573
|
-
when
|
572
|
+
when Integer
|
574
573
|
something
|
575
|
-
when
|
574
|
+
when Integer
|
576
575
|
something
|
577
576
|
else
|
578
577
|
raise "#{something} is a #{something.class}"
|
@@ -586,9 +585,9 @@ module Alexandria
|
|
586
585
|
something.ident
|
587
586
|
when String
|
588
587
|
something
|
589
|
-
when
|
588
|
+
when Integer
|
590
589
|
something
|
591
|
-
when
|
590
|
+
when Integer
|
592
591
|
something
|
593
592
|
else
|
594
593
|
raise "#{something} is #{something.class}"
|
@@ -602,7 +601,7 @@ module Alexandria
|
|
602
601
|
end
|
603
602
|
|
604
603
|
def n_rated
|
605
|
-
count { |x| !x.rating.nil?
|
604
|
+
count { |x| !x.rating.nil? && x.rating > 0 }
|
606
605
|
end
|
607
606
|
|
608
607
|
def n_unrated
|
@@ -628,7 +627,7 @@ module Alexandria
|
|
628
627
|
end
|
629
628
|
|
630
629
|
def final_cover(book)
|
631
|
-
# TODO what about PNG?
|
630
|
+
# TODO: what about PNG?
|
632
631
|
book.ident + (Library.jpeg?(cover(book)) ? '.jpg' : '.gif')
|
633
632
|
end
|
634
633
|
|
@@ -653,7 +652,7 @@ module Alexandria
|
|
653
652
|
|
654
653
|
ruined = []
|
655
654
|
deleted = []
|
656
|
-
all_regular_libraries.each {|library|
|
655
|
+
all_regular_libraries.each { |library|
|
657
656
|
ruined += library.ruined_books
|
658
657
|
# make deleted books from each library accessible so we don't crash on smart libraries
|
659
658
|
deleted += library.deleted_books
|
@@ -674,7 +673,8 @@ module Alexandria
|
|
674
673
|
# @all_libraries.select { |x| x.is_a?(SmartLibrary) }
|
675
674
|
# end
|
676
675
|
|
677
|
-
LIBRARY_ADDED
|
676
|
+
LIBRARY_ADDED = 1
|
677
|
+
LIBRARY_REMOVED = 2
|
678
678
|
|
679
679
|
def add_library(library)
|
680
680
|
@all_libraries << library
|
data/lib/alexandria/net.rb
CHANGED
@@ -36,7 +36,7 @@ module Alexandria
|
|
36
36
|
@extra_request_headers.each_pair do |header_name, value|
|
37
37
|
req.add_field(header_name, value)
|
38
38
|
end
|
39
|
-
res = WWWAgent.transport.start(uri.host, uri.port) {|http|
|
39
|
+
res = WWWAgent.transport.start(uri.host, uri.port) { |http|
|
40
40
|
http.request(req)
|
41
41
|
}
|
42
42
|
res
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
2
|
# Copyright (C) 2011 Cathal Mc Ginley
|
3
|
-
# Copyright (C) 2011 Matijs van Zuijlen
|
3
|
+
# Copyright (C) 2011, 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
|
@@ -26,12 +26,12 @@ module Alexandria
|
|
26
26
|
include Singleton
|
27
27
|
include Logging
|
28
28
|
|
29
|
-
APP_DIR = '/apps/alexandria'
|
30
|
-
HTTP_PROXY_DIR = '/system/http_proxy'
|
31
|
-
HTTP_PROXY_MODE = '/system/proxy/mode'
|
32
|
-
URL_HANDLERS_DIR = '/desktop/gnome/url-handlers'
|
29
|
+
APP_DIR = '/apps/alexandria'.freeze
|
30
|
+
HTTP_PROXY_DIR = '/system/http_proxy'.freeze
|
31
|
+
HTTP_PROXY_MODE = '/system/proxy/mode'.freeze
|
32
|
+
URL_HANDLERS_DIR = '/desktop/gnome/url-handlers'.freeze
|
33
33
|
|
34
|
-
GCONFTOOL = 'gconftool-2'
|
34
|
+
GCONFTOOL = 'gconftool-2'.freeze
|
35
35
|
|
36
36
|
def initialize
|
37
37
|
@alexandria_settings = {}
|
@@ -49,29 +49,10 @@ module Alexandria
|
|
49
49
|
@proxy_password = nil
|
50
50
|
|
51
51
|
load_alexandria_settings
|
52
|
-
# load_system_settings
|
53
|
-
end
|
54
|
-
|
55
|
-
def www_browser
|
56
|
-
unless @url_handlers_loaded
|
57
|
-
load_url_handler_settings
|
58
|
-
end
|
59
|
-
puts @http_command
|
60
|
-
@http_command
|
61
|
-
end
|
62
|
-
|
63
|
-
def email_client
|
64
|
-
unless @url_handlers_loaded
|
65
|
-
load_url_handler_settings
|
66
|
-
end
|
67
|
-
puts @mailto_command
|
68
|
-
@mailto_command
|
69
52
|
end
|
70
53
|
|
71
54
|
def http_proxy_config
|
72
|
-
unless @http_proxy_loaded
|
73
|
-
load_http_proxy_settings
|
74
|
-
end
|
55
|
+
load_http_proxy_settings unless @http_proxy_loaded
|
75
56
|
if @use_http_proxy && @proxy_host && @proxy_port
|
76
57
|
[@proxy_host, @proxy_port, @proxy_user, @proxy_password]
|
77
58
|
end
|
@@ -173,7 +154,7 @@ module Alexandria
|
|
173
154
|
def get_gconf_type(value)
|
174
155
|
if value.is_a?(String)
|
175
156
|
'string'
|
176
|
-
elsif value.is_a?(
|
157
|
+
elsif value.is_a?(Integer)
|
177
158
|
'int'
|
178
159
|
elsif value.is_a?(TrueClass) || value.is_a?(FalseClass)
|
179
160
|
'bool'
|
@@ -200,7 +181,7 @@ module Alexandria
|
|
200
181
|
|
201
182
|
def make_list_string(list)
|
202
183
|
if get_gconf_type(list.first) == 'string'
|
203
|
-
list.map! { |x| x.gsub(/\"/, "
|
184
|
+
list.map! { |x| x.gsub(/\"/, '\\"') }
|
204
185
|
end
|
205
186
|
contents = list.join(',')
|
206
187
|
'[' + contents + ']'
|
@@ -215,12 +196,10 @@ module Alexandria
|
|
215
196
|
type = get_gconf_type(new_value)
|
216
197
|
value_str = new_value
|
217
198
|
if new_value.is_a? String
|
218
|
-
new_value.gsub!(/\"/, "
|
199
|
+
new_value.gsub!(/\"/, '\\"')
|
219
200
|
value_str = "\"#{new_value}\""
|
220
201
|
end
|
221
|
-
if /cols_width/ =~ var_path
|
222
|
-
puts value_str
|
223
|
-
end
|
202
|
+
puts value_str if /cols_width/ =~ var_path
|
224
203
|
`gconftool-2 --type #{type} --set #{var_path} #{value_str}`
|
225
204
|
end
|
226
205
|
|
@@ -240,30 +219,6 @@ module Alexandria
|
|
240
219
|
@alexandria_settings.merge!(gconftool_values_to_hash(all_vals))
|
241
220
|
end
|
242
221
|
|
243
|
-
# May be useful to pre-load these settings
|
244
|
-
def load_system_settings
|
245
|
-
load_url_handler_settingss
|
246
|
-
load_http_proxy_settings
|
247
|
-
end
|
248
|
-
|
249
|
-
# Called at most once, by #web_browser or #email_client
|
250
|
-
# TODO: Enforce this.
|
251
|
-
def load_url_handler_settings
|
252
|
-
# /desktop/gnome/url-handlers/http
|
253
|
-
http_handler_vars = `#{GCONFTOOL} --recursive-list #{URL_HANDLERS_DIR + '/http'}`
|
254
|
-
http_handler = gconftool_values_to_hash(http_handler_vars)
|
255
|
-
if http_handler['enabled']
|
256
|
-
@http_command = http_handler['command']
|
257
|
-
end
|
258
|
-
|
259
|
-
mailto_handler_vars = `#{GCONFTOOL} --recursive-list #{URL_HANDLERS_DIR + '/mailto'}`
|
260
|
-
mailto_handler = gconftool_values_to_hash(mailto_handler_vars)
|
261
|
-
if mailto_handler['enabled']
|
262
|
-
@mailto_command = mailto_handler['command']
|
263
|
-
end
|
264
|
-
@url_handlers_loaded = true
|
265
|
-
end
|
266
|
-
|
267
222
|
# Called at most once, by #http_proxy_config
|
268
223
|
# TODO: Enforce this.
|
269
224
|
def load_http_proxy_settings
|
@@ -317,7 +272,7 @@ module Alexandria
|
|
317
272
|
return [0, 0]
|
318
273
|
end
|
319
274
|
else
|
320
|
-
return value
|
275
|
+
return value # string
|
321
276
|
end
|
322
277
|
end
|
323
278
|
end
|