64 lines
1.8 KiB
Rust
64 lines
1.8 KiB
Rust
|
/*
|
||
|
Copyright 2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||
|
|
||
|
This file is part of FitnessTrax.
|
||
|
|
||
|
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||
|
General Public License as published by the Free Software Foundation, either version 3 of the
|
||
|
License, or (at your option) any later version.
|
||
|
|
||
|
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||
|
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
|
// use chrono::NaiveDate;
|
||
|
// use ft_core::TraxRecord;
|
||
|
use glib::Object;
|
||
|
use gtk::{prelude::*, subclass::prelude::*};
|
||
|
|
||
|
#[derive(Default)]
|
||
|
pub struct DaySummaryPrivate {
|
||
|
date: gtk::Label,
|
||
|
}
|
||
|
|
||
|
#[glib::object_subclass]
|
||
|
impl ObjectSubclass for DaySummaryPrivate {
|
||
|
const NAME: &'static str = "DaySummary";
|
||
|
type Type = DaySummary;
|
||
|
type ParentType = gtk::Box;
|
||
|
|
||
|
fn new() -> Self {
|
||
|
Self {
|
||
|
date: gtk::Label::new(None),
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl ObjectImpl for DaySummaryPrivate {}
|
||
|
impl WidgetImpl for DaySummaryPrivate {}
|
||
|
impl BoxImpl for DaySummaryPrivate {}
|
||
|
|
||
|
glib::wrapper! {
|
||
|
pub struct DaySummary(ObjectSubclass<DaySummaryPrivate>) @extends gtk::Box, gtk::Widget, @implements gtk::Orientable;
|
||
|
}
|
||
|
|
||
|
impl DaySummary {
|
||
|
pub fn new() -> Self {
|
||
|
let s: Self = Object::builder().build();
|
||
|
s.set_orientation(gtk::Orientation::Vertical);
|
||
|
|
||
|
s.append(&s.imp().date);
|
||
|
|
||
|
s
|
||
|
}
|
||
|
|
||
|
pub fn set_date(&self, date: chrono::NaiveDate) {
|
||
|
self.imp()
|
||
|
.date
|
||
|
.set_text(&date.format("%y-%m-%d").to_string());
|
||
|
}
|
||
|
}
|