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
use crate::prelude::*;
use crate::{AboutDialog, Window};
use glib::translate::*;
use glib::{IsA, Quark, ToValue};
use once_cell::sync::Lazy;
#[doc(alias = "gtk_accelerator_valid")]
pub fn accelerator_valid(keyval: gdk::keys::Key, modifiers: gdk::ModifierType) -> bool {
assert_initialized_main_thread!();
unsafe {
from_glib(ffi::gtk_accelerator_valid(
keyval.into_glib(),
modifiers.into_glib(),
))
}
}
static SHOW_ABOUT_DIALOG_QUARK: Lazy<Quark> =
Lazy::new(|| Quark::from_string("gtk-rs-about-dialog"));
#[doc(alias = "gtk_show_about_dialog")]
pub fn show_about_dialog<P: IsA<Window>>(parent: Option<&P>, properties: &[(&str, &dyn ToValue)]) {
assert_initialized_main_thread!();
unsafe {
if let Some(d) = parent.and_then(|p| p.qdata::<AboutDialog>(*SHOW_ABOUT_DIALOG_QUARK)) {
d.as_ref().show();
} else {
let about_dialog = glib::Object::new::<AboutDialog>(properties)
.expect("Failed to crate an about dialog");
about_dialog.set_transient_for(parent);
about_dialog.set_modal(true);
about_dialog.set_destroy_with_parent(true);
if let Some(dialog_parent) = parent {
dialog_parent.set_qdata(*SHOW_ABOUT_DIALOG_QUARK, about_dialog.clone());
}
about_dialog.show();
};
}
}
#[doc(alias = "gtk_test_list_all_types")]
pub fn test_list_all_types() -> Vec<glib::Type> {
unsafe {
let mut n_types = std::mem::MaybeUninit::uninit();
let types = ffi::gtk_test_list_all_types(n_types.as_mut_ptr());
FromGlibContainer::from_glib_container_num(types, n_types.assume_init() as usize)
}
}