-
-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathtabby_cat.rs
56 lines (46 loc) · 1.31 KB
/
tabby_cat.rs
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
49
50
51
52
53
54
55
56
use glib::subclass::prelude::*;
use super::cat::{Cat, CatImpl};
use super::pet::{Pet, PetImpl};
use super::purrable::{Purrable, PurrableImpl, PurrableImplExt};
mod imp {
use crate::PetImplExt;
use super::*;
#[derive(Default)]
pub struct TabbyCat {}
#[glib::object_subclass]
impl ObjectSubclass for TabbyCat {
const NAME: &'static str = "TabbyCat";
type Type = super::TabbyCat;
type ParentType = Cat;
/// We override a method of [`PurrableImpl`], so we must re-declare
/// that we conform to the interface. Otherwise our implementation
/// methods do not end up in the vtable.
type Interfaces = (Purrable,);
}
impl ObjectImpl for TabbyCat {}
impl PetImpl for TabbyCat {
fn feed(&self) {
println!("TabbyCat::feed");
self.parent_feed()
}
}
impl CatImpl for TabbyCat {}
impl PurrableImpl for TabbyCat {
fn is_purring(&self) -> bool {
println!("TabbyCat::is_purring");
self.parent_is_purring()
}
}
impl TabbyCat {}
}
glib::wrapper! {
pub struct TabbyCat(ObjectSubclass<imp::TabbyCat>)
@extends Cat, Pet,
@implements Purrable;
}
impl TabbyCat {}
impl Default for TabbyCat {
fn default() -> Self {
glib::Object::new()
}
}