~elementary-pantheon/switchboard-plug-networking/prefs-spec

« back to all changes in this revision

Viewing changes to src/Widgets/SettingsButton.vala

* Fix that two different buttons launched the same dialog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
 namespace Network.Widgets {
21
21
    public class SettingsButton : Gtk.Button {
22
 
        private string? uuid = null;
23
 
 
24
 
        construct {
25
 
            clicked.connect (() => {
26
 
                if (uuid != null) {
27
 
                    new Granite.Services.SimpleCommand ("/usr/bin",
28
 
                                                        "nm-connection-editor --edit=%s".printf (uuid)).run ();
29
 
                } else {
30
 
                    new Granite.Services.SimpleCommand ("/usr/bin",
31
 
                                                        "nm-connection-editor").run ();
32
 
                }
33
 
            });  
34
 
        }
35
 
 
36
22
        public SettingsButton () {
37
23
            label = _("Edit Connections…");
 
24
            clicked.connect (() => {
 
25
                new Granite.Services.SimpleCommand ("/usr/bin",
 
26
                                                    "nm-connection-editor").run ();
 
27
            });            
38
28
        }
39
29
 
40
30
        public SettingsButton.from_device (NM.Device device, string title = _("Advanced Settings…")) {
41
31
            label = title;
42
 
            uuid = device.get_active_connection ().get_uuid ();
 
32
            clicked.connect (() => {
 
33
                string uuid = ""; 
 
34
                var active_connection = device.get_active_connection ();
 
35
                if (active_connection != null) {
 
36
                    uuid = device.get_active_connection ().get_uuid ();
 
37
                } else {
 
38
                    var available_connections = device.get_available_connections ();
 
39
                    if (available_connections.length > 0) {
 
40
                        uuid = available_connections[0].get_uuid ();
 
41
                    }
 
42
                }
 
43
 
 
44
                new Granite.Services.SimpleCommand ("/usr/bin",
 
45
                                                    "nm-connection-editor --edit=%s".printf (uuid)).run ();                    
 
46
            });  
43
47
        }
44
48
 
45
49
        public SettingsButton.from_connection (NM.Connection connection, string title = _("Advanced Settings…")) {
46
50
            label = title;
47
 
            uuid = connection.get_uuid ();
 
51
            clicked.connect (() => {
 
52
                new Granite.Services.SimpleCommand ("/usr/bin",
 
53
                                                    "nm-connection-editor --edit=%s".printf (connection.get_uuid ())).run ();
 
54
            });  
48
55
        }
49
56
    }
50
57
}
 
 
b'\\ No newline at end of file'