Changeset 628f3dc614aeb64636b8b50cb2c7413053d2e490
- Timestamp:
- 26/10/10 14:00:09 (3 years ago)
- Children:
- 33592374e666da943a2de0a6e84fab987585392b
- Parents:
- a70bdd96cc9cb661637388cca3306aa4e2305e3c
- git-author:
- Matias De la Puente <mfpuente.ar@…> (25/10/10 12:51:10)
- git-committer:
- Matias De la Puente <mfpuente.ar@…> (26/10/10 14:00:09)
- Files:
-
- 5 edited
-
gtkfrontend/main.vala (modified) (1 diff)
-
gtkfrontend/projectsview.vala (modified) (5 diffs)
-
libi4uccore/programmerslogic.vala (modified) (6 diffs)
-
libi4uccore/projectslogic.vala (modified) (8 diffs)
-
libi4uccore/projectsview.vala (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gtkfrontend/main.vala
rdfe49c7 r628f3dc 168 168 _main_window_logic = new MainWindowLogic (_main_window_view); 169 169 _documents_logic = new DocumentsLogic (_documents_view); 170 _projects_logic = new ProjectsLogic (_projects_view, _documents_logic);171 170 _programmers_logic = new ProgrammersLogic (_programmers_view, _documents_logic); 171 _projects_logic = new ProjectsLogic (_projects_view, _documents_logic, _programmers_logic); 172 172 173 173 _main_window_view.exit_clicked.connect (() => { -
gtkfrontend/projectsview.vala
rdfe49c7 r628f3dc 81 81 set { _action_group.get_action ("BuildProfileProjectAction").sensitive = value; } 82 82 get { return _action_group.get_action ("BuildProfileProjectAction").sensitive; } 83 } 84 85 public bool program_profile_sensitive 86 { 87 set { _action_group.get_action ("ProgramProfileProjectAction").sensitive = value; } 88 get { return _action_group.get_action ("ProgramProfileProjectAction").sensitive; } 83 89 } 84 90 … … 230 236 } 231 237 238 private void on_program_profile () 239 { 240 this.program_profile_clicked (); 241 } 242 232 243 private void on_stop () 233 244 { … … 257 268 { "RemoveProfileFromProjectProjectAction", STOCK_REMOVE, N_("Remove profile from project"), null, N_("Remove a profile from current project"), on_remove_profile }, 258 269 { "BuildProfileProjectAction", STOCK_EXECUTE, N_("Build profile"), "<Control><Shift>b", N_("Build current profile"), on_build_profile }, 270 { "ProgramProfileProjectAction", STOCK_MEDIA_RECORD, N_("Program profile"), "<Control><Shift>p", N_("Program current profile"), on_program_profile }, 259 271 { "StopProjectAction", STOCK_STOP, N_("Stop"), "", N_("Stop building current profile"), on_stop }, 260 272 { "CleanProfileProjectAction", STOCK_CLEAR, N_("Clean profile"), null, N_("Clean current profile"), on_clean_profile }, … … 281 293 <menuitem action="StopProjectAction"/> 282 294 <menuitem action="CleanProfileProjectAction"/> 295 <menuitem action="ProgramProfileProjectAction"/> 283 296 <separator/> 284 297 <menuitem action="CloseProjectAction"/> … … 291 304 <toolitem action="BuildProfileProjectAction"/> 292 305 <toolitem action="StopProjectAction"/> 306 <toolitem action="ProgramProfileProjectAction"/> 293 307 <separator/> 294 308 </placeholder> -
libi4uccore/programmerslogic.vala
rdfe49c7 r628f3dc 29 29 private string _read_hexfile; 30 30 31 public bool can_write_flash { private set; get; } 32 31 33 public ProgrammersLogic (ProgrammersView view, DocumentsLogic documents_logic) 32 34 { … … 79 81 } 80 82 83 public void write_flash (string uri) 84 { 85 if (_view.show_yes_no_message (_("Are you sure you want to write the flash memory?")) == Gtk.ResponseType.NO) 86 return; 87 88 var filtered_command = filter_command (_current_programmer.write_flash_command); 89 90 var hexfile = File.new_for_uri (uri).get_path (); 91 filtered_command = filtered_command.replace ("%hexfile", "\"" + hexfile + "\""); 92 93 if (_command.run (filtered_command)) 94 { 95 set_parameters_sensitive (false); 96 disable_actions (); 97 _view.stop_sensitive = true; 98 } 99 100 _view.show_log_page (); 101 } 102 81 103 private void on_page_changed (Page? page) 82 104 { … … 304 326 private void run_command (string command) 305 327 { 306 var filtered_command = command; 307 308 if (_current_programmer.has_serial_port) 309 filtered_command = filtered_command.replace ("%serial_port", _view.page.current_serial_port); 310 if (_current_programmer.has_baud_rate) 311 filtered_command = filtered_command.replace ("%baud_rate", _view.page.current_baud_rate); 312 if (_current_programmer.has_devices_file) 313 { 314 var devices_file = File.new_for_uri (_view.page.current_devices_file).get_path (); 315 filtered_command = filtered_command.replace ("%devices_file", "\"" + devices_file + "\""); 316 } 317 if (_current_programmer.has_devices_folder) 318 { 319 var devices_folder = File.new_for_uri (_view.page.current_devices_folder).get_path (); 320 filtered_command = filtered_command.replace ("%devices_folder", "\"" + devices_folder + "\""); 321 } 322 if (_current_programmer.has_clock) 323 filtered_command = filtered_command.replace ("%clock", _view.page.current_clock); 324 325 filtered_command = filtered_command.replace ("%device", _view.page.current_device); 326 327 if (_current_programmer.can_write_fuses) 328 filtered_command = filtered_command.replace ("%fuses", _view.page.current_fuses); 328 var filtered_command = filter_command (command); 329 329 330 330 if (_read_hexfile == null) … … 394 394 return; 395 395 396 this.can_write_flash = _current_programmer.can_write_flash; 396 397 _view.write_flash_sensitive = valid_page && _current_programmer.can_write_flash; 397 398 _view.read_flash_sensitive = _current_programmer.can_read_flash; … … 406 407 private void disable_actions () 407 408 { 409 this.can_write_flash = false; 408 410 _view.write_flash_sensitive = false; 409 411 _view.read_flash_sensitive = false; … … 415 417 _view.stop_sensitive = false; 416 418 } 419 420 private string filter_command (string command) 421 { 422 var filtered_command = command; 423 424 if (_current_programmer.has_serial_port) 425 filtered_command = filtered_command.replace ("%serial_port", _view.page.current_serial_port); 426 if (_current_programmer.has_baud_rate) 427 filtered_command = filtered_command.replace ("%baud_rate", _view.page.current_baud_rate); 428 if (_current_programmer.has_devices_file) 429 { 430 var devices_file = File.new_for_uri (_view.page.current_devices_file).get_path (); 431 filtered_command = filtered_command.replace ("%devices_file", "\"" + devices_file + "\""); 432 } 433 if (_current_programmer.has_devices_folder) 434 { 435 var devices_folder = File.new_for_uri (_view.page.current_devices_folder).get_path (); 436 filtered_command = filtered_command.replace ("%devices_folder", "\"" + devices_folder + "\""); 437 } 438 if (_current_programmer.has_clock) 439 filtered_command = filtered_command.replace ("%clock", _view.page.current_clock); 440 441 filtered_command = filtered_command.replace ("%device", _view.page.current_device); 442 443 if (_current_programmer.can_write_fuses) 444 filtered_command = filtered_command.replace ("%fuses", _view.page.current_fuses); 445 446 return filtered_command; 447 } 417 448 } -
libi4uccore/projectslogic.vala
rdfe49c7 r628f3dc 25 25 private ProjectsView _view; 26 26 private DocumentsLogic _documents_logic; 27 private ProgrammersLogic _programmers_logic; 27 28 private ProjectsPageLogic _page_logic; 28 29 private ProfileBuilder _profile_builder = new ProfileBuilder (); 29 30 30 public ProjectsLogic (ProjectsView view, DocumentsLogic documents_logic )31 public ProjectsLogic (ProjectsView view, DocumentsLogic documents_logic, ProgrammersLogic programmers_logic) 31 32 { 32 33 _view = view; 33 34 _documents_logic = documents_logic; 35 _programmers_logic = programmers_logic; 34 36 35 37 _documents_logic.add_document_opener (".i4uc", this); … … 47 49 _view.remove_profile_sensitive = false; 48 50 _view.build_profile_sensitive = false; 51 _view.program_profile_sensitive = false; 49 52 _view.stop_sensitive = false; 50 53 _view.clean_profile_sensitive = false; … … 65 68 _view.remove_profile_clicked.connect (on_remove_profile_clicked); 66 69 _view.build_profile_clicked.connect (on_build_profile_clicked); 70 _view.program_profile_clicked.connect (on_program_profile_clicked); 67 71 _view.stop_clicked.connect (on_stop_clicked); 68 72 _view.clean_profile_clicked.connect (on_clean_profile_clicked); … … 75 79 _profile_builder.new_message.connect (on_profile_builder_new_message); 76 80 _profile_builder.command_finished.connect (on_profile_builder_command_finished); 81 _programmers_logic.notify["can-write-flash"].connect (on_programmers_logic_can_write_flash_changed); 77 82 } 78 83 … … 232 237 _view.show_error_message (_("Error trying to build profile %s: %s").printf (current_profile.name, e.message)); 233 238 } 239 } 240 241 private void on_program_profile_clicked () 242 { 243 var current_project = _page_logic.current_project; 244 var current_profile = current_project.profiles[_view.page_view.current_profile]; 245 var hexfile = current_project.name + "-" + current_profile.name + ".hex"; 246 var hexfile_uri = current_project.get_file_uri (hexfile.replace (" ", "_")); 247 var hexfile_file = File.new_for_uri (hexfile_uri); 248 249 if (!hexfile_file.query_exists (null)) 250 { 251 _view.show_error_message (_("The file %s doesn't exists").printf (hexfile_file.get_path ())); 252 return; 253 } 254 _programmers_logic.write_flash (hexfile_uri); 234 255 } 235 256 … … 285 306 _view.build_profile_sensitive = profile_selected && !_profile_builder.is_building; 286 307 _view.clean_profile_sensitive = profile_selected && !_profile_builder.is_building; 308 _view.program_profile_sensitive = profile_selected && !_profile_builder.is_building && _programmers_logic.can_write_flash; 287 309 } 288 310 … … 324 346 _view.build_profile_sensitive = !is_building; 325 347 _view.stop_sensitive = is_building; 348 _view.program_profile_sensitive = !is_building; 326 349 } 327 350 … … 335 358 _view.build_log_page.add_command (command_context); 336 359 } 360 361 private void on_programmers_logic_can_write_flash_changed () 362 { 363 var profile_selected = _view.page_view.current_profile != null && 364 _view.page_view.current_profile != "__NONE__"; 365 _view.program_profile_sensitive = profile_selected && !_profile_builder.is_building && _programmers_logic.can_write_flash; 366 } 337 367 } -
libi4uccore/projectsview.vala
rdfe49c7 r628f3dc 32 32 public abstract bool remove_profile_sensitive { set; get; } 33 33 public abstract bool build_profile_sensitive { set; get; } 34 public abstract bool program_profile_sensitive { set; get; } 34 35 public abstract bool stop_sensitive { set; get; } 35 36 public abstract bool clean_profile_sensitive { set; get; } … … 45 46 public signal void remove_profile_clicked (); 46 47 public signal void build_profile_clicked (); 48 public signal void program_profile_clicked (); 47 49 public signal void stop_clicked (); 48 50 public signal void clean_profile_clicked ();
Note: See TracChangeset
for help on using the changeset viewer.

