Skip to content

Commit

Permalink
WifiPage: create settings dialog (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored Dec 10, 2024
1 parent 928cad7 commit af0368e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
53 changes: 26 additions & 27 deletions src/Views/WifiPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
};
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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 ();
});
}
}

Expand Down
1 change: 1 addition & 0 deletions src/Widgets/InfoBox.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
};
Expand Down
7 changes: 4 additions & 3 deletions src/Widgets/WifiMenuItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit af0368e

Please sign in to comment.