Add popover for entering session length

This commit is contained in:
Camden Dixie O'Brien 2025-02-27 22:56:04 +00:00
parent 5038a24539
commit 38ef12fa02

View File

@ -81,6 +81,50 @@ namespace StudySystemClient {
content.append(button); content.append(button);
set_child(content); set_child(content);
var log_session_popover = new LogSessionPopover();
log_session_popover.set_parent(button);
button.clicked.connect(() => log_session_popover.popup());
}
}
private class LogSessionPopover : Gtk.Popover {
private const int DEFAULT_LENGTH = 30;
private Gtk.SpinButton input;
public LogSessionPopover() {
var content = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 6);
var label = new Gtk.Label("Minutes");
label.halign = Gtk.Align.START;
content.append(label);
var adjustment
= new Gtk.Adjustment(DEFAULT_LENGTH, 10, 480, 10, 10, 0);
input = new Gtk.SpinButton(adjustment, 1, 0);
input.numeric = true;
content.append(input);
var button = new Gtk.Button.from_icon_name("emblem-ok-symbolic");
button.halign = Gtk.Align.END;
button.set_tooltip_text("Submit");
button.add_css_class("suggested-action");
button.clicked.connect(submit);
content.append(button);
set_child(content);
closed.connect(reset);
}
private void submit() {
reset();
popdown();
}
private void reset() {
input.value = DEFAULT_LENGTH;
} }
} }
} }