Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VPN: move edit connection button to info dialog #390

Merged
merged 4 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions src/Views/VPNPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,8 @@ public class Network.VPNPage : Network.Widgets.Page {
sensitive = false
};

var edit_connection_button = new Gtk.Button.from_icon_name ("preferences-system-symbolic") {
tooltip_text = _("Edit VPN connection…"),
sensitive = false
};

actionbar.pack_start (add_button);
actionbar.pack_start (remove_button);
actionbar.pack_start (edit_connection_button);

var scrolled = new Gtk.ScrolledWindow (null, null) {
child = vpn_list
Expand Down Expand Up @@ -109,11 +103,6 @@ public class Network.VPNPage : Network.Widgets.Page {
try_connection_editor ("--create --type=vpn");
});

edit_connection_button.clicked.connect (() => {
var selected_row = (VPNMenuItem) vpn_list.get_selected_row ();
try_connection_editor ("--edit=" + selected_row.connection.get_uuid ());
});

remove_button.clicked.connect (remove_button_cb);

remove_vpn_toast.default_action.connect (() => {
Expand All @@ -132,7 +121,6 @@ public class Network.VPNPage : Network.Widgets.Page {

vpn_list.row_selected.connect (row => {
remove_button.sensitive = row != null;
edit_connection_button.sensitive = row != null;
});

active_connections = new Gee.ArrayList<NM.ActiveConnection> ();
Expand Down
33 changes: 32 additions & 1 deletion src/Widgets/VPN/VPNInfoDialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class Network.Widgets.VPNInfoDialog : Granite.MessageDialog {

public VPNInfoDialog (NM.RemoteConnection? connection) {
Object (
buttons: Gtk.ButtonsType.CLOSE,
image_icon: new ThemedIcon ("network-vpn"),
connection: connection
);
Expand All @@ -50,6 +49,9 @@ public class Network.Widgets.VPNInfoDialog : Granite.MessageDialog {
xalign = 0
};

add_button (_("Edit Connection…"), 1);
add_button (_("Close"), Gtk.ResponseType.CLOSE);

var box = new Gtk.Box (VERTICAL, 0);
box.add (new Granite.HeaderLabel (("VPN Type")));
box.add (vpn_type);
Expand All @@ -64,6 +66,35 @@ public class Network.Widgets.VPNInfoDialog : Granite.MessageDialog {

connection.changed.connect (update_status);
update_status ();

response.connect ((response) => {
if (response == 1) {
try {
var appinfo = AppInfo.create_from_commandline (
"nm-connection-editor --edit=%s".printf (connection.get_uuid ()),
null,
GLib.AppInfoCreateFlags.NONE
);
appinfo.launch (null, null);
} catch (Error error) {
var dialog = new Granite.MessageDialog (
_("Failed to run Connection Editor"),
_("The program \"nm-connection-editor\" may not be installed."),
new ThemedIcon ("network-vpn"),
Gtk.ButtonsType.CLOSE
) {
badge_icon = new ThemedIcon ("dialog-error"),
modal = true,
transient_for = (Gtk.Window) get_toplevel ()
};
dialog.show_error_details (error.message);
dialog.present ();
dialog.response.connect (dialog.destroy);
}
}

destroy ();
danirabbit marked this conversation as resolved.
Show resolved Hide resolved
});
}

private string get_key_group_username () {
Expand Down
1 change: 0 additions & 1 deletion src/Widgets/VPN/VPNMenuItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public class Network.VPNMenuItem : Gtk.ListBoxRow {
};

vpn_info_dialog.present ();
vpn_info_dialog.response.connect (vpn_info_dialog.destroy);
});
}

Expand Down