Merge lp:~kvalo/indicator-network/vala-style into lp:~indicator-applet-developers/indicator-network/indicator-network

Proposed by Kalle Valo
Status: Merged
Merged at revision: 145
Proposed branch: lp:~kvalo/indicator-network/vala-style
Merge into: lp:~indicator-applet-developers/indicator-network/indicator-network
Diff against target: 616 lines (+263/-254)
3 files modified
HACKING (+12/-0)
scripts/cmcc (+1/-3)
src/settings/frontend/widgets/dialogs/edit-connection.vala (+250/-251)
To merge this branch: bzr merge lp:~kvalo/indicator-network/vala-style
Reviewer Review Type Date Requested Status
Conor Curran (community) Approve
Review via email: mp+49975@code.launchpad.net

Description of the change

Some vala style fixes and a small cmcc fix.

To post a comment you must log in.
Revision history for this message
Conor Curran (cjcurran) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'HACKING'
2--- HACKING 1970-01-01 00:00:00 +0000
3+++ HACKING 2011-02-16 14:17:53 +0000
4@@ -0,0 +1,12 @@
5+To compile indicator-network:
6+
7+sudo apt-get build-dep indicator-network
8+./autogen (if source taken from bzr)
9+./configure
10+make
11+
12+Vala coding style:
13+
14+o indentation four spaces
15+o "if {"
16+o "foo()"
17
18=== modified file 'scripts/cmcc'
19--- scripts/cmcc 2011-02-16 09:09:57 +0000
20+++ scripts/cmcc 2011-02-16 14:17:53 +0000
21@@ -163,9 +163,7 @@
22 def extract_dict(values):
23 s = ""
24 for k, v in values.items():
25- if type(v) is dbus.Array:
26- v = extract_list(v)
27- s += " %s=%s" % (k,v)
28+ s += " %s=%s" % (k, convert_dbus_value(v))
29 return "{ %s }" % s
30
31 def extract_list(values):
32
33=== modified file 'src/settings/frontend/widgets/dialogs/edit-connection.vala'
34--- src/settings/frontend/widgets/dialogs/edit-connection.vala 2011-02-15 11:27:57 +0000
35+++ src/settings/frontend/widgets/dialogs/edit-connection.vala 2011-02-16 14:17:53 +0000
36@@ -32,25 +32,25 @@
37 private Gtk.Label label_name;
38 private Gtk.CheckButton checkbutton_autoconnect;
39
40- /* wifi */
41+ /* wifi */
42 private Gtk.Label label_mode;
43 private Gtk.Label label_security;
44 private Gtk.Entry entry_passphrase;
45-
46- /* ipv4 */
47+
48+ /* ipv4 */
49 private Gtk.ComboBox combobox_ipv4_method;
50 private Gtk.Entry entry_ipv4_address;
51 private Gtk.Entry entry_ipv4_netmask;
52 private Gtk.Entry entry_ipv4_gateway;
53- private Gtk.TreeIter ipv4_off_iter;
54- private Gtk.TreeIter ipv4_manual_iter;
55- private Gtk.TreeIter ipv4_dhcp_iter;
56+ private Gtk.TreeIter ipv4_off_iter;
57+ private Gtk.TreeIter ipv4_manual_iter;
58+ private Gtk.TreeIter ipv4_dhcp_iter;
59
60 private Gtk.Entry entry_nameservers;
61 private Gtk.Entry entry_domains;
62
63- // button_cancel here is an _ugly_ workaround to get signals from
64- // objects working, reason for this is complete unknown
65+ // button_cancel here is an _ugly_ workaround to get signals from
66+ // objects working, reason for this is complete unknown
67 private string[] hint_labels = { "button_cancel" };
68
69 public EditConnectionDialog(Connman.Service connection, string datadir) {
70@@ -60,7 +60,7 @@
71 this.builder = Utils.Gui.new_builder(datadir+"ui/edit_connection_dialog.ui");
72 this.get_widgets();
73 this.create_extra_widgets();
74-
75+
76 this.connect_signals();
77 this.update_widget_values();
78 }
79@@ -76,57 +76,57 @@
80 });
81 }
82
83- var store = new Gtk.ListStore(2, typeof(int), typeof(string));
84- Gtk.TreeIter iter;
85-
86- this.combobox_ipv4_method.model = store;
87-
88- var cell = new Gtk.CellRendererText();
89- this.combobox_ipv4_method.pack_start(cell, false);
90- this.combobox_ipv4_method.set_attributes(cell, "text", 1);
91-
92- store.append(out iter);
93- store.set(iter, 0, Connman.IPv4Method.OFF, 1, "Off");
94- this.ipv4_off_iter = iter;
95-
96- store.append(out iter);
97- store.set(iter, 0, Connman.IPv4Method.MANUAL, 1, "Manual");
98- this.ipv4_manual_iter = iter;
99-
100- store.append(out iter);
101- store.set(iter, 0, Connman.IPv4Method.DHCP, 1, "DHCP");
102- this.ipv4_dhcp_iter = iter;
103+ var store = new Gtk.ListStore(2, typeof(int), typeof(string));
104+ Gtk.TreeIter iter;
105+
106+ this.combobox_ipv4_method.model = store;
107+
108+ var cell = new Gtk.CellRendererText();
109+ this.combobox_ipv4_method.pack_start(cell, false);
110+ this.combobox_ipv4_method.set_attributes(cell, "text", 1);
111+
112+ store.append(out iter);
113+ store.set(iter, 0, Connman.IPv4Method.OFF, 1, "Off");
114+ this.ipv4_off_iter = iter;
115+
116+ store.append(out iter);
117+ store.set(iter, 0, Connman.IPv4Method.MANUAL, 1, "Manual");
118+ this.ipv4_manual_iter = iter;
119+
120+ store.append(out iter);
121+ store.set(iter, 0, Connman.IPv4Method.DHCP, 1, "DHCP");
122+ this.ipv4_dhcp_iter = iter;
123 }
124
125 private void get_widgets() {
126- var b = this.builder;
127+ var b = this.builder;
128
129 this.dialog = b.get_object("window_main") as Gtk.Window;
130 this.table_main = b.get_object("table_main") as Gtk.Table;
131 this.button_save = b.get_object("button_save") as Gtk.Button;
132 this.button_cancel = b.get_object("button_cancel") as Gtk.Button;
133
134- /* main */
135+ /* main */
136 this.label_name = b.get_object("label_name") as Gtk.Label;
137 this.checkbutton_autoconnect = b.get_object("checkbutton_autoconnect")
138- as Gtk.CheckButton;
139+ as Gtk.CheckButton;
140
141- /* wifi */
142+ /* wifi */
143 this.label_mode = b.get_object("label_mode") as Gtk.Label;
144 this.label_security = b.get_object("label_security") as Gtk.Label;
145 this.entry_passphrase = b.get_object("entry_passphrase") as Gtk.Entry;
146
147- /* ipv4 */
148+ /* ipv4 */
149 this.combobox_ipv4_method = b.get_object("combobox_ipv4_method")
150- as Gtk.ComboBox;
151+ as Gtk.ComboBox;
152 this.entry_ipv4_address = b.get_object("entry_ipv4_address")
153- as Gtk.Entry;
154+ as Gtk.Entry;
155 this.entry_ipv4_netmask = b.get_object("entry_ipv4_netmask")
156- as Gtk.Entry;
157+ as Gtk.Entry;
158 this.entry_ipv4_gateway = b.get_object("entry_ipv4_gateway")
159- as Gtk.Entry;
160+ as Gtk.Entry;
161
162- /* dns */
163+ /* dns */
164 this.entry_nameservers = b.get_object("entry_nameservers") as Gtk.Entry;
165 this.entry_domains = b.get_object("entry_domains") as Gtk.Entry;
166 }
167@@ -134,223 +134,222 @@
168 private void connect_signals() {
169 this.button_save.clicked.connect(this.on_button_save_clicked);
170 this.button_cancel.clicked.connect(this.on_button_cancel_clicked);
171- this.combobox_ipv4_method.changed.connect(ipv4_method_changed);
172- }
173-
174- private void ipv4_method_changed(Gtk.ComboBox box) {
175- Gtk.TreeIter iter;
176- Gtk.ListStore store;
177- Connman.IPv4Method method;
178-
179- if (this.combobox_ipv4_method.get_active_iter(out iter) == false)
180- return;
181-
182- store = this.combobox_ipv4_method.model as Gtk.ListStore;
183- store.get(iter, 0, out method);
184-
185- switch (method) {
186- case Connman.IPv4Method.MANUAL:
187- this.entry_ipv4_address.sensitive = true;
188- this.entry_ipv4_netmask.sensitive = true;
189- this.entry_ipv4_gateway.sensitive = true;
190- break;
191- case Connman.IPv4Method.OFF:
192- case Connman.IPv4Method.DHCP:
193- default:
194- this.entry_ipv4_address.sensitive = false;
195- this.entry_ipv4_netmask.sensitive = false;
196- this.entry_ipv4_gateway.sensitive = false;
197- break;
198- }
199- }
200-
201- private void update_mode() {
202- string mode = "";
203-
204- switch (this.connection.mode) {
205- case Connman.ServiceMode.MANAGED:
206- mode = "Infrastructure";
207- break;
208- case Connman.ServiceMode.ADHOC:
209- mode = "Ad-Hoc";
210- break;
211- }
212-
213- this.label_mode.set_text(mode);
214- }
215-
216- private void update_name() {
217- this.label_name.set_text(this.connection.name);
218- }
219-
220- private void update_autoconnect() {
221+ this.combobox_ipv4_method.changed.connect(ipv4_method_changed);
222+ }
223+
224+ private void ipv4_method_changed(Gtk.ComboBox box) {
225+ Gtk.TreeIter iter;
226+ Gtk.ListStore store;
227+ Connman.IPv4Method method;
228+
229+ if (this.combobox_ipv4_method.get_active_iter(out iter) == false)
230+ return;
231+
232+ store = this.combobox_ipv4_method.model as Gtk.ListStore;
233+ store.get(iter, 0, out method);
234+
235+ switch (method) {
236+ case Connman.IPv4Method.MANUAL:
237+ this.entry_ipv4_address.sensitive = true;
238+ this.entry_ipv4_netmask.sensitive = true;
239+ this.entry_ipv4_gateway.sensitive = true;
240+ break;
241+ case Connman.IPv4Method.OFF:
242+ case Connman.IPv4Method.DHCP:
243+ default:
244+ this.entry_ipv4_address.sensitive = false;
245+ this.entry_ipv4_netmask.sensitive = false;
246+ this.entry_ipv4_gateway.sensitive = false;
247+ break;
248+ }
249+ }
250+
251+ private void update_mode() {
252+ string mode = "";
253+
254+ switch (this.connection.mode) {
255+ case Connman.ServiceMode.MANAGED:
256+ mode = "Infrastructure";
257+ break;
258+ case Connman.ServiceMode.ADHOC:
259+ mode = "Ad-Hoc";
260+ break;
261+ }
262+
263+ this.label_mode.set_text(mode);
264+ }
265+
266+ private void update_name() {
267+ this.label_name.set_text(this.connection.name);
268+ }
269+
270+ private void update_autoconnect() {
271 this.checkbutton_autoconnect.set_active(this.connection.autoconnect);
272- }
273+ }
274
275- private void save_autoconnect() {
276+ private void save_autoconnect() {
277 this.connection.autoconnect = this.checkbutton_autoconnect.get_active();
278- }
279-
280- private void update_security() {
281- string security ="";
282-
283-
284- /* security */
285- switch (this.connection.security) {
286- case Connman.ServiceSecurity.NONE:
287- security = "None";
288- break;
289- case Connman.ServiceSecurity.WEP:
290- security = "WEP";
291- break;
292- case Connman.ServiceSecurity.PSK:
293- security = "WPA-PSK";
294- break;
295- case Connman.ServiceSecurity.IEEE8021X:
296- security = "WPA-Enterprise";
297- break;
298- }
299-
300- this.label_security.set_text(security);
301- }
302-
303- private void update_passphrase() {
304- this.entry_passphrase.set_text(this.connection.passphrase);
305- }
306-
307- private void save_passphrase() {
308- /* FIXME: fix libconnman */
309- // this.connection.passphrase = this.entry_passphrase.get_text();
310- }
311-
312- private void update_ipv4() {
313- var ipv4 = this.connection.get_ipv4_configuration();
314- Gtk.TreeIter iter;
315-
316- switch (ipv4.method) {
317- case Connman.IPv4Method.OFF:
318- iter = this.ipv4_off_iter;
319- break;
320- case Connman.IPv4Method.MANUAL:
321- iter = this.ipv4_manual_iter;
322- this.entry_ipv4_address.text = ipv4.address;
323- this.entry_ipv4_netmask.text = ipv4.netmask;
324- this.entry_ipv4_gateway.text = ipv4.gateway;
325- break;
326- case Connman.IPv4Method.DHCP:
327- default:
328- iter = this.ipv4_dhcp_iter;
329- break;
330- }
331-
332- this.combobox_ipv4_method.set_active_iter(iter);
333- }
334-
335- private void save_ipv4() {
336- Gtk.TreeIter iter;
337- Connman.IPv4Method method;
338- Connman.IPv4 ipv4;
339-
340- var store = this.combobox_ipv4_method.model as Gtk.ListStore;
341-
342- this.combobox_ipv4_method.get_active_iter(out iter);
343- store.get(iter, 0, out method);
344-
345- var address = this.entry_ipv4_address.text;
346- var netmask = this.entry_ipv4_netmask.text;
347- var gateway = this.entry_ipv4_gateway.text;
348-
349- try {
350- ipv4 = new Connman.IPv4(method, address, netmask, gateway);
351- this.connection.set_ipv4_configuration(ipv4);
352- } catch (GLib.Error e) {
353- stderr.printf("Failed to create ipv4 object: %s", e.message);
354- }
355- }
356-
357- private void update_nameservers() {
358- string s = string.joinv(" ", this.connection.get_nameservers_configuration());
359- this.entry_nameservers.set_text(s);
360- }
361-
362- private void save_nameservers() {
363- string[] array = this.entry_nameservers.get_text().split(" ");
364- string[] servers = null;
365-
366- foreach (var server in array) {
367- servers += server.strip();
368- }
369-
370- this.connection.set_nameservers_configuration(servers);
371- }
372-
373- private void update_domains() {
374- string s = string.joinv(" ", this.connection.get_domains_configuration());
375- this.entry_domains.set_text(s);
376- }
377-
378- private void save_domains() {
379- string[] array = this.entry_domains.get_text().split(" ");
380- string[] domains = null;
381-
382- foreach (var server in array) {
383- domains += server.strip();
384- }
385-
386- this.connection.set_domains_configuration(domains);
387- }
388+ }
389+
390+ private void update_security() {
391+ string security ="";
392+
393+ /* security */
394+ switch (this.connection.security) {
395+ case Connman.ServiceSecurity.NONE:
396+ security = "None";
397+ break;
398+ case Connman.ServiceSecurity.WEP:
399+ security = "WEP";
400+ break;
401+ case Connman.ServiceSecurity.PSK:
402+ security = "WPA-PSK";
403+ break;
404+ case Connman.ServiceSecurity.IEEE8021X:
405+ security = "WPA-Enterprise";
406+ break;
407+ }
408+
409+ this.label_security.set_text(security);
410+ }
411+
412+ private void update_passphrase() {
413+ this.entry_passphrase.set_text(this.connection.passphrase);
414+ }
415+
416+ private void save_passphrase() {
417+ /* FIXME: fix libconnman */
418+ // this.connection.passphrase = this.entry_passphrase.get_text();
419+ }
420+
421+ private void update_ipv4() {
422+ var ipv4 = this.connection.get_ipv4_configuration();
423+ Gtk.TreeIter iter;
424+
425+ switch (ipv4.method) {
426+ case Connman.IPv4Method.OFF:
427+ iter = this.ipv4_off_iter;
428+ break;
429+ case Connman.IPv4Method.MANUAL:
430+ iter = this.ipv4_manual_iter;
431+ this.entry_ipv4_address.text = ipv4.address;
432+ this.entry_ipv4_netmask.text = ipv4.netmask;
433+ this.entry_ipv4_gateway.text = ipv4.gateway;
434+ break;
435+ case Connman.IPv4Method.DHCP:
436+ default:
437+ iter = this.ipv4_dhcp_iter;
438+ break;
439+ }
440+
441+ this.combobox_ipv4_method.set_active_iter(iter);
442+ }
443+
444+ private void save_ipv4() {
445+ Gtk.TreeIter iter;
446+ Connman.IPv4Method method;
447+ Connman.IPv4 ipv4;
448+
449+ var store = this.combobox_ipv4_method.model as Gtk.ListStore;
450+
451+ this.combobox_ipv4_method.get_active_iter(out iter);
452+ store.get(iter, 0, out method);
453+
454+ var address = this.entry_ipv4_address.text;
455+ var netmask = this.entry_ipv4_netmask.text;
456+ var gateway = this.entry_ipv4_gateway.text;
457+
458+ try {
459+ ipv4 = new Connman.IPv4(method, address, netmask, gateway);
460+ this.connection.set_ipv4_configuration(ipv4);
461+ } catch (GLib.Error e) {
462+ stderr.printf("Failed to create ipv4 object: %s", e.message);
463+ }
464+ }
465+
466+ private void update_nameservers() {
467+ string s = string.joinv(" ", this.connection.get_nameservers_configuration());
468+ this.entry_nameservers.set_text(s);
469+ }
470+
471+ private void save_nameservers() {
472+ string[] array = this.entry_nameservers.get_text().split(" ");
473+ string[] servers = null;
474+
475+ foreach (var server in array) {
476+ servers += server.strip();
477+ }
478+
479+ this.connection.set_nameservers_configuration(servers);
480+ }
481+
482+ private void update_domains() {
483+ string s = string.joinv(" ", this.connection.get_domains_configuration());
484+ this.entry_domains.set_text(s);
485+ }
486+
487+ private void save_domains() {
488+ string[] array = this.entry_domains.get_text().split(" ");
489+ string[] domains = null;
490+
491+ foreach (var server in array) {
492+ domains += server.strip();
493+ }
494+
495+ this.connection.set_domains_configuration(domains);
496+ }
497
498 private void update_widget_values() {
499- switch (this.connection.get_service_type()) {
500- case Connman.ServiceType.WIFI:
501- update_name();
502- update_autoconnect();
503- update_mode();
504- update_security();
505- update_passphrase();
506- update_ipv4();
507- update_nameservers();
508- update_domains();
509- break;
510- case Connman.ServiceType.ETHERNET:
511- update_name();
512- update_autoconnect();
513- update_ipv4();
514- update_nameservers();
515- update_domains();
516- break;
517- case Connman.ServiceType.BLUETOOTH:
518- update_name();
519- update_autoconnect();
520- update_ipv4();
521- update_nameservers();
522- update_domains();
523- break;
524- }
525+ switch (this.connection.get_service_type()) {
526+ case Connman.ServiceType.WIFI:
527+ update_name();
528+ update_autoconnect();
529+ update_mode();
530+ update_security();
531+ update_passphrase();
532+ update_ipv4();
533+ update_nameservers();
534+ update_domains();
535+ break;
536+ case Connman.ServiceType.ETHERNET:
537+ update_name();
538+ update_autoconnect();
539+ update_ipv4();
540+ update_nameservers();
541+ update_domains();
542+ break;
543+ case Connman.ServiceType.BLUETOOTH:
544+ update_name();
545+ update_autoconnect();
546+ update_ipv4();
547+ update_nameservers();
548+ update_domains();
549+ break;
550+ }
551 }
552-
553+
554 private void save_widget_values() {
555- switch (this.connection.get_service_type()) {
556- case Connman.ServiceType.WIFI:
557- save_autoconnect();
558- save_passphrase();
559- save_ipv4();
560- save_nameservers();
561- save_domains();
562- break;
563- case Connman.ServiceType.ETHERNET:
564- save_autoconnect();
565- save_ipv4();
566- save_nameservers();
567- save_domains();
568- break;
569- case Connman.ServiceType.BLUETOOTH:
570- save_autoconnect();
571- save_ipv4();
572- save_nameservers();
573- save_domains();
574- break;
575- }
576+ switch (this.connection.get_service_type()) {
577+ case Connman.ServiceType.WIFI:
578+ save_autoconnect();
579+ save_passphrase();
580+ save_ipv4();
581+ save_nameservers();
582+ save_domains();
583+ break;
584+ case Connman.ServiceType.ETHERNET:
585+ save_autoconnect();
586+ save_ipv4();
587+ save_nameservers();
588+ save_domains();
589+ break;
590+ case Connman.ServiceType.BLUETOOTH:
591+ save_autoconnect();
592+ save_ipv4();
593+ save_nameservers();
594+ save_domains();
595+ break;
596+ }
597 }
598
599 private void on_button_save_clicked() {
600@@ -358,7 +357,7 @@
601 this.dialog.destroy();
602 this.response(Gtk.ResponseType.APPLY);
603 }
604-
605+
606 private void on_button_cancel_clicked() {
607 this.dialog.destroy();
608 this.response(Gtk.ResponseType.CANCEL);
609@@ -366,6 +365,6 @@
610
611 public int run() {
612 this.dialog.show_all();
613- return 0;
614+ return 0;
615 }
616 }

Subscribers

People subscribed via source and target branches