forked from gtk-rs/gtk-rs-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthor.rs
More file actions
48 lines (42 loc) · 1.19 KB
/
author.rs
File metadata and controls
48 lines (42 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// You can copy/paste this file every time you need a simple GObject
// to hold some data
use glib::prelude::*;
use glib::subclass::prelude::*;
use glib::subclass::Signal;
use glib::Properties;
use std::cell::RefCell;
use std::sync::OnceLock;
mod imp {
use super::*;
#[derive(Properties, Default)]
#[properties(wrapper_type = super::Author)]
pub struct Author {
#[property(get, set)]
name: RefCell<String>,
#[property(get, set)]
surname: RefCell<String>,
}
#[glib::derived_properties]
impl ObjectImpl for Author {
fn signals() -> &'static [Signal] {
static SIGNALS: OnceLock<Vec<Signal>> = OnceLock::new();
SIGNALS.get_or_init(|| vec![Signal::builder("awarded").build()])
}
}
#[glib::object_subclass]
impl ObjectSubclass for Author {
const NAME: &'static str = "Author";
type Type = super::Author;
}
}
glib::wrapper! {
pub struct Author(ObjectSubclass<imp::Author>);
}
impl Author {
pub fn new(name: &str, surname: &str) -> Self {
glib::Object::builder()
.property("name", name)
.property("surname", surname)
.build()
}
}