This commit is contained in:
Günther Wagner 2022-10-15 17:17:58 +02:00
commit d7e8932a38
2 changed files with 56 additions and 0 deletions

9
build.rs Normal file
View File

@ -0,0 +1,9 @@
use gtk::gio;
fn main() {
gio::compile_resources(
"src",
"src/gtimelog4.gresource.xml",
"gtimelog4.gresource",
);
}

47
src/timeentry.rs Normal file
View File

@ -0,0 +1,47 @@
use gtk::glib;
use gtk::subclass::prelude::ObjectSubclassExt;
use rtimelog::store::Entry;
mod imp {
use std::cell::RefCell;
use std::rc::Rc;
use super::*;
use gtk::subclass::prelude::{ObjectImpl, ObjectSubclass};
#[derive(Default)]
pub struct TimeEntry {
pub(crate) entry: Rc<RefCell<rtimelog::store::Entry>>,
}
impl TimeEntry {
}
#[glib::object_subclass]
impl ObjectSubclass for TimeEntry {
const NAME: &'static str = "TimeEntry";
type Type = super::TimeEntry;
type ParentType = glib::Object;
}
impl ObjectImpl for TimeEntry {}
}
glib::wrapper! {
pub struct TimeEntry(ObjectSubclass<imp::TimeEntry>);
}
impl TimeEntry {
pub fn new(entry: rtimelog::store::Entry) -> Self {
let obj = glib::Object::new(&[]).expect("Could not create TimeEntry");
let imp = imp::TimeEntry::from_instance(&obj);
imp.entry.replace(entry);
obj
}
}
impl From<rtimelog::store::Entry> for TimeEntry {
fn from(entry: Entry) -> Self {
TimeEntry::new(entry)
}
}