Module: Tkri::Settings
- Defined in:
- lib/tkri.rb
Constant Summary collapse
- COMMAND =
DefaultSettings::COMMAND.dup
- VISUALS =
DefaultSettings::VISUALS.dup
- BINDINGS =
DefaultSettings::BINDINGS
Class Method Summary collapse
-
.get_configuration(name) ⇒ Object
get_configuration() converts any of the VISUAL hashes, above, to a hash suitable for use in Tk.
-
.load ⇒ Object
Load the settings from the ‘rc’ file.
Class Method Details
.get_configuration(name) ⇒ Object
get_configuration() converts any of the VISUAL hashes, above, to a hash suitable for use in Tk. Corrently, it only converts the :font attribute to a TkFont instance.
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/tkri.rb', line 179 def self.get_configuration(name) h = VISUALS[name].dup h.delete(:is_tag) if h[:font].instance_of? Hash h[:font] = h[:font].dup if h[:font][:family] availables = TkFont.families.map { |s| s.downcase } desired = Array(h[:font][:family]).map { |s| s.downcase } # Select the first family available on this system. h[:font][:family] = (desired & availables).first || 'courier' end h[:font] = TkFont.new(h[:font]) end return h end |
.load ⇒ Object
Load the settings from the ‘rc’ file. We merge them into the existing settings.
165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/tkri.rb', line 165 def self.load if File.exist? Tkri.get_rc_file_path require 'yaml' settings = YAML.load_file(Tkri.get_rc_file_path) if settings.instance_of? Hash COMMAND.merge!(settings['command']) if settings['command'] VISUALS.merge!(settings['visuals']) if settings['visuals'] BINDINGS.merge!(settings['bindings']) if settings['bindings'] end end end |