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
=== modified file 'src/Plug.vala'
--- src/Plug.vala 2015-07-30 20:10:55 +0000
+++ src/Plug.vala 2015-08-01 11:43:57 +0000
@@ -42,13 +42,11 @@
42 private Gtk.Grid? main_grid = null;42 private Gtk.Grid? main_grid = null;
43 private Gtk.Stack content;43 private Gtk.Stack content;
44 private Gtk.ScrolledWindow scrolled_window;44 private Gtk.ScrolledWindow scrolled_window;
45 private Widgets.DevicePage page;45 private Widgets.Page page;
46 private Widgets.DeviceList device_list;46 private Widgets.DeviceList device_list;
47 private Widgets.Footer footer; 47 private Widgets.Footer footer;
48 private Widgets.InfoScreen no_devices;48 private Widgets.InfoScreen no_devices;
4949
50 private uint8 wifi_page_id = 0;
51
52 public Plug () {50 public Plug () {
53 Object (category: Category.NETWORK,51 Object (category: Category.NETWORK,
54 code_name: Build.PLUGCODENAME,52 code_name: Build.PLUGCODENAME,
@@ -96,8 +94,6 @@
96 paned.pack2 (content, true, true);94 paned.pack2 (content, true, true);
97 paned.set_position (240);95 paned.set_position (240);
9896
99 device_list.wifi_device_detected.connect (setup_wifi_page);
100
101 device_list.init ();97 device_list.init ();
102 connect_signals ();98 connect_signals ();
103 device_list.select_first_item ();99 device_list.select_first_item ();
@@ -110,31 +106,6 @@
110 return main_grid;106 return main_grid;
111 }107 }
112108
113 private void setup_wifi_page (NM.DeviceWifi? device) {
114 device_list.create_wifi_entry ();
115
116 var wifi_page = new Widgets.WiFiPage (device as NM.DeviceWifi);
117 wifi_page.list_connections ();
118
119 string string_id = "wifi-page-%i".printf (wifi_page_id);
120 content.add_named (wifi_page, string_id);
121
122 update_wifi_status ();
123 client.notify["wireless-enabled"].connect (() => {
124 update_wifi_status ();
125 wifi_page.info_box.info_changed ();
126 });
127
128 device_list.wifi.activate.connect (() => {
129 if (content.get_visible_child_name () != string_id)
130 content.set_visible_child (wifi_page);
131
132 current_device = null;
133 });
134
135 wifi_page_id++;
136 }
137
138 /* Main function to connect all the signals */109 /* Main function to connect all the signals */
139 private void connect_signals () {110 private void connect_signals () {
140 device_list.create_proxy_entry ();111 device_list.create_proxy_entry ();
@@ -158,7 +129,12 @@
158129
159 device_list.row_changed.connect ((row) => {130 device_list.row_changed.connect ((row) => {
160 if ((row as Widgets.DeviceItem).get_item_device () != current_device) {131 if ((row as Widgets.DeviceItem).get_item_device () != current_device) {
161 page = new Widgets.DevicePage.from_owner (row as Widgets.DeviceItem); 132 if ((row as Widgets.DeviceItem).get_item_device ().get_device_type () == NM.DeviceType.WIFI) {
133 page = new Widgets.WiFiPage (((Widgets.DeviceItem) row));
134 } else {
135 page = new Widgets.DevicePage.from_owner (row as Widgets.DeviceItem);
136 }
137
162 content.add (page);138 content.add (page);
163 content.set_visible_child (page);139 content.set_visible_child (page);
164 140
@@ -198,14 +174,6 @@
198 });174 });
199 }175 }
200176
201 private void update_wifi_status () {
202 if (client.wireless_get_enabled ()) {
203 device_list.wifi.switch_status (null, "wifi-enabled");
204 } else {
205 device_list.wifi.switch_status (null, "wifi-disabled");
206 }
207 }
208
209 private void show_error_dialog () {177 private void show_error_dialog () {
210 var error_dialog = new Gtk.MessageDialog (null, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, " ");178 var error_dialog = new Gtk.MessageDialog (null, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, " ");
211 error_dialog.text = _("Could not enable device: there are no available179 error_dialog.text = _("Could not enable device: there are no available
212180
=== modified file 'src/Widgets/Device/DeviceItem.vala'
--- src/Widgets/Device/DeviceItem.vala 2015-07-23 21:29:23 +0000
+++ src/Widgets/Device/DeviceItem.vala 2015-08-01 11:43:57 +0000
@@ -44,10 +44,19 @@
44 create_ui (icon_name);44 create_ui (icon_name);
45 }45 }
4646
47 public DeviceItem.from_device (NM.Device _device, string _icon_name = "network-wired", bool _special = false) {47 public DeviceItem.from_device (NM.Device _device,
48 string _icon_name = "network-wired",
49 bool _special = false,
50 string _title = "") {
48 this.special = _special;51 this.special = _special;
49 this.device = _device;52 this.device = _device;
50 this.title = Utils.type_to_string (device.get_device_type ());53
54 if (_title != "") {
55 this.title = _title;
56 } else {
57 this.title = Utils.type_to_string (device.get_device_type ());
58 }
59
51 this.subtitle = "";60 this.subtitle = "";
52 this.icon_name = _icon_name;61 this.icon_name = _icon_name;
5362
@@ -148,14 +157,6 @@
148 row_description.label = _("Enabled (auto mode)");157 row_description.label = _("Enabled (auto mode)");
149 status_image.icon_name = "user-available";158 status_image.icon_name = "user-available";
150 break;159 break;
151 case "wifi-enabled":
152 row_description.label = _("Enabled");
153 status_image.icon_name = "user-available";
154 break;
155 case "wifi-disabled":
156 row_description.label = _("Disabled");
157 status_image.icon_name = "user-busy";
158 break;
159 }160 }
160 }161 }
161162
162163
=== modified file 'src/Widgets/DeviceList.vala'
--- src/Widgets/DeviceList.vala 2015-07-22 20:52:07 +0000
+++ src/Widgets/DeviceList.vala 2015-08-01 11:43:57 +0000
@@ -24,7 +24,6 @@
24 public class DeviceList : Gtk.ListBox {24 public class DeviceList : Gtk.ListBox {
25 public signal void row_changed (Gtk.ListBoxRow row);25 public signal void row_changed (Gtk.ListBoxRow row);
26 public signal void show_no_devices (bool show);26 public signal void show_no_devices (bool show);
27 public signal void wifi_device_detected (NM.DeviceWifi? d);
28 27
29 public NM.Client client;28 public NM.Client client;
30 public DeviceItem wifi = null;29 public DeviceItem wifi = null;
@@ -37,6 +36,8 @@
37 private Gtk.Label settings_l;36 private Gtk.Label settings_l;
38 private Gtk.Label devices_l;37 private Gtk.Label devices_l;
3938
39 private int wireless_item = 0;
40
40 public DeviceList (NM.Client _client) {41 public DeviceList (NM.Client _client) {
41 this.selection_mode = Gtk.SelectionMode.SINGLE;42 this.selection_mode = Gtk.SelectionMode.SINGLE;
42 this.activate_on_single_click = true; 43 this.activate_on_single_click = true;
@@ -112,7 +113,15 @@
112113
113 private void add_device_to_list (NM.Device device) {114 private void add_device_to_list (NM.Device device) {
114 if (device.get_device_type () == NM.DeviceType.WIFI) {115 if (device.get_device_type () == NM.DeviceType.WIFI) {
115 this.wifi_device_detected (device as NM.DeviceWifi);116 string title = _("Wireless");
117 if (wireless_item > 0) {
118 title += " " + wireless_item.to_string ();
119 }
120
121 item = new DeviceItem.from_device (device, "network-wireless", false, title);
122 items.append (item);
123 this.add (item);
124 wireless_item++;
116 return;125 return;
117 }126 }
118127
@@ -144,12 +153,6 @@
144 items = new_items.copy ();153 items = new_items.copy ();
145 }154 }
146155
147 public void create_wifi_entry () {
148 wifi = new DeviceItem (_("Wireless"), "", "network-wireless");
149 items.append (wifi);
150 this.add (wifi);
151 }
152
153 public void create_proxy_entry () {156 public void create_proxy_entry () {
154 proxy = new DeviceItem (_("Proxy"), "", "preferences-system-network", true);157 proxy = new DeviceItem (_("Proxy"), "", "preferences-system-network", true);
155 this.add (proxy); 158 this.add (proxy);
156159
=== modified file 'src/Widgets/WiFi/WiFiPage.vala'
--- src/Widgets/WiFi/WiFiPage.vala 2015-07-24 17:42:48 +0000
+++ src/Widgets/WiFi/WiFiPage.vala 2015-08-01 11:43:57 +0000
@@ -32,12 +32,12 @@
32 /* When access point added insert is on top */32 /* When access point added insert is on top */
33 private bool insert_on_top = true;33 private bool insert_on_top = true;
3434
35 public WiFiPage (NM.DeviceWifi? wifidevice) {35 public WiFiPage (DeviceItem owner) {
36 this.device = wifidevice;36 this.device = ((NM.DeviceWifi) owner.get_item_device ());
37 this.icon_name = "network-wireless";37 this.icon_name = "network-wireless";
38 this.title = _("Wi-Fi Network");38 this.title = _("Wi-Fi Network");
39 info_box = new InfoBox.from_device (device);39 info_box = new InfoBox.from_owner (owner);
40 this.init (wifidevice, info_box);40 this.init (device, info_box);
4141
42 entries = new List<WiFiEntry> ();42 entries = new List<WiFiEntry> ();
4343

Subscribers

People subscribed via source and target branches

to all changes: