forked from gtk-rs/gtk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
info_bar.rs
139 lines (118 loc) · 4.34 KB
/
info_bar.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
// This file was generated by gir (b7f5189) from gir-files (71d73f0)
// DO NOT EDIT
use Box;
use Button;
use Container;
use MessageType;
use Orientable;
use Widget;
use ffi;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use libc;
use std::boxed::Box as Box_;
use std::mem::transmute;
glib_wrapper! {
pub struct InfoBar(Object<ffi::GtkInfoBar>): Box, Container, Widget, Orientable;
match fn {
get_type => || ffi::gtk_info_bar_get_type(),
}
}
impl InfoBar {
pub fn new() -> InfoBar {
assert_initialized_main_thread!();
unsafe {
Widget::from_glib_none(ffi::gtk_info_bar_new()).downcast_unchecked()
}
}
//pub fn new_with_buttons<'a, T: Into<Option<&'a str>>>(first_button_text: T, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> InfoBar {
// unsafe { TODO: call ffi::gtk_info_bar_new_with_buttons() }
//}
pub fn add_action_widget<T: IsA<Widget>>(&self, child: &T, response_id: i32) {
unsafe {
ffi::gtk_info_bar_add_action_widget(self.to_glib_none().0, child.to_glib_none().0, response_id);
}
}
pub fn add_button(&self, button_text: &str, response_id: i32) -> Option<Button> {
unsafe {
from_glib_none(ffi::gtk_info_bar_add_button(self.to_glib_none().0, button_text.to_glib_none().0, response_id))
}
}
//pub fn add_buttons(&self, first_button_text: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
// unsafe { TODO: call ffi::gtk_info_bar_add_buttons() }
//}
pub fn get_action_area(&self) -> Option<Widget> {
unsafe {
from_glib_none(ffi::gtk_info_bar_get_action_area(self.to_glib_none().0))
}
}
pub fn get_content_area(&self) -> Option<Widget> {
unsafe {
from_glib_none(ffi::gtk_info_bar_get_content_area(self.to_glib_none().0))
}
}
pub fn get_message_type(&self) -> MessageType {
unsafe {
from_glib(ffi::gtk_info_bar_get_message_type(self.to_glib_none().0))
}
}
#[cfg(feature = "v3_10")]
pub fn get_show_close_button(&self) -> bool {
unsafe {
from_glib(ffi::gtk_info_bar_get_show_close_button(self.to_glib_none().0))
}
}
pub fn response(&self, response_id: i32) {
unsafe {
ffi::gtk_info_bar_response(self.to_glib_none().0, response_id);
}
}
pub fn set_default_response(&self, response_id: i32) {
unsafe {
ffi::gtk_info_bar_set_default_response(self.to_glib_none().0, response_id);
}
}
pub fn set_message_type(&self, message_type: MessageType) {
unsafe {
ffi::gtk_info_bar_set_message_type(self.to_glib_none().0, message_type.to_glib());
}
}
pub fn set_response_sensitive(&self, response_id: i32, setting: bool) {
unsafe {
ffi::gtk_info_bar_set_response_sensitive(self.to_glib_none().0, response_id, setting.to_glib());
}
}
#[cfg(feature = "v3_10")]
pub fn set_show_close_button(&self, setting: bool) {
unsafe {
ffi::gtk_info_bar_set_show_close_button(self.to_glib_none().0, setting.to_glib());
}
}
pub fn connect_close<F: Fn(&InfoBar) + 'static>(&self, f: F) -> u64 {
unsafe {
let f: Box_<Box_<Fn(&InfoBar) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "close",
transmute(close_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
pub fn connect_response<F: Fn(&InfoBar, i32) + 'static>(&self, f: F) -> u64 {
unsafe {
let f: Box_<Box_<Fn(&InfoBar, i32) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "response",
transmute(response_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe extern "C" fn close_trampoline(this: *mut ffi::GtkInfoBar, f: glib_ffi::gpointer) {
callback_guard!();
let f: &Box_<Fn(&InfoBar) + 'static> = transmute(f);
f(&from_glib_none(this))
}
unsafe extern "C" fn response_trampoline(this: *mut ffi::GtkInfoBar, response_id: libc::c_int, f: glib_ffi::gpointer) {
callback_guard!();
let f: &Box_<Fn(&InfoBar, i32) + 'static> = transmute(f);
f(&from_glib_none(this), response_id)
}