forked from gtk-rs/gtk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
calendar.rs
328 lines (280 loc) · 11.2 KB
/
calendar.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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
// This file was generated by gir (b7f5189) from gir-files (71d73f0)
// DO NOT EDIT
use CalendarDisplayOptions;
use Widget;
use ffi;
use glib::Value;
use glib::object::Downcast;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
glib_wrapper! {
pub struct Calendar(Object<ffi::GtkCalendar>): Widget;
match fn {
get_type => || ffi::gtk_calendar_get_type(),
}
}
impl Calendar {
pub fn new() -> Calendar {
assert_initialized_main_thread!();
unsafe {
Widget::from_glib_none(ffi::gtk_calendar_new()).downcast_unchecked()
}
}
pub fn clear_marks(&self) {
unsafe {
ffi::gtk_calendar_clear_marks(self.to_glib_none().0);
}
}
pub fn get_date(&self) -> (u32, u32, u32) {
unsafe {
let mut year = mem::uninitialized();
let mut month = mem::uninitialized();
let mut day = mem::uninitialized();
ffi::gtk_calendar_get_date(self.to_glib_none().0, &mut year, &mut month, &mut day);
(year, month, day)
}
}
pub fn get_day_is_marked(&self, day: u32) -> bool {
unsafe {
from_glib(ffi::gtk_calendar_get_day_is_marked(self.to_glib_none().0, day))
}
}
pub fn get_detail_height_rows(&self) -> i32 {
unsafe {
ffi::gtk_calendar_get_detail_height_rows(self.to_glib_none().0)
}
}
pub fn get_detail_width_chars(&self) -> i32 {
unsafe {
ffi::gtk_calendar_get_detail_width_chars(self.to_glib_none().0)
}
}
pub fn get_display_options(&self) -> CalendarDisplayOptions {
unsafe {
from_glib(ffi::gtk_calendar_get_display_options(self.to_glib_none().0))
}
}
pub fn mark_day(&self, day: u32) {
unsafe {
ffi::gtk_calendar_mark_day(self.to_glib_none().0, day);
}
}
pub fn select_day(&self, day: u32) {
unsafe {
ffi::gtk_calendar_select_day(self.to_glib_none().0, day);
}
}
pub fn select_month(&self, month: u32, year: u32) {
unsafe {
ffi::gtk_calendar_select_month(self.to_glib_none().0, month, year);
}
}
//pub fn set_detail_func(&self, func: /*Unknown conversion*//*Unimplemented*/CalendarDetailFunc, data: /*Unimplemented*/Option<Fundamental: Pointer>, destroy: /*Unknown conversion*//*Unimplemented*/DestroyNotify) {
// unsafe { TODO: call ffi::gtk_calendar_set_detail_func() }
//}
pub fn set_detail_height_rows(&self, rows: i32) {
unsafe {
ffi::gtk_calendar_set_detail_height_rows(self.to_glib_none().0, rows);
}
}
pub fn set_detail_width_chars(&self, chars: i32) {
unsafe {
ffi::gtk_calendar_set_detail_width_chars(self.to_glib_none().0, chars);
}
}
pub fn set_display_options(&self, flags: CalendarDisplayOptions) {
unsafe {
ffi::gtk_calendar_set_display_options(self.to_glib_none().0, flags.to_glib());
}
}
pub fn unmark_day(&self, day: u32) {
unsafe {
ffi::gtk_calendar_unmark_day(self.to_glib_none().0, day);
}
}
pub fn get_property_day(&self) -> i32 {
let mut value = Value::from(&0);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "day".to_glib_none().0, value.to_glib_none_mut().0);
}
value.get().unwrap()
}
pub fn set_property_day(&self, day: i32) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "day".to_glib_none().0, Value::from(&day).to_glib_none().0);
}
}
pub fn get_property_month(&self) -> i32 {
let mut value = Value::from(&0);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "month".to_glib_none().0, value.to_glib_none_mut().0);
}
value.get().unwrap()
}
pub fn set_property_month(&self, month: i32) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "month".to_glib_none().0, Value::from(&month).to_glib_none().0);
}
}
pub fn get_property_no_month_change(&self) -> bool {
let mut value = Value::from(&false);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "no-month-change".to_glib_none().0, value.to_glib_none_mut().0);
}
value.get().unwrap()
}
pub fn set_property_no_month_change(&self, no_month_change: bool) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "no-month-change".to_glib_none().0, Value::from(&no_month_change).to_glib_none().0);
}
}
pub fn get_property_show_day_names(&self) -> bool {
let mut value = Value::from(&false);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "show-day-names".to_glib_none().0, value.to_glib_none_mut().0);
}
value.get().unwrap()
}
pub fn set_property_show_day_names(&self, show_day_names: bool) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "show-day-names".to_glib_none().0, Value::from(&show_day_names).to_glib_none().0);
}
}
pub fn get_property_show_details(&self) -> bool {
let mut value = Value::from(&false);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "show-details".to_glib_none().0, value.to_glib_none_mut().0);
}
value.get().unwrap()
}
pub fn set_property_show_details(&self, show_details: bool) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "show-details".to_glib_none().0, Value::from(&show_details).to_glib_none().0);
}
}
pub fn get_property_show_heading(&self) -> bool {
let mut value = Value::from(&false);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "show-heading".to_glib_none().0, value.to_glib_none_mut().0);
}
value.get().unwrap()
}
pub fn set_property_show_heading(&self, show_heading: bool) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "show-heading".to_glib_none().0, Value::from(&show_heading).to_glib_none().0);
}
}
pub fn get_property_show_week_numbers(&self) -> bool {
let mut value = Value::from(&false);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "show-week-numbers".to_glib_none().0, value.to_glib_none_mut().0);
}
value.get().unwrap()
}
pub fn set_property_show_week_numbers(&self, show_week_numbers: bool) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "show-week-numbers".to_glib_none().0, Value::from(&show_week_numbers).to_glib_none().0);
}
}
pub fn get_property_year(&self) -> i32 {
let mut value = Value::from(&0);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "year".to_glib_none().0, value.to_glib_none_mut().0);
}
value.get().unwrap()
}
pub fn set_property_year(&self, year: i32) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "year".to_glib_none().0, Value::from(&year).to_glib_none().0);
}
}
pub fn connect_day_selected<F: Fn(&Calendar) + 'static>(&self, f: F) -> u64 {
unsafe {
let f: Box_<Box_<Fn(&Calendar) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "day-selected",
transmute(day_selected_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
pub fn connect_day_selected_double_click<F: Fn(&Calendar) + 'static>(&self, f: F) -> u64 {
unsafe {
let f: Box_<Box_<Fn(&Calendar) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "day-selected-double-click",
transmute(day_selected_double_click_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
pub fn connect_month_changed<F: Fn(&Calendar) + 'static>(&self, f: F) -> u64 {
unsafe {
let f: Box_<Box_<Fn(&Calendar) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "month-changed",
transmute(month_changed_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
pub fn connect_next_month<F: Fn(&Calendar) + 'static>(&self, f: F) -> u64 {
unsafe {
let f: Box_<Box_<Fn(&Calendar) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "next-month",
transmute(next_month_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
pub fn connect_next_year<F: Fn(&Calendar) + 'static>(&self, f: F) -> u64 {
unsafe {
let f: Box_<Box_<Fn(&Calendar) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "next-year",
transmute(next_year_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
pub fn connect_prev_month<F: Fn(&Calendar) + 'static>(&self, f: F) -> u64 {
unsafe {
let f: Box_<Box_<Fn(&Calendar) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "prev-month",
transmute(prev_month_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
pub fn connect_prev_year<F: Fn(&Calendar) + 'static>(&self, f: F) -> u64 {
unsafe {
let f: Box_<Box_<Fn(&Calendar) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "prev-year",
transmute(prev_year_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe extern "C" fn day_selected_trampoline(this: *mut ffi::GtkCalendar, f: glib_ffi::gpointer) {
callback_guard!();
let f: &Box_<Fn(&Calendar) + 'static> = transmute(f);
f(&from_glib_none(this))
}
unsafe extern "C" fn day_selected_double_click_trampoline(this: *mut ffi::GtkCalendar, f: glib_ffi::gpointer) {
callback_guard!();
let f: &Box_<Fn(&Calendar) + 'static> = transmute(f);
f(&from_glib_none(this))
}
unsafe extern "C" fn month_changed_trampoline(this: *mut ffi::GtkCalendar, f: glib_ffi::gpointer) {
callback_guard!();
let f: &Box_<Fn(&Calendar) + 'static> = transmute(f);
f(&from_glib_none(this))
}
unsafe extern "C" fn next_month_trampoline(this: *mut ffi::GtkCalendar, f: glib_ffi::gpointer) {
callback_guard!();
let f: &Box_<Fn(&Calendar) + 'static> = transmute(f);
f(&from_glib_none(this))
}
unsafe extern "C" fn next_year_trampoline(this: *mut ffi::GtkCalendar, f: glib_ffi::gpointer) {
callback_guard!();
let f: &Box_<Fn(&Calendar) + 'static> = transmute(f);
f(&from_glib_none(this))
}
unsafe extern "C" fn prev_month_trampoline(this: *mut ffi::GtkCalendar, f: glib_ffi::gpointer) {
callback_guard!();
let f: &Box_<Fn(&Calendar) + 'static> = transmute(f);
f(&from_glib_none(this))
}
unsafe extern "C" fn prev_year_trampoline(this: *mut ffi::GtkCalendar, f: glib_ffi::gpointer) {
callback_guard!();
let f: &Box_<Fn(&Calendar) + 'static> = transmute(f);
f(&from_glib_none(this))
}