Changes
2 changed files (+53/-5)
-
-
@@ -22,18 +22,25 @@var header_bar = new Adw.HeaderBar(); view.add_top_bar(header_bar); var body = new Gtk.Box(VERTICAL, 0); var list = new TimerList(model.active_timers); list.stop.connect((timer) => { model.update(new Event.TimerStopped(timer.id)); }); view.content = list; list.vexpand = true; body.append(list); var form = new NewTimerForm(); form.create.connect((title) => { model.update(new Event.TimerStarted(title)); }); body.append(form); view.content = body; this.title = "Time Tracker"; this.content = view; model.update(new Event.TimerStarted("Foo")); model.update(new Event.TimerStarted("Bar")); model.update(new Event.TimerStarted("Baz")); } } }
-
-
-
@@ -0,0 +1,41 @@// Copyright 2025 Shota FUJI // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. // // SPDX-License-Identifier: MPL-2.0 using GLib; namespace TimeTracker.Widget { public class NewTimerForm : Gtk.Box { public signal void create(string title); private Gtk.Text title_input = new Gtk.Text(); private Gtk.Button submit_button = new Gtk.Button(); construct { this.margin_top = 8; this.margin_bottom = this.margin_top; this.margin_start = 12; this.margin_end = this.margin_start; this.spacing = 8; title_input.activate.connect(this.submit); title_input.hexpand = true; this.append(title_input); submit_button.clicked.connect(this.submit); submit_button.label = "Start"; this.append(submit_button); } private void submit() { var title = title_input.text; create(title); title_input.text = ""; } } }
-