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
use Action;
use ffi;
use glib::object::IsA;
use glib::translate::*;
use gobject_ffi;
glib_wrapper! {
pub struct ActionMap(Object<ffi::GActionMap>);
match fn {
get_type => || ffi::g_action_map_get_type(),
}
}
pub trait ActionMapExt {
fn add_action<P: IsA<Action>>(&self, action: &P);
fn lookup_action(&self, action_name: &str) -> Option<Action>;
fn remove_action(&self, action_name: &str);
}
impl<O: IsA<ActionMap>> ActionMapExt for O {
fn add_action<P: IsA<Action>>(&self, action: &P) {
unsafe {
ffi::g_action_map_add_action(self.to_glib_none().0, action.to_glib_none().0);
}
}
fn lookup_action(&self, action_name: &str) -> Option<Action> {
unsafe {
from_glib_none(ffi::g_action_map_lookup_action(self.to_glib_none().0, action_name.to_glib_none().0))
}
}
fn remove_action(&self, action_name: &str) {
unsafe {
ffi::g_action_map_remove_action(self.to_glib_none().0, action_name.to_glib_none().0);
}
}
}