1use crate::{Widget, ffi};
6use glib::{
7 prelude::*,
8 signal::{SignalHandlerId, connect_raw},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[doc(alias = "GtkNotebookPage")]
82 pub struct NotebookPage(Object<ffi::GtkNotebookPage>);
83
84 match fn {
85 type_ => || ffi::gtk_notebook_page_get_type(),
86 }
87}
88
89impl NotebookPage {
90 #[doc(alias = "gtk_notebook_page_get_child")]
96 #[doc(alias = "get_child")]
97 pub fn child(&self) -> Widget {
98 unsafe { from_glib_none(ffi::gtk_notebook_page_get_child(self.to_glib_none().0)) }
99 }
100
101 pub fn is_detachable(&self) -> bool {
103 ObjectExt::property(self, "detachable")
104 }
105
106 pub fn set_detachable(&self, detachable: bool) {
108 ObjectExt::set_property(self, "detachable", detachable)
109 }
110
111 pub fn menu(&self) -> Option<Widget> {
113 ObjectExt::property(self, "menu")
114 }
115
116 #[doc(alias = "menu-label")]
118 pub fn menu_label(&self) -> Option<glib::GString> {
119 ObjectExt::property(self, "menu-label")
120 }
121
122 #[doc(alias = "menu-label")]
124 pub fn set_menu_label(&self, menu_label: Option<&str>) {
125 ObjectExt::set_property(self, "menu-label", menu_label)
126 }
127
128 pub fn position(&self) -> i32 {
130 ObjectExt::property(self, "position")
131 }
132
133 pub fn set_position(&self, position: i32) {
135 ObjectExt::set_property(self, "position", position)
136 }
137
138 pub fn is_reorderable(&self) -> bool {
140 ObjectExt::property(self, "reorderable")
141 }
142
143 pub fn set_reorderable(&self, reorderable: bool) {
145 ObjectExt::set_property(self, "reorderable", reorderable)
146 }
147
148 pub fn tab(&self) -> Option<Widget> {
150 ObjectExt::property(self, "tab")
151 }
152
153 #[doc(alias = "tab-expand")]
155 pub fn is_tab_expand(&self) -> bool {
156 ObjectExt::property(self, "tab-expand")
157 }
158
159 #[doc(alias = "tab-expand")]
161 pub fn set_tab_expand(&self, tab_expand: bool) {
162 ObjectExt::set_property(self, "tab-expand", tab_expand)
163 }
164
165 #[doc(alias = "tab-fill")]
167 pub fn is_tab_fill(&self) -> bool {
168 ObjectExt::property(self, "tab-fill")
169 }
170
171 #[doc(alias = "tab-fill")]
173 pub fn set_tab_fill(&self, tab_fill: bool) {
174 ObjectExt::set_property(self, "tab-fill", tab_fill)
175 }
176
177 #[doc(alias = "tab-label")]
179 pub fn tab_label(&self) -> Option<glib::GString> {
180 ObjectExt::property(self, "tab-label")
181 }
182
183 #[doc(alias = "tab-label")]
185 pub fn set_tab_label(&self, tab_label: Option<&str>) {
186 ObjectExt::set_property(self, "tab-label", tab_label)
187 }
188
189 #[doc(alias = "detachable")]
190 pub fn connect_detachable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
191 unsafe extern "C" fn notify_detachable_trampoline<F: Fn(&NotebookPage) + 'static>(
192 this: *mut ffi::GtkNotebookPage,
193 _param_spec: glib::ffi::gpointer,
194 f: glib::ffi::gpointer,
195 ) {
196 unsafe {
197 let f: &F = &*(f as *const F);
198 f(&from_glib_borrow(this))
199 }
200 }
201 unsafe {
202 let f: Box_<F> = Box_::new(f);
203 connect_raw(
204 self.as_ptr() as *mut _,
205 c"notify::detachable".as_ptr() as *const _,
206 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
207 notify_detachable_trampoline::<F> as *const (),
208 )),
209 Box_::into_raw(f),
210 )
211 }
212 }
213
214 #[doc(alias = "menu-label")]
215 pub fn connect_menu_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
216 unsafe extern "C" fn notify_menu_label_trampoline<F: Fn(&NotebookPage) + 'static>(
217 this: *mut ffi::GtkNotebookPage,
218 _param_spec: glib::ffi::gpointer,
219 f: glib::ffi::gpointer,
220 ) {
221 unsafe {
222 let f: &F = &*(f as *const F);
223 f(&from_glib_borrow(this))
224 }
225 }
226 unsafe {
227 let f: Box_<F> = Box_::new(f);
228 connect_raw(
229 self.as_ptr() as *mut _,
230 c"notify::menu-label".as_ptr() as *const _,
231 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
232 notify_menu_label_trampoline::<F> as *const (),
233 )),
234 Box_::into_raw(f),
235 )
236 }
237 }
238
239 #[doc(alias = "position")]
240 pub fn connect_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
241 unsafe extern "C" fn notify_position_trampoline<F: Fn(&NotebookPage) + 'static>(
242 this: *mut ffi::GtkNotebookPage,
243 _param_spec: glib::ffi::gpointer,
244 f: glib::ffi::gpointer,
245 ) {
246 unsafe {
247 let f: &F = &*(f as *const F);
248 f(&from_glib_borrow(this))
249 }
250 }
251 unsafe {
252 let f: Box_<F> = Box_::new(f);
253 connect_raw(
254 self.as_ptr() as *mut _,
255 c"notify::position".as_ptr() as *const _,
256 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
257 notify_position_trampoline::<F> as *const (),
258 )),
259 Box_::into_raw(f),
260 )
261 }
262 }
263
264 #[doc(alias = "reorderable")]
265 pub fn connect_reorderable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
266 unsafe extern "C" fn notify_reorderable_trampoline<F: Fn(&NotebookPage) + 'static>(
267 this: *mut ffi::GtkNotebookPage,
268 _param_spec: glib::ffi::gpointer,
269 f: glib::ffi::gpointer,
270 ) {
271 unsafe {
272 let f: &F = &*(f as *const F);
273 f(&from_glib_borrow(this))
274 }
275 }
276 unsafe {
277 let f: Box_<F> = Box_::new(f);
278 connect_raw(
279 self.as_ptr() as *mut _,
280 c"notify::reorderable".as_ptr() as *const _,
281 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
282 notify_reorderable_trampoline::<F> as *const (),
283 )),
284 Box_::into_raw(f),
285 )
286 }
287 }
288
289 #[doc(alias = "tab-expand")]
290 pub fn connect_tab_expand_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
291 unsafe extern "C" fn notify_tab_expand_trampoline<F: Fn(&NotebookPage) + 'static>(
292 this: *mut ffi::GtkNotebookPage,
293 _param_spec: glib::ffi::gpointer,
294 f: glib::ffi::gpointer,
295 ) {
296 unsafe {
297 let f: &F = &*(f as *const F);
298 f(&from_glib_borrow(this))
299 }
300 }
301 unsafe {
302 let f: Box_<F> = Box_::new(f);
303 connect_raw(
304 self.as_ptr() as *mut _,
305 c"notify::tab-expand".as_ptr() as *const _,
306 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
307 notify_tab_expand_trampoline::<F> as *const (),
308 )),
309 Box_::into_raw(f),
310 )
311 }
312 }
313
314 #[doc(alias = "tab-fill")]
315 pub fn connect_tab_fill_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
316 unsafe extern "C" fn notify_tab_fill_trampoline<F: Fn(&NotebookPage) + 'static>(
317 this: *mut ffi::GtkNotebookPage,
318 _param_spec: glib::ffi::gpointer,
319 f: glib::ffi::gpointer,
320 ) {
321 unsafe {
322 let f: &F = &*(f as *const F);
323 f(&from_glib_borrow(this))
324 }
325 }
326 unsafe {
327 let f: Box_<F> = Box_::new(f);
328 connect_raw(
329 self.as_ptr() as *mut _,
330 c"notify::tab-fill".as_ptr() as *const _,
331 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
332 notify_tab_fill_trampoline::<F> as *const (),
333 )),
334 Box_::into_raw(f),
335 )
336 }
337 }
338
339 #[doc(alias = "tab-label")]
340 pub fn connect_tab_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
341 unsafe extern "C" fn notify_tab_label_trampoline<F: Fn(&NotebookPage) + 'static>(
342 this: *mut ffi::GtkNotebookPage,
343 _param_spec: glib::ffi::gpointer,
344 f: glib::ffi::gpointer,
345 ) {
346 unsafe {
347 let f: &F = &*(f as *const F);
348 f(&from_glib_borrow(this))
349 }
350 }
351 unsafe {
352 let f: Box_<F> = Box_::new(f);
353 connect_raw(
354 self.as_ptr() as *mut _,
355 c"notify::tab-label".as_ptr() as *const _,
356 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
357 notify_tab_label_trampoline::<F> as *const (),
358 )),
359 Box_::into_raw(f),
360 )
361 }
362 }
363}