Merge lp:~renatofilho/indicator-server/device-switch into lp:indicator-server

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Mathieu Trudel-Lapierre
Approved revision: 235
Merged at revision: 233
Proposed branch: lp:~renatofilho/indicator-server/device-switch
Merge into: lp:indicator-server
Diff against target: 87 lines (+44/-2)
2 files modified
network/network-action-manager.vala (+24/-2)
network/network-menu.vala (+20/-0)
To merge this branch: bzr merge lp:~renatofilho/indicator-server/device-switch
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+166300@code.launchpad.net

Commit message

Implemented device switch on/off for wifi and mobile data

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
234. By Renato Araujo Oliveira Filho

Renamed Wireless title.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
235. By Renato Araujo Oliveira Filho

Fixed code style.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

Waiting for driver fixes before merge this.

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Approve, looks good to me, works after fixing for changes in gmenumodel.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'network/network-action-manager.vala'
2--- network/network-action-manager.vala 2013-02-20 19:40:31 +0000
3+++ network/network-action-manager.vala 2013-05-30 14:37:27 +0000
4@@ -319,8 +319,17 @@
5
6 private void bootstrap_actions ()
7 {
8- //TODO: Airplane mode action
9- //TODO: Wifi enabled/disabled action
10+ var wireless_enabled = new SimpleAction.stateful ("WirelessEnabled",
11+ VariantType.BOOLEAN,
12+ new Variant.boolean (client.wireless_get_enabled()));
13+ app.add_action (wireless_enabled);
14+ wireless_enabled.change_state.connect(on_device_enabled);
15+
16+ var mobile_data_enabled = new SimpleAction.stateful ("WwanEnabled",
17+ VariantType.BOOLEAN,
18+ new Variant.boolean (client.wwan_get_enabled()));
19+ app.add_action (mobile_data_enabled);
20+ mobile_data_enabled.change_state.connect(on_device_enabled);
21
22 client.device_added.connect ((client, device) => {add_device (device);});
23 client.device_removed.connect ((client, device) => {remove_device (device);});
24@@ -337,6 +346,19 @@
25 }
26 }
27
28+ private void on_device_enabled(SimpleAction ac, Variant? val)
29+ {
30+ if (ac.name == "WirelessEnabled")
31+ {
32+ client.wireless_set_enabled (val.get_boolean());
33+ }
34+ else if (ac.name == "WwanEnabled")
35+ {
36+ client.wwan_set_enabled (val.get_boolean());
37+ }
38+ ac.set_state (val.get_boolean());
39+ }
40+
41 private void add_network_status_action ()
42 {
43 /* This is the action that represents the global status of the network.
44
45=== modified file 'network/network-menu.vala'
46--- network/network-menu.vala 2013-02-20 19:40:31 +0000
47+++ network/network-menu.vala 2013-05-30 14:37:27 +0000
48@@ -280,6 +280,7 @@
49 {
50 private Menu root_menu;
51 private MenuItem root_item;
52+ private Menu devices_switch;
53 private Menu gmenu;
54 private NM.Client client;
55 private ActionManager am;
56@@ -314,6 +315,7 @@
57 private void bootstrap_menu ()
58 {
59 root_menu = new Menu ();
60+ devices_switch = new Menu ();
61 gmenu = new Menu ();
62 am = new ActionManager (this, client);
63
64@@ -321,6 +323,24 @@
65 root_item.set_attribute (GLib.Menu.ATTRIBUTE_ACTION, "s", "network-status");
66 root_item.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.root.network");
67 root_menu.append_item (root_item);
68+
69+ // switch
70+ gmenu.insert_section(0, "Devices", devices_switch);
71+ if (client.wireless_hardware_get_enabled())
72+ {
73+ MenuItem wireless_switch = new MenuItem("Wi-Fi", "");
74+ wireless_switch.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.switch");
75+ wireless_switch.set_attribute ("action", "s", "WirelessEnabled");
76+ devices_switch.append_item (wireless_switch);
77+ }
78+
79+ if (client.wwan_hardware_get_enabled())
80+ {
81+ MenuItem mobile_data_switch = new MenuItem("Mobile data", "");
82+ mobile_data_switch.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.switch");
83+ mobile_data_switch.set_attribute ("action", "s", "WwanEnabled");
84+ devices_switch.append_item (mobile_data_switch);
85+ }
86
87 var devices = client.get_devices ();
88

Subscribers

People subscribed via source and target branches