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
1=== modified file 'src/Utils.vala'
2--- src/Utils.vala 2015-06-23 17:19:30 +0000
3+++ src/Utils.vala 2015-08-07 13:06:03 +0000
4@@ -16,8 +16,8 @@
5 }
6 }
7
8- public new Gtk.Button get_advanced_button_from_device (NM.Device? device) {
9- var details_btn = new Gtk.Button.with_label (_("Advanced Settings…"));
10+ public new Gtk.Button get_advanced_button_from_device (NM.Device? device, string title = _("Advanced Settings…")) {
11+ var details_btn = new Gtk.Button.with_label (title);
12 details_btn.clicked.connect (() => {
13 new Granite.Services.SimpleCommand ("/usr/bin",
14 "nm-connection-editor --edit=" + device.get_active_connection ().get_uuid ()).run ();
15
16=== modified file 'src/Widgets/Page.vala'
17--- src/Widgets/Page.vala 2015-08-04 19:59:12 +0000
18+++ src/Widgets/Page.vala 2015-08-07 13:06:03 +0000
19@@ -25,6 +25,7 @@
20 public NM.Device device;
21 public InfoBox info_box;
22 public Gtk.Switch control_switch;
23+ public Gtk.Box control_box;
24 public signal void show_error ();
25
26 private string _icon_name;
27@@ -51,7 +52,6 @@
28 }
29 }
30
31- private Gtk.Box control_box;
32 private Gtk.Image device_img;
33 private Gtk.Label device_label;
34
35
36=== modified file 'src/Widgets/WifiInterface.vala'
37--- src/Widgets/WifiInterface.vala 2015-08-06 20:43:28 +0000
38+++ src/Widgets/WifiInterface.vala 2015-08-07 13:06:03 +0000
39@@ -24,7 +24,12 @@
40
41 namespace Network {
42 public class WifiInterface : AbstractWifiInterface {
43-
44+ protected Gtk.Frame connected_frame;
45+ protected Gtk.Box? connected_box = null;
46+ protected Gtk.Revealer top_revealer;
47+ protected Gtk.Button disconnect_btn;
48+ protected Gtk.Button settings_btn;
49+
50 public WifiInterface (NM.Client client, NM.RemoteSettings settings, NM.Device device_) {
51 info_box = new InfoBox.from_device (device_);
52 info_box.no_show_all = true;
53@@ -34,30 +39,42 @@
54
55 this.icon_name = "network-wireless";
56 this.title = _("Wi-Fi Network");
57-
58+ this.spacing = 0;
59+
60+ control_box.margin_bottom = 12;
61+
62 wifi_list.selection_mode = Gtk.SelectionMode.SINGLE;
63 wifi_list.activate_on_single_click = false;
64-
65+
66+ var css_provider = new Gtk.CssProvider ();
67+ try {
68+ css_provider.load_from_data ("GtkFrame {\nbackground: #ffffff;\n}", -1);
69+ } catch (Error e) {
70+ warning ("%s\n", e.message);
71+ }
72+
73+ connected_frame = new Gtk.Frame (null);
74+ connected_frame.get_style_context ().add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
75+
76+ top_revealer = new Gtk.Revealer ();
77+ top_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN;
78+ top_revealer.add (connected_frame);
79+
80 var scrolled = new Gtk.ScrolledWindow (null, null);
81+ scrolled.margin_bottom = 24;
82+ scrolled.margin_top = 12;
83 scrolled.add (wifi_list);
84 scrolled.vexpand = true;
85 scrolled.shadow_type = Gtk.ShadowType.OUT;
86
87 var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
88
89- var disconnect_btn = new Gtk.Button.with_label (_("Disconnect"));
90- disconnect_btn.sensitive = (device.get_state () == NM.DeviceState.ACTIVATED);
91- disconnect_btn.get_style_context ().add_class ("destructive-action");
92- disconnect_btn.clicked.connect (() => {
93- device.disconnect (null);
94- });
95-
96 var advanced_btn = Utils.get_advanced_button_from_device (device);
97 advanced_btn.sensitive = (device.get_state () == NM.DeviceState.ACTIVATED);
98 info_box.info_changed.connect (() => {
99 bool sensitive = (device.get_state () == NM.DeviceState.ACTIVATED);
100 disconnect_btn.sensitive = sensitive;
101- advanced_btn.sensitive = sensitive;
102+ settings_btn.sensitive = sensitive;
103
104 update ();
105 });
106@@ -69,14 +86,7 @@
107 hidden_dialog.run ();
108 });
109
110- var end_btn_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
111- end_btn_box.homogeneous = true;
112- end_btn_box.halign = Gtk.Align.END;
113- end_btn_box.pack_end (disconnect_btn, true, true, 0);
114- end_btn_box.pack_end (advanced_btn, true, true, 0);
115-
116 button_box.pack_start (hidden_btn, false, false, 0);
117- button_box.pack_end (end_btn_box, false, false, 0);
118
119 update ();
120
121@@ -84,11 +94,17 @@
122 bottom_box.add (button_box);
123
124 this.add_switch_title (_("Wireless:"));
125+ this.add (top_revealer);
126 this.add (scrolled);
127 this.add (bottom_revealer);
128 this.show_all ();
129 }
130
131+ public override void update () {
132+ update_connected_entry ();
133+ base.update ();
134+ }
135+
136 protected override void update_switch () {
137 control_switch.active = !software_locked;
138 }
139@@ -194,5 +210,51 @@
140 }
141 });
142 }
143+
144+ private void update_connected_entry () {
145+ top_revealer.set_reveal_child (wifi_device.get_active_access_point () != null);
146+ if (active_wifi_item.ap != null && control_switch.get_active ()) {
147+ active_wifi_item.no_show_all = false;
148+ active_wifi_item.visible = true;
149+ }
150+
151+ if (connected_frame != null && connected_frame.get_child () != null) {
152+ connected_frame.get_child ().destroy ();
153+ }
154+
155+ connected_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
156+
157+ if (wifi_device.get_active_access_point () != null) {
158+ active_wifi_item.no_show_all = true;
159+ active_wifi_item.visible = false;
160+
161+ var top_item = new WifiMenuItem (wifi_device.get_active_access_point (), null);
162+ top_item.hide_icons ();
163+ connected_box.add (top_item);
164+
165+ disconnect_btn = new Gtk.Button.with_label (_("Disconnect"));
166+ disconnect_btn.sensitive = (device.get_state () == NM.DeviceState.ACTIVATED);
167+ disconnect_btn.get_style_context ().add_class ("destructive-action");
168+ disconnect_btn.clicked.connect (() => {
169+ device.disconnect (null);
170+ });
171+
172+ settings_btn = Utils.get_advanced_button_from_device (wifi_device, _("Settings…"));
173+ settings_btn.sensitive = (device.get_state () == NM.DeviceState.ACTIVATED);
174+
175+ var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
176+ button_box.homogeneous = true;
177+ button_box.margin = 6;
178+ button_box.pack_end (disconnect_btn);
179+ button_box.pack_end (settings_btn);
180+ button_box.show_all ();
181+
182+ connected_box.pack_end (button_box, false, false, 0);
183+ connected_frame.add (connected_box);
184+ }
185+
186+ connected_box.show_all ();
187+ connected_frame.show_all ();
188+ }
189 }
190 }
191
192=== modified file 'src/common/Widgets/AbstractWifiInterface.vala'
193--- src/common/Widgets/AbstractWifiInterface.vala 2015-08-05 16:43:26 +0000
194+++ src/common/Widgets/AbstractWifiInterface.vala 2015-08-07 13:06:03 +0000
195@@ -25,7 +25,7 @@
196 protected NM.Client nm_client;
197 protected NM.RemoteSettings nm_settings;
198
199- protected WifiMenuItem? active_wifi_item = null;
200+ protected WifiMenuItem? active_wifi_item { get; set; }
201 protected WifiMenuItem? blank_item = null;
202 protected Gtk.Stack placeholder;
203
204@@ -41,6 +41,7 @@
205 device = _device;
206 wifi_device = device as NM.DeviceWifi;
207 blank_item = new WifiMenuItem.blank ();
208+ active_wifi_item = null;
209
210 placeholder = new Gtk.Stack ();
211 placeholder.visible = true;
212
213=== modified file 'src/common/Widgets/WifiMenuItem.vala'
214--- src/common/Widgets/WifiMenuItem.vala 2015-08-05 15:06:39 +0000
215+++ src/common/Widgets/WifiMenuItem.vala 2015-08-07 13:06:03 +0000
216@@ -42,6 +42,8 @@
217 }
218 }
219
220+ private bool show_icons = true;
221+
222 public NM.AccessPoint ap { get { return _tmp_ap; } }
223 NM.AccessPoint _tmp_ap;
224
225@@ -133,15 +135,21 @@
226 private void update () {
227 radio_button.label = NM.Utils.ssid_to_utf8 (ap.get_ssid ());
228
229- img_strength.set_from_icon_name("network-wireless-signal-" + strength_to_string(strength) + "-symbolic", Gtk.IconSize.MENU);
230- img_strength.show_all();
231-
232- lock_img.visible = is_secured;
233- set_lock_img_tooltip(ap.get_wpa_flags ());
234- lock_img.no_show_all = !lock_img.visible;
235-
236- hide_item(error_img);
237- hide_item(spinner);
238+#if PLUG_NETWORK
239+ if (show_icons) {
240+#endif
241+ img_strength.set_from_icon_name("network-wireless-signal-" + strength_to_string(strength) + "-symbolic", Gtk.IconSize.MENU);
242+ img_strength.show_all();
243+
244+ lock_img.visible = is_secured;
245+ set_lock_img_tooltip(ap.get_wpa_flags ());
246+ lock_img.no_show_all = !lock_img.visible;
247+
248+ hide_item(error_img);
249+ hide_item(spinner);
250+#if PLUG_NETWORK
251+ }
252+#endif
253 switch (state) {
254 case State.FAILED_WIFI:
255 show_item(error_img);
256@@ -155,6 +163,15 @@
257 }
258 }
259
260+ public void hide_icons () {
261+#if PLUG_NETWORK
262+ show_icons = false;
263+ hide_item (error_img);
264+ hide_item (lock_img);
265+ hide_item (img_strength);
266+#endif
267+ }
268+
269 void show_item(Gtk.Widget w) {
270 w.visible = true;
271 w.no_show_all = !w.visible;

Subscribers

People subscribed via source and target branches

to all changes: