aboutsummaryrefslogtreecommitdiff
path: root/src/gui/form/utils.rs
blob: 5cf59e339302aec0a76064dcc686b145b012a10e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use gtk4 as gtk;

use chrono::NaiveTime;

use crate::model::time;

pub fn time_entry(time: Option<NaiveTime>) -> gtk::Entry {
    entry(&time.map(time::pprint).unwrap_or_else(|| "".to_string()))
}

pub fn entry(text: &str) -> gtk::Entry {
    gtk::Entry::builder().text(text).margin_bottom(10).build()
}

pub fn label(text: &str) -> gtk::Label {
    gtk::Label::builder()
        .label(text)
        .halign(gtk::Align::Start)
        .margin_bottom(5)
        .build()
}