Class: Alexandria::Preferences
- Inherits:
-
Object
- Object
- Alexandria::Preferences
- Includes:
- Logging, Singleton
- Defined in:
- lib/alexandria/preferences.rb,
lib/alexandria/default_preferences.rb
Constant Summary collapse
- APP_DIR =
"/apps/alexandria"
- HTTP_PROXY_DIR =
"/system/http_proxy"
- HTTP_PROXY_MODE =
"/system/proxy/mode"
- URL_HANDLERS_DIR =
"/desktop/gnome/url-handlers"
- GCONFTOOL =
"gconftool-2"
- DEFAULT_VALUES =
{ "position" => [0, 0], "size" => [640, 480], "maximized" => false, "sidepane_position" => 140, "view_as" => 0, "arrange_icons_mode" => 0, "reverse_icons" => false, "selected_library" => "", "barcode_scanner" => "CueCat", "play_scanning_sound" => true, "play_scan_sound" => true, "toolbar_visible" => true, "sidepane_visible" => true, "statusbar_visible" => true, "col_authors_visible" => true, "col_edition_visible" => true, "col_isbn_visible" => true, "col_publisher_visible" => true, "col_publish_date_visible" => true, "col_loaned_to_visible" => true, "col_rating_visible" => true, "col_redd_visible" => true, "col_own_visible" => true, "col_want_visible" => true, "col_tags_visible" => true, "cols_width" => "{}", "providers_priority" => ["Thalia", "WorldCat", "LOC", "BL", "SBN"], "view_advanced_settings" => false }
Instance Method Summary collapse
- #get_variable(variable_name) ⇒ Object
- #http_proxy_config ⇒ Object
-
#initialize ⇒ Preferences
constructor
A new instance of Preferences.
- #remove_preference(variable_name) ⇒ Object
- #save! ⇒ Object
- #set_variable(variable_name, value) ⇒ Object
Methods included from Logging
Constructor Details
#initialize ⇒ Preferences
Returns a new instance of Preferences.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/alexandria/preferences.rb', line 23 def initialize @alexandria_settings = {} @changed_settings = Set.new @url_handlers_loaded = false @http_command = nil @mailto_command = nil @http_proxy_loaded = false @use_http_proxy = false @proxy_host = nil @proxy_port = nil @proxy_user = nil @proxy_password = nil load_alexandria_settings end |
Instance Method Details
#get_variable(variable_name) ⇒ Object
70 71 72 |
# File 'lib/alexandria/preferences.rb', line 70 def get_variable(variable_name) generic_getter(variable_name.to_s) end |
#http_proxy_config ⇒ Object
41 42 43 44 45 46 |
# File 'lib/alexandria/preferences.rb', line 41 def http_proxy_config load_http_proxy_settings unless @http_proxy_loaded if @use_http_proxy && @proxy_host && @proxy_port [@proxy_host, @proxy_port, @proxy_user, @proxy_password] end end |
#remove_preference(variable_name) ⇒ Object
60 61 62 63 |
# File 'lib/alexandria/preferences.rb', line 60 def remove_preference(variable_name) @alexandria_settings.delete(variable_name) @changed_settings << variable_name end |
#save! ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/alexandria/preferences.rb', line 48 def save! log.debug { "preferences save!" } @changed_settings.each do |variable_name| log.debug do klass = @alexandria_settings[variable_name].class "saving preference #{variable_name} / #{klass}" end generic_save_setting(variable_name, @alexandria_settings[variable_name]) end @changed_settings.clear end |
#set_variable(variable_name, value) ⇒ Object
74 75 76 |
# File 'lib/alexandria/preferences.rb', line 74 def set_variable(variable_name, value) generic_setter(variable_name.to_s, value) end |