1use crate::{ffi, Widget};
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[doc(alias = "GtkNotebookPage")]
15 pub struct NotebookPage(Object<ffi::GtkNotebookPage>);
16
17 match fn {
18 type_ => || ffi::gtk_notebook_page_get_type(),
19 }
20}
21
22impl NotebookPage {
23 #[doc(alias = "gtk_notebook_page_get_child")]
24 #[doc(alias = "get_child")]
25 pub fn child(&self) -> Widget {
26 unsafe { from_glib_none(ffi::gtk_notebook_page_get_child(self.to_glib_none().0)) }
27 }
28
29 pub fn is_detachable(&self) -> bool {
30 ObjectExt::property(self, "detachable")
31 }
32
33 pub fn set_detachable(&self, detachable: bool) {
34 ObjectExt::set_property(self, "detachable", detachable)
35 }
36
37 pub fn menu(&self) -> Option<Widget> {
38 ObjectExt::property(self, "menu")
39 }
40
41 #[doc(alias = "menu-label")]
42 pub fn menu_label(&self) -> Option<glib::GString> {
43 ObjectExt::property(self, "menu-label")
44 }
45
46 #[doc(alias = "menu-label")]
47 pub fn set_menu_label(&self, menu_label: Option<&str>) {
48 ObjectExt::set_property(self, "menu-label", menu_label)
49 }
50
51 pub fn position(&self) -> i32 {
52 ObjectExt::property(self, "position")
53 }
54
55 pub fn set_position(&self, position: i32) {
56 ObjectExt::set_property(self, "position", position)
57 }
58
59 pub fn is_reorderable(&self) -> bool {
60 ObjectExt::property(self, "reorderable")
61 }
62
63 pub fn set_reorderable(&self, reorderable: bool) {
64 ObjectExt::set_property(self, "reorderable", reorderable)
65 }
66
67 pub fn tab(&self) -> Option<Widget> {
68 ObjectExt::property(self, "tab")
69 }
70
71 #[doc(alias = "tab-expand")]
72 pub fn is_tab_expand(&self) -> bool {
73 ObjectExt::property(self, "tab-expand")
74 }
75
76 #[doc(alias = "tab-expand")]
77 pub fn set_tab_expand(&self, tab_expand: bool) {
78 ObjectExt::set_property(self, "tab-expand", tab_expand)
79 }
80
81 #[doc(alias = "tab-fill")]
82 pub fn is_tab_fill(&self) -> bool {
83 ObjectExt::property(self, "tab-fill")
84 }
85
86 #[doc(alias = "tab-fill")]
87 pub fn set_tab_fill(&self, tab_fill: bool) {
88 ObjectExt::set_property(self, "tab-fill", tab_fill)
89 }
90
91 #[doc(alias = "tab-label")]
92 pub fn tab_label(&self) -> Option<glib::GString> {
93 ObjectExt::property(self, "tab-label")
94 }
95
96 #[doc(alias = "tab-label")]
97 pub fn set_tab_label(&self, tab_label: Option<&str>) {
98 ObjectExt::set_property(self, "tab-label", tab_label)
99 }
100
101 #[doc(alias = "detachable")]
102 pub fn connect_detachable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
103 unsafe extern "C" fn notify_detachable_trampoline<F: Fn(&NotebookPage) + 'static>(
104 this: *mut ffi::GtkNotebookPage,
105 _param_spec: glib::ffi::gpointer,
106 f: glib::ffi::gpointer,
107 ) {
108 let f: &F = &*(f as *const F);
109 f(&from_glib_borrow(this))
110 }
111 unsafe {
112 let f: Box_<F> = Box_::new(f);
113 connect_raw(
114 self.as_ptr() as *mut _,
115 c"notify::detachable".as_ptr() as *const _,
116 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
117 notify_detachable_trampoline::<F> as *const (),
118 )),
119 Box_::into_raw(f),
120 )
121 }
122 }
123
124 #[doc(alias = "menu-label")]
125 pub fn connect_menu_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
126 unsafe extern "C" fn notify_menu_label_trampoline<F: Fn(&NotebookPage) + 'static>(
127 this: *mut ffi::GtkNotebookPage,
128 _param_spec: glib::ffi::gpointer,
129 f: glib::ffi::gpointer,
130 ) {
131 let f: &F = &*(f as *const F);
132 f(&from_glib_borrow(this))
133 }
134 unsafe {
135 let f: Box_<F> = Box_::new(f);
136 connect_raw(
137 self.as_ptr() as *mut _,
138 c"notify::menu-label".as_ptr() as *const _,
139 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
140 notify_menu_label_trampoline::<F> as *const (),
141 )),
142 Box_::into_raw(f),
143 )
144 }
145 }
146
147 #[doc(alias = "position")]
148 pub fn connect_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
149 unsafe extern "C" fn notify_position_trampoline<F: Fn(&NotebookPage) + 'static>(
150 this: *mut ffi::GtkNotebookPage,
151 _param_spec: glib::ffi::gpointer,
152 f: glib::ffi::gpointer,
153 ) {
154 let f: &F = &*(f as *const F);
155 f(&from_glib_borrow(this))
156 }
157 unsafe {
158 let f: Box_<F> = Box_::new(f);
159 connect_raw(
160 self.as_ptr() as *mut _,
161 c"notify::position".as_ptr() as *const _,
162 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
163 notify_position_trampoline::<F> as *const (),
164 )),
165 Box_::into_raw(f),
166 )
167 }
168 }
169
170 #[doc(alias = "reorderable")]
171 pub fn connect_reorderable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
172 unsafe extern "C" fn notify_reorderable_trampoline<F: Fn(&NotebookPage) + 'static>(
173 this: *mut ffi::GtkNotebookPage,
174 _param_spec: glib::ffi::gpointer,
175 f: glib::ffi::gpointer,
176 ) {
177 let f: &F = &*(f as *const F);
178 f(&from_glib_borrow(this))
179 }
180 unsafe {
181 let f: Box_<F> = Box_::new(f);
182 connect_raw(
183 self.as_ptr() as *mut _,
184 c"notify::reorderable".as_ptr() as *const _,
185 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
186 notify_reorderable_trampoline::<F> as *const (),
187 )),
188 Box_::into_raw(f),
189 )
190 }
191 }
192
193 #[doc(alias = "tab-expand")]
194 pub fn connect_tab_expand_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
195 unsafe extern "C" fn notify_tab_expand_trampoline<F: Fn(&NotebookPage) + 'static>(
196 this: *mut ffi::GtkNotebookPage,
197 _param_spec: glib::ffi::gpointer,
198 f: glib::ffi::gpointer,
199 ) {
200 let f: &F = &*(f as *const F);
201 f(&from_glib_borrow(this))
202 }
203 unsafe {
204 let f: Box_<F> = Box_::new(f);
205 connect_raw(
206 self.as_ptr() as *mut _,
207 c"notify::tab-expand".as_ptr() as *const _,
208 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
209 notify_tab_expand_trampoline::<F> as *const (),
210 )),
211 Box_::into_raw(f),
212 )
213 }
214 }
215
216 #[doc(alias = "tab-fill")]
217 pub fn connect_tab_fill_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
218 unsafe extern "C" fn notify_tab_fill_trampoline<F: Fn(&NotebookPage) + 'static>(
219 this: *mut ffi::GtkNotebookPage,
220 _param_spec: glib::ffi::gpointer,
221 f: glib::ffi::gpointer,
222 ) {
223 let f: &F = &*(f as *const F);
224 f(&from_glib_borrow(this))
225 }
226 unsafe {
227 let f: Box_<F> = Box_::new(f);
228 connect_raw(
229 self.as_ptr() as *mut _,
230 c"notify::tab-fill".as_ptr() as *const _,
231 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
232 notify_tab_fill_trampoline::<F> as *const (),
233 )),
234 Box_::into_raw(f),
235 )
236 }
237 }
238
239 #[doc(alias = "tab-label")]
240 pub fn connect_tab_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
241 unsafe extern "C" fn notify_tab_label_trampoline<F: Fn(&NotebookPage) + 'static>(
242 this: *mut ffi::GtkNotebookPage,
243 _param_spec: glib::ffi::gpointer,
244 f: glib::ffi::gpointer,
245 ) {
246 let f: &F = &*(f as *const F);
247 f(&from_glib_borrow(this))
248 }
249 unsafe {
250 let f: Box_<F> = Box_::new(f);
251 connect_raw(
252 self.as_ptr() as *mut _,
253 c"notify::tab-label".as_ptr() as *const _,
254 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
255 notify_tab_label_trampoline::<F> as *const (),
256 )),
257 Box_::into_raw(f),
258 )
259 }
260 }
261}