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

SettingsPage: add option to show end title buttons #293

Merged
merged 3 commits into from
Feb 16, 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
19 changes: 14 additions & 5 deletions data/styles/SettingsPage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ settingspage {
}
}

.header-area,
.content-area {
padding: rem(12px);
}

.header-area {
// avatar is inside of a widget
widget {
Expand Down Expand Up @@ -85,6 +80,11 @@ settingspage {
}
}

.header-area,
.content-area {
padding: rem(12px);
}

actionbar.action-area {
// Don't style the revealer
background: transparent;
Expand All @@ -97,4 +97,13 @@ settingspage {
padding: rem(12px);
}
}

windowcontrols {
margin: rem(6px);

&.start,
&.end {
border-spacing: rem(6px);
}
}
}
30 changes: 25 additions & 5 deletions lib/SettingsPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public abstract class Switchboard.SettingsPage : Gtk.Widget {
*/
public string description { get; construct set; }

/**
* Whether to show title buttons at the end of the header area
*/
public bool show_end_title_buttons { get; set;}

private Adw.Clamp content_area;
private Gtk.ActionBar action_bar;
private Gtk.SizeGroup start_button_group;
Expand Down Expand Up @@ -121,14 +126,18 @@ public abstract class Switchboard.SettingsPage : Gtk.Widget {
title_label.add_css_class (Granite.STYLE_CLASS_H2_LABEL);

var description_label = new Gtk.Label (description) {
max_width_chars = 0,
selectable = true,
use_markup = true,
wrap = true,
xalign = 0
};

var header_area = new Gtk.Grid ();
var header_area = new Gtk.Grid () {
halign = CENTER
};
header_area.attach (title_label, 1, 0);
header_area.add_css_class ("header-area");

if (description != null) {
header_area.attach (header_widget, 0, 0, 1, 2);
Expand All @@ -144,20 +153,30 @@ public abstract class Switchboard.SettingsPage : Gtk.Widget {
header_area.attach (status_switch, 2, 0);
}

var header_clamp = new Adw.Clamp () {
child = header_area
var end_widget = new Gtk.WindowControls (END) {
valign = START
};

var headerbar = new Gtk.CenterBox () {
center_widget = header_area,
end_widget = end_widget
};
header_clamp.add_css_class ("header-area");

var window_handle = new Gtk.WindowHandle () {
child = header_clamp
child = headerbar
};

content_area = new Adw.Clamp () {
maximum_size = 600,
tightening_threshold = 600,
vexpand = true
};
content_area.add_css_class ("content-area");

var size_group = new Gtk.SizeGroup (HORIZONTAL);
size_group.add_widget (header_area);
size_group.add_widget (content_area);

var scrolled = new Gtk.ScrolledWindow () {
child = content_area,
hscrollbar_policy = NEVER
Expand All @@ -179,6 +198,7 @@ public abstract class Switchboard.SettingsPage : Gtk.Widget {

bind_property ("description", description_label, "label");
bind_property ("title", title_label, "label");
bind_property ("show-end-title-buttons", end_widget, "visible", SYNC_CREATE);

notify["description"].connect (() => {
if (description_label.parent == null) {
Expand Down