Merge lp:~donadigo/switchboard-plug-networking/wifi-connected-on-top 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-connected-on-top
Merge into: lp:~elementary-pantheon/switchboard-plug-networking/trunk
Diff against target: 271 lines (+111/-31)
5 files modified
src/Utils.vala (+2/-2)
src/Widgets/Page.vala (+1/-1)
src/Widgets/WifiInterface.vala (+80/-18)
src/common/Widgets/AbstractWifiInterface.vala (+2/-1)
src/common/Widgets/WifiMenuItem.vala (+26/-9)
To merge this branch: bzr merge lp:~donadigo/switchboard-plug-networking/wifi-connected-on-top
Reviewer Review Type Date Requested Status
Adam Bieńkowski (community) Abstain
Danielle Foré ux Approve
xapantu code Pending
Review via email: mp+267189@code.launchpad.net

Commit message

* Fixes bug #1449669.
* Clean the code.

Description of the change

Fixes bug #1449669. Show the currently connected network at the top in SSID list, and some codestyle fixes. The branch can contain bugs so please point them out in the review if any.

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

Remove debug line and catch the css error

135. By Adam Bieńkowski

Visible not hardcoded

Revision history for this message
Danielle Foré (danrabbit) wrote :

Can we set "homogeneous" to true for the button box ;D

Also, can we get the spinner when connecting?

Other than those two things, I like it a lot! It looks nice. Nice animation. Buttons are more in-context. Good job :)

136. By Adam Bieńkowski

Button box homogeneous; show spinner when connecting

Revision history for this message
Danielle Foré (danrabbit) wrote :

Oops one more small thing. It looks like the entirety of the space isn't given back to the wifi list when there isn't a connection. What I mean is that the space that was reserved for padding in between the connected box and the wifi list should also go away so the wifi list can take advantage of that full empty space.

137. By Adam Bieńkowski

Hide revealer widget when it is no longer shown

138. By Adam Bieńkowski

Set page spacing to 0 and manually set margins

Revision history for this message
Danielle Foré (danrabbit) wrote :

Hey there we go! Lookin good. UX Approve :)

review: Approve (ux)
139. By Adam Bieńkowski

Update connected entry on update (); do not reparent widget; instead create new one

140. By Adam Bieńkowski

Merge trunk

141. By Adam Bieńkowski

Change protected to normal

Revision history for this message
Adam Bieńkowski (donadigo) wrote :

The branch was merged into another and is no longer needed.

review: Abstain

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Utils.vala'
--- src/Utils.vala 2015-06-23 17:19:30 +0000
+++ src/Utils.vala 2015-08-07 13:06:03 +0000
@@ -16,8 +16,8 @@
16 }16 }
17 }17 }
1818
19 public new Gtk.Button get_advanced_button_from_device (NM.Device? device) {19 public new Gtk.Button get_advanced_button_from_device (NM.Device? device, string title = _("Advanced Settings…")) {
20 var details_btn = new Gtk.Button.with_label (_("Advanced Settings…"));20 var details_btn = new Gtk.Button.with_label (title);
21 details_btn.clicked.connect (() => {21 details_btn.clicked.connect (() => {
22 new Granite.Services.SimpleCommand ("/usr/bin",22 new Granite.Services.SimpleCommand ("/usr/bin",
23 "nm-connection-editor --edit=" + device.get_active_connection ().get_uuid ()).run ();23 "nm-connection-editor --edit=" + device.get_active_connection ().get_uuid ()).run ();
2424
=== modified file 'src/Widgets/Page.vala'
--- src/Widgets/Page.vala 2015-08-04 19:59:12 +0000
+++ src/Widgets/Page.vala 2015-08-07 13:06:03 +0000
@@ -25,6 +25,7 @@
25 public NM.Device device;25 public NM.Device device;
26 public InfoBox info_box;26 public InfoBox info_box;
27 public Gtk.Switch control_switch;27 public Gtk.Switch control_switch;
28 public Gtk.Box control_box;
28 public signal void show_error ();29 public signal void show_error ();
2930
30 private string _icon_name; 31 private string _icon_name;
@@ -51,7 +52,6 @@
51 }52 }
52 }53 }
5354
54 private Gtk.Box control_box;
55 private Gtk.Image device_img;55 private Gtk.Image device_img;
56 private Gtk.Label device_label;56 private Gtk.Label device_label;
5757
5858
=== modified file 'src/Widgets/WifiInterface.vala'
--- src/Widgets/WifiInterface.vala 2015-08-06 20:43:28 +0000
+++ src/Widgets/WifiInterface.vala 2015-08-07 13:06:03 +0000
@@ -24,7 +24,12 @@
2424
25namespace Network {25namespace Network {
26 public class WifiInterface : AbstractWifiInterface {26 public class WifiInterface : AbstractWifiInterface {
27 27 protected Gtk.Frame connected_frame;
28 protected Gtk.Box? connected_box = null;
29 protected Gtk.Revealer top_revealer;
30 protected Gtk.Button disconnect_btn;
31 protected Gtk.Button settings_btn;
32
28 public WifiInterface (NM.Client client, NM.RemoteSettings settings, NM.Device device_) {33 public WifiInterface (NM.Client client, NM.RemoteSettings settings, NM.Device device_) {
29 info_box = new InfoBox.from_device (device_);34 info_box = new InfoBox.from_device (device_);
30 info_box.no_show_all = true;35 info_box.no_show_all = true;
@@ -34,30 +39,42 @@
3439
35 this.icon_name = "network-wireless";40 this.icon_name = "network-wireless";
36 this.title = _("Wi-Fi Network");41 this.title = _("Wi-Fi Network");
37 42 this.spacing = 0;
43
44 control_box.margin_bottom = 12;
45
38 wifi_list.selection_mode = Gtk.SelectionMode.SINGLE;46 wifi_list.selection_mode = Gtk.SelectionMode.SINGLE;
39 wifi_list.activate_on_single_click = false; 47 wifi_list.activate_on_single_click = false;
40 48
49 var css_provider = new Gtk.CssProvider ();
50 try {
51 css_provider.load_from_data ("GtkFrame {\nbackground: #ffffff;\n}", -1);
52 } catch (Error e) {
53 warning ("%s\n", e.message);
54 }
55
56 connected_frame = new Gtk.Frame (null);
57 connected_frame.get_style_context ().add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
58
59 top_revealer = new Gtk.Revealer ();
60 top_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN;
61 top_revealer.add (connected_frame);
62
41 var scrolled = new Gtk.ScrolledWindow (null, null);63 var scrolled = new Gtk.ScrolledWindow (null, null);
64 scrolled.margin_bottom = 24;
65 scrolled.margin_top = 12;
42 scrolled.add (wifi_list);66 scrolled.add (wifi_list);
43 scrolled.vexpand = true;67 scrolled.vexpand = true;
44 scrolled.shadow_type = Gtk.ShadowType.OUT;68 scrolled.shadow_type = Gtk.ShadowType.OUT;
4569
46 var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);70 var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
4771
48 var disconnect_btn = new Gtk.Button.with_label (_("Disconnect"));
49 disconnect_btn.sensitive = (device.get_state () == NM.DeviceState.ACTIVATED);
50 disconnect_btn.get_style_context ().add_class ("destructive-action");
51 disconnect_btn.clicked.connect (() => {
52 device.disconnect (null);
53 });
54
55 var advanced_btn = Utils.get_advanced_button_from_device (device);72 var advanced_btn = Utils.get_advanced_button_from_device (device);
56 advanced_btn.sensitive = (device.get_state () == NM.DeviceState.ACTIVATED);73 advanced_btn.sensitive = (device.get_state () == NM.DeviceState.ACTIVATED);
57 info_box.info_changed.connect (() => {74 info_box.info_changed.connect (() => {
58 bool sensitive = (device.get_state () == NM.DeviceState.ACTIVATED);75 bool sensitive = (device.get_state () == NM.DeviceState.ACTIVATED);
59 disconnect_btn.sensitive = sensitive;76 disconnect_btn.sensitive = sensitive;
60 advanced_btn.sensitive = sensitive;77 settings_btn.sensitive = sensitive;
61 78
62 update ();79 update ();
63 });80 });
@@ -69,14 +86,7 @@
69 hidden_dialog.run ();86 hidden_dialog.run ();
70 });87 });
7188
72 var end_btn_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
73 end_btn_box.homogeneous = true;
74 end_btn_box.halign = Gtk.Align.END;
75 end_btn_box.pack_end (disconnect_btn, true, true, 0);
76 end_btn_box.pack_end (advanced_btn, true, true, 0);
77
78 button_box.pack_start (hidden_btn, false, false, 0);89 button_box.pack_start (hidden_btn, false, false, 0);
79 button_box.pack_end (end_btn_box, false, false, 0);
8090
81 update ();91 update ();
8292
@@ -84,11 +94,17 @@
84 bottom_box.add (button_box);94 bottom_box.add (button_box);
8595
86 this.add_switch_title (_("Wireless:"));96 this.add_switch_title (_("Wireless:"));
97 this.add (top_revealer);
87 this.add (scrolled);98 this.add (scrolled);
88 this.add (bottom_revealer);99 this.add (bottom_revealer);
89 this.show_all (); 100 this.show_all ();
90 }101 }
91102
103 public override void update () {
104 update_connected_entry ();
105 base.update ();
106 }
107
92 protected override void update_switch () {108 protected override void update_switch () {
93 control_switch.active = !software_locked;109 control_switch.active = !software_locked;
94 }110 }
@@ -194,5 +210,51 @@
194 }210 }
195 });211 });
196 }212 }
213
214 private void update_connected_entry () {
215 top_revealer.set_reveal_child (wifi_device.get_active_access_point () != null);
216 if (active_wifi_item.ap != null && control_switch.get_active ()) {
217 active_wifi_item.no_show_all = false;
218 active_wifi_item.visible = true;
219 }
220
221 if (connected_frame != null && connected_frame.get_child () != null) {
222 connected_frame.get_child ().destroy ();
223 }
224
225 connected_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
226
227 if (wifi_device.get_active_access_point () != null) {
228 active_wifi_item.no_show_all = true;
229 active_wifi_item.visible = false;
230
231 var top_item = new WifiMenuItem (wifi_device.get_active_access_point (), null);
232 top_item.hide_icons ();
233 connected_box.add (top_item);
234
235 disconnect_btn = new Gtk.Button.with_label (_("Disconnect"));
236 disconnect_btn.sensitive = (device.get_state () == NM.DeviceState.ACTIVATED);
237 disconnect_btn.get_style_context ().add_class ("destructive-action");
238 disconnect_btn.clicked.connect (() => {
239 device.disconnect (null);
240 });
241
242 settings_btn = Utils.get_advanced_button_from_device (wifi_device, _("Settings…"));
243 settings_btn.sensitive = (device.get_state () == NM.DeviceState.ACTIVATED);
244
245 var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
246 button_box.homogeneous = true;
247 button_box.margin = 6;
248 button_box.pack_end (disconnect_btn);
249 button_box.pack_end (settings_btn);
250 button_box.show_all ();
251
252 connected_box.pack_end (button_box, false, false, 0);
253 connected_frame.add (connected_box);
254 }
255
256 connected_box.show_all ();
257 connected_frame.show_all ();
258 }
197 }259 }
198}260}
199261
=== modified file 'src/common/Widgets/AbstractWifiInterface.vala'
--- src/common/Widgets/AbstractWifiInterface.vala 2015-08-05 16:43:26 +0000
+++ src/common/Widgets/AbstractWifiInterface.vala 2015-08-07 13:06:03 +0000
@@ -25,7 +25,7 @@
25 protected NM.Client nm_client;25 protected NM.Client nm_client;
26 protected NM.RemoteSettings nm_settings;26 protected NM.RemoteSettings nm_settings;
27 27
28 protected WifiMenuItem? active_wifi_item = null;28 protected WifiMenuItem? active_wifi_item { get; set; }
29 protected WifiMenuItem? blank_item = null;29 protected WifiMenuItem? blank_item = null;
30 protected Gtk.Stack placeholder;30 protected Gtk.Stack placeholder;
3131
@@ -41,6 +41,7 @@
41 device = _device;41 device = _device;
42 wifi_device = device as NM.DeviceWifi;42 wifi_device = device as NM.DeviceWifi;
43 blank_item = new WifiMenuItem.blank ();43 blank_item = new WifiMenuItem.blank ();
44 active_wifi_item = null;
44 45
45 placeholder = new Gtk.Stack ();46 placeholder = new Gtk.Stack ();
46 placeholder.visible = true;47 placeholder.visible = true;
4748
=== modified file 'src/common/Widgets/WifiMenuItem.vala'
--- src/common/Widgets/WifiMenuItem.vala 2015-08-05 15:06:39 +0000
+++ src/common/Widgets/WifiMenuItem.vala 2015-08-07 13:06:03 +0000
@@ -42,6 +42,8 @@
42 }42 }
43 }43 }
4444
45 private bool show_icons = true;
46
45 public NM.AccessPoint ap { get { return _tmp_ap; } }47 public NM.AccessPoint ap { get { return _tmp_ap; } }
46 NM.AccessPoint _tmp_ap;48 NM.AccessPoint _tmp_ap;
4749
@@ -133,15 +135,21 @@
133 private void update () {135 private void update () {
134 radio_button.label = NM.Utils.ssid_to_utf8 (ap.get_ssid ());136 radio_button.label = NM.Utils.ssid_to_utf8 (ap.get_ssid ());
135137
136 img_strength.set_from_icon_name("network-wireless-signal-" + strength_to_string(strength) + "-symbolic", Gtk.IconSize.MENU);138#if PLUG_NETWORK
137 img_strength.show_all();139 if (show_icons) {
138140#endif
139 lock_img.visible = is_secured;141 img_strength.set_from_icon_name("network-wireless-signal-" + strength_to_string(strength) + "-symbolic", Gtk.IconSize.MENU);
140 set_lock_img_tooltip(ap.get_wpa_flags ());142 img_strength.show_all();
141 lock_img.no_show_all = !lock_img.visible;143
142144 lock_img.visible = is_secured;
143 hide_item(error_img);145 set_lock_img_tooltip(ap.get_wpa_flags ());
144 hide_item(spinner);146 lock_img.no_show_all = !lock_img.visible;
147
148 hide_item(error_img);
149 hide_item(spinner);
150#if PLUG_NETWORK
151 }
152#endif
145 switch (state) {153 switch (state) {
146 case State.FAILED_WIFI:154 case State.FAILED_WIFI:
147 show_item(error_img);155 show_item(error_img);
@@ -155,6 +163,15 @@
155 }163 }
156 }164 }
157165
166 public void hide_icons () {
167#if PLUG_NETWORK
168 show_icons = false;
169 hide_item (error_img);
170 hide_item (lock_img);
171 hide_item (img_strength);
172#endif
173 }
174
158 void show_item(Gtk.Widget w) {175 void show_item(Gtk.Widget w) {
159 w.visible = true;176 w.visible = true;
160 w.no_show_all = !w.visible;177 w.no_show_all = !w.visible;

Subscribers

People subscribed via source and target branches

to all changes: