PipeTap/src/gui/settings.vala
Vasiliy Doylov 2c08ae1195
Add contrast slider
Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
2025-04-06 00:50:22 +03:00

45 lines
No EOL
1.9 KiB
Vala

public class PipeTap.Ui.Settings : Adw.PreferencesDialog {
public Settings() {
var overlays = new Adw.PreferencesPage();
overlays.title = _("Overlays");
overlays.add(make_group_for("Main bar", "main-controls-pos"));
overlays.add(make_group_for("Exposure bar", "exp-pos"));
overlays.add(make_group_for("Contrast bar", "contrast-pos"));
overlays.add(make_group_for("Focus bar", "focus-pos"));
add(overlays);
}
Adw.PreferencesGroup make_group_for(string name, string child_name) {
var group = new Adw.PreferencesGroup();
group.title = _(name);
group.description = _("Set -1 to not anchor to side");
var orientation = new Adw.ComboRow();
orientation.title = _("Orientation");
orientation.model = new Gtk.StringList({ _("Vertical"), _("Horizontal") });
var top = new Adw.SpinRow.with_range(-1, double.MAX, 1);
top.title = _("Top spacing");
var bottom = new Adw.SpinRow.with_range(-1, double.MAX, 1);
bottom.title = _("Bottom spacing");
var right = new Adw.SpinRow.with_range(-1, double.MAX, 1);
right.title = _("Right spacing");
var left = new Adw.SpinRow.with_range(-1, double.MAX, 1);
left.title = _("Left spacing");
group.add(orientation);
group.add(top);
group.add(bottom);
group.add(left);
group.add(right);
var settings = Logic.app.settings.get_child(child_name);
settings.bind("margin-top", top, "value", SettingsBindFlags.DEFAULT);
settings.bind("margin-bottom", bottom, "value", SettingsBindFlags.DEFAULT);
settings.bind("margin-right", right, "value", SettingsBindFlags.DEFAULT);
settings.bind("margin-left", left, "value", SettingsBindFlags.DEFAULT);
settings.bind("orientation", orientation, "selected", SettingsBindFlags.DEFAULT);
return group;
}
}