Merge lp:~kvalo/indicator-network/settings-tech-control into lp:~indicator-applet-developers/indicator-network/indicator-network
- settings-tech-control
- Merge into indicator-network
Proposed by
Kalle Valo
Status: | Merged |
---|---|
Merged at revision: | 153 |
Proposed branch: | lp:~kvalo/indicator-network/settings-tech-control |
Merge into: | lp:~indicator-applet-developers/indicator-network/indicator-network |
Diff against target: |
579 lines (+197/-160) 8 files modified
src/settings/backend/device.vala (+103/-53) src/settings/frontend/pages/connections.vala (+23/-32) src/settings/frontend/widgets/device-boxes/base.vala (+0/-1) src/settings/frontend/widgets/device-boxes/bluetooth.vala (+3/-6) src/settings/frontend/widgets/device-boxes/flightmode.vala (+19/-19) src/settings/frontend/widgets/device-boxes/mobile.vala (+29/-26) src/settings/frontend/widgets/device-boxes/wired.vala (+3/-6) src/settings/frontend/widgets/device-boxes/wireless.vala (+17/-17) |
To merge this branch: | bzr merge lp:~kvalo/indicator-network/settings-tech-control |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Conor Curran (community) | Approve | ||
Andrew (community) | Needs Fixing | ||
Review via email: mp+50972@code.launchpad.net |
Commit message
Description of the change
Connect device on/off buttons to libconnman. Also the icons on the left show now real state.
Wired, mobile and bluetooth boxes still are not implemented.
To post a comment you must log in.
- 159. By Kalle Valo
-
settings: fix spelling of word flight
My most common spelling error :)
Revision history for this message
Kalle Valo (kvalo) wrote : | # |
Andrew <email address hidden> writes:
> Review: Needs Fixing
> This all looks great Kalle!
Thanks for review!
> Just one small issue, FligthModeDevice should be FlightModeDevice :)
Haha, I always do the same mistake :) I should make emacs warn about
this...
> The fact that this is the only issue is a credit to your work!
No, this is all credit to your work. The architecture for the settings
app is just excellent, it was extremely simple to connect libconnman to
it.
--
Kalle Valo
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 | === modified file 'src/settings/backend/device.vala' | |||
2 | --- src/settings/backend/device.vala 2011-01-24 17:15:22 +0000 | |||
3 | +++ src/settings/backend/device.vala 2011-02-24 08:05:23 +0000 | |||
4 | @@ -18,57 +18,107 @@ | |||
5 | 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
6 | 19 | */ | 19 | */ |
7 | 20 | 20 | ||
61 | 21 | public class Device : GLib.Object { | 21 | public abstract class Device : GLib.Object { |
62 | 22 | 22 | ||
63 | 23 | public DeviceType type_ { get; set; } | 23 | public DeviceType type_ { get; protected set; } |
64 | 24 | public DeviceState state { get; set; } | 24 | public DeviceState state { get; protected set; } |
65 | 25 | 25 | ||
66 | 26 | public Device() { | 26 | protected Connman.Manager connman; |
67 | 27 | } | 27 | |
68 | 28 | } | 28 | protected DeviceState convert_state(Connman.TechnologyState state) { |
69 | 29 | 29 | ||
70 | 30 | public static Device[] get_wired_devices() { | 30 | switch (state) { |
71 | 31 | // Populate Device View (temporary) | 31 | case Connman.TechnologyState.CONNECTED: |
72 | 32 | var device1 = new Device(); | 32 | return DeviceState.CONNECTED; |
73 | 33 | device1.type_ = DeviceType.WIRED; | 33 | case Connman.TechnologyState.ENABLED: |
74 | 34 | device1.state = DeviceState.OFFLINE; | 34 | return DeviceState.ONLINE; |
75 | 35 | // | 35 | case Connman.TechnologyState.OFFLINE: |
76 | 36 | return {device1}; | 36 | return DeviceState.OFFLINE; |
77 | 37 | } | 37 | case Connman.TechnologyState.AVAILABLE: |
78 | 38 | 38 | default: | |
79 | 39 | public static Device[] get_wireless_devices() { | 39 | return DeviceState.OFF; |
80 | 40 | // Populate Device View (temporary) | 40 | } |
81 | 41 | var device1 = new Device(); | 41 | } |
82 | 42 | device1.type_ = DeviceType.WIRELESS; | 42 | |
83 | 43 | device1.state = DeviceState.ONLINE; | 43 | protected void update_state(Connman.TechnologyState state) { |
84 | 44 | var device2 = new Device(); | 44 | this.state = convert_state(state); |
85 | 45 | device2.type_ = DeviceType.WIRELESS; | 45 | } |
86 | 46 | device2.state = DeviceState.OFF; | 46 | } |
87 | 47 | // | 47 | |
88 | 48 | return {device1, device2}; | 48 | public class WifiDevice : Device { |
89 | 49 | } | 49 | |
90 | 50 | 50 | public WifiDevice(Connman.Manager connman) { | |
91 | 51 | public static Device[] get_mobile_devices() { | 51 | this.type_ = DeviceType.WIRELESS; |
92 | 52 | // Populate Device View (temporary) | 52 | this.connman = connman; |
93 | 53 | var device3 = new Device(); | 53 | |
94 | 54 | device3.type_ = DeviceType.MOBILE; | 54 | this.connman.notify["wifi-state"].connect((s, p) => { |
95 | 55 | device3.state = DeviceState.CONNECTED; | 55 | update_state(this.connman.get_wifi_state()); |
96 | 56 | // | 56 | }); |
97 | 57 | return {device3}; | 57 | |
98 | 58 | } | 58 | update_state(this.connman.get_wifi_state()); |
99 | 59 | 59 | } | |
100 | 60 | public static Device[] get_bluetooth_devices() { | 60 | } |
101 | 61 | // Populate Device View (temporary) | 61 | |
102 | 62 | var device4 = new Device(); | 62 | public class EthernetDevice : Device { |
103 | 63 | device4.type_ = DeviceType.BLUETOOTH; | 63 | |
104 | 64 | device4.state = DeviceState.OFF; | 64 | public EthernetDevice(Connman.Manager connman) { |
105 | 65 | // | 65 | this.type_ = DeviceType.WIRED; |
106 | 66 | return {device4}; | 66 | this.connman = connman; |
107 | 67 | } | 67 | |
108 | 68 | 68 | this.connman.notify["ethernet-state"].connect((s, p) => { | |
109 | 69 | public static Device get_flightmode_device() { | 69 | update_state(this.connman.get_ethernet_state()); |
110 | 70 | var device = new Device(); | 70 | }); |
111 | 71 | device.type_ = DeviceType.FLIGHTMODE; | 71 | |
112 | 72 | device.state = DeviceState.OFF; | 72 | update_state(this.connman.get_ethernet_state()); |
113 | 73 | return device; | 73 | } |
114 | 74 | } | ||
115 | 75 | |||
116 | 76 | public class CellularDevice : Device { | ||
117 | 77 | |||
118 | 78 | public CellularDevice(Connman.Manager connman) { | ||
119 | 79 | this.type_ = DeviceType.MOBILE; | ||
120 | 80 | this.connman = connman; | ||
121 | 81 | |||
122 | 82 | this.connman.notify["cellular-state"].connect((s, p) => { | ||
123 | 83 | update_state(this.connman.get_cellular_state()); | ||
124 | 84 | }); | ||
125 | 85 | |||
126 | 86 | update_state(this.connman.get_cellular_state()); | ||
127 | 87 | } | ||
128 | 88 | } | ||
129 | 89 | |||
130 | 90 | public class BluetoothDevice : Device { | ||
131 | 91 | |||
132 | 92 | public BluetoothDevice(Connman.Manager connman) { | ||
133 | 93 | this.type_ = DeviceType.BLUETOOTH; | ||
134 | 94 | this.connman = connman; | ||
135 | 95 | |||
136 | 96 | this.connman.notify["bluetooth-state"].connect((s, p) => { | ||
137 | 97 | update_state(this.connman.get_bluetooth_state()); | ||
138 | 98 | }); | ||
139 | 99 | |||
140 | 100 | update_state(this.connman.get_bluetooth_state()); | ||
141 | 101 | } | ||
142 | 102 | } | ||
143 | 103 | |||
144 | 104 | public class FlightModeDevice : Device { | ||
145 | 105 | |||
146 | 106 | public FlightModeDevice(Connman.Manager connman) { | ||
147 | 107 | this.type_ = DeviceType.FLIGHTMODE; | ||
148 | 108 | this.connman = connman; | ||
149 | 109 | |||
150 | 110 | this.connman.notify["offline-mode"].connect((s, p) => { | ||
151 | 111 | update_mode(this.connman.offline_mode); | ||
152 | 112 | }); | ||
153 | 113 | |||
154 | 114 | update_mode(this.connman.offline_mode); | ||
155 | 115 | } | ||
156 | 116 | |||
157 | 117 | private void update_mode(bool mode) { | ||
158 | 118 | |||
159 | 119 | if (mode) | ||
160 | 120 | this.state = DeviceState.OFFLINE; | ||
161 | 121 | else | ||
162 | 122 | this.state = DeviceState.ONLINE; | ||
163 | 123 | } | ||
164 | 74 | } | 124 | } |
165 | 75 | 125 | ||
166 | === modified file 'src/settings/frontend/pages/connections.vala' | |||
167 | --- src/settings/frontend/pages/connections.vala 2011-02-01 12:59:54 +0000 | |||
168 | +++ src/settings/frontend/pages/connections.vala 2011-02-24 08:05:23 +0000 | |||
169 | @@ -47,43 +47,34 @@ | |||
170 | 47 | this.treeview_devices.reordered.connect( | 47 | this.treeview_devices.reordered.connect( |
171 | 48 | this.on_treeview_devices_reordered); | 48 | this.on_treeview_devices_reordered); |
172 | 49 | 49 | ||
204 | 50 | Device[] wired_devices = get_wired_devices(); | 50 | var wifi = new WifiDevice(connman); |
205 | 51 | Device[] wireless_devices = get_wireless_devices(); | 51 | var wifi_box = new WirelessBox(connman, datadir); |
206 | 52 | Device[] mobile_devices = get_mobile_devices(); | 52 | notebook_right.append_page(wifi_box, null); |
207 | 53 | Device[] bluetooth_devices = get_bluetooth_devices(); | 53 | this.add_device(wifi, wifi_box); |
208 | 54 | 54 | ||
209 | 55 | foreach (var device in wireless_devices) { | 55 | var ethernet = new EthernetDevice(connman); |
210 | 56 | var box = new WirelessBox(device, connman, datadir); | 56 | var ethernet_box = new WiredBox(connman, datadir); |
211 | 57 | notebook_right.append_page(box, null); | 57 | notebook_right.append_page(ethernet_box, null); |
212 | 58 | this.add_device(device, box); | 58 | this.add_device(ethernet, ethernet_box); |
213 | 59 | } | 59 | |
214 | 60 | 60 | var cellular = new CellularDevice(connman); | |
215 | 61 | foreach (var device in mobile_devices) { | 61 | var cellular_box = new MobileBox(connman, datadir); |
216 | 62 | var box = new MobileBox(device, datadir); | 62 | notebook_right.append_page(cellular_box, null); |
217 | 63 | notebook_right.append_page(box, null); | 63 | this.add_device(cellular, cellular_box); |
218 | 64 | this.add_device(device, box); | 64 | |
219 | 65 | } | 65 | var bluetooth = new BluetoothDevice(connman); |
220 | 66 | 66 | var bluetooth_box = new BluetoothBox(connman, datadir); | |
221 | 67 | foreach (var device in wired_devices) { | 67 | notebook_right.append_page(bluetooth_box, null); |
222 | 68 | var box = new WiredBox(device, datadir); | 68 | this.add_device(bluetooth, bluetooth_box); |
223 | 69 | notebook_right.append_page(box, null); | 69 | |
224 | 70 | this.add_device(device, box); | 70 | var flightmode_device = new FlightModeDevice(connman); |
225 | 71 | } | 71 | var flightmode_box = new FlightModeBox(flightmode_device, connman, |
226 | 72 | 72 | datadir); | |
196 | 73 | foreach (var device in bluetooth_devices) { | ||
197 | 74 | var box = new BluetoothBox(device, datadir); | ||
198 | 75 | notebook_right.append_page(box, null); | ||
199 | 76 | this.add_device(device, box); | ||
200 | 77 | } | ||
201 | 78 | |||
202 | 79 | var flightmode_device = get_flightmode_device(); | ||
203 | 80 | var flightmode_box = new FlightModeBox(flightmode_device, datadir); | ||
227 | 81 | notebook_right.append_page(flightmode_box, null); | 73 | notebook_right.append_page(flightmode_box, null); |
228 | 82 | this.add_device(flightmode_device, flightmode_box); | 74 | this.add_device(flightmode_device, flightmode_box); |
229 | 83 | 75 | ||
230 | 84 | // Order the RHS notebook pages inaccordance with the deviceview | 76 | // Order the RHS notebook pages inaccordance with the deviceview |
231 | 85 | this.on_treeview_devices_reordered(); | 77 | this.on_treeview_devices_reordered(); |
232 | 86 | |||
233 | 87 | } | 78 | } |
234 | 88 | 79 | ||
235 | 89 | public void add_device(Device device, DeviceBox box) { | 80 | public void add_device(Device device, DeviceBox box) { |
236 | 90 | 81 | ||
237 | === modified file 'src/settings/frontend/widgets/device-boxes/base.vala' | |||
238 | --- src/settings/frontend/widgets/device-boxes/base.vala 2011-01-10 17:35:19 +0000 | |||
239 | +++ src/settings/frontend/widgets/device-boxes/base.vala 2011-02-24 08:05:23 +0000 | |||
240 | @@ -22,5 +22,4 @@ | |||
241 | 22 | /* A gtk.VBox which holds all of the widgets to control a device */ | 22 | /* A gtk.VBox which holds all of the widgets to control a device */ |
242 | 23 | 23 | ||
243 | 24 | public DeviceBox() {} | 24 | public DeviceBox() {} |
244 | 25 | public abstract void on_device_state_changed(ParamSpec p); | ||
245 | 26 | } | 25 | } |
246 | 27 | 26 | ||
247 | === modified file 'src/settings/frontend/widgets/device-boxes/bluetooth.vala' | |||
248 | --- src/settings/frontend/widgets/device-boxes/bluetooth.vala 2011-01-10 17:35:19 +0000 | |||
249 | +++ src/settings/frontend/widgets/device-boxes/bluetooth.vala 2011-02-24 08:05:23 +0000 | |||
250 | @@ -23,13 +23,10 @@ | |||
251 | 23 | /* A Gtk.VBox which holds all of the widgets to control a bluetooth | 23 | /* A Gtk.VBox which holds all of the widgets to control a bluetooth |
252 | 24 | device. */ | 24 | device. */ |
253 | 25 | 25 | ||
255 | 26 | private Device device; | 26 | private Connman.Manager connman; |
256 | 27 | 27 | ||
258 | 28 | public BluetoothBox(Device device, string datadir) { | 28 | public BluetoothBox(Connman.Manager connman, string datadir) { |
259 | 29 | this.set_spacing(12); | 29 | this.set_spacing(12); |
262 | 30 | this.device = device; | 30 | this.connman = connman; |
261 | 31 | this.device.notify["state"].connect(this.on_device_state_changed); | ||
263 | 32 | } | 31 | } |
264 | 33 | |||
265 | 34 | public override void on_device_state_changed(ParamSpec p) {} | ||
266 | 35 | } | 32 | } |
267 | 36 | 33 | ||
268 | === modified file 'src/settings/frontend/widgets/device-boxes/flightmode.vala' | |||
269 | --- src/settings/frontend/widgets/device-boxes/flightmode.vala 2011-01-24 17:15:22 +0000 | |||
270 | +++ src/settings/frontend/widgets/device-boxes/flightmode.vala 2011-02-24 08:05:23 +0000 | |||
271 | @@ -26,6 +26,7 @@ | |||
272 | 26 | 26 | ||
273 | 27 | private string datadir; | 27 | private string datadir; |
274 | 28 | private Device device; | 28 | private Device device; |
275 | 29 | private Connman.Manager connman; | ||
276 | 29 | private InfoBox infobox; | 30 | private InfoBox infobox; |
277 | 30 | private ToggleSwitch toggleswitch; | 31 | private ToggleSwitch toggleswitch; |
278 | 31 | private Gtk.Label label_status; | 32 | private Gtk.Label label_status; |
279 | @@ -35,11 +36,13 @@ | |||
280 | 35 | private Gtk.Button button_more_information; | 36 | private Gtk.Button button_more_information; |
281 | 36 | private Gtk.CheckButton checkbutton_show; | 37 | private Gtk.CheckButton checkbutton_show; |
282 | 37 | 38 | ||
284 | 38 | public FlightModeBox(Device device, string datadir) { | 39 | public FlightModeBox(Device device, Connman.Manager connman, |
285 | 40 | string datadir) { | ||
286 | 39 | this.set_spacing(12); | 41 | this.set_spacing(12); |
287 | 40 | this.datadir = datadir; | 42 | this.datadir = datadir; |
288 | 41 | this.device = device; | 43 | this.device = device; |
290 | 42 | this.device.notify["state"].connect(this.on_device_state_changed); | 44 | this.connman = connman; |
291 | 45 | this.connman.notify["offline-mode"].connect(this.offline_mode_changed); | ||
292 | 43 | 46 | ||
293 | 44 | // Infobox and Togglswitch | 47 | // Infobox and Togglswitch |
294 | 45 | /// Creation | 48 | /// Creation |
295 | @@ -64,7 +67,7 @@ | |||
296 | 64 | /// Packing | 67 | /// Packing |
297 | 65 | this.pack_start(this.vbox_information, true, true); | 68 | this.pack_start(this.vbox_information, true, true); |
298 | 66 | 69 | ||
300 | 67 | this.update_widget_states(this.device.state); | 70 | this.update_widget_states(this.connman.offline_mode); |
301 | 68 | } | 71 | } |
302 | 69 | 72 | ||
303 | 70 | private void get_widgets() { | 73 | private void get_widgets() { |
304 | @@ -76,34 +79,31 @@ | |||
305 | 76 | private void connect_signals() { | 79 | private void connect_signals() { |
306 | 77 | } | 80 | } |
307 | 78 | 81 | ||
309 | 79 | private void update_widget_states(DeviceState state) { | 82 | private void update_widget_states(bool offline) { |
310 | 80 | bool toggleswitch_state = false; | 83 | bool toggleswitch_state = false; |
311 | 81 | string status_text = ""; | 84 | string status_text = ""; |
322 | 82 | 85 | ||
323 | 83 | switch (state) { | 86 | if (offline) { |
324 | 84 | case DeviceState.ONLINE: | 87 | toggleswitch_state = true; |
325 | 85 | toggleswitch_state = true; | 88 | status_text = ("Flight Mode is on."); |
326 | 86 | status_text = ("Flight Mode is on."); | 89 | } else { |
327 | 87 | break; | 90 | toggleswitch_state = false; |
328 | 88 | case DeviceState.OFF: | 91 | status_text = ("Flight Mode is off."); |
319 | 89 | toggleswitch_state = false; | ||
320 | 90 | status_text = ("Flight Mode is off."); | ||
321 | 91 | break; | ||
329 | 92 | } | 92 | } |
330 | 93 | 93 | ||
331 | 94 | this.toggleswitch.set_active(toggleswitch_state); | 94 | this.toggleswitch.set_active(toggleswitch_state); |
332 | 95 | this.label_status.set_text(status_text); | 95 | this.label_status.set_text(status_text); |
333 | 96 | } | 96 | } |
337 | 97 | 97 | ||
338 | 98 | public override void on_device_state_changed(ParamSpec p) { | 98 | private void offline_mode_changed(ParamSpec p) { |
339 | 99 | this.update_widget_states(this.device.state); | 99 | this.update_widget_states(this.connman.offline_mode); |
340 | 100 | } | 100 | } |
341 | 101 | 101 | ||
342 | 102 | private void on_toggleswitch_toggled() { | 102 | private void on_toggleswitch_toggled() { |
343 | 103 | if (this.toggleswitch.get_active()) { | 103 | if (this.toggleswitch.get_active()) { |
345 | 104 | this.device.state = DeviceState.ONLINE; | 104 | this.connman.offline_mode = true; |
346 | 105 | } else { | 105 | } else { |
348 | 106 | this.device.state = DeviceState.OFF; | 106 | this.connman.offline_mode = false; |
349 | 107 | } | 107 | } |
350 | 108 | } | 108 | } |
351 | 109 | } | 109 | } |
352 | 110 | 110 | ||
353 | === modified file 'src/settings/frontend/widgets/device-boxes/mobile.vala' | |||
354 | --- src/settings/frontend/widgets/device-boxes/mobile.vala 2011-01-10 17:35:19 +0000 | |||
355 | +++ src/settings/frontend/widgets/device-boxes/mobile.vala 2011-02-24 08:05:23 +0000 | |||
356 | @@ -25,7 +25,7 @@ | |||
357 | 25 | monitor the state of the mobile device, and a set of widgets | 25 | monitor the state of the mobile device, and a set of widgets |
358 | 26 | to enter details about the mobile network to connect to. */ | 26 | to enter details about the mobile network to connect to. */ |
359 | 27 | 27 | ||
361 | 28 | private Device device; | 28 | private Connman.Manager connman; |
362 | 29 | private InfoBox infobox; | 29 | private InfoBox infobox; |
363 | 30 | private ToggleSwitch toggleswitch; | 30 | private ToggleSwitch toggleswitch; |
364 | 31 | private Gtk.Label label_status; | 31 | private Gtk.Label label_status; |
365 | @@ -40,10 +40,11 @@ | |||
366 | 40 | private const string[] sensitive_widgets = {"label_apn_place", "label_apn", | 40 | private const string[] sensitive_widgets = {"label_apn_place", "label_apn", |
367 | 41 | "label_pin_auth", "checkbutton_show_pin"}; | 41 | "label_pin_auth", "checkbutton_show_pin"}; |
368 | 42 | 42 | ||
370 | 43 | public MobileBox(Device device, string datadir) { | 43 | public MobileBox(Connman.Manager connman, string datadir) { |
371 | 44 | this.set_spacing(12); | 44 | this.set_spacing(12); |
374 | 45 | this.device = device; | 45 | this.connman = connman; |
375 | 46 | this.device.notify["state"].connect(this.on_device_state_changed); | 46 | |
376 | 47 | this.connman.notify["cellular-state"].connect(this.on_cellular_state_changed); | ||
377 | 47 | 48 | ||
378 | 48 | // Infobox and Togglswitch | 49 | // Infobox and Togglswitch |
379 | 49 | /// Creation | 50 | /// Creation |
380 | @@ -68,7 +69,7 @@ | |||
381 | 68 | /// Packing | 69 | /// Packing |
382 | 69 | this.pack_start(this.table_settings, true, true); | 70 | this.pack_start(this.table_settings, true, true); |
383 | 70 | 71 | ||
385 | 71 | this.update_widget_states(this.device.state); | 72 | this.update_widget_states(this.connman.get_cellular_state()); |
386 | 72 | this.on_checkbutton_show_pin_toggled(); | 73 | this.on_checkbutton_show_pin_toggled(); |
387 | 73 | } | 74 | } |
388 | 74 | 75 | ||
389 | @@ -82,32 +83,32 @@ | |||
390 | 82 | this.checkbutton_show_pin.toggled.connect(this.on_checkbutton_show_pin_toggled); | 83 | this.checkbutton_show_pin.toggled.connect(this.on_checkbutton_show_pin_toggled); |
391 | 83 | } | 84 | } |
392 | 84 | 85 | ||
394 | 85 | private void update_widget_states(DeviceState state) { | 86 | private void update_widget_states(Connman.TechnologyState state) { |
395 | 86 | bool toggleswitch_state = false; | 87 | bool toggleswitch_state = false; |
396 | 87 | string status_text = ""; | 88 | string status_text = ""; |
397 | 88 | 89 | ||
398 | 89 | switch (state) { | 90 | switch (state) { |
413 | 90 | case DeviceState.CONNECTED: | 91 | case Connman.TechnologyState.ENABLED: |
414 | 91 | this.device_editable = true; | 92 | this.device_editable = true; |
401 | 92 | this.settings_editable = false; | ||
402 | 93 | toggleswitch_state = true; | ||
403 | 94 | status_text = ("Connected to “Vodafone UK”."); | ||
404 | 95 | break; | ||
405 | 96 | case DeviceState.ONLINE: | ||
406 | 97 | this.device_editable = true; | ||
407 | 98 | this.settings_editable = false; | ||
408 | 99 | toggleswitch_state = true; | ||
409 | 100 | status_text = ("Connected to the Internet on “Vodafone UK”."); | ||
410 | 101 | break; | ||
411 | 102 | case DeviceState.OFF: | ||
412 | 103 | this.device_editable = false; | ||
415 | 104 | this.settings_editable = true; | 93 | this.settings_editable = true; |
416 | 94 | toggleswitch_state = true; | ||
417 | 95 | status_text = ("Mobile Broadband is enabled."); | ||
418 | 96 | break; | ||
419 | 97 | case Connman.TechnologyState.CONNECTED: | ||
420 | 98 | this.device_editable = true; | ||
421 | 99 | this.settings_editable = false; | ||
422 | 100 | toggleswitch_state = true; | ||
423 | 101 | status_text = ("Connected to the Internet."); | ||
424 | 102 | break; | ||
425 | 103 | case Connman.TechnologyState.AVAILABLE: | ||
426 | 104 | this.device_editable = true; | ||
427 | 105 | this.settings_editable = false; | ||
428 | 105 | toggleswitch_state = false; | 106 | toggleswitch_state = false; |
429 | 106 | status_text = ("The Mobile Broadband device is powered off."); | 107 | status_text = ("The Mobile Broadband device is powered off."); |
430 | 107 | break; | 108 | break; |
432 | 108 | case DeviceState.OFFLINE: | 109 | case Connman.TechnologyState.OFFLINE: |
433 | 109 | this.device_editable = true; | 110 | this.device_editable = true; |
435 | 110 | this.settings_editable = true; | 111 | this.settings_editable = false; |
436 | 111 | toggleswitch_state = false; | 112 | toggleswitch_state = false; |
437 | 112 | status_text = ("Mobile Broadband is offline."); | 113 | status_text = ("Mobile Broadband is offline."); |
438 | 113 | break; | 114 | break; |
439 | @@ -133,15 +134,17 @@ | |||
440 | 133 | } | 134 | } |
441 | 134 | } | 135 | } |
442 | 135 | 136 | ||
445 | 136 | public override void on_device_state_changed(ParamSpec p) { | 137 | private void on_cellular_state_changed(ParamSpec p) { |
446 | 137 | this.update_widget_states(this.device.state); | 138 | this.update_widget_states(this.connman.get_cellular_state()); |
447 | 138 | } | 139 | } |
448 | 139 | 140 | ||
449 | 140 | private void on_toggleswitch_toggled() { | 141 | private void on_toggleswitch_toggled() { |
450 | 141 | if (this.toggleswitch.get_active()) { | 142 | if (this.toggleswitch.get_active()) { |
452 | 142 | this.device.state = DeviceState.CONNECTED; | 143 | this.connman.enable_technology(Connman.TechnologyType.CELLULAR, |
453 | 144 | null); | ||
454 | 143 | } else { | 145 | } else { |
456 | 144 | this.device.state = DeviceState.OFFLINE; | 146 | this.connman.disable_technology(Connman.TechnologyType.CELLULAR, |
457 | 147 | null); | ||
458 | 145 | } | 148 | } |
459 | 146 | } | 149 | } |
460 | 147 | 150 | ||
461 | 148 | 151 | ||
462 | === modified file 'src/settings/frontend/widgets/device-boxes/wired.vala' | |||
463 | --- src/settings/frontend/widgets/device-boxes/wired.vala 2011-01-10 17:35:19 +0000 | |||
464 | +++ src/settings/frontend/widgets/device-boxes/wired.vala 2011-02-24 08:05:23 +0000 | |||
465 | @@ -23,13 +23,10 @@ | |||
466 | 23 | /* A Gtk.VBox which holds all of the widgets to control a wired | 23 | /* A Gtk.VBox which holds all of the widgets to control a wired |
467 | 24 | device. */ | 24 | device. */ |
468 | 25 | 25 | ||
470 | 26 | private Device device; | 26 | private Connman.Manager connman; |
471 | 27 | 27 | ||
473 | 28 | public WiredBox(Device device, string datadir) { | 28 | public WiredBox(Connman.Manager connman, string datadir) { |
474 | 29 | this.set_spacing(12); | 29 | this.set_spacing(12); |
477 | 30 | this.device = device; | 30 | this.connman = connman; |
476 | 31 | this.device.notify["state"].connect(this.on_device_state_changed); | ||
478 | 32 | } | 31 | } |
479 | 33 | |||
480 | 34 | public override void on_device_state_changed(ParamSpec p) {} | ||
481 | 35 | } | 32 | } |
482 | 36 | 33 | ||
483 | === modified file 'src/settings/frontend/widgets/device-boxes/wireless.vala' | |||
484 | --- src/settings/frontend/widgets/device-boxes/wireless.vala 2011-02-01 13:29:19 +0000 | |||
485 | +++ src/settings/frontend/widgets/device-boxes/wireless.vala 2011-02-24 08:05:23 +0000 | |||
486 | @@ -27,7 +27,7 @@ | |||
487 | 27 | wireless networks. */ | 27 | wireless networks. */ |
488 | 28 | 28 | ||
489 | 29 | private string datadir; | 29 | private string datadir; |
491 | 30 | private Device device; | 30 | private Connman.Manager connman; |
492 | 31 | private InfoBox infobox; | 31 | private InfoBox infobox; |
493 | 32 | private ToggleSwitch toggleswitch; | 32 | private ToggleSwitch toggleswitch; |
494 | 33 | private Gtk.Label label_status; | 33 | private Gtk.Label label_status; |
495 | @@ -39,12 +39,12 @@ | |||
496 | 39 | private Gtk.Button button_edit; | 39 | private Gtk.Button button_edit; |
497 | 40 | private Gtk.ScrolledWindow scrolledwindow_connections; | 40 | private Gtk.ScrolledWindow scrolledwindow_connections; |
498 | 41 | 41 | ||
501 | 42 | public WirelessBox(Device device, Connman.Manager connman, | 42 | public WirelessBox(Connman.Manager connman, string datadir) { |
500 | 43 | string datadir) { | ||
502 | 44 | this.set_spacing(12); | 43 | this.set_spacing(12); |
503 | 45 | this.datadir = datadir; | 44 | this.datadir = datadir; |
506 | 46 | this.device = device; | 45 | this.connman = connman; |
507 | 47 | this.device.notify["state"].connect(this.on_device_state_changed); | 46 | |
508 | 47 | this.connman.notify["wifi-state"].connect(this.wifi_state_changed); | ||
509 | 48 | 48 | ||
510 | 49 | // Infobox and Togglswitch | 49 | // Infobox and Togglswitch |
511 | 50 | /// Creation | 50 | /// Creation |
512 | @@ -85,7 +85,7 @@ | |||
513 | 85 | this.add_service(service); | 85 | this.add_service(service); |
514 | 86 | } | 86 | } |
515 | 87 | 87 | ||
517 | 88 | this.update_widget_states(this.device.state); | 88 | this.update_widget_states(this.connman.get_wifi_state()); |
518 | 89 | this.on_treeview_connections_selection_changed(); | 89 | this.on_treeview_connections_selection_changed(); |
519 | 90 | } | 90 | } |
520 | 91 | 91 | ||
521 | @@ -102,32 +102,32 @@ | |||
522 | 102 | this.button_edit.clicked.connect(this.on_button_edit_clicked); | 102 | this.button_edit.clicked.connect(this.on_button_edit_clicked); |
523 | 103 | } | 103 | } |
524 | 104 | 104 | ||
526 | 105 | private void update_widget_states(DeviceState state) { | 105 | private void update_widget_states(Connman.TechnologyState state) { |
527 | 106 | bool device_editable = false; | 106 | bool device_editable = false; |
528 | 107 | bool settings_editable = false; | 107 | bool settings_editable = false; |
529 | 108 | bool toggleswitch_state = false; | 108 | bool toggleswitch_state = false; |
530 | 109 | string status_text = ""; | 109 | string status_text = ""; |
532 | 110 | 110 | ||
533 | 111 | switch (state) { | 111 | switch (state) { |
535 | 112 | case DeviceState.CONNECTED: | 112 | case Connman.TechnologyState.ENABLED: |
536 | 113 | device_editable = true; | 113 | device_editable = true; |
537 | 114 | settings_editable = true; | 114 | settings_editable = true; |
538 | 115 | toggleswitch_state = true; | 115 | toggleswitch_state = true; |
539 | 116 | status_text = ("Wi-fi is on but not connected to the Internet."); | 116 | status_text = ("Wi-fi is on but not connected to the Internet."); |
540 | 117 | break; | 117 | break; |
542 | 118 | case DeviceState.ONLINE: | 118 | case Connman.TechnologyState.CONNECTED: |
543 | 119 | device_editable = true; | 119 | device_editable = true; |
544 | 120 | settings_editable = true; | 120 | settings_editable = true; |
545 | 121 | toggleswitch_state = true; | 121 | toggleswitch_state = true; |
546 | 122 | status_text = ("Wi-fi is on and connected to the Internet."); | 122 | status_text = ("Wi-fi is on and connected to the Internet."); |
547 | 123 | break; | 123 | break; |
550 | 124 | case DeviceState.OFF: | 124 | case Connman.TechnologyState.AVAILABLE: |
551 | 125 | device_editable = false; | 125 | device_editable = true; |
552 | 126 | settings_editable = false; | 126 | settings_editable = false; |
553 | 127 | toggleswitch_state = false; | 127 | toggleswitch_state = false; |
554 | 128 | status_text = ("The Wi-fi device is powered off."); | 128 | status_text = ("The Wi-fi device is powered off."); |
555 | 129 | break; | 129 | break; |
557 | 130 | case DeviceState.OFFLINE: | 130 | case Connman.TechnologyState.OFFLINE: |
558 | 131 | device_editable = true; | 131 | device_editable = true; |
559 | 132 | settings_editable = false; | 132 | settings_editable = false; |
560 | 133 | toggleswitch_state = false; | 133 | toggleswitch_state = false; |
561 | @@ -150,15 +150,15 @@ | |||
562 | 150 | liststore.add_service(service, name, signal, last_used); | 150 | liststore.add_service(service, name, signal, last_used); |
563 | 151 | } | 151 | } |
564 | 152 | 152 | ||
567 | 153 | public override void on_device_state_changed(ParamSpec p) { | 153 | private void wifi_state_changed(ParamSpec p) { |
568 | 154 | this.update_widget_states(this.device.state); | 154 | this.update_widget_states(this.connman.get_wifi_state()); |
569 | 155 | } | 155 | } |
570 | 156 | 156 | ||
571 | 157 | private void on_toggleswitch_toggled() { | 157 | private void on_toggleswitch_toggled() { |
572 | 158 | if (this.toggleswitch.get_active()) { | 158 | if (this.toggleswitch.get_active()) { |
574 | 159 | this.device.state = DeviceState.CONNECTED; | 159 | this.connman.enable_technology(Connman.TechnologyType.WIFI, null); |
575 | 160 | } else { | 160 | } else { |
577 | 161 | this.device.state = DeviceState.OFFLINE; | 161 | this.connman.disable_technology(Connman.TechnologyType.WIFI, null); |
578 | 162 | } | 162 | } |
579 | 163 | } | 163 | } |
580 | 164 | 164 |
This all looks great Kalle!
Just one small issue, FligthModeDevice should be FlightModeDevice :) The fact that this is the only issue is a credit to your work!