Merge lp:~xapantu/switchboard-plug-networking/several-interfaces into lp:~elementary-pantheon/switchboard-plug-networking/trunk

Proposed by xapantu
Status: Rejected
Rejected by: xapantu
Proposed branch: lp:~xapantu/switchboard-plug-networking/several-interfaces
Merge into: lp:~elementary-pantheon/switchboard-plug-networking/trunk
Diff against target: 375 lines (+141/-45)
11 files modified
src/CMakeLists.txt (+2/-0)
src/Widgets/Device/DeviceItem.vala (+12/-11)
src/Widgets/Device/DevicePage.vala (+2/-2)
src/Widgets/DeviceList.vala (+2/-14)
src/Widgets/EtherInterface.vala (+47/-0)
src/Widgets/Page.vala (+1/-13)
src/Widgets/WifiInterface.vala (+0/-1)
src/common/Widgets/AbstractEtherInterface.vala (+28/-0)
src/common/Widgets/AbstractWifiInterface.vala (+9/-0)
src/common/Widgets/NMVisualizer.vala (+24/-4)
src/common/Widgets/WidgetNMInterface.vala (+14/-0)
To merge this branch: bzr merge lp:~xapantu/switchboard-plug-networking/several-interfaces
Reviewer Review Type Date Requested Status
Adam Bieńkowski (community) Needs Fixing
Review via email: mp+276321@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Cody Garver (codygarver) wrote :

Did you forget to `bzr add` the file EtherInterface.vala?

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

I couldn't test it because of EtherInterface.vala file is not added to the branch. I've also made some inline comments.

review: Needs Fixing
174. By xapantu

Add EtherInterface

175. By xapantu

Use Unknown devices and make it translatable

Revision history for this message
xapantu (xapantu) wrote :

Just pushed fixes for both issues.

Revision history for this message
xapantu (xapantu) wrote :

Superseded by the hotspot branch, which needed 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/CMakeLists.txt'
2--- src/CMakeLists.txt 2015-08-01 23:06:00 +0000
3+++ src/CMakeLists.txt 2015-11-18 10:28:19 +0000
4@@ -21,6 +21,7 @@
5 Widgets/Device/DeviceItem.vala
6 Widgets/Device/DevicePage.vala
7 Widgets/WifiInterface.vala
8+ Widgets/EtherInterface.vala
9 Widgets/Proxy/ProxyConfigurationPage.vala
10 Widgets/Proxy/ProxyExceptionsPage.vala
11 Widgets/Proxy/ProxyPage.vala
12@@ -30,6 +31,7 @@
13 common/Utils.vala
14 common/Widgets/WifiMenuItem.vala
15 common/Widgets/AbstractWifiInterface.vala
16+ common/Widgets/AbstractEtherInterface.vala
17 common/rfkill.vala
18 common/Widgets/NMVisualizer.vala
19 common/Widgets/WidgetNMInterface.vala
20
21=== modified file 'src/Widgets/Device/DeviceItem.vala'
22--- src/Widgets/Device/DeviceItem.vala 2015-10-20 20:34:36 +0000
23+++ src/Widgets/Device/DeviceItem.vala 2015-11-18 10:28:19 +0000
24@@ -30,7 +30,11 @@
25 private Gtk.Image row_image;
26 private Gtk.Image status_image;
27
28- private string title;
29+ public string title {
30+ set {
31+ row_title.label = value;
32+ }
33+ }
34 private string subtitle;
35 private string icon_name;
36
37@@ -38,12 +42,13 @@
38 private Gtk.Label row_title;
39
40 public DeviceItem (string _title, string _subtitle, string _icon_name = "network-wired") {
41- this.title = _title;
42 this.subtitle = _subtitle;
43 this.icon_name = _icon_name;
44 this.type = Utils.ItemType.INVALID;
45
46 create_ui (icon_name);
47+
48+ this.title = _title;
49 }
50
51 public DeviceItem.from_interface (WidgetNMInterface iface,
52@@ -52,18 +57,14 @@
53 this.page = iface;
54 this.device = iface.device;
55 this.type = Utils.ItemType.DEVICE;
56-
57- if (_title != "") {
58- this.title = _title;
59- } else {
60- this.title = Utils.type_to_string (device.get_device_type ());
61- }
62-
63+
64 this.subtitle = "";
65 this.icon_name = _icon_name;
66
67 create_ui (icon_name);
68- switch_status (device.get_state ());
69+ iface.bind_property ("display-title", this, "title");
70+
71+ switch_status (device.get_state ());
72
73 device.state_changed.connect ( () => {
74 switch_status (device.get_state ());
75@@ -82,7 +83,7 @@
76 row_image = new Gtk.Image.from_icon_name (icon_name, Gtk.IconSize.DND);
77 row_image.pixel_size = 32;
78
79- row_title = new Gtk.Label (title);
80+ row_title = new Gtk.Label ("");
81 row_title.get_style_context ().add_class ("h3");
82 row_title.ellipsize = Pango.EllipsizeMode.END;
83 row_title.halign = Gtk.Align.START;
84
85=== modified file 'src/Widgets/Device/DevicePage.vala'
86--- src/Widgets/Device/DevicePage.vala 2015-10-08 19:04:34 +0000
87+++ src/Widgets/Device/DevicePage.vala 2015-11-18 10:28:19 +0000
88@@ -30,7 +30,7 @@
89 bottom_revealer.transition_type = Gtk.RevealerTransitionType.NONE;
90
91 this.icon_name = "network-wired";
92- this.title = Utils.type_to_string (device.get_device_type ());
93+ display_title = Utils.type_to_string (device.get_device_type ());
94
95 var details_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
96 details_box.pack_end (Utils.get_advanced_button_from_device (device), false, false, 0);
97@@ -49,7 +49,7 @@
98 this.init (owner.get_item_device (), info_box);
99
100 this.icon_name = owner.get_item_icon_name ();
101- this.title = Utils.type_to_string (device.get_device_type ());
102+ display_title = Utils.type_to_string (device.get_device_type ());
103
104 var details_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
105 details_box.pack_start (Utils.get_advanced_button_from_device (device), false, false, 0);
106
107=== modified file 'src/Widgets/DeviceList.vala'
108--- src/Widgets/DeviceList.vala 2015-10-22 17:08:56 +0000
109+++ src/Widgets/DeviceList.vala 2015-11-18 10:28:19 +0000
110@@ -33,8 +33,6 @@
111 private Gtk.Label devices_l;
112 private DeviceItem proxy;
113
114- private int wireless_item = 0;
115-
116 public DeviceList () {
117 this.selection_mode = Gtk.SelectionMode.SINGLE;
118 this.activate_on_single_click = true;
119@@ -56,14 +54,8 @@
120 }
121
122 public void add_device_to_list (WidgetNMInterface iface) {
123- if (iface.device.get_device_type () == NM.DeviceType.WIFI) {
124- string title = _("Wireless");
125- if (wireless_item > 0) {
126- title += SUFFIX + wireless_item.to_string ();
127- }
128-
129- item = new DeviceItem.from_interface (iface, "network-wireless", title);
130- wireless_item++;
131+ if (iface is AbstractWifiInterface) {
132+ item = new DeviceItem.from_interface (iface, "network-wireless");
133 } else {
134
135 if (!iface.device.get_managed ()) {
136@@ -92,10 +84,6 @@
137 }
138
139 public void remove_row_from_list (DeviceItem item) {
140- if (item.device.get_device_type () == NM.DeviceType.WIFI && wireless_item > 0) {
141- wireless_item--;
142- }
143-
144 items.remove (item);
145 this.remove (item);
146 }
147
148=== added file 'src/Widgets/EtherInterface.vala'
149--- src/Widgets/EtherInterface.vala 1970-01-01 00:00:00 +0000
150+++ src/Widgets/EtherInterface.vala 2015-11-18 10:28:19 +0000
151@@ -0,0 +1,47 @@
152+// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
153+/*-
154+ * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug)
155+ *
156+ * This library is free software; you can redistribute it and/or
157+ * modify it under the terms of the GNU Library General Public
158+ * License as published by the Free Software Foundation; either
159+ * version 3 of the License, or (at your option) any later version.
160+ *
161+ * This library is distributed in the hope that it will be useful,
162+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
163+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
164+ * Library General Public License for more details.
165+ *
166+ * You should have received a copy of the GNU Library General Public
167+ * License along with this library; if not, write to the
168+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
169+ * Boston, MA 02111-1307, USA.
170+ *
171+ * Authored by: Adam Bieńkowski <donadigos159@gmail.co
172+ * xapantu <xapantu@gmail.com>
173+ */
174+
175+namespace Network.Widgets {
176+ public class EtherInterface : Network.AbstractEtherInterface {
177+
178+ public EtherInterface (NM.Client client, NM.RemoteSettings settings, NM.Device device) {
179+ info_box = new info_box.from_device (device);
180+ this.init (device, info_box);
181+
182+ bottom_revealer.transition_type = Gtk.RevealerTransitionType.NONE;
183+
184+ this.icon_name = "network-wired";
185+
186+ var details_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
187+ details_box.pack_end (Utils.get_advanced_button_from_device (device), false, false, 0);
188+
189+ update ();
190+
191+ bottom_box.pack_start (info_box, true, true);
192+ bottom_box.pack_end (details_box, false, false);
193+
194+ pack_start (bottom_revealer, true, true);
195+ this.show_all ();
196+ }
197+ }
198+}
199
200=== modified file 'src/Widgets/Page.vala'
201--- src/Widgets/Page.vala 2015-10-09 19:12:42 +0000
202+++ src/Widgets/Page.vala 2015-11-18 10:28:19 +0000
203@@ -41,20 +41,8 @@
204 }
205 }
206
207- private string _title;
208- public string title {
209- get {
210- return _title;
211- }
212-
213- set {
214- _title = value;
215- device_label.label = _title;
216- }
217- }
218-
219 private Gtk.Image device_img;
220- private Gtk.Label device_label;
221+ protected Gtk.Label device_label;
222
223 protected Gtk.Revealer bottom_revealer;
224 protected Gtk.Box bottom_box;
225
226=== modified file 'src/Widgets/WifiInterface.vala'
227--- src/Widgets/WifiInterface.vala 2015-10-09 19:12:42 +0000
228+++ src/Widgets/WifiInterface.vala 2015-11-18 10:28:19 +0000
229@@ -61,7 +61,6 @@
230 init_wifi_interface (nm_client, settings, device_);
231
232 this.icon_name = "network-wireless";
233- this.title = _("Wireless");
234 this.spacing = 0;
235
236 control_box.margin_bottom = 12;
237
238=== added file 'src/common/Widgets/AbstractEtherInterface.vala'
239--- src/common/Widgets/AbstractEtherInterface.vala 1970-01-01 00:00:00 +0000
240+++ src/common/Widgets/AbstractEtherInterface.vala 2015-11-18 10:28:19 +0000
241@@ -0,0 +1,28 @@
242+/*
243+ * Copyright (c) 2015 Wingpanel Developers (http://launchpad.net/wingpanel)
244+ *
245+ * This program is free software: you can redistribute it and/or modify
246+ * it under the terms of the GNU Library General Public License as published by
247+ * the Free Software Foundation, either version 2.1 of the License, or
248+ * (at your option) any later version.
249+ *
250+ * This program is distributed in the hope that it will be useful,
251+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
252+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
253+ * GNU Library General Public License for more details.
254+ *
255+ * You should have received a copy of the GNU Library General Public License
256+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
257+ */
258+
259+public abstract class Network.AbstractEtherInterface : Network.WidgetNMInterface {
260+
261+ public override void update_name (int count) {
262+ if (count <= 1) {
263+ display_title = _("Ethernet");
264+ }
265+ else {
266+ display_title = device.get_description ();
267+ }
268+ }
269+}
270
271=== modified file 'src/common/Widgets/AbstractWifiInterface.vala'
272--- src/common/Widgets/AbstractWifiInterface.vala 2015-10-22 16:46:13 +0000
273+++ src/common/Widgets/AbstractWifiInterface.vala 2015-11-18 10:28:19 +0000
274@@ -112,6 +112,15 @@
275 update();
276 }
277
278+ public override void update_name (int count) {
279+ if (count <= 1) {
280+ display_title = _("Wi-Fi");
281+ }
282+ else {
283+ display_title = device.get_description ();
284+ }
285+ }
286+
287 Gtk.Label construct_placeholder_label (string text, bool title) {
288 var label = new Gtk.Label (text);
289 label.visible = true;
290
291=== modified file 'src/common/Widgets/NMVisualizer.vala'
292--- src/common/Widgets/NMVisualizer.vala 2015-08-02 12:30:11 +0000
293+++ src/common/Widgets/NMVisualizer.vala 2015-11-18 10:28:19 +0000
294@@ -56,6 +56,26 @@
295 break;
296 }
297 }
298+
299+ update_interfaces_names ();
300+ }
301+
302+ void update_interfaces_names () {
303+ var count_type = new Gee.HashMap<string, int?> ();
304+ foreach (var iface in network_interface) {
305+ var type = iface.get_type ().name ();
306+ if (count_type.has_key (type)) {
307+ count_type[type] = count_type[type] + 1;
308+ }
309+ else {
310+ count_type[type] = 1;
311+ }
312+ }
313+
314+ foreach (var iface in network_interface) {
315+ var type = iface.get_type ().name ();
316+ iface.update_name (count_type [type]);
317+ }
318 }
319
320 private void device_added_cb (NM.Device device) {
321@@ -63,13 +83,10 @@
322
323 if (device is NM.DeviceWifi) {
324 widget_interface = new WifiInterface (nm_client, nm_settings, device);
325+
326 debug ("Wifi interface added");
327 } else if (device is NM.DeviceEthernet) {
328-#if INDICATOR_NETWORK
329 widget_interface = new EtherInterface (nm_client, nm_settings, device);
330-#else
331- widget_interface = new Widgets.DevicePage (nm_client, nm_settings, device);
332-#endif
333 debug ("Ethernet interface added");
334 } else {
335 debug ("Unknown device: %s\n", device.get_device_type().to_string());
336@@ -82,6 +99,9 @@
337 widget_interface.notify["state"].connect(update_state);
338
339 }
340+
341+ update_interfaces_names ();
342+
343
344 update_all();
345
346
347=== modified file 'src/common/Widgets/WidgetNMInterface.vala'
348--- src/common/Widgets/WidgetNMInterface.vala 2015-08-01 22:16:50 +0000
349+++ src/common/Widgets/WidgetNMInterface.vala 2015-11-18 10:28:19 +0000
350@@ -23,6 +23,16 @@
351 #endif
352 public Network.State state { get; protected set; default = Network.State.DISCONNECTED; }
353
354+ public string display_title { get; protected set; default = _("Unknown device"); }
355+
356+#if PLUG_NETWORK
357+ construct {
358+ notify["display-title"].connect ( () => {
359+ device_label.label = display_title;
360+ });
361+ }
362+#endif
363+
364 #if INDICATOR_NETWORK
365 public Wingpanel.Widgets.Separator? sep = null;
366
367@@ -41,4 +51,8 @@
368 public virtual void update () {
369 #endif
370 }
371+
372+ public virtual void update_name (int count) {
373+ display_title = _("Unknown type: %s ").printf (device.get_description ());
374+ }
375 }

Subscribers

People subscribed via source and target branches

to all changes: