Changeset 628f3dc614aeb64636b8b50cb2c7413053d2e490


Ignore:
Timestamp:
26/10/10 14:00:09 (3 years ago)
Author:
Matias De la Puente <mfpuente.ar@…>
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)
Message:

Add 'program profile' option

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • gtkfrontend/main.vala

    rdfe49c7 r628f3dc  
    168168        _main_window_logic = new MainWindowLogic (_main_window_view); 
    169169        _documents_logic = new DocumentsLogic (_documents_view); 
    170         _projects_logic = new ProjectsLogic (_projects_view, _documents_logic); 
    171170        _programmers_logic = new ProgrammersLogic (_programmers_view, _documents_logic); 
     171        _projects_logic = new ProjectsLogic (_projects_view, _documents_logic, _programmers_logic); 
    172172         
    173173        _main_window_view.exit_clicked.connect (() => { 
  • gtkfrontend/projectsview.vala

    rdfe49c7 r628f3dc  
    8181                set { _action_group.get_action ("BuildProfileProjectAction").sensitive = value; } 
    8282                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; } 
    8389        } 
    8490         
     
    230236        } 
    231237         
     238        private void on_program_profile () 
     239        { 
     240                this.program_profile_clicked (); 
     241        } 
     242         
    232243        private void on_stop () 
    233244        { 
     
    257268                { "RemoveProfileFromProjectProjectAction", STOCK_REMOVE, N_("Remove profile from project"), null, N_("Remove a profile from current project"), on_remove_profile }, 
    258269                { "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 }, 
    259271                { "StopProjectAction", STOCK_STOP, N_("Stop"), "", N_("Stop building current profile"), on_stop }, 
    260272                { "CleanProfileProjectAction", STOCK_CLEAR, N_("Clean profile"), null, N_("Clean current profile"), on_clean_profile }, 
     
    281293                                <menuitem action="StopProjectAction"/> 
    282294                                <menuitem action="CleanProfileProjectAction"/> 
     295                                <menuitem action="ProgramProfileProjectAction"/> 
    283296                                <separator/> 
    284297                                <menuitem action="CloseProjectAction"/> 
     
    291304                                <toolitem action="BuildProfileProjectAction"/> 
    292305                                <toolitem action="StopProjectAction"/> 
     306                                <toolitem action="ProgramProfileProjectAction"/> 
    293307                        <separator/> 
    294308                </placeholder> 
  • libi4uccore/programmerslogic.vala

    rdfe49c7 r628f3dc  
    2929        private string _read_hexfile; 
    3030         
     31        public bool can_write_flash { private set; get; } 
     32         
    3133        public ProgrammersLogic (ProgrammersView view, DocumentsLogic documents_logic) 
    3234        { 
     
    7981        } 
    8082         
     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         
    81103        private void on_page_changed (Page? page) 
    82104        { 
     
    304326        private void run_command (string command) 
    305327        { 
    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); 
    329329                 
    330330                if (_read_hexfile == null) 
     
    394394                    return; 
    395395                 
     396                this.can_write_flash = _current_programmer.can_write_flash; 
    396397                _view.write_flash_sensitive = valid_page && _current_programmer.can_write_flash; 
    397398                _view.read_flash_sensitive = _current_programmer.can_read_flash; 
     
    406407        private void disable_actions () 
    407408        { 
     409                this.can_write_flash = false; 
    408410                _view.write_flash_sensitive = false; 
    409411                _view.read_flash_sensitive = false; 
     
    415417                _view.stop_sensitive = false; 
    416418        } 
     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        } 
    417448} 
  • libi4uccore/projectslogic.vala

    rdfe49c7 r628f3dc  
    2525        private ProjectsView _view; 
    2626        private DocumentsLogic _documents_logic; 
     27        private ProgrammersLogic _programmers_logic; 
    2728        private ProjectsPageLogic _page_logic; 
    2829        private ProfileBuilder _profile_builder = new ProfileBuilder (); 
    2930 
    30         public ProjectsLogic (ProjectsView view, DocumentsLogic documents_logic) 
     31        public ProjectsLogic (ProjectsView view, DocumentsLogic documents_logic, ProgrammersLogic programmers_logic) 
    3132        { 
    3233                _view = view; 
    3334                _documents_logic = documents_logic; 
     35                _programmers_logic = programmers_logic; 
    3436                 
    3537                _documents_logic.add_document_opener (".i4uc", this); 
     
    4749                _view.remove_profile_sensitive = false; 
    4850                _view.build_profile_sensitive = false; 
     51                _view.program_profile_sensitive = false; 
    4952                _view.stop_sensitive = false; 
    5053                _view.clean_profile_sensitive = false; 
     
    6568                _view.remove_profile_clicked.connect (on_remove_profile_clicked); 
    6669                _view.build_profile_clicked.connect (on_build_profile_clicked); 
     70                _view.program_profile_clicked.connect (on_program_profile_clicked); 
    6771                _view.stop_clicked.connect (on_stop_clicked); 
    6872                _view.clean_profile_clicked.connect (on_clean_profile_clicked); 
     
    7579                _profile_builder.new_message.connect (on_profile_builder_new_message); 
    7680                _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); 
    7782        } 
    7883 
     
    232237                        _view.show_error_message (_("Error trying to build profile %s: %s").printf (current_profile.name, e.message)); 
    233238                } 
     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); 
    234255        } 
    235256         
     
    285306                _view.build_profile_sensitive = profile_selected && !_profile_builder.is_building; 
    286307                _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; 
    287309        } 
    288310 
     
    324346                _view.build_profile_sensitive = !is_building; 
    325347                _view.stop_sensitive = is_building; 
     348                _view.program_profile_sensitive = !is_building; 
    326349        } 
    327350         
     
    335358                _view.build_log_page.add_command (command_context); 
    336359        } 
     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        } 
    337367} 
  • libi4uccore/projectsview.vala

    rdfe49c7 r628f3dc  
    3232        public abstract bool remove_profile_sensitive { set; get; } 
    3333        public abstract bool build_profile_sensitive { set; get; } 
     34        public abstract bool program_profile_sensitive { set; get; } 
    3435        public abstract bool stop_sensitive { set; get; } 
    3536        public abstract bool clean_profile_sensitive { set; get; } 
     
    4546        public signal void remove_profile_clicked (); 
    4647        public signal void build_profile_clicked (); 
     48        public signal void program_profile_clicked (); 
    4749        public signal void stop_clicked (); 
    4850        public signal void clean_profile_clicked (); 
Note: See TracChangeset for help on using the changeset viewer.