| 1 | /* i4ucprogrammerssidepage.vala |
|---|
| 2 | * |
|---|
| 3 | * Copyright (C) 2010 Matias De la Puente |
|---|
| 4 | * |
|---|
| 5 | * This program is free software: you can redistribute it and/or modify |
|---|
| 6 | * it under the terms of the GNU General Public License as published by |
|---|
| 7 | * the Free Software Foundation, either version 3 of the License, or |
|---|
| 8 | * (at your option) any later version. |
|---|
| 9 | * |
|---|
| 10 | * This program is distributed in the hope that it will be useful, |
|---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | * GNU General Public License for more details. |
|---|
| 14 | * |
|---|
| 15 | * You should have received a copy of the GNU General Public License |
|---|
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 17 | * |
|---|
| 18 | * Author: |
|---|
| 19 | * Matias De la Puente <mfpuente.ar@gmail.com> |
|---|
| 20 | */ |
|---|
| 21 | using Gtk; |
|---|
| 22 | |
|---|
| 23 | public class I4uc.ProgrammersSidePage : SidePage, ProgrammersSidePageIface |
|---|
| 24 | { |
|---|
| 25 | private ItemsCombo _programmers_combo = new ItemsCombo (); |
|---|
| 26 | private ItemsCombo _serial_ports_combo = new ItemsCombo (); |
|---|
| 27 | private ItemsCombo _baud_rates_combo = new ItemsCombo (); |
|---|
| 28 | private FileChooserButton _devices_file_chooser = new FileChooserButton (_("Select devices file"), FileChooserAction.OPEN); |
|---|
| 29 | private FileChooserButton _devices_folder_chooser = new FileChooserButton (_("Select devices folder"), FileChooserAction.SELECT_FOLDER); |
|---|
| 30 | private Entry _clock_entry = new Entry (); |
|---|
| 31 | private ItemsCombo _devices_combo = new ItemsCombo (); |
|---|
| 32 | private Entry _fuses_entry = new Entry (); |
|---|
| 33 | |
|---|
| 34 | private VBox _programmer_vbox = new VBox (false, 0); |
|---|
| 35 | private VBox _serial_port_vbox = new VBox (false, 0); |
|---|
| 36 | private VBox _baud_rate_vbox = new VBox (false, 0); |
|---|
| 37 | private VBox _devices_file_vbox = new VBox (false, 0); |
|---|
| 38 | private VBox _devices_folder_vbox = new VBox (false, 0); |
|---|
| 39 | private VBox _clock_vbox = new VBox (false, 0); |
|---|
| 40 | private VBox _device_vbox = new VBox (false, 0); |
|---|
| 41 | private VBox _fuses_vbox = new VBox (false, 0); |
|---|
| 42 | |
|---|
| 43 | public string current_programmer |
|---|
| 44 | { |
|---|
| 45 | set { _programmers_combo.current_item = value; } |
|---|
| 46 | get { return _programmers_combo.current_item; } |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | public string current_serial_port |
|---|
| 50 | { |
|---|
| 51 | set { _serial_ports_combo.current_item = value; } |
|---|
| 52 | get { return _serial_ports_combo.current_item; } |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | public string current_baud_rate |
|---|
| 56 | { |
|---|
| 57 | set { _baud_rates_combo.current_item = value; } |
|---|
| 58 | get { return _baud_rates_combo.current_item; } |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | public string current_devices_file |
|---|
| 62 | { |
|---|
| 63 | set { _devices_file_chooser.set_uri (value); } |
|---|
| 64 | owned get { return _devices_file_chooser.get_uri (); } |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | public string current_devices_folder |
|---|
| 68 | { |
|---|
| 69 | set { _devices_folder_chooser.set_current_folder_uri (value); } |
|---|
| 70 | owned get { return _devices_folder_chooser.get_current_folder_uri (); } |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | public string current_clock |
|---|
| 74 | { |
|---|
| 75 | set { _clock_entry.text = value; } |
|---|
| 76 | get { return _clock_entry.text; } |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | public string current_device |
|---|
| 80 | { |
|---|
| 81 | set { _devices_combo.current_item = value; } |
|---|
| 82 | get { return _devices_combo.current_item; } |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | public string current_fuses |
|---|
| 86 | { |
|---|
| 87 | set { _fuses_entry.text = value; } |
|---|
| 88 | get { return _fuses_entry.text; } |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | public bool serial_port_visible |
|---|
| 92 | { |
|---|
| 93 | set { _serial_port_vbox.visible = value; } |
|---|
| 94 | get { return _serial_port_vbox.visible; } |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | public bool baud_rate_visible |
|---|
| 98 | { |
|---|
| 99 | set { _baud_rate_vbox.visible = value; } |
|---|
| 100 | get { return _baud_rate_vbox.visible; } |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | public bool devices_file_visible |
|---|
| 104 | { |
|---|
| 105 | set { _devices_file_vbox.visible = value; } |
|---|
| 106 | get { return _devices_file_vbox.visible; } |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | public bool devices_folder_visible |
|---|
| 110 | { |
|---|
| 111 | set { _devices_folder_vbox.visible = value; } |
|---|
| 112 | get { return _devices_folder_vbox.visible; } |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | public bool clock_visible |
|---|
| 116 | { |
|---|
| 117 | set { _clock_vbox.visible = value; } |
|---|
| 118 | get { return _clock_vbox.visible; } |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | public bool fuses_visible |
|---|
| 122 | { |
|---|
| 123 | set { _fuses_vbox.visible = value; } |
|---|
| 124 | get { return _fuses_vbox.visible; } |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | public bool programmer_sensitive |
|---|
| 128 | { |
|---|
| 129 | set { _programmer_vbox.sensitive = value; } |
|---|
| 130 | get { return _programmer_vbox.sensitive; } |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | public bool serial_port_sensitive |
|---|
| 134 | { |
|---|
| 135 | set { _serial_port_vbox.sensitive = value; } |
|---|
| 136 | get { return _serial_port_vbox.sensitive; } |
|---|
| 137 | } |
|---|
| 138 | |
|---|
| 139 | public bool baud_rate_sensitive |
|---|
| 140 | { |
|---|
| 141 | set { _baud_rate_vbox.sensitive = value; } |
|---|
| 142 | get { return _baud_rate_vbox.sensitive; } |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | public bool devices_file_sensitive |
|---|
| 146 | { |
|---|
| 147 | set { _devices_file_vbox.sensitive = value; } |
|---|
| 148 | get { return _devices_file_vbox.sensitive; } |
|---|
| 149 | } |
|---|
| 150 | |
|---|
| 151 | public bool devices_folder_sensitive |
|---|
| 152 | { |
|---|
| 153 | set { _devices_folder_vbox.sensitive = value; } |
|---|
| 154 | get { return _devices_folder_vbox.sensitive; } |
|---|
| 155 | } |
|---|
| 156 | |
|---|
| 157 | public bool clock_sensitive |
|---|
| 158 | { |
|---|
| 159 | set { _clock_vbox.sensitive = value; } |
|---|
| 160 | get { return _clock_vbox.sensitive; } |
|---|
| 161 | } |
|---|
| 162 | |
|---|
| 163 | public bool device_sensitive |
|---|
| 164 | { |
|---|
| 165 | set { _device_vbox.sensitive = value; } |
|---|
| 166 | get { return _device_vbox.sensitive; } |
|---|
| 167 | } |
|---|
| 168 | |
|---|
| 169 | public bool fuses_sensitive |
|---|
| 170 | { |
|---|
| 171 | set { _fuses_vbox.sensitive = value; } |
|---|
| 172 | get { return _fuses_vbox.sensitive; } |
|---|
| 173 | } |
|---|
| 174 | |
|---|
| 175 | public ProgrammersSidePage () |
|---|
| 176 | { |
|---|
| 177 | var update_serial_port_button = new Button (); |
|---|
| 178 | update_serial_port_button.add (new Image.from_stock (Gtk.STOCK_REFRESH, IconSize.MENU)); |
|---|
| 179 | |
|---|
| 180 | var hbox = new HBox (false, 0); |
|---|
| 181 | hbox.pack_start (_serial_ports_combo, true, true, 0); |
|---|
| 182 | hbox.pack_start (update_serial_port_button, false, false, 0); |
|---|
| 183 | |
|---|
| 184 | ViewUtils.add_vbox_label (_programmer_vbox, _("Programmer:"), _programmers_combo); |
|---|
| 185 | ViewUtils.add_vbox_label (_serial_port_vbox, _("Serial port:"), hbox); |
|---|
| 186 | ViewUtils.add_vbox_label (_baud_rate_vbox, _("Baud rate:"), _baud_rates_combo); |
|---|
| 187 | ViewUtils.add_vbox_label (_devices_file_vbox, _("Devices file:"), _devices_file_chooser); |
|---|
| 188 | ViewUtils.add_vbox_label (_devices_folder_vbox, _("Devices folder:"), _devices_folder_chooser); |
|---|
| 189 | ViewUtils.add_vbox_label (_clock_vbox, _("Clock:"), _clock_entry); |
|---|
| 190 | ViewUtils.add_vbox_label (_device_vbox, _("Device:"), _devices_combo); |
|---|
| 191 | ViewUtils.add_vbox_label (_fuses_vbox, _("Fuses:"), _fuses_entry); |
|---|
| 192 | |
|---|
| 193 | var vbox = new VBox (false, 0); |
|---|
| 194 | |
|---|
| 195 | vbox.pack_start (_programmer_vbox, false, false, 4); |
|---|
| 196 | vbox.pack_start (_serial_port_vbox, false, false, 4); |
|---|
| 197 | vbox.pack_start (_baud_rate_vbox, false, false, 4); |
|---|
| 198 | vbox.pack_start (_devices_file_vbox, false, false, 4); |
|---|
| 199 | vbox.pack_start (_devices_folder_vbox, false, false, 4); |
|---|
| 200 | vbox.pack_start (_clock_vbox, false, false, 4); |
|---|
| 201 | vbox.pack_start (_device_vbox, false, false, 4); |
|---|
| 202 | vbox.pack_start (_fuses_vbox, false, false, 4); |
|---|
| 203 | |
|---|
| 204 | var scrolled_window = new ScrolledWindow (null, null); |
|---|
| 205 | scrolled_window.add_with_viewport (vbox); |
|---|
| 206 | scrolled_window.set_policy (PolicyType.AUTOMATIC, PolicyType.AUTOMATIC); |
|---|
| 207 | |
|---|
| 208 | pack_start (scrolled_window, true, true, 2); |
|---|
| 209 | show_all (); |
|---|
| 210 | |
|---|
| 211 | //Connect signals |
|---|
| 212 | _programmers_combo.item_changed.connect (() => this.programmer_changed ()); |
|---|
| 213 | _serial_ports_combo.item_changed.connect (() => this.serial_port_changed ()); |
|---|
| 214 | update_serial_port_button.clicked.connect (() => this.update_serial_port_clicked ()); |
|---|
| 215 | _baud_rates_combo.item_changed.connect (() => this.baud_rate_changed ()); |
|---|
| 216 | _devices_file_chooser.selection_changed.connect (() => this.devices_file_changed ()); |
|---|
| 217 | _devices_folder_chooser.selection_changed.connect (() => this.devices_folder_changed ()); |
|---|
| 218 | _clock_entry.changed.connect (() => this.clock_changed ()); |
|---|
| 219 | _devices_combo.item_changed.connect (() => this.device_changed ()); |
|---|
| 220 | _fuses_entry.changed.connect (() => this.fuses_changed ()); |
|---|
| 221 | } |
|---|
| 222 | |
|---|
| 223 | public void add_programmer (string programmer) |
|---|
| 224 | { |
|---|
| 225 | _programmers_combo.add_item (programmer); |
|---|
| 226 | } |
|---|
| 227 | |
|---|
| 228 | public void add_serial_port (string serial_port) |
|---|
| 229 | { |
|---|
| 230 | _serial_ports_combo.add_item (serial_port); |
|---|
| 231 | } |
|---|
| 232 | |
|---|
| 233 | public void add_baud_rate (string baud_rate) |
|---|
| 234 | { |
|---|
| 235 | _baud_rates_combo.add_item (baud_rate); |
|---|
| 236 | } |
|---|
| 237 | |
|---|
| 238 | public void add_device (string device) |
|---|
| 239 | { |
|---|
| 240 | _devices_combo.add_item (device); |
|---|
| 241 | } |
|---|
| 242 | |
|---|
| 243 | public void clear_serial_ports_list () |
|---|
| 244 | { |
|---|
| 245 | _serial_ports_combo.clear_list (); |
|---|
| 246 | } |
|---|
| 247 | |
|---|
| 248 | public void clear_devices_list () |
|---|
| 249 | { |
|---|
| 250 | _devices_combo.clear_list (); |
|---|
| 251 | } |
|---|
| 252 | } |
|---|