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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
use StateFlags;
use StyleProvider;
use SymbolicColor;
use ffi;
use glib;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::mem;
use std::ptr;
glib_wrapper! {
pub struct StyleProperties(Object<ffi::GtkStyleProperties, ffi::GtkStylePropertiesClass>): StyleProvider;
match fn {
get_type => || ffi::gtk_style_properties_get_type(),
}
}
impl StyleProperties {
pub fn new() -> StyleProperties {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gtk_style_properties_new())
}
}
}
impl Default for StyleProperties {
fn default() -> Self {
Self::new()
}
}
pub trait StylePropertiesExt {
fn clear(&self);
fn get_property(&self, property: &str, state: StateFlags) -> Option<glib::Value>;
fn lookup_color(&self, name: &str) -> Option<SymbolicColor>;
fn map_color(&self, name: &str, color: &SymbolicColor);
fn merge(&self, props_to_merge: &StyleProperties, replace: bool);
fn set_property(&self, property: &str, state: StateFlags, value: &glib::Value);
fn unset_property(&self, property: &str, state: StateFlags);
}
impl<O: IsA<StyleProperties>> StylePropertiesExt for O {
fn clear(&self) {
unsafe {
ffi::gtk_style_properties_clear(self.to_glib_none().0);
}
}
fn get_property(&self, property: &str, state: StateFlags) -> Option<glib::Value> {
unsafe {
let mut value = glib::Value::uninitialized();
let ret = from_glib(ffi::gtk_style_properties_get_property(self.to_glib_none().0, property.to_glib_none().0, state.to_glib(), value.to_glib_none_mut().0));
if ret { Some(value) } else { None }
}
}
fn lookup_color(&self, name: &str) -> Option<SymbolicColor> {
unsafe {
from_glib_none(ffi::gtk_style_properties_lookup_color(self.to_glib_none().0, name.to_glib_none().0))
}
}
fn map_color(&self, name: &str, color: &SymbolicColor) {
unsafe {
ffi::gtk_style_properties_map_color(self.to_glib_none().0, name.to_glib_none().0, color.to_glib_none().0);
}
}
fn merge(&self, props_to_merge: &StyleProperties, replace: bool) {
unsafe {
ffi::gtk_style_properties_merge(self.to_glib_none().0, props_to_merge.to_glib_none().0, replace.to_glib());
}
}
fn set_property(&self, property: &str, state: StateFlags, value: &glib::Value) {
unsafe {
ffi::gtk_style_properties_set_property(self.to_glib_none().0, property.to_glib_none().0, state.to_glib(), value.to_glib_none().0);
}
}
fn unset_property(&self, property: &str, state: StateFlags) {
unsafe {
ffi::gtk_style_properties_unset_property(self.to_glib_none().0, property.to_glib_none().0, state.to_glib());
}
}
}