[go: up one dir, main page]

gtk4/auto/
notebook.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6    ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, DirectionType,
7    LayoutManager, NotebookPage, NotebookTab, Overflow, PackType, PositionType, Widget,
8};
9use glib::{
10    object::ObjectType as _,
11    prelude::*,
12    signal::{connect_raw, SignalHandlerId},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18    #[doc(alias = "GtkNotebook")]
19    pub struct Notebook(Object<ffi::GtkNotebook>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
20
21    match fn {
22        type_ => || ffi::gtk_notebook_get_type(),
23    }
24}
25
26impl Notebook {
27    #[doc(alias = "gtk_notebook_new")]
28    pub fn new() -> Notebook {
29        assert_initialized_main_thread!();
30        unsafe { Widget::from_glib_none(ffi::gtk_notebook_new()).unsafe_cast() }
31    }
32
33    // rustdoc-stripper-ignore-next
34    /// Creates a new builder-pattern struct instance to construct [`Notebook`] objects.
35    ///
36    /// This method returns an instance of [`NotebookBuilder`](crate::builders::NotebookBuilder) which can be used to create [`Notebook`] objects.
37    pub fn builder() -> NotebookBuilder {
38        NotebookBuilder::new()
39    }
40
41    #[doc(alias = "gtk_notebook_detach_tab")]
42    pub fn detach_tab(&self, child: &impl IsA<Widget>) {
43        unsafe {
44            ffi::gtk_notebook_detach_tab(self.to_glib_none().0, child.as_ref().to_glib_none().0);
45        }
46    }
47
48    #[doc(alias = "gtk_notebook_get_action_widget")]
49    #[doc(alias = "get_action_widget")]
50    pub fn action_widget(&self, pack_type: PackType) -> Option<Widget> {
51        unsafe {
52            from_glib_none(ffi::gtk_notebook_get_action_widget(
53                self.to_glib_none().0,
54                pack_type.into_glib(),
55            ))
56        }
57    }
58
59    #[doc(alias = "gtk_notebook_get_group_name")]
60    #[doc(alias = "get_group_name")]
61    #[doc(alias = "group-name")]
62    pub fn group_name(&self) -> Option<glib::GString> {
63        unsafe { from_glib_none(ffi::gtk_notebook_get_group_name(self.to_glib_none().0)) }
64    }
65
66    #[doc(alias = "gtk_notebook_get_menu_label")]
67    #[doc(alias = "get_menu_label")]
68    pub fn menu_label(&self, child: &impl IsA<Widget>) -> Option<Widget> {
69        unsafe {
70            from_glib_none(ffi::gtk_notebook_get_menu_label(
71                self.to_glib_none().0,
72                child.as_ref().to_glib_none().0,
73            ))
74        }
75    }
76
77    #[doc(alias = "gtk_notebook_get_menu_label_text")]
78    #[doc(alias = "get_menu_label_text")]
79    pub fn menu_label_text(&self, child: &impl IsA<Widget>) -> Option<glib::GString> {
80        unsafe {
81            from_glib_none(ffi::gtk_notebook_get_menu_label_text(
82                self.to_glib_none().0,
83                child.as_ref().to_glib_none().0,
84            ))
85        }
86    }
87
88    #[doc(alias = "gtk_notebook_get_page")]
89    #[doc(alias = "get_page")]
90    pub fn page(&self, child: &impl IsA<Widget>) -> NotebookPage {
91        unsafe {
92            from_glib_none(ffi::gtk_notebook_get_page(
93                self.to_glib_none().0,
94                child.as_ref().to_glib_none().0,
95            ))
96        }
97    }
98
99    #[doc(alias = "gtk_notebook_get_pages")]
100    #[doc(alias = "get_pages")]
101    pub fn pages(&self) -> gio::ListModel {
102        unsafe { from_glib_full(ffi::gtk_notebook_get_pages(self.to_glib_none().0)) }
103    }
104
105    #[doc(alias = "gtk_notebook_get_scrollable")]
106    #[doc(alias = "get_scrollable")]
107    #[doc(alias = "scrollable")]
108    pub fn is_scrollable(&self) -> bool {
109        unsafe { from_glib(ffi::gtk_notebook_get_scrollable(self.to_glib_none().0)) }
110    }
111
112    #[doc(alias = "gtk_notebook_get_show_border")]
113    #[doc(alias = "get_show_border")]
114    #[doc(alias = "show-border")]
115    pub fn shows_border(&self) -> bool {
116        unsafe { from_glib(ffi::gtk_notebook_get_show_border(self.to_glib_none().0)) }
117    }
118
119    #[doc(alias = "gtk_notebook_get_show_tabs")]
120    #[doc(alias = "get_show_tabs")]
121    #[doc(alias = "show-tabs")]
122    pub fn shows_tabs(&self) -> bool {
123        unsafe { from_glib(ffi::gtk_notebook_get_show_tabs(self.to_glib_none().0)) }
124    }
125
126    #[doc(alias = "gtk_notebook_get_tab_detachable")]
127    #[doc(alias = "get_tab_detachable")]
128    pub fn tab_is_detachable(&self, child: &impl IsA<Widget>) -> bool {
129        unsafe {
130            from_glib(ffi::gtk_notebook_get_tab_detachable(
131                self.to_glib_none().0,
132                child.as_ref().to_glib_none().0,
133            ))
134        }
135    }
136
137    #[doc(alias = "gtk_notebook_get_tab_label")]
138    #[doc(alias = "get_tab_label")]
139    pub fn tab_label(&self, child: &impl IsA<Widget>) -> Option<Widget> {
140        unsafe {
141            from_glib_none(ffi::gtk_notebook_get_tab_label(
142                self.to_glib_none().0,
143                child.as_ref().to_glib_none().0,
144            ))
145        }
146    }
147
148    #[doc(alias = "gtk_notebook_get_tab_label_text")]
149    #[doc(alias = "get_tab_label_text")]
150    pub fn tab_label_text(&self, child: &impl IsA<Widget>) -> Option<glib::GString> {
151        unsafe {
152            from_glib_none(ffi::gtk_notebook_get_tab_label_text(
153                self.to_glib_none().0,
154                child.as_ref().to_glib_none().0,
155            ))
156        }
157    }
158
159    #[doc(alias = "gtk_notebook_get_tab_pos")]
160    #[doc(alias = "get_tab_pos")]
161    #[doc(alias = "tab-pos")]
162    pub fn tab_pos(&self) -> PositionType {
163        unsafe { from_glib(ffi::gtk_notebook_get_tab_pos(self.to_glib_none().0)) }
164    }
165
166    #[doc(alias = "gtk_notebook_get_tab_reorderable")]
167    #[doc(alias = "get_tab_reorderable")]
168    pub fn tab_is_reorderable(&self, child: &impl IsA<Widget>) -> bool {
169        unsafe {
170            from_glib(ffi::gtk_notebook_get_tab_reorderable(
171                self.to_glib_none().0,
172                child.as_ref().to_glib_none().0,
173            ))
174        }
175    }
176
177    #[doc(alias = "gtk_notebook_next_page")]
178    pub fn next_page(&self) {
179        unsafe {
180            ffi::gtk_notebook_next_page(self.to_glib_none().0);
181        }
182    }
183
184    #[doc(alias = "gtk_notebook_popup_disable")]
185    pub fn popup_disable(&self) {
186        unsafe {
187            ffi::gtk_notebook_popup_disable(self.to_glib_none().0);
188        }
189    }
190
191    #[doc(alias = "gtk_notebook_popup_enable")]
192    pub fn popup_enable(&self) {
193        unsafe {
194            ffi::gtk_notebook_popup_enable(self.to_glib_none().0);
195        }
196    }
197
198    #[doc(alias = "gtk_notebook_prev_page")]
199    pub fn prev_page(&self) {
200        unsafe {
201            ffi::gtk_notebook_prev_page(self.to_glib_none().0);
202        }
203    }
204
205    #[doc(alias = "gtk_notebook_set_action_widget")]
206    pub fn set_action_widget(&self, widget: &impl IsA<Widget>, pack_type: PackType) {
207        unsafe {
208            ffi::gtk_notebook_set_action_widget(
209                self.to_glib_none().0,
210                widget.as_ref().to_glib_none().0,
211                pack_type.into_glib(),
212            );
213        }
214    }
215
216    #[doc(alias = "gtk_notebook_set_group_name")]
217    #[doc(alias = "group-name")]
218    pub fn set_group_name(&self, group_name: Option<&str>) {
219        unsafe {
220            ffi::gtk_notebook_set_group_name(self.to_glib_none().0, group_name.to_glib_none().0);
221        }
222    }
223
224    #[doc(alias = "gtk_notebook_set_menu_label")]
225    pub fn set_menu_label(&self, child: &impl IsA<Widget>, menu_label: Option<&impl IsA<Widget>>) {
226        unsafe {
227            ffi::gtk_notebook_set_menu_label(
228                self.to_glib_none().0,
229                child.as_ref().to_glib_none().0,
230                menu_label.map(|p| p.as_ref()).to_glib_none().0,
231            );
232        }
233    }
234
235    #[doc(alias = "gtk_notebook_set_menu_label_text")]
236    pub fn set_menu_label_text(&self, child: &impl IsA<Widget>, menu_text: &str) {
237        unsafe {
238            ffi::gtk_notebook_set_menu_label_text(
239                self.to_glib_none().0,
240                child.as_ref().to_glib_none().0,
241                menu_text.to_glib_none().0,
242            );
243        }
244    }
245
246    #[doc(alias = "gtk_notebook_set_scrollable")]
247    #[doc(alias = "scrollable")]
248    pub fn set_scrollable(&self, scrollable: bool) {
249        unsafe {
250            ffi::gtk_notebook_set_scrollable(self.to_glib_none().0, scrollable.into_glib());
251        }
252    }
253
254    #[doc(alias = "gtk_notebook_set_show_border")]
255    #[doc(alias = "show-border")]
256    pub fn set_show_border(&self, show_border: bool) {
257        unsafe {
258            ffi::gtk_notebook_set_show_border(self.to_glib_none().0, show_border.into_glib());
259        }
260    }
261
262    #[doc(alias = "gtk_notebook_set_show_tabs")]
263    #[doc(alias = "show-tabs")]
264    pub fn set_show_tabs(&self, show_tabs: bool) {
265        unsafe {
266            ffi::gtk_notebook_set_show_tabs(self.to_glib_none().0, show_tabs.into_glib());
267        }
268    }
269
270    #[doc(alias = "gtk_notebook_set_tab_detachable")]
271    pub fn set_tab_detachable(&self, child: &impl IsA<Widget>, detachable: bool) {
272        unsafe {
273            ffi::gtk_notebook_set_tab_detachable(
274                self.to_glib_none().0,
275                child.as_ref().to_glib_none().0,
276                detachable.into_glib(),
277            );
278        }
279    }
280
281    #[doc(alias = "gtk_notebook_set_tab_label")]
282    pub fn set_tab_label(&self, child: &impl IsA<Widget>, tab_label: Option<&impl IsA<Widget>>) {
283        unsafe {
284            ffi::gtk_notebook_set_tab_label(
285                self.to_glib_none().0,
286                child.as_ref().to_glib_none().0,
287                tab_label.map(|p| p.as_ref()).to_glib_none().0,
288            );
289        }
290    }
291
292    #[doc(alias = "gtk_notebook_set_tab_label_text")]
293    pub fn set_tab_label_text(&self, child: &impl IsA<Widget>, tab_text: &str) {
294        unsafe {
295            ffi::gtk_notebook_set_tab_label_text(
296                self.to_glib_none().0,
297                child.as_ref().to_glib_none().0,
298                tab_text.to_glib_none().0,
299            );
300        }
301    }
302
303    #[doc(alias = "gtk_notebook_set_tab_pos")]
304    #[doc(alias = "tab-pos")]
305    pub fn set_tab_pos(&self, pos: PositionType) {
306        unsafe {
307            ffi::gtk_notebook_set_tab_pos(self.to_glib_none().0, pos.into_glib());
308        }
309    }
310
311    #[doc(alias = "gtk_notebook_set_tab_reorderable")]
312    pub fn set_tab_reorderable(&self, child: &impl IsA<Widget>, reorderable: bool) {
313        unsafe {
314            ffi::gtk_notebook_set_tab_reorderable(
315                self.to_glib_none().0,
316                child.as_ref().to_glib_none().0,
317                reorderable.into_glib(),
318            );
319        }
320    }
321
322    #[doc(alias = "enable-popup")]
323    pub fn enables_popup(&self) -> bool {
324        ObjectExt::property(self, "enable-popup")
325    }
326
327    #[doc(alias = "enable-popup")]
328    pub fn set_enable_popup(&self, enable_popup: bool) {
329        ObjectExt::set_property(self, "enable-popup", enable_popup)
330    }
331
332    #[doc(alias = "change-current-page")]
333    pub fn connect_change_current_page<F: Fn(&Self, i32) -> bool + 'static>(
334        &self,
335        f: F,
336    ) -> SignalHandlerId {
337        unsafe extern "C" fn change_current_page_trampoline<
338            F: Fn(&Notebook, i32) -> bool + 'static,
339        >(
340            this: *mut ffi::GtkNotebook,
341            page: std::ffi::c_int,
342            f: glib::ffi::gpointer,
343        ) -> glib::ffi::gboolean {
344            let f: &F = &*(f as *const F);
345            f(&from_glib_borrow(this), page).into_glib()
346        }
347        unsafe {
348            let f: Box_<F> = Box_::new(f);
349            connect_raw(
350                self.as_ptr() as *mut _,
351                c"change-current-page".as_ptr() as *const _,
352                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
353                    change_current_page_trampoline::<F> as *const (),
354                )),
355                Box_::into_raw(f),
356            )
357        }
358    }
359
360    pub fn emit_change_current_page(&self, page: i32) -> bool {
361        self.emit_by_name("change-current-page", &[&page])
362    }
363
364    #[doc(alias = "create-window")]
365    pub fn connect_create_window<F: Fn(&Self, &Widget) -> Option<Notebook> + 'static>(
366        &self,
367        f: F,
368    ) -> SignalHandlerId {
369        unsafe extern "C" fn create_window_trampoline<
370            F: Fn(&Notebook, &Widget) -> Option<Notebook> + 'static,
371        >(
372            this: *mut ffi::GtkNotebook,
373            page: *mut ffi::GtkWidget,
374            f: glib::ffi::gpointer,
375        ) -> *mut ffi::GtkNotebook {
376            let f: &F = &*(f as *const F);
377            f(&from_glib_borrow(this), &from_glib_borrow(page)) /*Not checked*/
378                .to_glib_none()
379                .0
380        }
381        unsafe {
382            let f: Box_<F> = Box_::new(f);
383            connect_raw(
384                self.as_ptr() as *mut _,
385                c"create-window".as_ptr() as *const _,
386                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
387                    create_window_trampoline::<F> as *const (),
388                )),
389                Box_::into_raw(f),
390            )
391        }
392    }
393
394    #[doc(alias = "focus-tab")]
395    pub fn connect_focus_tab<F: Fn(&Self, NotebookTab) -> bool + 'static>(
396        &self,
397        f: F,
398    ) -> SignalHandlerId {
399        unsafe extern "C" fn focus_tab_trampoline<
400            F: Fn(&Notebook, NotebookTab) -> bool + 'static,
401        >(
402            this: *mut ffi::GtkNotebook,
403            tab: ffi::GtkNotebookTab,
404            f: glib::ffi::gpointer,
405        ) -> glib::ffi::gboolean {
406            let f: &F = &*(f as *const F);
407            f(&from_glib_borrow(this), from_glib(tab)).into_glib()
408        }
409        unsafe {
410            let f: Box_<F> = Box_::new(f);
411            connect_raw(
412                self.as_ptr() as *mut _,
413                c"focus-tab".as_ptr() as *const _,
414                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
415                    focus_tab_trampoline::<F> as *const (),
416                )),
417                Box_::into_raw(f),
418            )
419        }
420    }
421
422    pub fn emit_focus_tab(&self, tab: NotebookTab) -> bool {
423        self.emit_by_name("focus-tab", &[&tab])
424    }
425
426    #[doc(alias = "move-focus-out")]
427    pub fn connect_move_focus_out<F: Fn(&Self, DirectionType) + 'static>(
428        &self,
429        f: F,
430    ) -> SignalHandlerId {
431        unsafe extern "C" fn move_focus_out_trampoline<
432            F: Fn(&Notebook, DirectionType) + 'static,
433        >(
434            this: *mut ffi::GtkNotebook,
435            direction: ffi::GtkDirectionType,
436            f: glib::ffi::gpointer,
437        ) {
438            let f: &F = &*(f as *const F);
439            f(&from_glib_borrow(this), from_glib(direction))
440        }
441        unsafe {
442            let f: Box_<F> = Box_::new(f);
443            connect_raw(
444                self.as_ptr() as *mut _,
445                c"move-focus-out".as_ptr() as *const _,
446                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
447                    move_focus_out_trampoline::<F> as *const (),
448                )),
449                Box_::into_raw(f),
450            )
451        }
452    }
453
454    pub fn emit_move_focus_out(&self, direction: DirectionType) {
455        self.emit_by_name::<()>("move-focus-out", &[&direction]);
456    }
457
458    #[doc(alias = "page-added")]
459    pub fn connect_page_added<F: Fn(&Self, &Widget, u32) + 'static>(
460        &self,
461        f: F,
462    ) -> SignalHandlerId {
463        unsafe extern "C" fn page_added_trampoline<F: Fn(&Notebook, &Widget, u32) + 'static>(
464            this: *mut ffi::GtkNotebook,
465            child: *mut ffi::GtkWidget,
466            page_num: std::ffi::c_uint,
467            f: glib::ffi::gpointer,
468        ) {
469            let f: &F = &*(f as *const F);
470            f(&from_glib_borrow(this), &from_glib_borrow(child), page_num)
471        }
472        unsafe {
473            let f: Box_<F> = Box_::new(f);
474            connect_raw(
475                self.as_ptr() as *mut _,
476                c"page-added".as_ptr() as *const _,
477                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
478                    page_added_trampoline::<F> as *const (),
479                )),
480                Box_::into_raw(f),
481            )
482        }
483    }
484
485    #[doc(alias = "page-removed")]
486    pub fn connect_page_removed<F: Fn(&Self, &Widget, u32) + 'static>(
487        &self,
488        f: F,
489    ) -> SignalHandlerId {
490        unsafe extern "C" fn page_removed_trampoline<F: Fn(&Notebook, &Widget, u32) + 'static>(
491            this: *mut ffi::GtkNotebook,
492            child: *mut ffi::GtkWidget,
493            page_num: std::ffi::c_uint,
494            f: glib::ffi::gpointer,
495        ) {
496            let f: &F = &*(f as *const F);
497            f(&from_glib_borrow(this), &from_glib_borrow(child), page_num)
498        }
499        unsafe {
500            let f: Box_<F> = Box_::new(f);
501            connect_raw(
502                self.as_ptr() as *mut _,
503                c"page-removed".as_ptr() as *const _,
504                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
505                    page_removed_trampoline::<F> as *const (),
506                )),
507                Box_::into_raw(f),
508            )
509        }
510    }
511
512    #[doc(alias = "page-reordered")]
513    pub fn connect_page_reordered<F: Fn(&Self, &Widget, u32) + 'static>(
514        &self,
515        f: F,
516    ) -> SignalHandlerId {
517        unsafe extern "C" fn page_reordered_trampoline<F: Fn(&Notebook, &Widget, u32) + 'static>(
518            this: *mut ffi::GtkNotebook,
519            child: *mut ffi::GtkWidget,
520            page_num: std::ffi::c_uint,
521            f: glib::ffi::gpointer,
522        ) {
523            let f: &F = &*(f as *const F);
524            f(&from_glib_borrow(this), &from_glib_borrow(child), page_num)
525        }
526        unsafe {
527            let f: Box_<F> = Box_::new(f);
528            connect_raw(
529                self.as_ptr() as *mut _,
530                c"page-reordered".as_ptr() as *const _,
531                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
532                    page_reordered_trampoline::<F> as *const (),
533                )),
534                Box_::into_raw(f),
535            )
536        }
537    }
538
539    #[doc(alias = "reorder-tab")]
540    pub fn connect_reorder_tab<F: Fn(&Self, DirectionType, bool) -> bool + 'static>(
541        &self,
542        f: F,
543    ) -> SignalHandlerId {
544        unsafe extern "C" fn reorder_tab_trampoline<
545            F: Fn(&Notebook, DirectionType, bool) -> bool + 'static,
546        >(
547            this: *mut ffi::GtkNotebook,
548            direction: ffi::GtkDirectionType,
549            move_to_last: glib::ffi::gboolean,
550            f: glib::ffi::gpointer,
551        ) -> glib::ffi::gboolean {
552            let f: &F = &*(f as *const F);
553            f(
554                &from_glib_borrow(this),
555                from_glib(direction),
556                from_glib(move_to_last),
557            )
558            .into_glib()
559        }
560        unsafe {
561            let f: Box_<F> = Box_::new(f);
562            connect_raw(
563                self.as_ptr() as *mut _,
564                c"reorder-tab".as_ptr() as *const _,
565                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
566                    reorder_tab_trampoline::<F> as *const (),
567                )),
568                Box_::into_raw(f),
569            )
570        }
571    }
572
573    pub fn emit_reorder_tab(&self, direction: DirectionType, move_to_last: bool) -> bool {
574        self.emit_by_name("reorder-tab", &[&direction, &move_to_last])
575    }
576
577    #[doc(alias = "select-page")]
578    pub fn connect_select_page<F: Fn(&Self, bool) -> bool + 'static>(
579        &self,
580        f: F,
581    ) -> SignalHandlerId {
582        unsafe extern "C" fn select_page_trampoline<F: Fn(&Notebook, bool) -> bool + 'static>(
583            this: *mut ffi::GtkNotebook,
584            move_focus: glib::ffi::gboolean,
585            f: glib::ffi::gpointer,
586        ) -> glib::ffi::gboolean {
587            let f: &F = &*(f as *const F);
588            f(&from_glib_borrow(this), from_glib(move_focus)).into_glib()
589        }
590        unsafe {
591            let f: Box_<F> = Box_::new(f);
592            connect_raw(
593                self.as_ptr() as *mut _,
594                c"select-page".as_ptr() as *const _,
595                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
596                    select_page_trampoline::<F> as *const (),
597                )),
598                Box_::into_raw(f),
599            )
600        }
601    }
602
603    pub fn emit_select_page(&self, move_focus: bool) -> bool {
604        self.emit_by_name("select-page", &[&move_focus])
605    }
606
607    #[doc(alias = "switch-page")]
608    pub fn connect_switch_page<F: Fn(&Self, &Widget, u32) + 'static>(
609        &self,
610        f: F,
611    ) -> SignalHandlerId {
612        unsafe extern "C" fn switch_page_trampoline<F: Fn(&Notebook, &Widget, u32) + 'static>(
613            this: *mut ffi::GtkNotebook,
614            page: *mut ffi::GtkWidget,
615            page_num: std::ffi::c_uint,
616            f: glib::ffi::gpointer,
617        ) {
618            let f: &F = &*(f as *const F);
619            f(&from_glib_borrow(this), &from_glib_borrow(page), page_num)
620        }
621        unsafe {
622            let f: Box_<F> = Box_::new(f);
623            connect_raw(
624                self.as_ptr() as *mut _,
625                c"switch-page".as_ptr() as *const _,
626                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
627                    switch_page_trampoline::<F> as *const (),
628                )),
629                Box_::into_raw(f),
630            )
631        }
632    }
633
634    #[doc(alias = "enable-popup")]
635    pub fn connect_enable_popup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
636        unsafe extern "C" fn notify_enable_popup_trampoline<F: Fn(&Notebook) + 'static>(
637            this: *mut ffi::GtkNotebook,
638            _param_spec: glib::ffi::gpointer,
639            f: glib::ffi::gpointer,
640        ) {
641            let f: &F = &*(f as *const F);
642            f(&from_glib_borrow(this))
643        }
644        unsafe {
645            let f: Box_<F> = Box_::new(f);
646            connect_raw(
647                self.as_ptr() as *mut _,
648                c"notify::enable-popup".as_ptr() as *const _,
649                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
650                    notify_enable_popup_trampoline::<F> as *const (),
651                )),
652                Box_::into_raw(f),
653            )
654        }
655    }
656
657    #[doc(alias = "group-name")]
658    pub fn connect_group_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
659        unsafe extern "C" fn notify_group_name_trampoline<F: Fn(&Notebook) + 'static>(
660            this: *mut ffi::GtkNotebook,
661            _param_spec: glib::ffi::gpointer,
662            f: glib::ffi::gpointer,
663        ) {
664            let f: &F = &*(f as *const F);
665            f(&from_glib_borrow(this))
666        }
667        unsafe {
668            let f: Box_<F> = Box_::new(f);
669            connect_raw(
670                self.as_ptr() as *mut _,
671                c"notify::group-name".as_ptr() as *const _,
672                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
673                    notify_group_name_trampoline::<F> as *const (),
674                )),
675                Box_::into_raw(f),
676            )
677        }
678    }
679
680    #[doc(alias = "page")]
681    pub fn connect_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
682        unsafe extern "C" fn notify_page_trampoline<F: Fn(&Notebook) + 'static>(
683            this: *mut ffi::GtkNotebook,
684            _param_spec: glib::ffi::gpointer,
685            f: glib::ffi::gpointer,
686        ) {
687            let f: &F = &*(f as *const F);
688            f(&from_glib_borrow(this))
689        }
690        unsafe {
691            let f: Box_<F> = Box_::new(f);
692            connect_raw(
693                self.as_ptr() as *mut _,
694                c"notify::page".as_ptr() as *const _,
695                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
696                    notify_page_trampoline::<F> as *const (),
697                )),
698                Box_::into_raw(f),
699            )
700        }
701    }
702
703    #[doc(alias = "pages")]
704    pub fn connect_pages_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
705        unsafe extern "C" fn notify_pages_trampoline<F: Fn(&Notebook) + 'static>(
706            this: *mut ffi::GtkNotebook,
707            _param_spec: glib::ffi::gpointer,
708            f: glib::ffi::gpointer,
709        ) {
710            let f: &F = &*(f as *const F);
711            f(&from_glib_borrow(this))
712        }
713        unsafe {
714            let f: Box_<F> = Box_::new(f);
715            connect_raw(
716                self.as_ptr() as *mut _,
717                c"notify::pages".as_ptr() as *const _,
718                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
719                    notify_pages_trampoline::<F> as *const (),
720                )),
721                Box_::into_raw(f),
722            )
723        }
724    }
725
726    #[doc(alias = "scrollable")]
727    pub fn connect_scrollable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
728        unsafe extern "C" fn notify_scrollable_trampoline<F: Fn(&Notebook) + 'static>(
729            this: *mut ffi::GtkNotebook,
730            _param_spec: glib::ffi::gpointer,
731            f: glib::ffi::gpointer,
732        ) {
733            let f: &F = &*(f as *const F);
734            f(&from_glib_borrow(this))
735        }
736        unsafe {
737            let f: Box_<F> = Box_::new(f);
738            connect_raw(
739                self.as_ptr() as *mut _,
740                c"notify::scrollable".as_ptr() as *const _,
741                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
742                    notify_scrollable_trampoline::<F> as *const (),
743                )),
744                Box_::into_raw(f),
745            )
746        }
747    }
748
749    #[doc(alias = "show-border")]
750    pub fn connect_show_border_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
751        unsafe extern "C" fn notify_show_border_trampoline<F: Fn(&Notebook) + 'static>(
752            this: *mut ffi::GtkNotebook,
753            _param_spec: glib::ffi::gpointer,
754            f: glib::ffi::gpointer,
755        ) {
756            let f: &F = &*(f as *const F);
757            f(&from_glib_borrow(this))
758        }
759        unsafe {
760            let f: Box_<F> = Box_::new(f);
761            connect_raw(
762                self.as_ptr() as *mut _,
763                c"notify::show-border".as_ptr() as *const _,
764                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
765                    notify_show_border_trampoline::<F> as *const (),
766                )),
767                Box_::into_raw(f),
768            )
769        }
770    }
771
772    #[doc(alias = "show-tabs")]
773    pub fn connect_show_tabs_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
774        unsafe extern "C" fn notify_show_tabs_trampoline<F: Fn(&Notebook) + 'static>(
775            this: *mut ffi::GtkNotebook,
776            _param_spec: glib::ffi::gpointer,
777            f: glib::ffi::gpointer,
778        ) {
779            let f: &F = &*(f as *const F);
780            f(&from_glib_borrow(this))
781        }
782        unsafe {
783            let f: Box_<F> = Box_::new(f);
784            connect_raw(
785                self.as_ptr() as *mut _,
786                c"notify::show-tabs".as_ptr() as *const _,
787                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
788                    notify_show_tabs_trampoline::<F> as *const (),
789                )),
790                Box_::into_raw(f),
791            )
792        }
793    }
794
795    #[doc(alias = "tab-pos")]
796    pub fn connect_tab_pos_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
797        unsafe extern "C" fn notify_tab_pos_trampoline<F: Fn(&Notebook) + 'static>(
798            this: *mut ffi::GtkNotebook,
799            _param_spec: glib::ffi::gpointer,
800            f: glib::ffi::gpointer,
801        ) {
802            let f: &F = &*(f as *const F);
803            f(&from_glib_borrow(this))
804        }
805        unsafe {
806            let f: Box_<F> = Box_::new(f);
807            connect_raw(
808                self.as_ptr() as *mut _,
809                c"notify::tab-pos".as_ptr() as *const _,
810                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
811                    notify_tab_pos_trampoline::<F> as *const (),
812                )),
813                Box_::into_raw(f),
814            )
815        }
816    }
817}
818
819impl Default for Notebook {
820    fn default() -> Self {
821        Self::new()
822    }
823}
824
825// rustdoc-stripper-ignore-next
826/// A [builder-pattern] type to construct [`Notebook`] objects.
827///
828/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
829#[must_use = "The builder must be built to be used"]
830pub struct NotebookBuilder {
831    builder: glib::object::ObjectBuilder<'static, Notebook>,
832}
833
834impl NotebookBuilder {
835    fn new() -> Self {
836        Self {
837            builder: glib::object::Object::builder(),
838        }
839    }
840
841    pub fn enable_popup(self, enable_popup: bool) -> Self {
842        Self {
843            builder: self.builder.property("enable-popup", enable_popup),
844        }
845    }
846
847    pub fn group_name(self, group_name: impl Into<glib::GString>) -> Self {
848        Self {
849            builder: self.builder.property("group-name", group_name.into()),
850        }
851    }
852
853    pub fn page(self, page: i32) -> Self {
854        Self {
855            builder: self.builder.property("page", page),
856        }
857    }
858
859    pub fn scrollable(self, scrollable: bool) -> Self {
860        Self {
861            builder: self.builder.property("scrollable", scrollable),
862        }
863    }
864
865    pub fn show_border(self, show_border: bool) -> Self {
866        Self {
867            builder: self.builder.property("show-border", show_border),
868        }
869    }
870
871    pub fn show_tabs(self, show_tabs: bool) -> Self {
872        Self {
873            builder: self.builder.property("show-tabs", show_tabs),
874        }
875    }
876
877    pub fn tab_pos(self, tab_pos: PositionType) -> Self {
878        Self {
879            builder: self.builder.property("tab-pos", tab_pos),
880        }
881    }
882
883    pub fn can_focus(self, can_focus: bool) -> Self {
884        Self {
885            builder: self.builder.property("can-focus", can_focus),
886        }
887    }
888
889    pub fn can_target(self, can_target: bool) -> Self {
890        Self {
891            builder: self.builder.property("can-target", can_target),
892        }
893    }
894
895    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
896        Self {
897            builder: self.builder.property("css-classes", css_classes.into()),
898        }
899    }
900
901    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
902        Self {
903            builder: self.builder.property("css-name", css_name.into()),
904        }
905    }
906
907    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
908        Self {
909            builder: self.builder.property("cursor", cursor.clone()),
910        }
911    }
912
913    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
914        Self {
915            builder: self.builder.property("focus-on-click", focus_on_click),
916        }
917    }
918
919    pub fn focusable(self, focusable: bool) -> Self {
920        Self {
921            builder: self.builder.property("focusable", focusable),
922        }
923    }
924
925    pub fn halign(self, halign: Align) -> Self {
926        Self {
927            builder: self.builder.property("halign", halign),
928        }
929    }
930
931    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
932        Self {
933            builder: self.builder.property("has-tooltip", has_tooltip),
934        }
935    }
936
937    pub fn height_request(self, height_request: i32) -> Self {
938        Self {
939            builder: self.builder.property("height-request", height_request),
940        }
941    }
942
943    pub fn hexpand(self, hexpand: bool) -> Self {
944        Self {
945            builder: self.builder.property("hexpand", hexpand),
946        }
947    }
948
949    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
950        Self {
951            builder: self.builder.property("hexpand-set", hexpand_set),
952        }
953    }
954
955    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
956        Self {
957            builder: self
958                .builder
959                .property("layout-manager", layout_manager.clone().upcast()),
960        }
961    }
962
963    #[cfg(feature = "v4_18")]
964    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
965    pub fn limit_events(self, limit_events: bool) -> Self {
966        Self {
967            builder: self.builder.property("limit-events", limit_events),
968        }
969    }
970
971    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
972        Self {
973            builder: self.builder.property("margin-bottom", margin_bottom),
974        }
975    }
976
977    pub fn margin_end(self, margin_end: i32) -> Self {
978        Self {
979            builder: self.builder.property("margin-end", margin_end),
980        }
981    }
982
983    pub fn margin_start(self, margin_start: i32) -> Self {
984        Self {
985            builder: self.builder.property("margin-start", margin_start),
986        }
987    }
988
989    pub fn margin_top(self, margin_top: i32) -> Self {
990        Self {
991            builder: self.builder.property("margin-top", margin_top),
992        }
993    }
994
995    pub fn name(self, name: impl Into<glib::GString>) -> Self {
996        Self {
997            builder: self.builder.property("name", name.into()),
998        }
999    }
1000
1001    pub fn opacity(self, opacity: f64) -> Self {
1002        Self {
1003            builder: self.builder.property("opacity", opacity),
1004        }
1005    }
1006
1007    pub fn overflow(self, overflow: Overflow) -> Self {
1008        Self {
1009            builder: self.builder.property("overflow", overflow),
1010        }
1011    }
1012
1013    pub fn receives_default(self, receives_default: bool) -> Self {
1014        Self {
1015            builder: self.builder.property("receives-default", receives_default),
1016        }
1017    }
1018
1019    pub fn sensitive(self, sensitive: bool) -> Self {
1020        Self {
1021            builder: self.builder.property("sensitive", sensitive),
1022        }
1023    }
1024
1025    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1026        Self {
1027            builder: self
1028                .builder
1029                .property("tooltip-markup", tooltip_markup.into()),
1030        }
1031    }
1032
1033    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1034        Self {
1035            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1036        }
1037    }
1038
1039    pub fn valign(self, valign: Align) -> Self {
1040        Self {
1041            builder: self.builder.property("valign", valign),
1042        }
1043    }
1044
1045    pub fn vexpand(self, vexpand: bool) -> Self {
1046        Self {
1047            builder: self.builder.property("vexpand", vexpand),
1048        }
1049    }
1050
1051    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1052        Self {
1053            builder: self.builder.property("vexpand-set", vexpand_set),
1054        }
1055    }
1056
1057    pub fn visible(self, visible: bool) -> Self {
1058        Self {
1059            builder: self.builder.property("visible", visible),
1060        }
1061    }
1062
1063    pub fn width_request(self, width_request: i32) -> Self {
1064        Self {
1065            builder: self.builder.property("width-request", width_request),
1066        }
1067    }
1068
1069    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1070        Self {
1071            builder: self.builder.property("accessible-role", accessible_role),
1072        }
1073    }
1074
1075    // rustdoc-stripper-ignore-next
1076    /// Build the [`Notebook`].
1077    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1078    pub fn build(self) -> Notebook {
1079        assert_initialized_main_thread!();
1080        self.builder.build()
1081    }
1082}