Changeset d84deaa77ffc2ee77ef689893cea4a4958f7a22e
- Timestamp:
- 07/01/11 20:07:47 (2 years ago)
- Children:
- c54bf3ec1198e1c71828bfdf05569ea46e5894e5
- Parents:
- 6907a8e216b3303b3279c644e459eecaded0446a
- git-committer:
- Matias De la Puente <mfpuente.ar@…> (07/01/11 20:07:47)
- Files:
-
- 1 added
- 6 edited
-
gtkfrontend/documentpageview.vala (modified) (2 diffs)
-
gtkfrontend/main.vala (modified) (2 diffs)
-
libi4uccore/Makefile.am (modified) (1 diff)
-
libi4uccore/documentpagelogic.vala (modified) (2 diffs)
-
libi4uccore/documentpreferencespagelogic.vala (modified) (3 diffs)
-
libi4uccore/settings.vala (modified) (4 diffs)
-
libi4uccore/settingsloader.vala (added)
Legend:
- Unmodified
- Added
- Removed
-
gtkfrontend/documentpageview.vala
ra380ad2 rd84deaa7 1 1 /* documentpageview.vala 2 2 * 3 * Copyright (C) 2010 Matias De la Puente3 * Copyright (C) 2010-2011 Matias De la Puente 4 4 * 5 5 * This program is free software: you can redistribute it and/or modify … … 201 201 { 202 202 var print_compositor = new SourcePrintCompositor (_source_buffer); 203 print_compositor.tab_width = _app.settings. documents_tab_width;204 print_compositor.print_line_numbers = _app.settings. documents_show_line_numbers ? 1 : 0;205 print_compositor.body_font_name = _app.settings. documents_font;203 print_compositor.tab_width = _app.settings.tab_width; 204 print_compositor.print_line_numbers = _app.settings.show_line_numbers ? 1 : 0; 205 print_compositor.body_font_name = _app.settings.font; 206 206 print_compositor.set_header_format (true, null, this.title, null); 207 207 print_compositor.set_footer_format (true, null, _("Page %N of %Q"), null); -
gtkfrontend/main.vala
r372eb3d rd84deaa7 169 169 170 170 // Load core settings 171 _app.settings.open (Path.build_filename (settings_folder, "i4ucrc")); 171 var settings_filename = Path.build_filename (settings_folder, "settings.xml"); 172 if (FileUtils.test (settings_filename, FileTest.EXISTS)) 173 SettingsLoader.load (_app.settings, settings_filename); 172 174 173 175 // Load printer settings … … 192 194 { 193 195 // Save core settings 194 _app.settings.save (); 196 var settings_str = _app.settings.to_xml (); 197 var settings_filename = Path.build_filename (Environment.get_home_dir (), ".i4uc", "settings.xml"); 198 FileUtils.set_contents (settings_filename, settings_str); 195 199 196 200 // Save printer settings -
libi4uccore/Makefile.am
r134a360 rd84deaa7 77 77 serialportutilsfactory.c \ 78 78 settings.vala \ 79 settingsloader.vala \ 79 80 syntaxhighlightmenu.vala \ 80 81 viewfactory.vala \ -
libi4uccore/documentpagelogic.vala
ra380ad2 rd84deaa7 1 1 /* documentpagelogic.vala 2 2 * 3 * Copyright (C) 2010 Matias De la Puente3 * Copyright (C) 2010-2011 Matias De la Puente 4 4 * 5 5 * This program is free software: you can redistribute it and/or modify … … 53 53 54 54 //configure view 55 _view.font_name = _app.settings. documents_font;56 _view.tab_width = _app.settings. documents_tab_width;57 _view.auto_indent = _app.settings. documents_auto_indent;58 _view.highlight_current_line = _app.settings. documents_highlight_current_line;59 _view.insert_spaces_instead_of_tabs = _app.settings. documents_insert_spaces_instead_of_tabs;60 _view.show_line_numbers = _app.settings. documents_show_line_numbers;61 _view.highlight_matching_brackets = _app.settings. documents_highlight_matching_brackets;62 _view.wrap_mode = _app.settings. documents_wrap_mode;55 _view.font_name = _app.settings.font; 56 _view.tab_width = _app.settings.tab_width; 57 _view.auto_indent = _app.settings.auto_indent; 58 _view.highlight_current_line = _app.settings.highlight_current_line; 59 _view.insert_spaces_instead_of_tabs = _app.settings.insert_spaces_instead_of_tabs; 60 _view.show_line_numbers = _app.settings.show_line_numbers; 61 _view.highlight_matching_brackets = _app.settings.highlight_matching_brackets; 62 _view.wrap_mode = _app.settings.wrap_mode; 63 63 64 64 _view.error_message_bar.visible = false; -
libi4uccore/documentpreferencespagelogic.vala
r47b701a rd84deaa7 1 1 /* documentpreferencespagelogic.vala 2 2 * 3 * Copyright (C) 2010 Matias De la Puente3 * Copyright (C) 2010-2011 Matias De la Puente 4 4 * 5 5 * This program is free software: you can redistribute it and/or modify … … 38 38 39 39 //configure view 40 _view.font_name = _app.settings. documents_font;41 _view.tab_width = _app.settings. documents_tab_width;42 _view.auto_indent = _app.settings. documents_auto_indent;43 _view.highlight_current_line = _app.settings. documents_highlight_current_line;44 _view.insert_spaces_instead_of_tabs = _app.settings. documents_insert_spaces_instead_of_tabs;45 _view.show_line_numbers = _app.settings. documents_show_line_numbers;46 _view.highlight_matching_brackets = _app.settings. documents_highlight_matching_brackets;47 _view.wrap_mode = _app.settings. documents_wrap_mode;40 _view.font_name = _app.settings.font; 41 _view.tab_width = _app.settings.tab_width; 42 _view.auto_indent = _app.settings.auto_indent; 43 _view.highlight_current_line = _app.settings.highlight_current_line; 44 _view.insert_spaces_instead_of_tabs = _app.settings.insert_spaces_instead_of_tabs; 45 _view.show_line_numbers = _app.settings.show_line_numbers; 46 _view.highlight_matching_brackets = _app.settings.highlight_matching_brackets; 47 _view.wrap_mode = _app.settings.wrap_mode; 48 48 49 49 //connect view signals … … 72 72 } 73 73 74 _app.settings. documents_font = _view.font_name;75 _app.settings. documents_tab_width = _view.tab_width;76 _app.settings. documents_auto_indent = _view.auto_indent;77 _app.settings. documents_highlight_current_line = _view.highlight_current_line;78 _app.settings. documents_insert_spaces_instead_of_tabs = _view.insert_spaces_instead_of_tabs;79 _app.settings. documents_show_line_numbers = _view.show_line_numbers;80 _app.settings. documents_highlight_matching_brackets = _view.highlight_matching_brackets;81 _app.settings. documents_wrap_mode = _view.wrap_mode;74 _app.settings.font = _view.font_name; 75 _app.settings.tab_width = _view.tab_width; 76 _app.settings.auto_indent = _view.auto_indent; 77 _app.settings.highlight_current_line = _view.highlight_current_line; 78 _app.settings.insert_spaces_instead_of_tabs = _view.insert_spaces_instead_of_tabs; 79 _app.settings.show_line_numbers = _view.show_line_numbers; 80 _app.settings.highlight_matching_brackets = _view.highlight_matching_brackets; 81 _app.settings.wrap_mode = _view.wrap_mode; 82 82 } 83 83 } -
libi4uccore/settings.vala
r372eb3d rd84deaa7 23 23 public class I4uc.Core.Settings : GLib.Object 24 24 { 25 private const string _I4UC_SETTINGS = "i4uc settings";26 private const string _DOCUMENTS_SETTINGS = "Documents settings";27 28 private string _filename;29 25 private HashMap<string, string> _devices_files = new HashMap<string, string> (); 30 26 private HashMap<string, string> _devices_folders = new HashMap<string, string> (); … … 33 29 private HashMap<string, string> _fuses = new HashMap<string, string> (); 34 30 31 public string working_folder { set; get; } 32 33 // MainWindow Settings 35 34 public int width { set; get; default = 320; } 36 35 public int height { set; get; default = 240; } … … 38 37 public bool side_panel_visible { set; get; } 39 38 public bool bottom_panel_visible { set; get; } 40 public string working_folder { set; get; }41 39 42 public string documents_font { set; get; default = "Monospace 10"; } 43 public int documents_tab_width { set; get; default = 8; } 44 public bool documents_auto_indent { set; get; } 45 public bool documents_highlight_current_line { set; get; } 46 public bool documents_insert_spaces_instead_of_tabs { set; get; } 47 public bool documents_show_line_numbers { set; get; } 48 public bool documents_highlight_matching_brackets { set; get; } 49 public bool documents_wrap_mode { set; get; } 40 // Documents Settings 41 public string font { set; get; default = "Monospace 10"; } 42 public int tab_width { set; get; default = 8; } 43 public bool auto_indent { set; get; } 44 public bool highlight_current_line { set; get; } 45 public bool insert_spaces_instead_of_tabs { set; get; } 46 public bool show_line_numbers { set; get; } 47 public bool highlight_matching_brackets { set; get; } 48 public bool wrap_mode { set; get; } 50 49 50 // Programmers settings 51 51 public string programmer { set; get; default = ""; } 52 52 public string serial_port { set; get; default = ""; } … … 63 63 } 64 64 65 public void open (string filename) throws GLib.Error, GLib.KeyFileError65 public string to_xml () 66 66 { 67 _filename = filename; 68 var key_file = new KeyFile (); 67 var xml_str = "<settings>\n"; 69 68 70 if (!FileUtils.test (_filename, FileTest.EXISTS) || 71 !key_file.load_from_file (_filename, KeyFileFlags.NONE) || 72 key_file.get_start_group () != _I4UC_SETTINGS) 73 return; 69 // MainWindow settings 70 xml_str += @"\t<width>$(_width)</width>\n"; 71 xml_str += @"\t<height>$(_height)</height>\n"; 72 xml_str += @"\t<maximized>$(_maximized)</maximized>\n"; 73 xml_str += @"\t<side_panel_visible>$(_side_panel_visible)</side_panel_visible>\n"; 74 xml_str += @"\t<bottom_panel_visible>$(_bottom_panel_visible)</bottom_panel_visible>\n"; 74 75 75 this.width = key_file.get_integer (_I4UC_SETTINGS, "width"); 76 this.height = key_file.get_integer (_I4UC_SETTINGS, "height"); 77 this.maximized = key_file.get_boolean (_I4UC_SETTINGS, "maximized"); 78 this.side_panel_visible = key_file.get_boolean (_I4UC_SETTINGS, "side_panel_visible"); 79 this.bottom_panel_visible = key_file.get_boolean (_I4UC_SETTINGS, "bottom_panel_visible"); 76 // Documents settings 77 xml_str += @"\t<font>$(_font)</font>\n"; 78 xml_str += @"\t<tab_width>$(_tab_width)</tab_width>\n"; 79 xml_str += @"\t<auto_indent>$(_auto_indent)</auto_indent>\n"; 80 xml_str += @"\t<highlight_current_line>$(_highlight_current_line)</highlight_current_line>\n"; 81 xml_str += @"\t<insert_spaces_instead_of_tabs>$(_insert_spaces_instead_of_tabs)</insert_spaces_instead_of_tabs>\n"; 82 xml_str += @"\t<show_line_numbers>$(_show_line_numbers)</show_line_numbers>\n"; 83 xml_str += @"\t<highlight_matching_brackets>$(_highlight_matching_brackets)</highlight_matching_brackets>\n"; 84 xml_str += @"\t<wrap_mode>$(_wrap_mode)</wrap_mode>\n"; 80 85 81 this.documents_font = key_file.get_string (_DOCUMENTS_SETTINGS, "font"); 82 this.documents_tab_width = key_file.get_integer (_DOCUMENTS_SETTINGS, "tab_width"); 83 this.documents_auto_indent = key_file.get_boolean (_DOCUMENTS_SETTINGS, "auto_indent"); 84 this.documents_highlight_current_line = key_file.get_boolean (_DOCUMENTS_SETTINGS, "highlight_current_line"); 85 this.documents_insert_spaces_instead_of_tabs = key_file.get_boolean (_DOCUMENTS_SETTINGS, "insert_spaces_instead_of_tabs"); 86 this.documents_show_line_numbers = key_file.get_boolean (_DOCUMENTS_SETTINGS, "show_line_numbers"); 87 this.documents_highlight_matching_brackets = key_file.get_boolean (_DOCUMENTS_SETTINGS, "highlight_matching_brackets"); 88 this.documents_wrap_mode = key_file.get_boolean (_DOCUMENTS_SETTINGS, "wrap_mode"); 86 // Programmers settings 87 xml_str += @"\t<programmer>$(_programmer)</programmer>\n"; 89 88 90 this.programmer = key_file.get_string (_I4UC_SETTINGS, "programmer"); 91 this.serial_port = key_file.get_string (_I4UC_SETTINGS, "serial_port"); 92 this.baud_rate = key_file.get_string (_I4UC_SETTINGS, "baud_rate"); 93 load_entries (key_file, _I4UC_SETTINGS, "devices_files", _devices_files); 94 load_entries (key_file, _I4UC_SETTINGS, "devices_folders", _devices_folders); 95 load_entries (key_file, _I4UC_SETTINGS, "clocks", _clocks); 96 load_entries (key_file, _I4UC_SETTINGS, "devices", _devices); 97 load_entries (key_file, _I4UC_SETTINGS, "fuses", _fuses); 98 } 99 100 public void save () throws GLib.FileError 101 { 102 var key_file = new KeyFile (); 103 104 key_file.set_integer (_I4UC_SETTINGS, "width", _width); 105 key_file.set_integer (_I4UC_SETTINGS, "height", _height); 106 key_file.set_boolean (_I4UC_SETTINGS, "maximized", _maximized); 107 key_file.set_boolean (_I4UC_SETTINGS, "side_panel_visible", _side_panel_visible); 108 key_file.set_boolean (_I4UC_SETTINGS, "bottom_panel_visible", _bottom_panel_visible); 109 110 key_file.set_string (_DOCUMENTS_SETTINGS, "font", _documents_font); 111 key_file.set_integer (_DOCUMENTS_SETTINGS, "tab_width", _documents_tab_width); 112 key_file.set_boolean (_DOCUMENTS_SETTINGS, "auto_indent", _documents_auto_indent); 113 key_file.set_boolean (_DOCUMENTS_SETTINGS, "highlight_current_line", _documents_highlight_current_line); 114 key_file.set_boolean (_DOCUMENTS_SETTINGS, "insert_spaces_instead_of_tabs", _documents_insert_spaces_instead_of_tabs); 115 key_file.set_boolean (_DOCUMENTS_SETTINGS, "show_line_numbers", _documents_show_line_numbers); 116 key_file.set_boolean (_DOCUMENTS_SETTINGS, "highlight_matching_brackets", _documents_highlight_matching_brackets); 117 key_file.set_boolean (_DOCUMENTS_SETTINGS, "wrap_mode", _documents_wrap_mode); 118 119 key_file.set_string (_I4UC_SETTINGS, "programmer", _programmer); 120 key_file.set_string (_I4UC_SETTINGS, "serial_port", _serial_port); 121 key_file.set_string (_I4UC_SETTINGS, "baud_rate", _baud_rate); 122 save_entries (key_file, _I4UC_SETTINGS, "devices_files", _devices_files); 123 save_entries (key_file, _I4UC_SETTINGS, "devices_folders", _devices_folders); 124 save_entries (key_file, _I4UC_SETTINGS, "clocks", _clocks); 125 save_entries (key_file, _I4UC_SETTINGS, "devices", _devices); 126 save_entries (key_file, _I4UC_SETTINGS, "fuses", _fuses); 127 128 size_t len; 129 var str = key_file.to_data (out len); 130 FileUtils.set_contents (_filename, str, (long)len); 131 } 132 133 private void load_entries (KeyFile key_file, string group, string key, Gee.Map<string, string> map) throws GLib.KeyFileError 134 { 135 foreach (var entry in key_file.get_string_list (group, key)) 136 { 137 var splitted_entry = entry.split ("|"); 138 map[splitted_entry[0]] = splitted_entry[1]; 139 } 140 } 141 142 private void save_entries (KeyFile key_file, string group, string key, Gee.Map<string, string> map) 143 { 144 var list = new string[map.size]; 145 var i = 0; 146 foreach (var entry in map) 147 list[i++] = entry.key + "|" + entry.value; 148 key_file.set_string_list (group, key, list); 89 return xml_str + "</settings>"; 149 90 } 150 91 }
Note: See TracChangeset
for help on using the changeset viewer.

