# encoding: ascii-8bit # Copyright 2014 Ball Aerospace & Technologies Corp. # All Rights Reserved. # # This program is free software; you can modify and/or redistribute it # under the terms of the GNU General Public License # as published by the Free Software Foundation; version 3 with # attribution addendums as found in the LICENSE.txt require 'cosmos' require 'cosmos/config/config_parser' module Cosmos # Reads and interprets the Launcher configuration file class LauncherConfig # Launcher title attr_reader :title # Array for tool font settings [font_name, font_size] attr_reader :tool_font_settings # Array for label font settings [font_name, font_size] attr_reader :label_font_settings # Array of [[item_type, text, shell command, icon filename, variable params], ...] # Where variable params is nil or an array of [[parameter name, parameter value], ...] attr_reader :items # Number of columns per row attr_reader :num_columns # Processes a file and adds in the configuration defined in the file def initialize(filename) # Initialize instance variables @title = 'COSMOS Launcher' @tool_font_settings = ['Arial', 12] @label_font_settings = ['Arial', 16] @num_columns = 4 @items = [] if File.exist?(filename.to_s) multitool = false multitool_text = nil multitool_icon_filename = nil multitool_settings = nil # Loop over each line of the configuration file parser = ConfigParser.new parser.parse_file(filename) do |keyword, params| # Handle each keyword case keyword when 'TOOL' if multitool parser.verify_num_parameters(1, 1, "TOOL ") multitool_settings << [:TOOL, format_shell_command(params[0]), true] else parser.verify_num_parameters(2, nil, "TOOL