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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
use CellRenderer;
use CellRendererAccelMode;
use CellRendererText;
use TreePath;
use ffi;
use gdk;
use gdk_ffi;
use glib;
use glib::Value;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use libc;
use std::boxed::Box as Box_;
use std::mem::transmute;
glib_wrapper! {
pub struct CellRendererAccel(Object<ffi::GtkCellRendererAccel>): CellRendererText, CellRenderer;
match fn {
get_type => || ffi::gtk_cell_renderer_accel_get_type(),
}
}
impl CellRendererAccel {
pub fn new() -> CellRendererAccel {
assert_initialized_main_thread!();
unsafe {
CellRenderer::from_glib_none(ffi::gtk_cell_renderer_accel_new()).downcast_unchecked()
}
}
}
pub trait CellRendererAccelExt {
fn get_property_accel_key(&self) -> u32;
fn set_property_accel_key(&self, accel_key: u32);
fn get_property_accel_mode(&self) -> CellRendererAccelMode;
fn set_property_accel_mode(&self, accel_mode: CellRendererAccelMode);
fn get_property_accel_mods(&self) -> gdk::ModifierType;
fn set_property_accel_mods(&self, accel_mods: gdk::ModifierType);
fn get_property_keycode(&self) -> u32;
fn set_property_keycode(&self, keycode: u32);
fn connect_accel_cleared<F: Fn(&Self, TreePath) + 'static>(&self, f: F) -> u64;
fn connect_accel_edited<F: Fn(&Self, TreePath, u32, gdk::ModifierType, u32) + 'static>(&self, f: F) -> u64;
}
impl<O: IsA<CellRendererAccel> + IsA<glib::object::Object>> CellRendererAccelExt for O {
fn get_property_accel_key(&self) -> u32 {
let mut value = Value::from(&0u32);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "accel-key".to_glib_none().0, value.to_glib_none_mut().0);
}
value.get().unwrap()
}
fn set_property_accel_key(&self, accel_key: u32) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "accel-key".to_glib_none().0, Value::from(&accel_key).to_glib_none().0);
}
}
fn get_property_accel_mode(&self) -> CellRendererAccelMode {
let mut value = Value::from(&0);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "accel-mode".to_glib_none().0, value.to_glib_none_mut().0);
from_glib(transmute(value.get::<i32>().unwrap()))
}
}
fn set_property_accel_mode(&self, accel_mode: CellRendererAccelMode) {
let accel_mode = accel_mode.to_glib() as i32;
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "accel-mode".to_glib_none().0, Value::from(&accel_mode).to_glib_none().0);
}
}
fn get_property_accel_mods(&self) -> gdk::ModifierType {
let mut value = Value::from(&0u32);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "accel-mods".to_glib_none().0, value.to_glib_none_mut().0);
from_glib(transmute(value.get::<u32>().unwrap()))
}
}
fn set_property_accel_mods(&self, accel_mods: gdk::ModifierType) {
let accel_mods = accel_mods.to_glib().bits() as u32;
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "accel-mods".to_glib_none().0, Value::from(&accel_mods).to_glib_none().0);
}
}
fn get_property_keycode(&self) -> u32 {
let mut value = Value::from(&0u32);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "keycode".to_glib_none().0, value.to_glib_none_mut().0);
}
value.get().unwrap()
}
fn set_property_keycode(&self, keycode: u32) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "keycode".to_glib_none().0, Value::from(&keycode).to_glib_none().0);
}
}
fn connect_accel_cleared<F: Fn(&Self, TreePath) + 'static>(&self, f: F) -> u64 {
unsafe {
let f: Box_<Box_<Fn(&Self, TreePath) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "accel-cleared",
transmute(accel_cleared_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_accel_edited<F: Fn(&Self, TreePath, u32, gdk::ModifierType, u32) + 'static>(&self, f: F) -> u64 {
unsafe {
let f: Box_<Box_<Fn(&Self, TreePath, u32, gdk::ModifierType, u32) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "accel-edited",
transmute(accel_edited_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe extern "C" fn accel_cleared_trampoline<P>(this: *mut ffi::GtkCellRendererAccel, path_string: *mut libc::c_char, f: glib_ffi::gpointer)
where P: IsA<CellRendererAccel> {
callback_guard!();
let f: &Box_<Fn(&P, TreePath) + 'static> = transmute(f);
let path = from_glib_full(ffi::gtk_tree_path_new_from_string(path_string));
f(&CellRendererAccel::from_glib_none(this).downcast_unchecked(), path)
}
unsafe extern "C" fn accel_edited_trampoline<P>(this: *mut ffi::GtkCellRendererAccel, path_string: *mut libc::c_char, accel_key: libc::c_uint, accel_mods: gdk_ffi::GdkModifierType, hardware_keycode: libc::c_uint, f: glib_ffi::gpointer)
where P: IsA<CellRendererAccel> {
callback_guard!();
let f: &Box_<Fn(&P, TreePath, u32, gdk::ModifierType, u32) + 'static> = transmute(f);
let path = from_glib_full(ffi::gtk_tree_path_new_from_string(path_string));
f(&CellRendererAccel::from_glib_none(this).downcast_unchecked(), path, accel_key, from_glib(accel_mods), hardware_keycode)
}