From af0368ebbfc4852e24ddfdff1ec053a8dd165c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 10 Dec 2024 10:32:48 -0800 Subject: [PATCH] WifiPage: create settings dialog (#413) --- src/Views/WifiPage.vala | 53 +++++++++++++++++------------------ src/Widgets/InfoBox.vala | 1 + src/Widgets/WifiMenuItem.vala | 7 +++-- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/Views/WifiPage.vala b/src/Views/WifiPage.vala index 0202b986..950eceac 100644 --- a/src/Views/WifiPage.vala +++ b/src/Views/WifiPage.vala @@ -24,13 +24,10 @@ public class Network.WifiInterface : Network.Widgets.Page { protected Gtk.Stack list_stack; protected Gtk.ScrolledWindow scrolled; protected Gtk.Box hotspot_mode_alert; - protected Gtk.Box? connected_box = null; protected Gtk.Revealer top_revealer; protected Gtk.Button? disconnect_btn; protected Gtk.Button? settings_btn; protected Gtk.Button? hidden_btn; - protected Gtk.MenuButton info_btn; - protected Gtk.Popover popover; public WifiInterface (NM.Device device) { Object ( @@ -74,16 +71,6 @@ public class Network.WifiInterface : Network.Widgets.Page { }; main_frame.add_css_class (Granite.STYLE_CLASS_VIEW); - info_box.margin_start = 12; - info_box.margin_end = 12; - info_box.margin_top = 12; - info_box.margin_bottom = 12; - - popover = new Gtk.Popover () { - child = info_box, - position = BOTTOM - }; - connected_frame = new Gtk.Frame (null) { margin_bottom = 12, // Prevent extra space when this is hidden }; @@ -284,10 +271,6 @@ public class Network.WifiInterface : Network.Widgets.Page { settings_btn.sensitive = sensitive; } - if (info_btn != null) { - info_btn.sensitive = sensitive; - } - if (hidden_btn != null) { hidden_btn.sensitive = (state != NM.DeviceState.UNAVAILABLE); } @@ -393,15 +376,6 @@ public class Network.WifiInterface : Network.Widgets.Page { settings_btn = new Gtk.Button.with_label (_("Settingsā€¦")) { sensitive = (device.get_state () == NM.DeviceState.ACTIVATED) }; - settings_btn.clicked.connect (open_advanced_settings); - - info_btn = new Gtk.MenuButton () { - icon_name = "view-more-symbolic", - popover = popover, - valign = CENTER, - tooltip_text = _("Connection info") - }; - info_btn.add_css_class (Granite.STYLE_CLASS_FLAT); var button_box = new Gtk.Box (HORIZONTAL, 6) { homogeneous = true, @@ -412,7 +386,6 @@ public class Network.WifiInterface : Network.Widgets.Page { var connected_box = new Gtk.Box (HORIZONTAL, 12); connected_box.append (top_item); - connected_box.append (info_btn); connected_box.append (button_box); // Create a single item listbox to match styles with main listbox @@ -424,6 +397,32 @@ public class Network.WifiInterface : Network.Widgets.Page { connected_listbox.get_first_child ().focusable = false; connected_frame.child = connected_listbox; + + var settings_dialog = new Granite.MessageDialog.with_image_from_icon_name ( + top_item.ssid_label.label, + top_item.status_label.label, + top_item.img_strength.icon_name, + NONE + ) { + modal = true, + transient_for = ((Gtk.Application) Application.get_default ()).active_window + }; + + settings_dialog.add_button (_("Advancedā€¦"), 0); + settings_dialog.add_button (_("Close"), Gtk.ResponseType.CLOSE); + settings_dialog.custom_bin.append (info_box); + + settings_btn.clicked.connect (() => { + settings_dialog.present (); + }); + + settings_dialog.response.connect ((response) => { + if (response == 0) { + open_advanced_settings (); + } + + settings_dialog.hide (); + }); } } diff --git a/src/Widgets/InfoBox.vala b/src/Widgets/InfoBox.vala index d38fdba3..295ca07a 100644 --- a/src/Widgets/InfoBox.vala +++ b/src/Widgets/InfoBox.vala @@ -84,6 +84,7 @@ public class Network.Widgets.InfoBox : Gtk.Box { }; var reduce_data_header = new Granite.HeaderLabel (_("Reduce background data usage")) { + hexpand = true, mnemonic_widget = reduce_data_switch, secondary_text = _("While connected to this network, background tasks like automatic updates will be paused.") }; diff --git a/src/Widgets/WifiMenuItem.vala b/src/Widgets/WifiMenuItem.vala index ec33eb76..73d828bb 100644 --- a/src/Widgets/WifiMenuItem.vala +++ b/src/Widgets/WifiMenuItem.vala @@ -46,11 +46,12 @@ public class Network.WifiMenuItem : Gtk.ListBoxRow { } } - private Gtk.Image img_strength; + public Gtk.Image img_strength { get; private set; } + public Gtk.Label ssid_label { get; private set; } + public Gtk.Label status_label { get; private set; } + private Gtk.Image lock_img; private Gtk.Image error_img; - private Gtk.Label ssid_label; - private Gtk.Label status_label; private Gtk.Revealer connect_button_revealer; private Gtk.Spinner spinner;