Merge lp:~donadigo/switchboard-plug-networking/various-fixes into lp:~elementary-pantheon/switchboard-plug-networking/trunk

Proposed by Adam Bieńkowski
Status: Merged
Merged at revision: 172
Proposed branch: lp:~donadigo/switchboard-plug-networking/various-fixes
Merge into: lp:~elementary-pantheon/switchboard-plug-networking/trunk
Diff against target: 149 lines (+23/-22)
4 files modified
src/Plug.vala (+14/-6)
src/Utils.vala (+0/-10)
src/Widgets/DeviceList.vala (+6/-5)
src/common/Widgets/AbstractWifiInterface.vala (+3/-1)
To merge this branch: bzr merge lp:~donadigo/switchboard-plug-networking/various-fixes
Reviewer Review Type Date Requested Status
elementary Pantheon team Pending
Review via email: mp+275423@code.launchpad.net

Commit message

* Fixes bug #1508376.
* Fixes bug #1508378.
* Fixes bug #1508373.
* Fixes bug #1508372.

* Fixes: Wireless item variable wasn't decreased on removing Wifi device.

Description of the change

The branch contains few important fixes for UI:
* Fixes bug #1508376. Removes most of the warnings.
* Fixes bug #1508378. As this method was used only one time, it got completely removed and replaced with native solution.
* Fixes bug #1508373. Make device list insenitive when in ariplane mode.
* Fixes bug #1508372. Inteligently select items on removing devices rather than selecting first item.

* Fixes: Wireless item variable wasn't decreased on removing Wifi device which was resulting in having only one device displaying e.g: "Wireless 3"

To post a comment you must log in.
172. By Adam Bieńkowski

Removed unused method

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-10-20 20:34:36 +0000
+++ src/Plug.vala 2015-10-22 17:10:36 +0000
@@ -21,7 +21,7 @@
21 */21 */
2222
23/* Main client instance */23/* Main client instance */
24static NM.Client client;24NM.Client client;
2525
26/* Proxy settings */26/* Proxy settings */
27Network.ProxySettings proxy_settings;27Network.ProxySettings proxy_settings;
@@ -45,7 +45,6 @@
45 private Widgets.Footer footer; 45 private Widgets.Footer footer;
46 private Widgets.InfoScreen no_devices;46 private Widgets.InfoScreen no_devices;
4747
48
49 protected override void add_interface (WidgetNMInterface widget_interface) {48 protected override void add_interface (WidgetNMInterface widget_interface) {
50 device_list.add_device_to_list (widget_interface);49 device_list.add_device_to_list (widget_interface);
5150
@@ -55,9 +54,17 @@
5554
56 protected override void remove_interface (WidgetNMInterface widget_interface) {55 protected override void remove_interface (WidgetNMInterface widget_interface) {
57 device_list.remove_device_from_list (widget_interface.device);56 device_list.remove_device_from_list (widget_interface.device);
57 if (content.get_visible_child () == widget_interface) {
58 int index = device_list.get_selected_row ().get_index ();
59 if (index >= 0) {
60 device_list.get_row_at_index (index).activate ();
61 } else {
62 select_first ();
63 }
64 }
65
58 content.remove (widget_interface);66 content.remove (widget_interface);
59 67
60 select_first ();
61 show_all ();68 show_all ();
62 }69 }
6370
@@ -114,11 +121,11 @@
114 /* Main function to connect all the signals */121 /* Main function to connect all the signals */
115 private void connect_signals () {122 private void connect_signals () {
116 device_list.row_activated.connect ((row) => {123 device_list.row_activated.connect ((row) => {
117 if (!Utils.list_contains (content.get_children (), ((Widgets.DeviceItem) row).page)) {124 if (content.get_children ().find (((Widgets.DeviceItem)row).page) == null) {
118 content.add (((Widgets.DeviceItem) row).page);125 content.add (((Widgets.DeviceItem) row).page);
119 }126 }
120127
121 content.visible_child = ((Widgets.DeviceItem) row).page;128 content.visible_child = ((Widgets.DeviceItem)row).page;
122 });129 });
123 130
124 device_list.show_no_devices.connect ((show) => {131 device_list.show_no_devices.connect ((show) => {
@@ -132,6 +139,7 @@
132 });139 });
133140
134 client.notify["networking-enabled"].connect (() => {141 client.notify["networking-enabled"].connect (() => {
142 device_list.sensitive = client.networking_get_enabled ();
135 if (client.networking_get_enabled ()) {143 if (client.networking_get_enabled ()) {
136 device_list.select_first_item ();144 device_list.select_first_item ();
137 } else {145 } else {
138146
=== modified file 'src/Utils.vala'
--- src/Utils.vala 2015-10-20 20:34:36 +0000
+++ src/Utils.vala 2015-10-22 17:10:36 +0000
@@ -15,16 +15,6 @@
15 return details_btn;15 return details_btn;
16 }16 }
17 17
18 public bool list_contains (List list, List.G data) {
19 foreach (var unit in list.copy ()) {
20 if (unit == data) {
21 return true;
22 }
23 }
24
25 return false;
26 }
27
28 public string state_to_string (NM.DeviceState state) {18 public string state_to_string (NM.DeviceState state) {
29 switch (state) {19 switch (state) {
30 case NM.DeviceState.ACTIVATED:20 case NM.DeviceState.ACTIVATED:
3121
=== modified file 'src/Widgets/DeviceList.vala'
--- src/Widgets/DeviceList.vala 2015-10-20 20:34:36 +0000
+++ src/Widgets/DeviceList.vala 2015-10-22 17:10:36 +0000
@@ -25,14 +25,13 @@
25 public signal void show_no_devices (bool show);25 public signal void show_no_devices (bool show);
26 26
27 public NM.Client client;27 public NM.Client client;
28 public DeviceItem wifi = null;
29 public DeviceItem proxy;
3028
31 private List<DeviceItem> items;29 private List<DeviceItem> items;
32 private DeviceItem item;30 private DeviceItem item;
3331
34 private Gtk.Label settings_l;32 private Gtk.Label settings_l;
35 private Gtk.Label devices_l;33 private Gtk.Label devices_l;
34 private DeviceItem proxy;
3635
37 private int wireless_item = 0;36 private int wireless_item = 0;
3837
@@ -56,7 +55,6 @@
56 this.add_proxy ();55 this.add_proxy ();
57 }56 }
5857
59
60 public void add_device_to_list (WidgetNMInterface iface) {58 public void add_device_to_list (WidgetNMInterface iface) {
61 if (iface.device.get_device_type () == NM.DeviceType.WIFI) {59 if (iface.device.get_device_type () == NM.DeviceType.WIFI) {
62 string title = _("Wireless");60 string title = _("Wireless");
@@ -94,10 +92,12 @@
94 }92 }
9593
96 public void remove_row_from_list (DeviceItem item) {94 public void remove_row_from_list (DeviceItem item) {
95 if (item.device.get_device_type () == NM.DeviceType.WIFI && wireless_item > 0) {
96 wireless_item--;
97 }
98
97 items.remove (item);99 items.remove (item);
98
99 this.remove (item);100 this.remove (item);
100 this.select_row (this.get_row_at_index (0));
101 }101 }
102102
103 private void add_proxy () {103 private void add_proxy () {
@@ -106,6 +106,7 @@
106 proxy.type = Utils.ItemType.PROXY;106 proxy.type = Utils.ItemType.PROXY;
107 this.add (proxy);107 this.add (proxy);
108 }108 }
109
109 public void select_first_item () {110 public void select_first_item () {
110 this.get_row_at_index (0).activate ();111 this.get_row_at_index (0).activate ();
111 } 112 }
112113
=== modified file 'src/common/Widgets/AbstractWifiInterface.vala'
--- src/common/Widgets/AbstractWifiInterface.vala 2015-08-11 22:35:35 +0000
+++ src/common/Widgets/AbstractWifiInterface.vala 2015-10-22 17:10:36 +0000
@@ -105,7 +105,9 @@
105 wifi_device.state_changed.connect (update);105 wifi_device.state_changed.connect (update);
106 106
107 var aps = wifi_device.get_access_points ();107 var aps = wifi_device.get_access_points ();
108 aps.foreach(access_point_added_cb);108 if (aps != null && aps.length > 0) {
109 aps.foreach(access_point_added_cb);
110 }
109111
110 update();112 update();
111 }113 }

Subscribers

People subscribed via source and target branches

to all changes: