Merge lp:~tintou/wingpanel-indicator-network/with-hidden-network into lp:~wingpanel-devs/wingpanel-indicator-network/trunk

Proposed by Corentin Noël
Status: Merged
Approved by: Danielle Foré
Approved revision: 144
Merged at revision: 144
Proposed branch: lp:~tintou/wingpanel-indicator-network/with-hidden-network
Merge into: lp:~wingpanel-devs/wingpanel-indicator-network/trunk
Diff against target: 294 lines (+122/-28)
5 files modified
po/network-indicator.pot (+23/-19)
src/Widgets/PopoverWidget.vala (+44/-4)
src/Widgets/WifiInterface.vala (+50/-1)
src/common/Widgets/AbstractWifiInterface.vala (+1/-1)
src/libnm-gtk.vapi (+4/-3)
To merge this branch: bzr merge lp:~tintou/wingpanel-indicator-network/with-hidden-network
Reviewer Review Type Date Requested Status
WingPanel Devs Pending
Review via email: mp+292590@code.launchpad.net

Commit message

Add Hidden network dialog

To post a comment you must log in.
Revision history for this message
Danielle Foré (danrabbit) wrote :

Hm even though it's probably technically correct, it looks like of weird to have the "Connect to Hidden" above the separator. Can we put it below? :p

Other than that, works for me :)

144. By Corentin Noël

Added Hidden networks

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed directory 'data'
2=== modified file 'po/network-indicator.pot'
3--- po/network-indicator.pot 2016-02-07 02:10:06 +0000
4+++ po/network-indicator.pot 2016-04-22 00:57:40 +0000
5@@ -8,7 +8,7 @@
6 msgstr ""
7 "Project-Id-Version: PACKAGE VERSION\n"
8 "Report-Msgid-Bugs-To: \n"
9-"POT-Creation-Date: 2016-02-06 20:09-0600\n"
10+"POT-Creation-Date: 2016-04-22 02:56+0200\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <LL@li.org>\n"
14@@ -17,6 +17,14 @@
15 "Content-Type: text/plain; charset=UTF-8\n"
16 "Content-Transfer-Encoding: 8bit\n"
17
18+#: ../src/Widgets/PopoverWidget.vala:52
19+msgid "Network Settings…"
20+msgstr ""
21+
22+#: ../src/Widgets/PopoverWidget.vala:55
23+msgid "Connect to Hidden Network…"
24+msgstr ""
25+
26 #: ../src/Indicator.vala:25
27 msgid "Network"
28 msgstr ""
29@@ -25,10 +33,6 @@
30 msgid "Network indicator"
31 msgstr ""
32
33-#: ../src/Widgets/PopoverWidget.vala:42
34-msgid "Network Settings…"
35-msgstr ""
36-
37 #: ../src/common/Widgets/AbstractHotspotInterface.vala:23
38 msgid "Hotspot"
39 msgstr ""
40@@ -37,14 +41,6 @@
41 msgid "Hotspot %s"
42 msgstr ""
43
44-#: ../src/common/Widgets/WidgetNMInterface.vala:26
45-msgid "Unknown device"
46-msgstr ""
47-
48-#: ../src/common/Widgets/WidgetNMInterface.vala:56
49-msgid "Unknown type: %s "
50-msgstr ""
51-
52 #: ../src/common/Widgets/AbstractWifiInterface.vala:50
53 msgid "No Access Points Available"
54 msgstr ""
55@@ -62,11 +58,19 @@
56 msgstr ""
57
58 #: ../src/common/Widgets/AbstractWifiInterface.vala:75
59-msgid "Scanning for Access Points..."
60+msgid "Scanning for Access Points…"
61 msgstr ""
62
63 #: ../src/common/Widgets/AbstractWifiInterface.vala:120
64-msgid "Wi-Fi"
65+msgid "Wireless"
66+msgstr ""
67+
68+#: ../src/common/Widgets/AbstractEtherInterface.vala:25
69+msgid "Virtual network: %s"
70+msgstr ""
71+
72+#: ../src/common/Widgets/AbstractEtherInterface.vala:29
73+msgid "Wired"
74 msgstr ""
75
76 #: ../src/common/Widgets/WifiMenuItem.vala:77
77@@ -89,12 +93,12 @@
78 msgid "This network uses encryption."
79 msgstr ""
80
81-#: ../src/common/Widgets/AbstractEtherInterface.vala:25
82-msgid "Virtual network: %s"
83+#: ../src/common/Widgets/WidgetNMInterface.vala:26
84+msgid "Unknown device"
85 msgstr ""
86
87-#: ../src/common/Widgets/AbstractEtherInterface.vala:29
88-msgid "Wired"
89+#: ../src/common/Widgets/WidgetNMInterface.vala:56
90+msgid "Unknown type: %s "
91 msgstr ""
92
93 #: ../src/common/Utils.vala:37
94
95=== modified file 'src/Widgets/PopoverWidget.vala'
96--- src/Widgets/PopoverWidget.vala 2015-11-03 22:06:54 +0000
97+++ src/Widgets/PopoverWidget.vala 2016-04-22 00:57:40 +0000
98@@ -17,10 +17,14 @@
99
100 public class Network.Widgets.PopoverWidget : Network.Widgets.NMVisualizer {
101 Gtk.Box main_box;
102+ Gtk.Box other_box;
103+ Gtk.Box wifi_box;
104+ Gtk.Box settings_box;
105
106 private const string SETTINGS_EXEC = "/usr/bin/switchboard -o pantheon-network";
107
108 private Wingpanel.Widgets.Button show_settings_button;
109+ private Wingpanel.Widgets.Button hidden_item;
110
111 public signal void settings_shown ();
112
113@@ -35,12 +39,22 @@
114 protected override void build_ui () {
115
116 main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
117+ other_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
118+ wifi_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
119+ settings_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
120+ main_box.add (other_box);
121+ main_box.add (wifi_box);
122+ main_box.add (settings_box);
123
124 add (main_box);
125
126 if(!is_dm ()) {
127 show_settings_button = new Wingpanel.Widgets.Button (_("Network Settings…"));
128- main_box.pack_end (show_settings_button);
129+ settings_box.pack_end (show_settings_button);
130+
131+ hidden_item = new Wingpanel.Widgets.Button (_("Connect to Hidden Network…"));
132+ hidden_item.no_show_all = true;
133+ settings_box.pack_start (hidden_item);
134 }
135 }
136
137@@ -53,17 +67,43 @@
138 }
139
140 protected override void add_interface (WidgetNMInterface widget_interface) {
141+ Gtk.Box container_box = other_box;
142+ if (widget_interface is Network.WifiInterface) {
143+ container_box = wifi_box;
144+ hidden_item.no_show_all = false;
145+ hidden_item.show_all ();
146+ ((Network.WifiInterface) widget_interface).notify["hidden-sensitivity"].connect (() => {
147+ bool hidden_sensitivity = false;
148+ wifi_box.get_children ().foreach ((child) => {
149+ if (child is Network.WifiInterface) {
150+ hidden_sensitivity = hidden_sensitivity || ((Network.WifiInterface) child).hidden_sensitivity;
151+ }
152+
153+ hidden_item.sensitive = hidden_sensitivity;
154+ });
155+ });
156+ }
157+
158 if (!is_dm () || main_box.get_children ().length () > 0) {
159 widget_interface.sep = new Wingpanel.Widgets.Separator ();
160- main_box.pack_end (widget_interface.sep);
161+ container_box.pack_end (widget_interface.sep);
162 }
163- main_box.pack_end (widget_interface);
164+ container_box.pack_end (widget_interface);
165
166 widget_interface.need_settings.connect (show_settings);
167 }
168-
169+
170 void connect_signals () {
171 show_settings_button.clicked.connect (show_settings);
172+ hidden_item.clicked.connect (() => {
173+ bool found = false;
174+ wifi_box.get_children ().foreach ((child) => {
175+ if (child is Network.WifiInterface && ((Network.WifiInterface) child).hidden_sensitivity && !found) {
176+ ((Network.WifiInterface) child).connect_to_hidden ();
177+ found = true;
178+ }
179+ });
180+ });
181 }
182
183 void show_settings () {
184
185=== modified file 'src/Widgets/WifiInterface.vala'
186--- src/Widgets/WifiInterface.vala 2015-10-26 13:05:52 +0000
187+++ src/Widgets/WifiInterface.vala 2016-04-22 00:57:40 +0000
188@@ -16,6 +16,7 @@
189 */
190
191 public class Network.WifiInterface : Network.AbstractWifiInterface {
192+ public bool hidden_sensitivity { get; set; default = true; }
193 Wingpanel.Widgets.Switch wifi_item;
194 Gtk.Revealer revealer;
195
196@@ -48,7 +49,6 @@
197
198 revealer = new Gtk.Revealer ();
199 revealer.add (scrolled_box);
200-
201 pack_start (revealer);
202 }
203
204@@ -62,8 +62,10 @@
205
206 if (wifi_device.state == NM.DeviceState.UNAVAILABLE || state == Network.State.FAILED_WIFI) {
207 revealer.reveal_child = false;
208+ hidden_sensitivity = false;
209 } else {
210 revealer.reveal_child = true;
211+ hidden_sensitivity = true;
212 }
213 }
214
215@@ -115,5 +117,52 @@
216 Idle.add( () => { update (); return false; });
217 }
218
219+ public void connect_to_hidden () {
220+ var hidden_dialog = new NMAWifiDialog.for_other (nm_client, nm_settings);
221+ hidden_dialog.response.connect ((response) => {
222+ if (response == Gtk.ResponseType.OK) {
223+ NM.Connection? fuzzy = null;
224+ NM.Device dialog_device;
225+ NM.AccessPoint? dialog_ap = null;
226+ var dialog_connection = hidden_dialog.get_connection (out dialog_device, out dialog_ap);
227+
228+ foreach (var possible in nm_settings.list_connections ()) {
229+ if (dialog_connection.compare (possible, NM.SettingCompareFlags.FUZZY | NM.SettingCompareFlags.IGNORE_ID)) {
230+ fuzzy = possible;
231+ }
232+ }
233+
234+ string? path = null;
235+ if (dialog_ap != null) {
236+ path = dialog_ap.get_path ();
237+ }
238+
239+ if (fuzzy != null) {
240+ nm_client.activate_connection (fuzzy, wifi_device, path, null);
241+ } else {
242+ var connection_setting = dialog_connection.get_setting (typeof (NM.Setting));;
243+
244+ string? mode = null;
245+ var setting_wireless = (NM.SettingWireless) dialog_connection.get_setting (typeof (NM.SettingWireless));
246+ if (setting_wireless != null) {
247+ mode = setting_wireless.get_mode ();
248+ }
249+
250+ if (mode == "adhoc") {
251+ if (connection_setting == null) {
252+ connection_setting = new NM.SettingConnection ();
253+ }
254+
255+ dialog_connection.add_setting (connection_setting);
256+ }
257+
258+ nm_client.add_and_activate_connection (dialog_connection, dialog_device, path, null);
259+ }
260+ }
261+ });
262+
263+ hidden_dialog.run ();
264+ hidden_dialog.destroy ();
265+ }
266 }
267
268
269=== modified file 'src/common/Widgets/AbstractWifiInterface.vala'
270--- src/common/Widgets/AbstractWifiInterface.vala 2016-04-09 21:13:41 +0000
271+++ src/common/Widgets/AbstractWifiInterface.vala 2016-04-22 00:57:40 +0000
272@@ -72,7 +72,7 @@
273 spinner.start ();
274
275 var scanning_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 5);
276- var scanning = construct_placeholder_label (_("Scanning for Access Points..."), true);
277+ var scanning = construct_placeholder_label (_("Scanning for Access Points…"), true);
278
279 scanning_box.add (scanning);
280 scanning_box.add (spinner);
281
282=== modified file 'src/libnm-gtk.vapi'
283--- src/libnm-gtk.vapi 2015-05-26 00:05:00 +0000
284+++ src/libnm-gtk.vapi 2016-04-22 00:57:40 +0000
285@@ -1,5 +1,6 @@
286 [CCode (cheader_filename = "nm-wifi-dialog.h")]
287-class NMAWifiDialog : Gtk.Dialog
288-{
289- public NMAWifiDialog (NM.Client client, NM.RemoteSettings settings, NM.Connection connection, NM.Device device, NM.AccessPoint ap, bool secrets_only);
290+class NMAWifiDialog : Gtk.Dialog {
291+ public NMAWifiDialog (NM.Client client, NM.RemoteSettings settings, NM.Connection 0connection, NM.Device device, NM.AccessPoint ap, bool secrets_only);
292+ public NMAWifiDialog.for_other (NM.Client client, NM.RemoteSettings settings);
293+ public NM.Connection get_connection (out NM.Device device, out NM.AccessPoint ap);
294 }

Subscribers

People subscribed via source and target branches

to all changes: