/* i4ucprogrammerssidepage.vala * * Copyright (C) 2010 Matias De la Puente * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Author: * Matias De la Puente */ using Gtk; public class I4uc.ProgrammersSidePage : SidePage, ProgrammersSidePageIface { private ItemsCombo _programmers_combo = new ItemsCombo (); private ItemsCombo _serial_ports_combo = new ItemsCombo (); private ItemsCombo _baud_rates_combo = new ItemsCombo (); private FileChooserButton _devices_file_chooser = new FileChooserButton (_("Select devices file"), FileChooserAction.OPEN); private FileChooserButton _devices_folder_chooser = new FileChooserButton (_("Select devices folder"), FileChooserAction.SELECT_FOLDER); private Entry _clock_entry = new Entry (); private ItemsCombo _devices_combo = new ItemsCombo (); private Entry _fuses_entry = new Entry (); private VBox _programmer_vbox = new VBox (false, 0); private VBox _serial_port_vbox = new VBox (false, 0); private VBox _baud_rate_vbox = new VBox (false, 0); private VBox _devices_file_vbox = new VBox (false, 0); private VBox _devices_folder_vbox = new VBox (false, 0); private VBox _clock_vbox = new VBox (false, 0); private VBox _device_vbox = new VBox (false, 0); private VBox _fuses_vbox = new VBox (false, 0); private Button _write_flash_button = new Button.with_label (_("Write flash")); private Button _read_flash_button = new Button.with_label (_("Read flash")); private Button _verify_flash_button = new Button.with_label (_("Verify flash")); private Button _erase_flash_button = new Button.with_label (_("Erase flash")); private Button _write_fuses_button = new Button.with_label (_("Write fuses")); private Button _read_fuses_button = new Button.with_label (_("Read fuses")); private Button _get_version_button = new Button.with_label (_("Get version")); private Button _stop_button = new Button.with_label (_("Stop")); public string current_programmer { set { _programmers_combo.current_item = value; } get { return _programmers_combo.current_item; } } public string current_serial_port { set { _serial_ports_combo.current_item = value; } get { return _serial_ports_combo.current_item; } } public string current_baud_rate { set { _baud_rates_combo.current_item = value; } get { return _baud_rates_combo.current_item; } } public string current_devices_file { set { _devices_file_chooser.set_uri (value); } owned get { return _devices_file_chooser.get_uri (); } } public string current_devices_folder { set { _devices_folder_chooser.set_current_folder_uri (value); } owned get { return _devices_folder_chooser.get_current_folder_uri (); } } public string current_clock { set { _clock_entry.text = value; } get { return _clock_entry.text; } } public string current_device { set { _devices_combo.current_item = value; } get { return _devices_combo.current_item; } } public string current_fuses { set { _fuses_entry.text = value; } get { return _fuses_entry.text; } } public bool serial_port_visible { set { _serial_port_vbox.visible = value; } get { return _serial_port_vbox.visible; } } public bool baud_rate_visible { set { _baud_rate_vbox.visible = value; } get { return _baud_rate_vbox.visible; } } public bool devices_file_visible { set { _devices_file_vbox.visible = value; } get { return _devices_file_vbox.visible; } } public bool devices_folder_visible { set { _devices_folder_vbox.visible = value; } get { return _devices_folder_vbox.visible; } } public bool clock_visible { set { _clock_vbox.visible = value; } get { return _clock_vbox.visible; } } public bool fuses_visible { set { _fuses_vbox.visible = value; } get { return _fuses_vbox.visible; } } public bool programmer_sensitive { set { _programmer_vbox.sensitive = value; } get { return _programmer_vbox.sensitive; } } public bool serial_port_sensitive { set { _serial_port_vbox.sensitive = value; } get { return _serial_port_vbox.sensitive; } } public bool baud_rate_sensitive { set { _baud_rate_vbox.sensitive = value; } get { return _baud_rate_vbox.sensitive; } } public bool devices_file_sensitive { set { _devices_file_vbox.sensitive = value; } get { return _devices_file_vbox.sensitive; } } public bool devices_folder_sensitive { set { _devices_folder_vbox.sensitive = value; } get { return _devices_folder_vbox.sensitive; } } public bool clock_sensitive { set { _clock_vbox.sensitive = value; } get { return _clock_vbox.sensitive; } } public bool device_sensitive { set { _device_vbox.sensitive = value; } get { return _device_vbox.sensitive; } } public bool fuses_sensitive { set { _fuses_vbox.sensitive = value; } get { return _fuses_vbox.sensitive; } } public bool write_flash_sensitive { set { _write_flash_button.sensitive = value; } get { return _write_flash_button.sensitive; } } public bool read_flash_sensitive { set { _read_flash_button.sensitive = value; } get { return _read_flash_button.sensitive; } } public bool verify_flash_sensitive { set { _verify_flash_button.sensitive = value; } get { return _verify_flash_button.sensitive; } } public bool erase_flash_sensitive { set { _erase_flash_button.sensitive = value; } get { return _erase_flash_button.sensitive; } } public bool write_fuses_sensitive { set { _write_fuses_button.sensitive = value; } get { return _write_fuses_button.sensitive; } } public bool read_fuses_sensitive { set { _read_fuses_button.sensitive = value; } get { return _read_fuses_button.sensitive; } } public bool get_version_sensitive { set { _get_version_button.sensitive = value; } get { return _get_version_button.sensitive; } } public bool stop_sensitive { set { _stop_button.sensitive = value; } get { return _stop_button.sensitive; } } public ProgrammersSidePage () { var update_serial_port_button = new Button (); update_serial_port_button.add (new Image.from_stock (Gtk.STOCK_REFRESH, IconSize.MENU)); var hbox = new HBox (false, 0); hbox.pack_start (_serial_ports_combo, true, true, 0); hbox.pack_start (update_serial_port_button, false, false, 0); add_vbox_label (_programmer_vbox, _("Programmer:"), _programmers_combo); add_vbox_label (_serial_port_vbox, _("Serial port:"), hbox); add_vbox_label (_baud_rate_vbox, _("Baud rate:"), _baud_rates_combo); add_vbox_label (_devices_file_vbox, _("Devices file:"), _devices_file_chooser); add_vbox_label (_devices_folder_vbox, _("Devices folder:"), _devices_folder_chooser); add_vbox_label (_clock_vbox, _("Clock:"), _clock_entry); add_vbox_label (_device_vbox, _("Device:"), _devices_combo); add_vbox_label (_fuses_vbox, _("Fuses:"), _fuses_entry); var vbox = new VBox (false, 0); vbox.pack_start (_programmer_vbox, false, false, 4); vbox.pack_start (_serial_port_vbox, false, false, 4); vbox.pack_start (_baud_rate_vbox, false, false, 4); vbox.pack_start (_devices_file_vbox, false, false, 4); vbox.pack_start (_devices_folder_vbox, false, false, 4); vbox.pack_start (_clock_vbox, false, false, 4); vbox.pack_start (_device_vbox, false, false, 4); vbox.pack_start (_fuses_vbox, false, false, 4); vbox.pack_start (new HSeparator (), false, false, 7); vbox.pack_start (_write_flash_button, false, false, 2); vbox.pack_start (_read_flash_button, false, false, 2); vbox.pack_start (_verify_flash_button, false, false, 2); vbox.pack_start (_erase_flash_button, false, false, 2); vbox.pack_start (_write_fuses_button, false, false, 2); vbox.pack_start (_read_fuses_button, false, false, 2); vbox.pack_start (_get_version_button, false, false, 2); vbox.pack_start (_stop_button, false, false, 2); var scrolled_window = new ScrolledWindow (null, null); scrolled_window.add_with_viewport (vbox); scrolled_window.set_policy (PolicyType.AUTOMATIC, PolicyType.AUTOMATIC); pack_start (scrolled_window, true, true, 2); show_all (); //Connect signals _programmers_combo.item_changed.connect (() => this.programmer_changed ()); _serial_ports_combo.item_changed.connect (() => this.serial_port_changed ()); update_serial_port_button.clicked.connect (() => this.update_serial_port_clicked ()); _baud_rates_combo.item_changed.connect (() => this.baud_rate_changed ()); _devices_file_chooser.selection_changed.connect (() => this.devices_file_changed ()); _devices_folder_chooser.selection_changed.connect (() => this.devices_folder_changed ()); _clock_entry.changed.connect (() => this.clock_changed ()); _devices_combo.item_changed.connect (() => this.device_changed ()); _fuses_entry.changed.connect (() => this.fuses_changed ()); _write_flash_button.clicked.connect (() => this.write_flash_clicked ()); _read_flash_button.clicked.connect (() => this.read_flash_clicked ()); _verify_flash_button.clicked.connect (() => this.verify_flash_clicked ()); _erase_flash_button.clicked.connect (() => this.erase_flash_clicked ()); _write_fuses_button.clicked.connect (() => this.write_fuses_clicked ()); _read_fuses_button.clicked.connect (() => this.read_fuses_clicked ()); _get_version_button.clicked.connect (() => this.get_version_clicked ()); _stop_button.clicked.connect (() => this.stop_clicked ()); } public void add_programmer (string programmer) { _programmers_combo.add_item (programmer); } public void add_serial_port (string serial_port) { _serial_ports_combo.add_item (serial_port); } public void add_baud_rate (string baud_rate) { _baud_rates_combo.add_item (baud_rate); } public void add_device (string device) { _devices_combo.add_item (device); } public void clear_serial_ports_list () { _serial_ports_combo.clear_list (); } public void clear_devices_list () { _devices_combo.clear_list (); } private void add_vbox_label (VBox vbox, string label_text, Widget widget) { var label = new Label (label_text); label.xalign = 0; vbox.pack_start (label, false, false, 0); vbox.pack_start (widget, false, false, 0); } }