Merge lp:~donadigo/switchboard-plug-networking/fix-settings-button-same-dialogs into lp:~elementary-pantheon/switchboard-plug-networking/trunk

Proposed by Adam Bieńkowski
Status: Merged
Approved by: Felipe Escoto
Approved revision: 304
Merged at revision: 304
Proposed branch: lp:~donadigo/switchboard-plug-networking/fix-settings-button-same-dialogs
Merge into: lp:~elementary-pantheon/switchboard-plug-networking/trunk
Diff against target: 60 lines (+23/-16)
1 file modified
src/Widgets/SettingsButton.vala (+23/-16)
To merge this branch: bzr merge lp:~donadigo/switchboard-plug-networking/fix-settings-button-same-dialogs
Reviewer Review Type Date Requested Status
elementary Pantheon team Pending
Review via email: mp+303498@code.launchpad.net

Commit message

* Fix that two different buttons launched the same dialog.

Description of the change

This branch fixes that two different buttons launched the same dialog. Now the active connection will be retreived on click event rather than assaigning it statically and causing the connection to be null. If it is still null the plug will choose first available connection and show dialog for it. If there isn't any available it will fallback to the all connections dialog.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Widgets/SettingsButton.vala'
2--- src/Widgets/SettingsButton.vala 2016-08-09 12:41:03 +0000
3+++ src/Widgets/SettingsButton.vala 2016-08-21 22:05:18 +0000
4@@ -19,32 +19,39 @@
5
6 namespace Network.Widgets {
7 public class SettingsButton : Gtk.Button {
8- private string? uuid = null;
9-
10- construct {
11- clicked.connect (() => {
12- if (uuid != null) {
13- new Granite.Services.SimpleCommand ("/usr/bin",
14- "nm-connection-editor --edit=%s".printf (uuid)).run ();
15- } else {
16- new Granite.Services.SimpleCommand ("/usr/bin",
17- "nm-connection-editor").run ();
18- }
19- });
20- }
21-
22 public SettingsButton () {
23 label = _("Edit Connections…");
24+ clicked.connect (() => {
25+ new Granite.Services.SimpleCommand ("/usr/bin",
26+ "nm-connection-editor").run ();
27+ });
28 }
29
30 public SettingsButton.from_device (NM.Device device, string title = _("Advanced Settings…")) {
31 label = title;
32- uuid = device.get_active_connection ().get_uuid ();
33+ clicked.connect (() => {
34+ string uuid = "";
35+ var active_connection = device.get_active_connection ();
36+ if (active_connection != null) {
37+ uuid = device.get_active_connection ().get_uuid ();
38+ } else {
39+ var available_connections = device.get_available_connections ();
40+ if (available_connections.length > 0) {
41+ uuid = available_connections[0].get_uuid ();
42+ }
43+ }
44+
45+ new Granite.Services.SimpleCommand ("/usr/bin",
46+ "nm-connection-editor --edit=%s".printf (uuid)).run ();
47+ });
48 }
49
50 public SettingsButton.from_connection (NM.Connection connection, string title = _("Advanced Settings…")) {
51 label = title;
52- uuid = connection.get_uuid ();
53+ clicked.connect (() => {
54+ new Granite.Services.SimpleCommand ("/usr/bin",
55+ "nm-connection-editor --edit=%s".printf (connection.get_uuid ())).run ();
56+ });
57 }
58 }
59 }
60\ No newline at end of file

Subscribers

People subscribed via source and target branches

to all changes: