From 38ef12fa02b87d1fdff8f43b208555ff42e83e26 Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Thu, 27 Feb 2025 22:56:04 +0000 Subject: [PATCH] Add popover for entering session length --- client/src/activities_view.vala | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/client/src/activities_view.vala b/client/src/activities_view.vala index 3c30249..143243b 100644 --- a/client/src/activities_view.vala +++ b/client/src/activities_view.vala @@ -81,6 +81,50 @@ namespace StudySystemClient { content.append(button); 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; } } }