Merge lp:~donadigo/switchboard-plug-networking/wifi-page-status into lp:~elementary-pantheon/switchboard-plug-networking/trunk

Proposed by Adam Bieńkowski
Status: Rejected
Rejected by: Adam Bieńkowski
Proposed branch: lp:~donadigo/switchboard-plug-networking/wifi-page-status
Merge into: lp:~elementary-pantheon/switchboard-plug-networking/trunk
Diff against target: 200 lines (+33/-61)
4 files modified
src/Plug.vala (+7/-39)
src/Widgets/Device/DeviceItem.vala (+11/-10)
src/Widgets/DeviceList.vala (+11/-8)
src/Widgets/WiFi/WiFiPage.vala (+4/-4)
To merge this branch: bzr merge lp:~donadigo/switchboard-plug-networking/wifi-page-status
Reviewer Review Type Date Requested Status
Danielle Foré Pending
Review via email: mp+266648@code.launchpad.net

Description of the change

This branch fixes the bug #1479940. Wifi item now uses status from wifi page instead of enable / disable states. This needed some code refactoring from the ground because of how currently the wifi page is created in the plug.

To post a comment you must log in.
Revision history for this message
Adam Bieńkowski (donadigo) wrote :

The branch will no longer be merged to the trunk as of the new branch that has merged this one.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Plug.vala'
2--- src/Plug.vala 2015-07-30 20:10:55 +0000
3+++ src/Plug.vala 2015-08-01 11:43:57 +0000
4@@ -42,13 +42,11 @@
5 private Gtk.Grid? main_grid = null;
6 private Gtk.Stack content;
7 private Gtk.ScrolledWindow scrolled_window;
8- private Widgets.DevicePage page;
9+ private Widgets.Page page;
10 private Widgets.DeviceList device_list;
11 private Widgets.Footer footer;
12 private Widgets.InfoScreen no_devices;
13
14- private uint8 wifi_page_id = 0;
15-
16 public Plug () {
17 Object (category: Category.NETWORK,
18 code_name: Build.PLUGCODENAME,
19@@ -96,8 +94,6 @@
20 paned.pack2 (content, true, true);
21 paned.set_position (240);
22
23- device_list.wifi_device_detected.connect (setup_wifi_page);
24-
25 device_list.init ();
26 connect_signals ();
27 device_list.select_first_item ();
28@@ -110,31 +106,6 @@
29 return main_grid;
30 }
31
32- private void setup_wifi_page (NM.DeviceWifi? device) {
33- device_list.create_wifi_entry ();
34-
35- var wifi_page = new Widgets.WiFiPage (device as NM.DeviceWifi);
36- wifi_page.list_connections ();
37-
38- string string_id = "wifi-page-%i".printf (wifi_page_id);
39- content.add_named (wifi_page, string_id);
40-
41- update_wifi_status ();
42- client.notify["wireless-enabled"].connect (() => {
43- update_wifi_status ();
44- wifi_page.info_box.info_changed ();
45- });
46-
47- device_list.wifi.activate.connect (() => {
48- if (content.get_visible_child_name () != string_id)
49- content.set_visible_child (wifi_page);
50-
51- current_device = null;
52- });
53-
54- wifi_page_id++;
55- }
56-
57 /* Main function to connect all the signals */
58 private void connect_signals () {
59 device_list.create_proxy_entry ();
60@@ -158,7 +129,12 @@
61
62 device_list.row_changed.connect ((row) => {
63 if ((row as Widgets.DeviceItem).get_item_device () != current_device) {
64- page = new Widgets.DevicePage.from_owner (row as Widgets.DeviceItem);
65+ if ((row as Widgets.DeviceItem).get_item_device ().get_device_type () == NM.DeviceType.WIFI) {
66+ page = new Widgets.WiFiPage (((Widgets.DeviceItem) row));
67+ } else {
68+ page = new Widgets.DevicePage.from_owner (row as Widgets.DeviceItem);
69+ }
70+
71 content.add (page);
72 content.set_visible_child (page);
73
74@@ -198,14 +174,6 @@
75 });
76 }
77
78- private void update_wifi_status () {
79- if (client.wireless_get_enabled ()) {
80- device_list.wifi.switch_status (null, "wifi-enabled");
81- } else {
82- device_list.wifi.switch_status (null, "wifi-disabled");
83- }
84- }
85-
86 private void show_error_dialog () {
87 var error_dialog = new Gtk.MessageDialog (null, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, " ");
88 error_dialog.text = _("Could not enable device: there are no available
89
90=== modified file 'src/Widgets/Device/DeviceItem.vala'
91--- src/Widgets/Device/DeviceItem.vala 2015-07-23 21:29:23 +0000
92+++ src/Widgets/Device/DeviceItem.vala 2015-08-01 11:43:57 +0000
93@@ -44,10 +44,19 @@
94 create_ui (icon_name);
95 }
96
97- public DeviceItem.from_device (NM.Device _device, string _icon_name = "network-wired", bool _special = false) {
98+ public DeviceItem.from_device (NM.Device _device,
99+ string _icon_name = "network-wired",
100+ bool _special = false,
101+ string _title = "") {
102 this.special = _special;
103 this.device = _device;
104- this.title = Utils.type_to_string (device.get_device_type ());
105+
106+ if (_title != "") {
107+ this.title = _title;
108+ } else {
109+ this.title = Utils.type_to_string (device.get_device_type ());
110+ }
111+
112 this.subtitle = "";
113 this.icon_name = _icon_name;
114
115@@ -148,14 +157,6 @@
116 row_description.label = _("Enabled (auto mode)");
117 status_image.icon_name = "user-available";
118 break;
119- case "wifi-enabled":
120- row_description.label = _("Enabled");
121- status_image.icon_name = "user-available";
122- break;
123- case "wifi-disabled":
124- row_description.label = _("Disabled");
125- status_image.icon_name = "user-busy";
126- break;
127 }
128 }
129
130
131=== modified file 'src/Widgets/DeviceList.vala'
132--- src/Widgets/DeviceList.vala 2015-07-22 20:52:07 +0000
133+++ src/Widgets/DeviceList.vala 2015-08-01 11:43:57 +0000
134@@ -24,7 +24,6 @@
135 public class DeviceList : Gtk.ListBox {
136 public signal void row_changed (Gtk.ListBoxRow row);
137 public signal void show_no_devices (bool show);
138- public signal void wifi_device_detected (NM.DeviceWifi? d);
139
140 public NM.Client client;
141 public DeviceItem wifi = null;
142@@ -37,6 +36,8 @@
143 private Gtk.Label settings_l;
144 private Gtk.Label devices_l;
145
146+ private int wireless_item = 0;
147+
148 public DeviceList (NM.Client _client) {
149 this.selection_mode = Gtk.SelectionMode.SINGLE;
150 this.activate_on_single_click = true;
151@@ -112,7 +113,15 @@
152
153 private void add_device_to_list (NM.Device device) {
154 if (device.get_device_type () == NM.DeviceType.WIFI) {
155- this.wifi_device_detected (device as NM.DeviceWifi);
156+ string title = _("Wireless");
157+ if (wireless_item > 0) {
158+ title += " " + wireless_item.to_string ();
159+ }
160+
161+ item = new DeviceItem.from_device (device, "network-wireless", false, title);
162+ items.append (item);
163+ this.add (item);
164+ wireless_item++;
165 return;
166 }
167
168@@ -144,12 +153,6 @@
169 items = new_items.copy ();
170 }
171
172- public void create_wifi_entry () {
173- wifi = new DeviceItem (_("Wireless"), "", "network-wireless");
174- items.append (wifi);
175- this.add (wifi);
176- }
177-
178 public void create_proxy_entry () {
179 proxy = new DeviceItem (_("Proxy"), "", "preferences-system-network", true);
180 this.add (proxy);
181
182=== modified file 'src/Widgets/WiFi/WiFiPage.vala'
183--- src/Widgets/WiFi/WiFiPage.vala 2015-07-24 17:42:48 +0000
184+++ src/Widgets/WiFi/WiFiPage.vala 2015-08-01 11:43:57 +0000
185@@ -32,12 +32,12 @@
186 /* When access point added insert is on top */
187 private bool insert_on_top = true;
188
189- public WiFiPage (NM.DeviceWifi? wifidevice) {
190- this.device = wifidevice;
191+ public WiFiPage (DeviceItem owner) {
192+ this.device = ((NM.DeviceWifi) owner.get_item_device ());
193 this.icon_name = "network-wireless";
194 this.title = _("Wi-Fi Network");
195- info_box = new InfoBox.from_device (device);
196- this.init (wifidevice, info_box);
197+ info_box = new InfoBox.from_owner (owner);
198+ this.init (device, info_box);
199
200 entries = new List<WiFiEntry> ();
201

Subscribers

People subscribed via source and target branches

to all changes: