From 238013e819664936479e367f545ea3c118612fc4 Mon Sep 17 00:00:00 2001 From: Danielle Fore Date: Mon, 8 Jan 2024 12:17:02 -0800 Subject: [PATCH] Dialogs use present and response --- src/Views/VPNPage.vala | 15 +++++---- src/Views/WifiPage.vala | 24 +++++++------- src/Widgets/Page.vala | 9 ++++-- src/Widgets/Proxy/ProxyConfigurationPage.vala | 31 +++++++++++-------- src/Widgets/VPN/VPNMenuItem.vala | 8 +++-- 5 files changed, 50 insertions(+), 37 deletions(-) diff --git a/src/Views/VPNPage.vala b/src/Views/VPNPage.vala index 100fb666..1222dfa3 100644 --- a/src/Views/VPNPage.vala +++ b/src/Views/VPNPage.vala @@ -295,10 +295,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 (); @@ -328,11 +329,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); } } @@ -351,11 +353,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."); diff --git a/src/Views/WifiPage.vala b/src/Views/WifiPage.vala index 455aa6aa..e86d1885 100644 --- a/src/Views/WifiPage.vala +++ b/src/Views/WifiPage.vala @@ -179,7 +179,7 @@ namespace Network { content_area.add (top_revealer); content_area.add (main_frame); - content_area.show_all (); + show_all (); update (); } @@ -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 ()) { @@ -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) { diff --git a/src/Widgets/Page.vala b/src/Widgets/Page.vala index a7a31478..608a0ac7 100644 --- a/src/Widgets/Page.vala +++ b/src/Widgets/Page.vala @@ -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 (); diff --git a/src/Widgets/Proxy/ProxyConfigurationPage.vala b/src/Widgets/Proxy/ProxyConfigurationPage.vala index d59a925d..78187ad0 100644 --- a/src/Widgets/Proxy/ProxyConfigurationPage.vala +++ b/src/Widgets/Proxy/ProxyConfigurationPage.vala @@ -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 (); + }); } } } diff --git a/src/Widgets/VPN/VPNMenuItem.vala b/src/Widgets/VPN/VPNMenuItem.vala index bed77a3a..bae39dcb 100644 --- a/src/Widgets/VPN/VPNMenuItem.vala +++ b/src/Widgets/VPN/VPNMenuItem.vala @@ -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), @@ -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); }); }