Ignore:
Timestamp:
10/01/11 12:05:22 (2 years ago)
Author:
Matias De la Puente <mfpuente.ar@…>
Children:
178436daf1f6b1d9634d229404184532c8f23333
Parents:
9cd11c02b25537ee501c8e398b6baeb2e6eb7bc7
git-committer:
Matias De la Puente <mfpuente.ar@…> (10/01/11 12:05:22)
Message:

Programmers: Load and save programmer's command settings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libi4uccore/settings.vala

    r9cd11c0 r7960aa9  
    2121using Gee; 
    2222 
     23public class OptionSettings : GLib.Object 
     24{ 
     25        public string name { set; get; } 
     26        public string value { set; get; } 
     27        public bool active { set; get; } 
     28         
     29        public string to_xml (size_t tab_width) 
     30        { 
     31                var prefix = string.nfill (tab_width, '\t'); 
     32                var xml_str = "<option_value name=\"%s\" value=\"%s\" active=\"%s\"/>\n"; 
     33                return prefix + xml_str.printf (_name, _value, _active.to_string ()); 
     34        } 
     35} 
     36 
     37public class ProgrammerSettings : GLib.Object 
     38{ 
     39        private HashMap<string, OptionSettings> _options = new HashMap<string, OptionSettings> (); 
     40         
     41        public string name { set; get; } 
     42        public Gee.Map<string, OptionSettings> options { get { return _options; } } 
     43         
     44        public string to_xml (size_t tab_width) 
     45        { 
     46                var prefix = string.nfill (tab_width, '\t'); 
     47                var xml_str = prefix + "<programmer name=\"%s\">\n".printf (_name); 
     48                foreach (var option_settings in _options.values) 
     49                        xml_str += option_settings.to_xml (tab_width+1); 
     50                xml_str += prefix + "</programmer>\n"; 
     51                return xml_str; 
     52        } 
     53} 
     54 
    2355public class I4uc.Core.Settings : GLib.Object 
    2456{ 
     57        private HashMap<string, ProgrammerSettings> _programmers = new HashMap<string, ProgrammerSettings> (); 
     58         
    2559        public string working_folder { set; get; } 
    2660         
     
    4478        // Programmers settings 
    4579        public string programmer { set; get; default = ""; } 
     80        public Gee.Map<string, ProgrammerSettings> programmers { get { return _programmers; } } 
    4681         
    4782        public Settings () 
     
    72107                 
    73108                // Programmers settings 
    74                 xml_str += @"\t<programmer>$(_programmer)</programmer>\n"; 
     109                xml_str += @"\t<current_programmer>$(_programmer)</current_programmer>\n"; 
     110                 
     111                xml_str += "\t<programmers>\n"; 
     112                foreach (var programmer in _programmers.values) 
     113                        xml_str += programmer.to_xml (2); 
     114                xml_str += "\t</programmers>\n"; 
    75115                 
    76116                return xml_str + "</settings>"; 
Note: See TracChangeset for help on using the changeset viewer.