source: libi4uc/i4ucprogrammerssidepage.vala @ fed76872db57be25180c04c6856972ef1e8ef8ff

Revision fed76872db57be25180c04c6856972ef1e8ef8ff, 10.5 KB checked in by Matias De la Puente <mfpuente.ar@…>, 3 years ago (diff)

Programmers: Add update serial ports button

  • Property mode set to 100644
Line 
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 */
21using Gtk;
22
23public 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        private Button _write_flash_button = new Button.with_label (_("Write flash"));
44        private Button _read_flash_button = new Button.with_label (_("Read flash"));
45        private Button _verify_flash_button = new Button.with_label (_("Verify flash"));
46        private Button _erase_flash_button = new Button.with_label (_("Erase flash"));
47        private Button _write_fuses_button = new Button.with_label (_("Write fuses"));
48        private Button _read_fuses_button = new Button.with_label (_("Read fuses"));
49        private Button _get_version_button = new Button.with_label (_("Get version"));
50        private Button _stop_button = new Button.with_label (_("Stop"));
51       
52        public string current_programmer
53        {
54                set { _programmers_combo.current_item = value; }
55                get { return _programmers_combo.current_item; }
56        }
57       
58        public string current_serial_port
59        {
60                set { _serial_ports_combo.current_item = value; }
61                get { return _serial_ports_combo.current_item; }
62        }
63       
64        public string current_baud_rate
65        {
66                set { _baud_rates_combo.current_item = value; }
67                get { return _baud_rates_combo.current_item; }
68        }
69       
70        public string current_devices_file
71        {
72                set { _devices_file_chooser.set_uri (value); }
73                owned get { return _devices_file_chooser.get_uri (); }
74        }
75       
76        public string current_devices_folder
77        {
78                set { _devices_folder_chooser.set_current_folder_uri (value); }
79                owned get { return _devices_folder_chooser.get_current_folder_uri (); }
80        }
81       
82        public string current_clock
83        {
84                set { _clock_entry.text = value; }
85                get { return _clock_entry.text; }
86        }
87       
88        public string current_device
89        {
90                set { _devices_combo.current_item = value; }
91                get { return _devices_combo.current_item; }
92        }
93       
94        public string current_fuses
95        {
96                set { _fuses_entry.text = value; }
97                get { return _fuses_entry.text; }
98        }
99       
100        public bool serial_port_visible
101        {
102                set { _serial_port_vbox.visible = value; }
103                get { return _serial_port_vbox.visible; }
104        }
105       
106        public bool baud_rate_visible
107        {
108                set { _baud_rate_vbox.visible = value; }
109                get { return _baud_rate_vbox.visible; }
110        }
111       
112        public bool devices_file_visible
113        {
114                set { _devices_file_vbox.visible = value; }
115                get { return _devices_file_vbox.visible; }
116        }
117       
118        public bool devices_folder_visible
119        {
120                set { _devices_folder_vbox.visible = value; }
121                get { return _devices_folder_vbox.visible; }
122        }
123       
124        public bool clock_visible
125        {
126                set { _clock_vbox.visible = value; }
127                get { return _clock_vbox.visible; }
128        }
129       
130        public bool fuses_visible
131        {
132                set { _fuses_vbox.visible = value; }
133                get { return _fuses_vbox.visible; }
134        }
135       
136        public bool programmer_sensitive
137        {
138                set { _programmer_vbox.sensitive = value; }
139                get { return _programmer_vbox.sensitive; }
140        }
141       
142        public bool serial_port_sensitive
143        {
144                set { _serial_port_vbox.sensitive = value; }
145                get { return _serial_port_vbox.sensitive; }
146        }
147       
148        public bool baud_rate_sensitive
149        {
150                set { _baud_rate_vbox.sensitive = value; }
151                get { return _baud_rate_vbox.sensitive; }
152        }
153       
154        public bool devices_file_sensitive
155        {
156                set { _devices_file_vbox.sensitive = value; }
157                get { return _devices_file_vbox.sensitive; }
158        }
159       
160        public bool devices_folder_sensitive
161        {
162                set { _devices_folder_vbox.sensitive = value; }
163                get { return _devices_folder_vbox.sensitive; }
164        }
165       
166        public bool clock_sensitive
167        {
168                set { _clock_vbox.sensitive = value; }
169                get { return _clock_vbox.sensitive; }
170        }
171       
172        public bool device_sensitive
173        {
174                set { _device_vbox.sensitive = value; }
175                get { return _device_vbox.sensitive; }
176        }
177       
178        public bool fuses_sensitive
179        {
180                set { _fuses_vbox.sensitive = value; }
181                get { return _fuses_vbox.sensitive; }
182        }
183       
184        public bool write_flash_sensitive
185        {
186                set { _write_flash_button.sensitive = value; }
187                get { return _write_flash_button.sensitive; }
188        }
189       
190        public bool read_flash_sensitive
191        {
192                set { _read_flash_button.sensitive = value; }
193                get { return _read_flash_button.sensitive; }
194        }
195       
196        public bool verify_flash_sensitive
197        {
198                set { _verify_flash_button.sensitive = value; }
199                get { return _verify_flash_button.sensitive; }
200        }
201       
202        public bool erase_flash_sensitive
203        {
204                set { _erase_flash_button.sensitive = value; }
205                get { return _erase_flash_button.sensitive; }
206        }
207       
208        public bool write_fuses_sensitive
209        {
210                set { _write_fuses_button.sensitive = value; }
211                get { return _write_fuses_button.sensitive; }
212        }
213       
214        public bool read_fuses_sensitive
215        {
216                set { _read_fuses_button.sensitive = value; }
217                get { return _read_fuses_button.sensitive; }
218        }
219       
220        public bool get_version_sensitive
221        {
222                set { _get_version_button.sensitive = value; }
223                get { return _get_version_button.sensitive; }
224        }
225       
226        public bool stop_sensitive
227        {
228                set { _stop_button.sensitive = value; }
229                get { return _stop_button.sensitive; }
230        }
231       
232        public ProgrammersSidePage ()
233        {
234                var update_serial_port_button = new Button ();
235                update_serial_port_button.add (new Image.from_stock (Gtk.STOCK_REFRESH, IconSize.MENU));
236               
237                var hbox = new HBox (false, 0);
238                hbox.pack_start (_serial_ports_combo, true, true, 0);
239                hbox.pack_start (update_serial_port_button, false, false, 0);
240               
241                add_vbox_label (_programmer_vbox, _("Programmer:"), _programmers_combo);
242                add_vbox_label (_serial_port_vbox, _("Serial port:"), hbox);
243                add_vbox_label (_baud_rate_vbox, _("Baud rate:"), _baud_rates_combo);
244                add_vbox_label (_devices_file_vbox, _("Devices file:"), _devices_file_chooser);
245                add_vbox_label (_devices_folder_vbox, _("Devices folder:"), _devices_folder_chooser);
246                add_vbox_label (_clock_vbox, _("Clock:"), _clock_entry);
247                add_vbox_label (_device_vbox, _("Device:"), _devices_combo);
248                add_vbox_label (_fuses_vbox, _("Fuses:"), _fuses_entry);
249               
250                var vbox = new VBox (false, 0);
251               
252                vbox.pack_start (_programmer_vbox, false, false, 4);
253                vbox.pack_start (_serial_port_vbox, false, false, 4);
254                vbox.pack_start (_baud_rate_vbox, false, false, 4);
255                vbox.pack_start (_devices_file_vbox, false, false, 4);
256                vbox.pack_start (_devices_folder_vbox, false, false, 4);
257                vbox.pack_start (_clock_vbox, false, false, 4);
258                vbox.pack_start (_device_vbox, false, false, 4);
259                vbox.pack_start (_fuses_vbox, false, false, 4);
260               
261                vbox.pack_start (new HSeparator (), false, false, 7);
262               
263                vbox.pack_start (_write_flash_button, false, false, 2);
264                vbox.pack_start (_read_flash_button, false, false, 2);
265                vbox.pack_start (_verify_flash_button, false, false, 2);
266                vbox.pack_start (_erase_flash_button, false, false, 2);
267                vbox.pack_start (_write_fuses_button, false, false, 2);
268                vbox.pack_start (_read_fuses_button, false, false, 2);
269                vbox.pack_start (_get_version_button, false, false, 2);
270                vbox.pack_start (_stop_button, false, false, 2);
271               
272                var scrolled_window = new ScrolledWindow (null, null);
273                scrolled_window.add_with_viewport (vbox);
274                scrolled_window.set_policy (PolicyType.AUTOMATIC, PolicyType.AUTOMATIC);
275               
276                pack_start (scrolled_window, true, true, 2);
277                show_all ();
278               
279                //Connect signals
280                _programmers_combo.item_changed.connect (() => this.programmer_changed ());
281                _serial_ports_combo.item_changed.connect (() => this.serial_port_changed ());
282                update_serial_port_button.clicked.connect (() => this.update_serial_port_clicked ());
283                _baud_rates_combo.item_changed.connect (() => this.baud_rate_changed ());
284                _devices_file_chooser.selection_changed.connect (() => this.devices_file_changed ());
285                _devices_folder_chooser.selection_changed.connect (() => this.devices_folder_changed ());
286                _clock_entry.changed.connect (() => this.clock_changed ());
287                _devices_combo.item_changed.connect (() => this.device_changed ());
288                _fuses_entry.changed.connect (() => this.fuses_changed ());
289                _write_flash_button.clicked.connect (() => this.write_flash_clicked ());
290                _read_flash_button.clicked.connect (() => this.read_flash_clicked ());
291                _verify_flash_button.clicked.connect (() => this.verify_flash_clicked ());
292                _erase_flash_button.clicked.connect (() => this.erase_flash_clicked ());
293                _write_fuses_button.clicked.connect (() => this.write_fuses_clicked ());
294                _read_fuses_button.clicked.connect (() => this.read_fuses_clicked ());
295                _get_version_button.clicked.connect (() => this.get_version_clicked ());
296                _stop_button.clicked.connect (() => this.stop_clicked ());
297        }
298       
299        public void add_programmer (string programmer)
300        {
301                _programmers_combo.add_item (programmer);
302        }
303       
304        public void add_serial_port (string serial_port)
305        {
306                _serial_ports_combo.add_item (serial_port);
307        }
308       
309        public void add_baud_rate (string baud_rate)
310        {
311                _baud_rates_combo.add_item (baud_rate);
312        }
313       
314        public void add_device (string device)
315        {
316                _devices_combo.add_item (device);
317        }
318       
319        public void clear_serial_ports_list ()
320        {
321                _serial_ports_combo.clear_list ();
322        }
323       
324        public void clear_devices_list ()
325        {
326                _devices_combo.clear_list ();
327        }
328       
329        private void add_vbox_label (VBox vbox, string label_text, Widget widget)
330        {
331                var label = new Label (label_text);
332                label.xalign = 0;
333                vbox.pack_start (label, false, false, 0);
334                vbox.pack_start (widget, false, false, 0);
335        }
336}
Note: See TracBrowser for help on using the repository browser.