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

Dialogs use present and response #369

Merged
merged 2 commits into from
Jan 10, 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
15 changes: 9 additions & 6 deletions src/Views/VPNPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,11 @@ public class Network.VPNPage : Network.Widgets.Page {
Gtk.ButtonsType.CLOSE
) {
badge_icon = new ThemedIcon ("dialog-error"),
modal = true,
transient_for = (Gtk.Window) get_toplevel ()
};
dialog.run ();
dialog.destroy ();
dialog.present ();
dialog.response.connect (dialog.destroy);
return;
} else {
remove_vpn_toast.send_notification ();
Expand Down Expand Up @@ -339,11 +340,12 @@ public class Network.VPNPage : Network.Widgets.Page {
Gtk.ButtonsType.CLOSE
) {
badge_icon = new ThemedIcon ("dialog-error"),
modal = true,
transient_for = (Gtk.Window) get_toplevel ()
};
dialog.show_error_details (error.message);
dialog.run ();
dialog.destroy ();
dialog.present ();
dialog.response.connect (dialog.destroy);
}
}

Expand All @@ -362,11 +364,12 @@ public class Network.VPNPage : Network.Widgets.Page {
Gtk.ButtonsType.CLOSE
) {
badge_icon = new ThemedIcon ("dialog-error"),
modal = true,
transient_for = (Gtk.Window) get_toplevel ()
};
dialog.show_error_details (e.message);
dialog.run ();
dialog.destroy ();
dialog.present ();
dialog.response.connect (dialog.destroy);
}
} else {
warning ("Row selection changed between operations. Cancelling removal of VPN.");
Expand Down
24 changes: 12 additions & 12 deletions src/Views/WifiPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ namespace Network {

content_area.add (top_revealer);
content_area.add (main_frame);
content_area.show_all ();
show_all ();

update ();
}
Expand Down Expand Up @@ -520,17 +520,17 @@ namespace Network {
// behind switchboard, so we spawn our own
var wifi_dialog = new NMA.WifiDialog (client, connection, wifi_device, row.ap, false) {
deletable = false,
transient_for = (Gtk.Window) get_toplevel (),
window_position = Gtk.WindowPosition.CENTER_ON_PARENT
modal = true,
transient_for = (Gtk.Window) get_toplevel ()
};
wifi_dialog.present ();

wifi_dialog.response.connect ((response) => {
if (response == Gtk.ResponseType.OK) {
connect_to_network.begin (wifi_dialog);
}
wifi_dialog.destroy ();
});

wifi_dialog.run ();
wifi_dialog.destroy ();
} else {
if (NM.@80211ApSecurityFlags.KEY_MGMT_OWE in row.ap.get_rsn_flags () ||
NM.@80211ApSecurityFlags.KEY_MGMT_OWE in row.ap.get_wpa_flags ()) {
Expand Down Expand Up @@ -581,21 +581,21 @@ namespace Network {
}

private void connect_to_hidden () {
unowned NetworkManager network_manager = NetworkManager.get_default ();
unowned var network_manager = NetworkManager.get_default ();

var hidden_dialog = new NMA.WifiDialog.for_other (network_manager.client) {
deletable = false,
transient_for = (Gtk.Window) get_toplevel (),
window_position = Gtk.WindowPosition.CENTER_ON_PARENT
modal = true,
transient_for = (Gtk.Window) get_toplevel ()
};
hidden_dialog.present ();

hidden_dialog.response.connect ((response) => {
if (response == Gtk.ResponseType.OK) {
connect_to_network.begin (hidden_dialog);
}
hidden_dialog.destroy ();
});

hidden_dialog.run ();
hidden_dialog.destroy ();
}

private async void connect_to_network (NMA.WifiDialog wifi_dialog) {
Expand Down
9 changes: 6 additions & 3 deletions src/Widgets/Page.vala
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,13 @@ namespace Network.Widgets {
_("Unable to disconnect from the currently connected network"),
"network-error",
Gtk.ButtonsType.CLOSE
);
) {
modal = true,
transient_for = (Gtk.Window) get_toplevel ()
};
message_dialog.show_error_details (e.message);
message_dialog.run ();
message_dialog.destroy ();
message_dialog.present ();
message_dialog.response.connect (message_dialog.destroy);
}
} else if (status_switch.active && device.get_state () == NM.DeviceState.DISCONNECTED) {
var connection = NM.SimpleConnection.new ();
Expand Down
31 changes: 18 additions & 13 deletions src/Widgets/Proxy/ProxyConfigurationPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -270,30 +270,35 @@ namespace Network.Widgets {
new ThemedIcon ("dialog-question"),
Gtk.ButtonsType.CANCEL
) {
modal = true,
transient_for = (Gtk.Window) get_toplevel ()
};

var reset_button = (Gtk.Button) reset_dialog.add_button (_("Reset Settings"), Gtk.ResponseType.APPLY);
reset_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);

if (reset_dialog.run () == Gtk.ResponseType.APPLY) {
Network.Plug.proxy_settings.set_string ("mode", "none");
Network.Plug.proxy_settings.set_string ("autoconfig-url", "");
reset_dialog.present ();

http_settings.set_string ("host", "");
http_settings.set_int ("port", 0);
reset_dialog.response.connect ((response) => {
if (response == Gtk.ResponseType.APPLY) {
Network.Plug.proxy_settings.set_string ("mode", "none");
Network.Plug.proxy_settings.set_string ("autoconfig-url", "");

https_settings.set_string ("host", "");
https_settings.set_int ("port", 0);
http_settings.set_string ("host", "");
http_settings.set_int ("port", 0);

ftp_settings.set_string ("host", "");
ftp_settings.set_int ("port", 0);
https_settings.set_string ("host", "");
https_settings.set_int ("port", 0);

socks_settings.set_string ("host", "");
socks_settings.set_int ("port", 0);
}
ftp_settings.set_string ("host", "");
ftp_settings.set_int ("port", 0);

socks_settings.set_string ("host", "");
socks_settings.set_int ("port", 0);
}

reset_dialog.destroy ();
reset_dialog.destroy ();
});
}
}
}
8 changes: 5 additions & 3 deletions src/Widgets/VPN/VPNMenuItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public class Network.VPNMenuItem : Gtk.ListBoxRow {
xalign = 0
};

vpn_info_dialog = new Widgets.VPNInfoDialog (connection);
vpn_info_dialog = new Widgets.VPNInfoDialog (connection) {
modal = true
};

var vpn_info_button = new Gtk.Button () {
image = new Gtk.Image.from_icon_name ("view-more-horizontal-symbolic", Gtk.IconSize.MENU),
Expand Down Expand Up @@ -98,8 +100,8 @@ public class Network.VPNMenuItem : Gtk.ListBoxRow {

vpn_info_button.clicked.connect (() => {
vpn_info_dialog.transient_for = (Gtk.Window) get_toplevel ();
vpn_info_dialog.run ();
vpn_info_dialog.hide ();
vpn_info_dialog.present ();
vpn_info_dialog.response.connect (vpn_info_dialog.destroy);
});
}

Expand Down