Skip to main content

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    Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, DirectionType, LayoutManager,
7    NotebookPage, NotebookTab, Overflow, PackType, PositionType, Widget, ffi,
8};
9use glib::{
10    object::ObjectType as _,
11    prelude::*,
12    signal::{SignalHandlerId, connect_raw},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18    /// Switches between children using tabs.
19    ///
20    /// <picture>
21    ///   <source srcset="notebook-dark.png" media="(prefers-color-scheme: dark)">
22    ///   <img alt="An example GtkNotebook" src="notebook.png">
23    /// </picture>
24    ///
25    /// There are many configuration options for [`Notebook`][crate::Notebook]. Among
26    /// other things, you can choose on which edge the tabs appear
27    /// (see [`set_tab_pos()`][Self::set_tab_pos()]), whether, if there are
28    /// too many tabs to fit the notebook should be made bigger or scrolling
29    /// arrows added (see [`set_scrollable()`][Self::set_scrollable()]), and whether
30    /// there will be a popup menu allowing the users to switch pages.
31    /// (see [`popup_enable()`][Self::popup_enable()]).
32    ///
33    /// # GtkNotebook as GtkBuildable
34    ///
35    /// The [`Notebook`][crate::Notebook] implementation of the [`Buildable`][crate::Buildable] interface
36    /// supports placing children into tabs by specifying “tab” as the
37    /// “type” attribute of a `<child>` element. Note that the content
38    /// of the tab must be created before the tab can be filled.
39    /// A tab child can be specified without specifying a `<child>`
40    /// type attribute.
41    ///
42    /// To add a child widget in the notebooks action area, specify
43    /// "action-start" or “action-end” as the “type” attribute of the
44    /// `<child>` element.
45    ///
46    /// An example of a UI definition fragment with [`Notebook`][crate::Notebook]:
47    ///
48    /// ```xml
49    /// <object class="GtkNotebook">
50    ///   <child>
51    ///     <object class="GtkLabel" id="notebook-content">
52    ///       <property name="label">Content</property>
53    ///     </object>
54    ///   </child>
55    ///   <child type="tab">
56    ///     <object class="GtkLabel" id="notebook-tab">
57    ///       <property name="label">Tab</property>
58    ///     </object>
59    ///   </child>
60    /// </object>
61    /// ```
62    ///
63    /// # Shortcuts and Gestures
64    ///
65    /// [`Notebook`][crate::Notebook] supports the following keyboard shortcuts:
66    ///
67    /// - <kbd>Shift</kbd>+<kbd>F10</kbd> or <kbd>Menu</kbd> opens the context menu.
68    /// - <kbd>Home</kbd> moves the focus to the first tab.
69    /// - <kbd>End</kbd> moves the focus to the last tab.
70    ///
71    /// Additionally, the following signals have default keybindings:
72    ///
73    /// - [`change-current-page`][struct@crate::Notebook#change-current-page]
74    /// - [`focus-tab`][struct@crate::Notebook#focus-tab]
75    /// - [`move-focus-out`][struct@crate::Notebook#move-focus-out]
76    /// - [`reorder-tab`][struct@crate::Notebook#reorder-tab]
77    /// - [`select-page`][struct@crate::Notebook#select-page]
78    ///
79    /// Tabs support drag-and-drop between notebooks sharing the same `group-name`,
80    /// or to new windows by handling the `::create-window` signal.
81    ///
82    /// # Actions
83    ///
84    /// [`Notebook`][crate::Notebook] defines a set of built-in actions:
85    ///
86    /// - `menu.popup` opens the tabs context menu.
87    ///
88    /// # CSS nodes
89    ///
90    /// ```text
91    /// notebook
92    /// ├── header.top
93    /// │   ├── [<action widget>]
94    /// │   ├── tabs
95    /// │   │   ├── [arrow]
96    /// │   │   ├── tab
97    /// │   │   │   ╰── <tab label>
98    /// ┊   ┊   ┊
99    /// │   │   ├── tab[.reorderable-page]
100    /// │   │   │   ╰── <tab label>
101    /// │   │   ╰── [arrow]
102    /// │   ╰── [<action widget>]
103    /// │
104    /// ╰── stack
105    ///     ├── <child>
106    ///     ┊
107    ///     ╰── <child>
108    /// ```
109    ///
110    /// [`Notebook`][crate::Notebook] has a main CSS node with name `notebook`, a subnode
111    /// with name `header` and below that a subnode with name `tabs` which
112    /// contains one subnode per tab with name `tab`.
113    ///
114    /// If action widgets are present, their CSS nodes are placed next
115    /// to the `tabs` node. If the notebook is scrollable, CSS nodes with
116    /// name `arrow` are placed as first and last child of the `tabs` node.
117    ///
118    /// The main node gets the `.frame` style class when the notebook
119    /// has a border (see [`set_show_border()`][Self::set_show_border()]).
120    ///
121    /// The header node gets one of the style class `.top`, `.bottom`,
122    /// `.left` or `.right`, depending on where the tabs are placed. For
123    /// reorderable pages, the tab node gets the `.reorderable-page` class.
124    ///
125    /// A `tab` node gets the `.dnd` style class while it is moved with drag-and-drop.
126    ///
127    /// The nodes are always arranged from left-to-right, regardless of text direction.
128    ///
129    /// # Accessibility
130    ///
131    /// [`Notebook`][crate::Notebook] uses the following roles:
132    ///
133    ///  - [enum@Gtk.AccessibleRole.group] for the notebook widget
134    ///  - [enum@Gtk.AccessibleRole.tab_list] for the list of tabs
135    ///  - [enum@Gtk.AccessibleRole.tab] role for each tab
136    ///  - [enum@Gtk.AccessibleRole.tab_panel] for each page
137    ///
138    /// ## Properties
139    ///
140    ///
141    /// #### `enable-popup`
142    ///  If [`true`], pressing the right mouse button on the notebook shows a page switching menu.
143    ///
144    /// Readable | Writeable
145    ///
146    ///
147    /// #### `group-name`
148    ///  Group name for tab drag and drop.
149    ///
150    /// Readable | Writeable
151    ///
152    ///
153    /// #### `page`
154    ///  The index of the current page.
155    ///
156    /// Readable | Writeable
157    ///
158    ///
159    /// #### `pages`
160    ///  A selection model with the pages.
161    ///
162    /// Readable
163    ///
164    ///
165    /// #### `scrollable`
166    ///  If [`true`], scroll arrows are added if there are too many pages to fit.
167    ///
168    /// Readable | Writeable
169    ///
170    ///
171    /// #### `show-border`
172    ///  Whether the border should be shown.
173    ///
174    /// Readable | Writeable
175    ///
176    ///
177    /// #### `show-tabs`
178    ///  Whether tabs should be shown.
179    ///
180    /// Readable | Writeable
181    ///
182    ///
183    /// #### `tab-pos`
184    ///  Which side of the notebook holds the tabs.
185    ///
186    /// Readable | Writeable
187    /// <details><summary><h4>Widget</h4></summary>
188    ///
189    ///
190    /// #### `can-focus`
191    ///  Whether the widget or any of its descendents can accept
192    /// the input focus.
193    ///
194    /// This property is meant to be set by widget implementations,
195    /// typically in their instance init function.
196    ///
197    /// Readable | Writeable
198    ///
199    ///
200    /// #### `can-target`
201    ///  Whether the widget can receive pointer events.
202    ///
203    /// Readable | Writeable
204    ///
205    ///
206    /// #### `css-classes`
207    ///  A list of css classes applied to this widget.
208    ///
209    /// Readable | Writeable
210    ///
211    ///
212    /// #### `css-name`
213    ///  The name of this widget in the CSS tree.
214    ///
215    /// This property is meant to be set by widget implementations,
216    /// typically in their instance init function.
217    ///
218    /// Readable | Writeable | Construct Only
219    ///
220    ///
221    /// #### `cursor`
222    ///  The cursor used by @widget.
223    ///
224    /// Readable | Writeable
225    ///
226    ///
227    /// #### `focus-on-click`
228    ///  Whether the widget should grab focus when it is clicked with the mouse.
229    ///
230    /// This property is only relevant for widgets that can take focus.
231    ///
232    /// Readable | Writeable
233    ///
234    ///
235    /// #### `focusable`
236    ///  Whether this widget itself will accept the input focus.
237    ///
238    /// Readable | Writeable
239    ///
240    ///
241    /// #### `halign`
242    ///  How to distribute horizontal space if widget gets extra space.
243    ///
244    /// Readable | Writeable
245    ///
246    ///
247    /// #### `has-default`
248    ///  Whether the widget is the default widget.
249    ///
250    /// Readable
251    ///
252    ///
253    /// #### `has-focus`
254    ///  Whether the widget has the input focus.
255    ///
256    /// Readable
257    ///
258    ///
259    /// #### `has-tooltip`
260    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
261    /// signal on @widget.
262    ///
263    /// A true value indicates that @widget can have a tooltip, in this case
264    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
265    /// determine whether it will provide a tooltip or not.
266    ///
267    /// Readable | Writeable
268    ///
269    ///
270    /// #### `height-request`
271    ///  Overrides for height request of the widget.
272    ///
273    /// If this is -1, the natural request will be used.
274    ///
275    /// Readable | Writeable
276    ///
277    ///
278    /// #### `hexpand`
279    ///  Whether to expand horizontally.
280    ///
281    /// Readable | Writeable
282    ///
283    ///
284    /// #### `hexpand-set`
285    ///  Whether to use the `hexpand` property.
286    ///
287    /// Readable | Writeable
288    ///
289    ///
290    /// #### `layout-manager`
291    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
292    /// the preferred size of the widget, and allocate its children.
293    ///
294    /// This property is meant to be set by widget implementations,
295    /// typically in their instance init function.
296    ///
297    /// Readable | Writeable
298    ///
299    ///
300    /// #### `limit-events`
301    ///  Makes this widget act like a modal dialog, with respect to
302    /// event delivery.
303    ///
304    /// Global event controllers will not handle events with targets
305    /// inside the widget, unless they are set up to ignore propagation
306    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
307    ///
308    /// Readable | Writeable
309    ///
310    ///
311    /// #### `margin-bottom`
312    ///  Margin on bottom side of widget.
313    ///
314    /// This property adds margin outside of the widget's normal size
315    /// request, the margin will be added in addition to the size from
316    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
317    ///
318    /// Readable | Writeable
319    ///
320    ///
321    /// #### `margin-end`
322    ///  Margin on end of widget, horizontally.
323    ///
324    /// This property supports left-to-right and right-to-left text
325    /// directions.
326    ///
327    /// This property adds margin outside of the widget's normal size
328    /// request, the margin will be added in addition to the size from
329    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
330    ///
331    /// Readable | Writeable
332    ///
333    ///
334    /// #### `margin-start`
335    ///  Margin on start of widget, horizontally.
336    ///
337    /// This property supports left-to-right and right-to-left text
338    /// directions.
339    ///
340    /// This property adds margin outside of the widget's normal size
341    /// request, the margin will be added in addition to the size from
342    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
343    ///
344    /// Readable | Writeable
345    ///
346    ///
347    /// #### `margin-top`
348    ///  Margin on top side of widget.
349    ///
350    /// This property adds margin outside of the widget's normal size
351    /// request, the margin will be added in addition to the size from
352    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
353    ///
354    /// Readable | Writeable
355    ///
356    ///
357    /// #### `name`
358    ///  The name of the widget.
359    ///
360    /// Readable | Writeable
361    ///
362    ///
363    /// #### `opacity`
364    ///  The requested opacity of the widget.
365    ///
366    /// Readable | Writeable
367    ///
368    ///
369    /// #### `overflow`
370    ///  How content outside the widget's content area is treated.
371    ///
372    /// This property is meant to be set by widget implementations,
373    /// typically in their instance init function.
374    ///
375    /// Readable | Writeable
376    ///
377    ///
378    /// #### `parent`
379    ///  The parent widget of this widget.
380    ///
381    /// Readable
382    ///
383    ///
384    /// #### `receives-default`
385    ///  Whether the widget will receive the default action when it is focused.
386    ///
387    /// Readable | Writeable
388    ///
389    ///
390    /// #### `root`
391    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
392    ///
393    /// This will be `NULL` if the widget is not contained in a root widget.
394    ///
395    /// Readable
396    ///
397    ///
398    /// #### `scale-factor`
399    ///  The scale factor of the widget.
400    ///
401    /// Readable
402    ///
403    ///
404    /// #### `sensitive`
405    ///  Whether the widget responds to input.
406    ///
407    /// Readable | Writeable
408    ///
409    ///
410    /// #### `tooltip-markup`
411    ///  Sets the text of tooltip to be the given string, which is marked up
412    /// with Pango markup.
413    ///
414    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
415    ///
416    /// This is a convenience property which will take care of getting the
417    /// tooltip shown if the given string is not `NULL`:
418    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
419    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
420    /// the default signal handler.
421    ///
422    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
423    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
424    ///
425    /// Readable | Writeable
426    ///
427    ///
428    /// #### `tooltip-text`
429    ///  Sets the text of tooltip to be the given string.
430    ///
431    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
432    ///
433    /// This is a convenience property which will take care of getting the
434    /// tooltip shown if the given string is not `NULL`:
435    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
436    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
437    /// the default signal handler.
438    ///
439    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
440    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
441    ///
442    /// Readable | Writeable
443    ///
444    ///
445    /// #### `valign`
446    ///  How to distribute vertical space if widget gets extra space.
447    ///
448    /// Readable | Writeable
449    ///
450    ///
451    /// #### `vexpand`
452    ///  Whether to expand vertically.
453    ///
454    /// Readable | Writeable
455    ///
456    ///
457    /// #### `vexpand-set`
458    ///  Whether to use the `vexpand` property.
459    ///
460    /// Readable | Writeable
461    ///
462    ///
463    /// #### `visible`
464    ///  Whether the widget is visible.
465    ///
466    /// Readable | Writeable
467    ///
468    ///
469    /// #### `width-request`
470    ///  Overrides for width request of the widget.
471    ///
472    /// If this is -1, the natural request will be used.
473    ///
474    /// Readable | Writeable
475    /// </details>
476    /// <details><summary><h4>Accessible</h4></summary>
477    ///
478    ///
479    /// #### `accessible-role`
480    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
481    ///
482    /// The accessible role cannot be changed once set.
483    ///
484    /// Readable | Writeable
485    /// </details>
486    ///
487    /// ## Signals
488    ///
489    ///
490    /// #### `change-current-page`
491    ///  Emitted when the current page should be changed.
492    ///
493    /// The default bindings for this signal are
494    /// <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>PgUp</kbd>,
495    /// <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>PgDn</kbd>,
496    /// <kbd>Ctrl</kbd>+<kbd>PgUp</kbd> and <kbd>Ctrl</kbd>+<kbd>PgDn</kbd>.
497    ///
498    /// Action
499    ///
500    ///
501    /// #### `create-window`
502    ///  The ::create-window signal is emitted when a detachable
503    /// tab is dropped on the root window.
504    ///
505    /// A handler for this signal can create a window containing
506    /// a notebook where the tab will be attached. It is also
507    /// responsible for moving/resizing the window and adding the
508    /// necessary properties to the notebook (e.g. the
509    /// [`Notebook`][crate::Notebook]:group-name ).
510    ///
511    ///
512    ///
513    ///
514    /// #### `focus-tab`
515    ///  Emitted when a tab should be focused.
516    ///
517    /// Action
518    ///
519    ///
520    /// #### `move-focus-out`
521    ///  Emitted when focus was moved out.
522    ///
523    /// The default bindings for this signal are
524    /// <kbd>Ctrl</kbd>+<kbd>Tab</kbd>,
525    /// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Tab</kbd>,
526    /// <kbd>Ctrl</kbd>+<kbd>←</kbd>, <kbd>Ctrl</kbd>+<kbd>→</kbd>,
527    /// <kbd>Ctrl</kbd>+<kbd>↑</kbd> and <kbd>Ctrl</kbd>+<kbd>↓</kbd>.
528    ///
529    /// Action
530    ///
531    ///
532    /// #### `page-added`
533    ///  the ::page-added signal is emitted in the notebook
534    /// right after a page is added to the notebook.
535    ///
536    ///
537    ///
538    ///
539    /// #### `page-removed`
540    ///  the ::page-removed signal is emitted in the notebook
541    /// right after a page is removed from the notebook.
542    ///
543    ///
544    ///
545    ///
546    /// #### `page-reordered`
547    ///  the ::page-reordered signal is emitted in the notebook
548    /// right after a page has been reordered.
549    ///
550    ///
551    ///
552    ///
553    /// #### `reorder-tab`
554    ///  Emitted when the tab should be reordered.
555    ///
556    /// The default bindings for this signal are
557    /// <kbd>Alt</kbd>+<kbd>Home</kbd>, <kbd>Alt</kbd>+<kbd>End</kbd>,
558    /// <kbd>Alt</kbd>+<kbd>PgUp</kbd>, <kbd>Alt</kbd>+<kbd>PgDn</kbd>,
559    /// <kbd>Alt</kbd>+<kbd>←</kbd>, <kbd>Alt</kbd>+<kbd>→</kbd>,
560    /// <kbd>Alt</kbd>+<kbd>↑</kbd> and <kbd>Alt</kbd>+<kbd>↓</kbd>.
561    ///
562    /// Action
563    ///
564    ///
565    /// #### `select-page`
566    ///  Emitted when a page should be selected.
567    ///
568    /// The default binding for this signal is <kbd>␣</kbd>.
569    ///
570    /// Action
571    ///
572    ///
573    /// #### `switch-page`
574    ///  Emitted when the user or a function changes the current page.
575    ///
576    ///
577    /// <details><summary><h4>Widget</h4></summary>
578    ///
579    ///
580    /// #### `destroy`
581    ///  Signals that all holders of a reference to the widget should release
582    /// the reference that they hold.
583    ///
584    /// May result in finalization of the widget if all references are released.
585    ///
586    /// This signal is not suitable for saving widget state.
587    ///
588    ///
589    ///
590    ///
591    /// #### `direction-changed`
592    ///  Emitted when the text direction of a widget changes.
593    ///
594    ///
595    ///
596    ///
597    /// #### `hide`
598    ///  Emitted when @widget is hidden.
599    ///
600    ///
601    ///
602    ///
603    /// #### `keynav-failed`
604    ///  Emitted if keyboard navigation fails.
605    ///
606    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
607    ///
608    ///
609    ///
610    ///
611    /// #### `map`
612    ///  Emitted when @widget is going to be mapped.
613    ///
614    /// A widget is mapped when the widget is visible (which is controlled with
615    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
616    /// are also visible.
617    ///
618    /// The `::map` signal can be used to determine whether a widget will be drawn,
619    /// for instance it can resume an animation that was stopped during the
620    /// emission of [`unmap`][struct@crate::Widget#unmap].
621    ///
622    ///
623    ///
624    ///
625    /// #### `mnemonic-activate`
626    ///  Emitted when a widget is activated via a mnemonic.
627    ///
628    /// The default handler for this signal activates @widget if @group_cycling
629    /// is false, or just makes @widget grab focus if @group_cycling is true.
630    ///
631    ///
632    ///
633    ///
634    /// #### `move-focus`
635    ///  Emitted when the focus is moved.
636    ///
637    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
638    ///
639    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
640    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
641    ///
642    /// Action
643    ///
644    ///
645    /// #### `query-tooltip`
646    ///  Emitted when the widget’s tooltip is about to be shown.
647    ///
648    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
649    /// is true and the hover timeout has expired with the cursor hovering
650    /// above @widget; or emitted when @widget got focus in keyboard mode.
651    ///
652    /// Using the given coordinates, the signal handler should determine
653    /// whether a tooltip should be shown for @widget. If this is the case
654    /// true should be returned, false otherwise. Note that if @keyboard_mode
655    /// is true, the values of @x and @y are undefined and should not be used.
656    ///
657    /// The signal handler is free to manipulate @tooltip with the therefore
658    /// destined function calls.
659    ///
660    ///
661    ///
662    ///
663    /// #### `realize`
664    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
665    ///
666    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
667    /// or the widget has been mapped (that is, it is going to be drawn).
668    ///
669    ///
670    ///
671    ///
672    /// #### `show`
673    ///  Emitted when @widget is shown.
674    ///
675    ///
676    ///
677    ///
678    /// #### `state-flags-changed`
679    ///  Emitted when the widget state changes.
680    ///
681    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
682    ///
683    ///
684    ///
685    ///
686    /// #### `unmap`
687    ///  Emitted when @widget is going to be unmapped.
688    ///
689    /// A widget is unmapped when either it or any of its parents up to the
690    /// toplevel widget have been set as hidden.
691    ///
692    /// As `::unmap` indicates that a widget will not be shown any longer,
693    /// it can be used to, for example, stop an animation on the widget.
694    ///
695    ///
696    ///
697    ///
698    /// #### `unrealize`
699    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
700    ///
701    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
702    /// or the widget has been unmapped (that is, it is going to be hidden).
703    ///
704    ///
705    /// </details>
706    ///
707    /// # Implements
708    ///
709    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
710    #[doc(alias = "GtkNotebook")]
711    pub struct Notebook(Object<ffi::GtkNotebook>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
712
713    match fn {
714        type_ => || ffi::gtk_notebook_get_type(),
715    }
716}
717
718impl Notebook {
719    /// Creates a new [`Notebook`][crate::Notebook] widget with no pages.
720    ///
721    /// # Returns
722    ///
723    /// the newly created [`Notebook`][crate::Notebook]
724    #[doc(alias = "gtk_notebook_new")]
725    pub fn new() -> Notebook {
726        assert_initialized_main_thread!();
727        unsafe { Widget::from_glib_none(ffi::gtk_notebook_new()).unsafe_cast() }
728    }
729
730    // rustdoc-stripper-ignore-next
731    /// Creates a new builder-pattern struct instance to construct [`Notebook`] objects.
732    ///
733    /// This method returns an instance of [`NotebookBuilder`](crate::builders::NotebookBuilder) which can be used to create [`Notebook`] objects.
734    pub fn builder() -> NotebookBuilder {
735        NotebookBuilder::new()
736    }
737
738    /// Removes the child from the notebook.
739    ///
740    /// This function is very similar to [`remove_page()`][Self::remove_page()],
741    /// but additionally informs the notebook that the removal
742    /// is happening as part of a tab DND operation, which should
743    /// not be cancelled.
744    /// ## `child`
745    /// a child
746    #[doc(alias = "gtk_notebook_detach_tab")]
747    pub fn detach_tab(&self, child: &impl IsA<Widget>) {
748        unsafe {
749            ffi::gtk_notebook_detach_tab(self.to_glib_none().0, child.as_ref().to_glib_none().0);
750        }
751    }
752
753    /// Gets one of the action widgets.
754    ///
755    /// See [`set_action_widget()`][Self::set_action_widget()].
756    /// ## `pack_type`
757    /// pack type of the action widget to receive
758    ///
759    /// # Returns
760    ///
761    /// The action widget
762    ///   with the given @pack_type or [`None`] when this action
763    ///   widget has not been set
764    #[doc(alias = "gtk_notebook_get_action_widget")]
765    #[doc(alias = "get_action_widget")]
766    pub fn action_widget(&self, pack_type: PackType) -> Option<Widget> {
767        unsafe {
768            from_glib_none(ffi::gtk_notebook_get_action_widget(
769                self.to_glib_none().0,
770                pack_type.into_glib(),
771            ))
772        }
773    }
774
775    /// Gets the current group name for @self.
776    ///
777    /// # Returns
778    ///
779    /// the group name,
780    ///   or [`None`] if none is set
781    #[doc(alias = "gtk_notebook_get_group_name")]
782    #[doc(alias = "get_group_name")]
783    #[doc(alias = "group-name")]
784    pub fn group_name(&self) -> Option<glib::GString> {
785        unsafe { from_glib_none(ffi::gtk_notebook_get_group_name(self.to_glib_none().0)) }
786    }
787
788    /// Retrieves the menu label widget of the page containing @child.
789    /// ## `child`
790    /// a widget contained in a page of @self
791    ///
792    /// # Returns
793    ///
794    /// the menu label, or [`None`]
795    ///   if the notebook page does not have a menu label other than
796    ///   the default (the tab label).
797    #[doc(alias = "gtk_notebook_get_menu_label")]
798    #[doc(alias = "get_menu_label")]
799    pub fn menu_label(&self, child: &impl IsA<Widget>) -> Option<Widget> {
800        unsafe {
801            from_glib_none(ffi::gtk_notebook_get_menu_label(
802                self.to_glib_none().0,
803                child.as_ref().to_glib_none().0,
804            ))
805        }
806    }
807
808    /// Retrieves the text of the menu label for the page containing
809    /// @child.
810    /// ## `child`
811    /// the child widget of a page of the notebook.
812    ///
813    /// # Returns
814    ///
815    /// the text of the tab label, or [`None`] if
816    ///   the widget does not have a menu label other than the default
817    ///   menu label, or the menu label widget is not a [`Label`][crate::Label].
818    ///   The string is owned by the widget and must not be freed.
819    #[doc(alias = "gtk_notebook_get_menu_label_text")]
820    #[doc(alias = "get_menu_label_text")]
821    pub fn menu_label_text(&self, child: &impl IsA<Widget>) -> Option<glib::GString> {
822        unsafe {
823            from_glib_none(ffi::gtk_notebook_get_menu_label_text(
824                self.to_glib_none().0,
825                child.as_ref().to_glib_none().0,
826            ))
827        }
828    }
829
830    /// Returns the [`NotebookPage`][crate::NotebookPage] for @child.
831    /// ## `child`
832    /// a child of @self
833    ///
834    /// # Returns
835    ///
836    /// the [`NotebookPage`][crate::NotebookPage] for @child
837    #[doc(alias = "gtk_notebook_get_page")]
838    #[doc(alias = "get_page")]
839    pub fn page(&self, child: &impl IsA<Widget>) -> NotebookPage {
840        unsafe {
841            from_glib_none(ffi::gtk_notebook_get_page(
842                self.to_glib_none().0,
843                child.as_ref().to_glib_none().0,
844            ))
845        }
846    }
847
848    /// Returns a `GListModel` that contains the pages of the notebook.
849    ///
850    /// This can be used to keep an up-to-date view. The model also
851    /// implements [`SelectionModel`][crate::SelectionModel] and can be used to track
852    /// and modify the visible page.
853    ///
854    /// # Returns
855    ///
856    /// a
857    ///   `GListModel` for the notebook's children
858    #[doc(alias = "gtk_notebook_get_pages")]
859    #[doc(alias = "get_pages")]
860    pub fn pages(&self) -> gio::ListModel {
861        unsafe { from_glib_full(ffi::gtk_notebook_get_pages(self.to_glib_none().0)) }
862    }
863
864    /// Returns whether the tab label area has arrows for scrolling.
865    ///
866    /// # Returns
867    ///
868    /// [`true`] if arrows for scrolling are present
869    #[doc(alias = "gtk_notebook_get_scrollable")]
870    #[doc(alias = "get_scrollable")]
871    #[doc(alias = "scrollable")]
872    pub fn is_scrollable(&self) -> bool {
873        unsafe { from_glib(ffi::gtk_notebook_get_scrollable(self.to_glib_none().0)) }
874    }
875
876    /// Returns whether a bevel will be drawn around the notebook pages.
877    ///
878    /// # Returns
879    ///
880    /// [`true`] if the bevel is drawn
881    #[doc(alias = "gtk_notebook_get_show_border")]
882    #[doc(alias = "get_show_border")]
883    #[doc(alias = "show-border")]
884    pub fn shows_border(&self) -> bool {
885        unsafe { from_glib(ffi::gtk_notebook_get_show_border(self.to_glib_none().0)) }
886    }
887
888    /// Returns whether the tabs of the notebook are shown.
889    ///
890    /// # Returns
891    ///
892    /// [`true`] if the tabs are shown
893    #[doc(alias = "gtk_notebook_get_show_tabs")]
894    #[doc(alias = "get_show_tabs")]
895    #[doc(alias = "show-tabs")]
896    pub fn shows_tabs(&self) -> bool {
897        unsafe { from_glib(ffi::gtk_notebook_get_show_tabs(self.to_glib_none().0)) }
898    }
899
900    /// Returns whether the tab contents can be detached from @self.
901    /// ## `child`
902    /// a child [`Widget`][crate::Widget]
903    ///
904    /// # Returns
905    ///
906    /// [`true`] if the tab is detachable.
907    #[doc(alias = "gtk_notebook_get_tab_detachable")]
908    #[doc(alias = "get_tab_detachable")]
909    pub fn tab_is_detachable(&self, child: &impl IsA<Widget>) -> bool {
910        unsafe {
911            from_glib(ffi::gtk_notebook_get_tab_detachable(
912                self.to_glib_none().0,
913                child.as_ref().to_glib_none().0,
914            ))
915        }
916    }
917
918    /// Returns the tab label widget for the page @child.
919    ///
920    /// [`None`] is returned if @child is not in @self or
921    /// if no tab label has specifically been set for @child.
922    /// ## `child`
923    /// the page
924    ///
925    /// # Returns
926    ///
927    /// the tab label
928    #[doc(alias = "gtk_notebook_get_tab_label")]
929    #[doc(alias = "get_tab_label")]
930    pub fn tab_label(&self, child: &impl IsA<Widget>) -> Option<Widget> {
931        unsafe {
932            from_glib_none(ffi::gtk_notebook_get_tab_label(
933                self.to_glib_none().0,
934                child.as_ref().to_glib_none().0,
935            ))
936        }
937    }
938
939    /// Retrieves the text of the tab label for the page containing
940    /// @child.
941    /// ## `child`
942    /// a widget contained in a page of @self
943    ///
944    /// # Returns
945    ///
946    /// the text of the tab label, or [`None`] if
947    ///   the tab label widget is not a [`Label`][crate::Label]. The string is owned
948    ///   by the widget and must not be freed.
949    #[doc(alias = "gtk_notebook_get_tab_label_text")]
950    #[doc(alias = "get_tab_label_text")]
951    pub fn tab_label_text(&self, child: &impl IsA<Widget>) -> Option<glib::GString> {
952        unsafe {
953            from_glib_none(ffi::gtk_notebook_get_tab_label_text(
954                self.to_glib_none().0,
955                child.as_ref().to_glib_none().0,
956            ))
957        }
958    }
959
960    /// Gets the edge at which the tabs are drawn.
961    ///
962    /// # Returns
963    ///
964    /// the edge at which the tabs are drawn
965    #[doc(alias = "gtk_notebook_get_tab_pos")]
966    #[doc(alias = "get_tab_pos")]
967    #[doc(alias = "tab-pos")]
968    pub fn tab_pos(&self) -> PositionType {
969        unsafe { from_glib(ffi::gtk_notebook_get_tab_pos(self.to_glib_none().0)) }
970    }
971
972    /// Gets whether the tab can be reordered via drag and drop or not.
973    /// ## `child`
974    /// a child [`Widget`][crate::Widget]
975    ///
976    /// # Returns
977    ///
978    /// [`true`] if the tab is reorderable.
979    #[doc(alias = "gtk_notebook_get_tab_reorderable")]
980    #[doc(alias = "get_tab_reorderable")]
981    pub fn tab_is_reorderable(&self, child: &impl IsA<Widget>) -> bool {
982        unsafe {
983            from_glib(ffi::gtk_notebook_get_tab_reorderable(
984                self.to_glib_none().0,
985                child.as_ref().to_glib_none().0,
986            ))
987        }
988    }
989
990    /// Switches to the next page.
991    ///
992    /// Nothing happens if the current page is the last page.
993    #[doc(alias = "gtk_notebook_next_page")]
994    pub fn next_page(&self) {
995        unsafe {
996            ffi::gtk_notebook_next_page(self.to_glib_none().0);
997        }
998    }
999
1000    /// Disables the popup menu.
1001    #[doc(alias = "gtk_notebook_popup_disable")]
1002    pub fn popup_disable(&self) {
1003        unsafe {
1004            ffi::gtk_notebook_popup_disable(self.to_glib_none().0);
1005        }
1006    }
1007
1008    /// Enables the popup menu.
1009    ///
1010    /// If the user clicks with the right mouse button on the tab labels,
1011    /// a menu with all the pages will be popped up.
1012    #[doc(alias = "gtk_notebook_popup_enable")]
1013    pub fn popup_enable(&self) {
1014        unsafe {
1015            ffi::gtk_notebook_popup_enable(self.to_glib_none().0);
1016        }
1017    }
1018
1019    /// Switches to the previous page.
1020    ///
1021    /// Nothing happens if the current page is the first page.
1022    #[doc(alias = "gtk_notebook_prev_page")]
1023    pub fn prev_page(&self) {
1024        unsafe {
1025            ffi::gtk_notebook_prev_page(self.to_glib_none().0);
1026        }
1027    }
1028
1029    /// Sets @widget as one of the action widgets.
1030    ///
1031    /// Depending on the pack type the widget will be placed before
1032    /// or after the tabs. You can use a [`Box`][crate::Box] if you need to pack
1033    /// more than one widget on the same side.
1034    /// ## `widget`
1035    /// a [`Widget`][crate::Widget]
1036    /// ## `pack_type`
1037    /// pack type of the action widget
1038    #[doc(alias = "gtk_notebook_set_action_widget")]
1039    pub fn set_action_widget(&self, widget: &impl IsA<Widget>, pack_type: PackType) {
1040        unsafe {
1041            ffi::gtk_notebook_set_action_widget(
1042                self.to_glib_none().0,
1043                widget.as_ref().to_glib_none().0,
1044                pack_type.into_glib(),
1045            );
1046        }
1047    }
1048
1049    /// Sets a group name for @self.
1050    ///
1051    /// Notebooks with the same name will be able to exchange tabs
1052    /// via drag and drop. A notebook with a [`None`] group name will
1053    /// not be able to exchange tabs with any other notebook.
1054    /// ## `group_name`
1055    /// the name of the notebook group,
1056    ///   or [`None`] to unset it
1057    #[doc(alias = "gtk_notebook_set_group_name")]
1058    #[doc(alias = "group-name")]
1059    pub fn set_group_name(&self, group_name: Option<&str>) {
1060        unsafe {
1061            ffi::gtk_notebook_set_group_name(self.to_glib_none().0, group_name.to_glib_none().0);
1062        }
1063    }
1064
1065    /// Changes the menu label for the page containing @child.
1066    /// ## `child`
1067    /// the child widget
1068    /// ## `menu_label`
1069    /// the menu label, or [`None`] for default
1070    #[doc(alias = "gtk_notebook_set_menu_label")]
1071    pub fn set_menu_label(&self, child: &impl IsA<Widget>, menu_label: Option<&impl IsA<Widget>>) {
1072        unsafe {
1073            ffi::gtk_notebook_set_menu_label(
1074                self.to_glib_none().0,
1075                child.as_ref().to_glib_none().0,
1076                menu_label.map(|p| p.as_ref()).to_glib_none().0,
1077            );
1078        }
1079    }
1080
1081    /// Creates a new label and sets it as the menu label of @child.
1082    /// ## `child`
1083    /// the child widget
1084    /// ## `menu_text`
1085    /// the label text
1086    #[doc(alias = "gtk_notebook_set_menu_label_text")]
1087    pub fn set_menu_label_text(&self, child: &impl IsA<Widget>, menu_text: &str) {
1088        unsafe {
1089            ffi::gtk_notebook_set_menu_label_text(
1090                self.to_glib_none().0,
1091                child.as_ref().to_glib_none().0,
1092                menu_text.to_glib_none().0,
1093            );
1094        }
1095    }
1096
1097    /// Sets whether the tab label area will have arrows for
1098    /// scrolling if there are too many tabs to fit in the area.
1099    /// ## `scrollable`
1100    /// [`true`] if scroll arrows should be added
1101    #[doc(alias = "gtk_notebook_set_scrollable")]
1102    #[doc(alias = "scrollable")]
1103    pub fn set_scrollable(&self, scrollable: bool) {
1104        unsafe {
1105            ffi::gtk_notebook_set_scrollable(self.to_glib_none().0, scrollable.into_glib());
1106        }
1107    }
1108
1109    /// Sets whether a bevel will be drawn around the notebook pages.
1110    ///
1111    /// This only has a visual effect when the tabs are not shown.
1112    /// ## `show_border`
1113    /// [`true`] if a bevel should be drawn around the notebook
1114    #[doc(alias = "gtk_notebook_set_show_border")]
1115    #[doc(alias = "show-border")]
1116    pub fn set_show_border(&self, show_border: bool) {
1117        unsafe {
1118            ffi::gtk_notebook_set_show_border(self.to_glib_none().0, show_border.into_glib());
1119        }
1120    }
1121
1122    /// Sets whether to show the tabs for the notebook or not.
1123    /// ## `show_tabs`
1124    /// [`true`] if the tabs should be shown
1125    #[doc(alias = "gtk_notebook_set_show_tabs")]
1126    #[doc(alias = "show-tabs")]
1127    pub fn set_show_tabs(&self, show_tabs: bool) {
1128        unsafe {
1129            ffi::gtk_notebook_set_show_tabs(self.to_glib_none().0, show_tabs.into_glib());
1130        }
1131    }
1132
1133    /// Sets whether the tab can be detached from @self to another
1134    /// notebook or widget.
1135    ///
1136    /// Note that two notebooks must share a common group identifier
1137    /// (see [`set_group_name()`][Self::set_group_name()]) to allow automatic tabs
1138    /// interchange between them.
1139    ///
1140    /// If you want a widget to interact with a notebook through DnD
1141    /// (i.e.: accept dragged tabs from it) it must be set as a drop
1142    /// destination by adding to it a [`DropTarget`][crate::DropTarget] controller that accepts
1143    /// the GType `GTK_TYPE_NOTEBOOK_PAGE`. The `:value` of said drop target will be
1144    /// preloaded with a [`NotebookPage`][crate::NotebookPage] object that corresponds to the
1145    /// dropped tab, so you can process the value via `::accept` or `::drop` signals.
1146    ///
1147    /// Note that you should use [`detach_tab()`][Self::detach_tab()] instead
1148    /// of [`remove_page()`][Self::remove_page()] if you want to remove the tab
1149    /// from the source notebook as part of accepting a drop. Otherwise,
1150    /// the source notebook will think that the dragged tab was removed
1151    /// from underneath the ongoing drag operation, and will initiate a
1152    /// drag cancel animation.
1153    ///
1154    /// **⚠️ The following code is in c ⚠️**
1155    ///
1156    /// ```c
1157    /// static void
1158    /// on_drag_data_received (GtkWidget        *widget,
1159    ///                        GdkDrop          *drop,
1160    ///                        GtkSelectionData *data,
1161    ///                        guint             time,
1162    ///                        gpointer          user_data)
1163    /// {
1164    ///   GtkDrag *drag;
1165    ///   GtkWidget *notebook;
1166    ///   GtkWidget **child;
1167    ///
1168    ///   drag = gtk_drop_get_drag (drop);
1169    ///   notebook = g_object_get_data (drag, "gtk-notebook-drag-origin");
1170    ///   child = (void*) gtk_selection_data_get_data (data);
1171    ///
1172    ///   // process_widget (*child);
1173    ///
1174    ///   gtk_notebook_detach_tab (GTK_NOTEBOOK (notebook), *child);
1175    /// }
1176    /// ```
1177    ///
1178    /// If you want a notebook to accept drags from other widgets,
1179    /// you will have to set your own DnD code to do it.
1180    /// ## `child`
1181    /// a child [`Widget`][crate::Widget]
1182    /// ## `detachable`
1183    /// whether the tab is detachable or not
1184    #[doc(alias = "gtk_notebook_set_tab_detachable")]
1185    pub fn set_tab_detachable(&self, child: &impl IsA<Widget>, detachable: bool) {
1186        unsafe {
1187            ffi::gtk_notebook_set_tab_detachable(
1188                self.to_glib_none().0,
1189                child.as_ref().to_glib_none().0,
1190                detachable.into_glib(),
1191            );
1192        }
1193    }
1194
1195    /// Changes the tab label for @child.
1196    ///
1197    /// If [`None`] is specified for @tab_label, then the page will
1198    /// have the label “page N”.
1199    /// ## `child`
1200    /// the page
1201    /// ## `tab_label`
1202    /// the tab label widget to use, or [`None`]
1203    ///   for default tab label
1204    #[doc(alias = "gtk_notebook_set_tab_label")]
1205    pub fn set_tab_label(&self, child: &impl IsA<Widget>, tab_label: Option<&impl IsA<Widget>>) {
1206        unsafe {
1207            ffi::gtk_notebook_set_tab_label(
1208                self.to_glib_none().0,
1209                child.as_ref().to_glib_none().0,
1210                tab_label.map(|p| p.as_ref()).to_glib_none().0,
1211            );
1212        }
1213    }
1214
1215    /// Creates a new label and sets it as the tab label for the page
1216    /// containing @child.
1217    /// ## `child`
1218    /// the page
1219    /// ## `tab_text`
1220    /// the label text
1221    #[doc(alias = "gtk_notebook_set_tab_label_text")]
1222    pub fn set_tab_label_text(&self, child: &impl IsA<Widget>, tab_text: &str) {
1223        unsafe {
1224            ffi::gtk_notebook_set_tab_label_text(
1225                self.to_glib_none().0,
1226                child.as_ref().to_glib_none().0,
1227                tab_text.to_glib_none().0,
1228            );
1229        }
1230    }
1231
1232    /// Sets the edge at which the tabs are drawn.
1233    /// ## `pos`
1234    /// the edge to draw the tabs at
1235    #[doc(alias = "gtk_notebook_set_tab_pos")]
1236    #[doc(alias = "tab-pos")]
1237    pub fn set_tab_pos(&self, pos: PositionType) {
1238        unsafe {
1239            ffi::gtk_notebook_set_tab_pos(self.to_glib_none().0, pos.into_glib());
1240        }
1241    }
1242
1243    /// Sets whether the notebook tab can be reordered
1244    /// via drag and drop or not.
1245    /// ## `child`
1246    /// a child [`Widget`][crate::Widget]
1247    /// ## `reorderable`
1248    /// whether the tab is reorderable or not
1249    #[doc(alias = "gtk_notebook_set_tab_reorderable")]
1250    pub fn set_tab_reorderable(&self, child: &impl IsA<Widget>, reorderable: bool) {
1251        unsafe {
1252            ffi::gtk_notebook_set_tab_reorderable(
1253                self.to_glib_none().0,
1254                child.as_ref().to_glib_none().0,
1255                reorderable.into_glib(),
1256            );
1257        }
1258    }
1259
1260    /// If [`true`], pressing the right mouse button on the notebook shows a page switching menu.
1261    #[doc(alias = "enable-popup")]
1262    pub fn enables_popup(&self) -> bool {
1263        ObjectExt::property(self, "enable-popup")
1264    }
1265
1266    /// If [`true`], pressing the right mouse button on the notebook shows a page switching menu.
1267    #[doc(alias = "enable-popup")]
1268    pub fn set_enable_popup(&self, enable_popup: bool) {
1269        ObjectExt::set_property(self, "enable-popup", enable_popup)
1270    }
1271
1272    /// Emitted when the current page should be changed.
1273    ///
1274    /// The default bindings for this signal are
1275    /// <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>PgUp</kbd>,
1276    /// <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>PgDn</kbd>,
1277    /// <kbd>Ctrl</kbd>+<kbd>PgUp</kbd> and <kbd>Ctrl</kbd>+<kbd>PgDn</kbd>.
1278    /// ## `page`
1279    /// the page index
1280    ///
1281    /// # Returns
1282    ///
1283    /// whether the page was changed
1284    #[doc(alias = "change-current-page")]
1285    pub fn connect_change_current_page<F: Fn(&Self, i32) -> bool + 'static>(
1286        &self,
1287        f: F,
1288    ) -> SignalHandlerId {
1289        unsafe extern "C" fn change_current_page_trampoline<
1290            F: Fn(&Notebook, i32) -> bool + 'static,
1291        >(
1292            this: *mut ffi::GtkNotebook,
1293            page: std::ffi::c_int,
1294            f: glib::ffi::gpointer,
1295        ) -> glib::ffi::gboolean {
1296            unsafe {
1297                let f: &F = &*(f as *const F);
1298                f(&from_glib_borrow(this), page).into_glib()
1299            }
1300        }
1301        unsafe {
1302            let f: Box_<F> = Box_::new(f);
1303            connect_raw(
1304                self.as_ptr() as *mut _,
1305                c"change-current-page".as_ptr() as *const _,
1306                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1307                    change_current_page_trampoline::<F> as *const (),
1308                )),
1309                Box_::into_raw(f),
1310            )
1311        }
1312    }
1313
1314    pub fn emit_change_current_page(&self, page: i32) -> bool {
1315        self.emit_by_name("change-current-page", &[&page])
1316    }
1317
1318    /// The ::create-window signal is emitted when a detachable
1319    /// tab is dropped on the root window.
1320    ///
1321    /// A handler for this signal can create a window containing
1322    /// a notebook where the tab will be attached. It is also
1323    /// responsible for moving/resizing the window and adding the
1324    /// necessary properties to the notebook (e.g. the
1325    /// [`Notebook`][crate::Notebook]:group-name ).
1326    /// ## `page`
1327    /// the tab of @notebook that is being detached
1328    ///
1329    /// # Returns
1330    ///
1331    /// a [`Notebook`][crate::Notebook] that
1332    ///   @page should be added to
1333    #[doc(alias = "create-window")]
1334    pub fn connect_create_window<F: Fn(&Self, &Widget) -> Option<Notebook> + 'static>(
1335        &self,
1336        f: F,
1337    ) -> SignalHandlerId {
1338        unsafe extern "C" fn create_window_trampoline<
1339            F: Fn(&Notebook, &Widget) -> Option<Notebook> + 'static,
1340        >(
1341            this: *mut ffi::GtkNotebook,
1342            page: *mut ffi::GtkWidget,
1343            f: glib::ffi::gpointer,
1344        ) -> *mut ffi::GtkNotebook {
1345            unsafe {
1346                let f: &F = &*(f as *const F);
1347                f(&from_glib_borrow(this), &from_glib_borrow(page)) /*Not checked*/
1348                    .to_glib_none()
1349                    .0
1350            }
1351        }
1352        unsafe {
1353            let f: Box_<F> = Box_::new(f);
1354            connect_raw(
1355                self.as_ptr() as *mut _,
1356                c"create-window".as_ptr() as *const _,
1357                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1358                    create_window_trampoline::<F> as *const (),
1359                )),
1360                Box_::into_raw(f),
1361            )
1362        }
1363    }
1364
1365    /// Emitted when a tab should be focused.
1366    /// ## `tab`
1367    /// the notebook tab
1368    ///
1369    /// # Returns
1370    ///
1371    /// whether the tab has been focused
1372    #[doc(alias = "focus-tab")]
1373    pub fn connect_focus_tab<F: Fn(&Self, NotebookTab) -> bool + 'static>(
1374        &self,
1375        f: F,
1376    ) -> SignalHandlerId {
1377        unsafe extern "C" fn focus_tab_trampoline<
1378            F: Fn(&Notebook, NotebookTab) -> bool + 'static,
1379        >(
1380            this: *mut ffi::GtkNotebook,
1381            tab: ffi::GtkNotebookTab,
1382            f: glib::ffi::gpointer,
1383        ) -> glib::ffi::gboolean {
1384            unsafe {
1385                let f: &F = &*(f as *const F);
1386                f(&from_glib_borrow(this), from_glib(tab)).into_glib()
1387            }
1388        }
1389        unsafe {
1390            let f: Box_<F> = Box_::new(f);
1391            connect_raw(
1392                self.as_ptr() as *mut _,
1393                c"focus-tab".as_ptr() as *const _,
1394                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1395                    focus_tab_trampoline::<F> as *const (),
1396                )),
1397                Box_::into_raw(f),
1398            )
1399        }
1400    }
1401
1402    pub fn emit_focus_tab(&self, tab: NotebookTab) -> bool {
1403        self.emit_by_name("focus-tab", &[&tab])
1404    }
1405
1406    /// Emitted when focus was moved out.
1407    ///
1408    /// The default bindings for this signal are
1409    /// <kbd>Ctrl</kbd>+<kbd>Tab</kbd>,
1410    /// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Tab</kbd>,
1411    /// <kbd>Ctrl</kbd>+<kbd>←</kbd>, <kbd>Ctrl</kbd>+<kbd>→</kbd>,
1412    /// <kbd>Ctrl</kbd>+<kbd>↑</kbd> and <kbd>Ctrl</kbd>+<kbd>↓</kbd>.
1413    /// ## `direction`
1414    /// the direction to move the focus
1415    #[doc(alias = "move-focus-out")]
1416    pub fn connect_move_focus_out<F: Fn(&Self, DirectionType) + 'static>(
1417        &self,
1418        f: F,
1419    ) -> SignalHandlerId {
1420        unsafe extern "C" fn move_focus_out_trampoline<
1421            F: Fn(&Notebook, DirectionType) + 'static,
1422        >(
1423            this: *mut ffi::GtkNotebook,
1424            direction: ffi::GtkDirectionType,
1425            f: glib::ffi::gpointer,
1426        ) {
1427            unsafe {
1428                let f: &F = &*(f as *const F);
1429                f(&from_glib_borrow(this), from_glib(direction))
1430            }
1431        }
1432        unsafe {
1433            let f: Box_<F> = Box_::new(f);
1434            connect_raw(
1435                self.as_ptr() as *mut _,
1436                c"move-focus-out".as_ptr() as *const _,
1437                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1438                    move_focus_out_trampoline::<F> as *const (),
1439                )),
1440                Box_::into_raw(f),
1441            )
1442        }
1443    }
1444
1445    pub fn emit_move_focus_out(&self, direction: DirectionType) {
1446        self.emit_by_name::<()>("move-focus-out", &[&direction]);
1447    }
1448
1449    /// the ::page-added signal is emitted in the notebook
1450    /// right after a page is added to the notebook.
1451    /// ## `child`
1452    /// the child [`Widget`][crate::Widget] affected
1453    /// ## `page_num`
1454    /// the new page number for @child
1455    #[doc(alias = "page-added")]
1456    pub fn connect_page_added<F: Fn(&Self, &Widget, u32) + 'static>(
1457        &self,
1458        f: F,
1459    ) -> SignalHandlerId {
1460        unsafe extern "C" fn page_added_trampoline<F: Fn(&Notebook, &Widget, u32) + 'static>(
1461            this: *mut ffi::GtkNotebook,
1462            child: *mut ffi::GtkWidget,
1463            page_num: std::ffi::c_uint,
1464            f: glib::ffi::gpointer,
1465        ) {
1466            unsafe {
1467                let f: &F = &*(f as *const F);
1468                f(&from_glib_borrow(this), &from_glib_borrow(child), page_num)
1469            }
1470        }
1471        unsafe {
1472            let f: Box_<F> = Box_::new(f);
1473            connect_raw(
1474                self.as_ptr() as *mut _,
1475                c"page-added".as_ptr() as *const _,
1476                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1477                    page_added_trampoline::<F> as *const (),
1478                )),
1479                Box_::into_raw(f),
1480            )
1481        }
1482    }
1483
1484    /// the ::page-removed signal is emitted in the notebook
1485    /// right after a page is removed from the notebook.
1486    /// ## `child`
1487    /// the child [`Widget`][crate::Widget] affected
1488    /// ## `page_num`
1489    /// the @child page number
1490    #[doc(alias = "page-removed")]
1491    pub fn connect_page_removed<F: Fn(&Self, &Widget, u32) + 'static>(
1492        &self,
1493        f: F,
1494    ) -> SignalHandlerId {
1495        unsafe extern "C" fn page_removed_trampoline<F: Fn(&Notebook, &Widget, u32) + 'static>(
1496            this: *mut ffi::GtkNotebook,
1497            child: *mut ffi::GtkWidget,
1498            page_num: std::ffi::c_uint,
1499            f: glib::ffi::gpointer,
1500        ) {
1501            unsafe {
1502                let f: &F = &*(f as *const F);
1503                f(&from_glib_borrow(this), &from_glib_borrow(child), page_num)
1504            }
1505        }
1506        unsafe {
1507            let f: Box_<F> = Box_::new(f);
1508            connect_raw(
1509                self.as_ptr() as *mut _,
1510                c"page-removed".as_ptr() as *const _,
1511                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1512                    page_removed_trampoline::<F> as *const (),
1513                )),
1514                Box_::into_raw(f),
1515            )
1516        }
1517    }
1518
1519    /// the ::page-reordered signal is emitted in the notebook
1520    /// right after a page has been reordered.
1521    /// ## `child`
1522    /// the child [`Widget`][crate::Widget] affected
1523    /// ## `page_num`
1524    /// the new page number for @child
1525    #[doc(alias = "page-reordered")]
1526    pub fn connect_page_reordered<F: Fn(&Self, &Widget, u32) + 'static>(
1527        &self,
1528        f: F,
1529    ) -> SignalHandlerId {
1530        unsafe extern "C" fn page_reordered_trampoline<F: Fn(&Notebook, &Widget, u32) + 'static>(
1531            this: *mut ffi::GtkNotebook,
1532            child: *mut ffi::GtkWidget,
1533            page_num: std::ffi::c_uint,
1534            f: glib::ffi::gpointer,
1535        ) {
1536            unsafe {
1537                let f: &F = &*(f as *const F);
1538                f(&from_glib_borrow(this), &from_glib_borrow(child), page_num)
1539            }
1540        }
1541        unsafe {
1542            let f: Box_<F> = Box_::new(f);
1543            connect_raw(
1544                self.as_ptr() as *mut _,
1545                c"page-reordered".as_ptr() as *const _,
1546                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1547                    page_reordered_trampoline::<F> as *const (),
1548                )),
1549                Box_::into_raw(f),
1550            )
1551        }
1552    }
1553
1554    /// Emitted when the tab should be reordered.
1555    ///
1556    /// The default bindings for this signal are
1557    /// <kbd>Alt</kbd>+<kbd>Home</kbd>, <kbd>Alt</kbd>+<kbd>End</kbd>,
1558    /// <kbd>Alt</kbd>+<kbd>PgUp</kbd>, <kbd>Alt</kbd>+<kbd>PgDn</kbd>,
1559    /// <kbd>Alt</kbd>+<kbd>←</kbd>, <kbd>Alt</kbd>+<kbd>→</kbd>,
1560    /// <kbd>Alt</kbd>+<kbd>↑</kbd> and <kbd>Alt</kbd>+<kbd>↓</kbd>.
1561    /// ## `direction`
1562    /// the direction to move the tab
1563    /// ## `move_to_last`
1564    /// whether to move to the last position
1565    ///
1566    /// # Returns
1567    ///
1568    /// whether the tab was moved.
1569    #[doc(alias = "reorder-tab")]
1570    pub fn connect_reorder_tab<F: Fn(&Self, DirectionType, bool) -> bool + 'static>(
1571        &self,
1572        f: F,
1573    ) -> SignalHandlerId {
1574        unsafe extern "C" fn reorder_tab_trampoline<
1575            F: Fn(&Notebook, DirectionType, bool) -> bool + 'static,
1576        >(
1577            this: *mut ffi::GtkNotebook,
1578            direction: ffi::GtkDirectionType,
1579            move_to_last: glib::ffi::gboolean,
1580            f: glib::ffi::gpointer,
1581        ) -> glib::ffi::gboolean {
1582            unsafe {
1583                let f: &F = &*(f as *const F);
1584                f(
1585                    &from_glib_borrow(this),
1586                    from_glib(direction),
1587                    from_glib(move_to_last),
1588                )
1589                .into_glib()
1590            }
1591        }
1592        unsafe {
1593            let f: Box_<F> = Box_::new(f);
1594            connect_raw(
1595                self.as_ptr() as *mut _,
1596                c"reorder-tab".as_ptr() as *const _,
1597                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1598                    reorder_tab_trampoline::<F> as *const (),
1599                )),
1600                Box_::into_raw(f),
1601            )
1602        }
1603    }
1604
1605    pub fn emit_reorder_tab(&self, direction: DirectionType, move_to_last: bool) -> bool {
1606        self.emit_by_name("reorder-tab", &[&direction, &move_to_last])
1607    }
1608
1609    /// Emitted when a page should be selected.
1610    ///
1611    /// The default binding for this signal is <kbd>␣</kbd>.
1612    /// ## `move_focus`
1613    /// whether to move focus
1614    ///
1615    /// # Returns
1616    ///
1617    /// whether the page was selected
1618    #[doc(alias = "select-page")]
1619    pub fn connect_select_page<F: Fn(&Self, bool) -> bool + 'static>(
1620        &self,
1621        f: F,
1622    ) -> SignalHandlerId {
1623        unsafe extern "C" fn select_page_trampoline<F: Fn(&Notebook, bool) -> bool + 'static>(
1624            this: *mut ffi::GtkNotebook,
1625            move_focus: glib::ffi::gboolean,
1626            f: glib::ffi::gpointer,
1627        ) -> glib::ffi::gboolean {
1628            unsafe {
1629                let f: &F = &*(f as *const F);
1630                f(&from_glib_borrow(this), from_glib(move_focus)).into_glib()
1631            }
1632        }
1633        unsafe {
1634            let f: Box_<F> = Box_::new(f);
1635            connect_raw(
1636                self.as_ptr() as *mut _,
1637                c"select-page".as_ptr() as *const _,
1638                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1639                    select_page_trampoline::<F> as *const (),
1640                )),
1641                Box_::into_raw(f),
1642            )
1643        }
1644    }
1645
1646    pub fn emit_select_page(&self, move_focus: bool) -> bool {
1647        self.emit_by_name("select-page", &[&move_focus])
1648    }
1649
1650    /// Emitted when the user or a function changes the current page.
1651    /// ## `page`
1652    /// the new current page
1653    /// ## `page_num`
1654    /// the index of the page
1655    #[doc(alias = "switch-page")]
1656    pub fn connect_switch_page<F: Fn(&Self, &Widget, u32) + 'static>(
1657        &self,
1658        f: F,
1659    ) -> SignalHandlerId {
1660        unsafe extern "C" fn switch_page_trampoline<F: Fn(&Notebook, &Widget, u32) + 'static>(
1661            this: *mut ffi::GtkNotebook,
1662            page: *mut ffi::GtkWidget,
1663            page_num: std::ffi::c_uint,
1664            f: glib::ffi::gpointer,
1665        ) {
1666            unsafe {
1667                let f: &F = &*(f as *const F);
1668                f(&from_glib_borrow(this), &from_glib_borrow(page), page_num)
1669            }
1670        }
1671        unsafe {
1672            let f: Box_<F> = Box_::new(f);
1673            connect_raw(
1674                self.as_ptr() as *mut _,
1675                c"switch-page".as_ptr() as *const _,
1676                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1677                    switch_page_trampoline::<F> as *const (),
1678                )),
1679                Box_::into_raw(f),
1680            )
1681        }
1682    }
1683
1684    #[doc(alias = "enable-popup")]
1685    pub fn connect_enable_popup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1686        unsafe extern "C" fn notify_enable_popup_trampoline<F: Fn(&Notebook) + 'static>(
1687            this: *mut ffi::GtkNotebook,
1688            _param_spec: glib::ffi::gpointer,
1689            f: glib::ffi::gpointer,
1690        ) {
1691            unsafe {
1692                let f: &F = &*(f as *const F);
1693                f(&from_glib_borrow(this))
1694            }
1695        }
1696        unsafe {
1697            let f: Box_<F> = Box_::new(f);
1698            connect_raw(
1699                self.as_ptr() as *mut _,
1700                c"notify::enable-popup".as_ptr() as *const _,
1701                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1702                    notify_enable_popup_trampoline::<F> as *const (),
1703                )),
1704                Box_::into_raw(f),
1705            )
1706        }
1707    }
1708
1709    #[doc(alias = "group-name")]
1710    pub fn connect_group_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1711        unsafe extern "C" fn notify_group_name_trampoline<F: Fn(&Notebook) + 'static>(
1712            this: *mut ffi::GtkNotebook,
1713            _param_spec: glib::ffi::gpointer,
1714            f: glib::ffi::gpointer,
1715        ) {
1716            unsafe {
1717                let f: &F = &*(f as *const F);
1718                f(&from_glib_borrow(this))
1719            }
1720        }
1721        unsafe {
1722            let f: Box_<F> = Box_::new(f);
1723            connect_raw(
1724                self.as_ptr() as *mut _,
1725                c"notify::group-name".as_ptr() as *const _,
1726                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1727                    notify_group_name_trampoline::<F> as *const (),
1728                )),
1729                Box_::into_raw(f),
1730            )
1731        }
1732    }
1733
1734    #[doc(alias = "page")]
1735    pub fn connect_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1736        unsafe extern "C" fn notify_page_trampoline<F: Fn(&Notebook) + 'static>(
1737            this: *mut ffi::GtkNotebook,
1738            _param_spec: glib::ffi::gpointer,
1739            f: glib::ffi::gpointer,
1740        ) {
1741            unsafe {
1742                let f: &F = &*(f as *const F);
1743                f(&from_glib_borrow(this))
1744            }
1745        }
1746        unsafe {
1747            let f: Box_<F> = Box_::new(f);
1748            connect_raw(
1749                self.as_ptr() as *mut _,
1750                c"notify::page".as_ptr() as *const _,
1751                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1752                    notify_page_trampoline::<F> as *const (),
1753                )),
1754                Box_::into_raw(f),
1755            )
1756        }
1757    }
1758
1759    #[doc(alias = "pages")]
1760    pub fn connect_pages_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1761        unsafe extern "C" fn notify_pages_trampoline<F: Fn(&Notebook) + 'static>(
1762            this: *mut ffi::GtkNotebook,
1763            _param_spec: glib::ffi::gpointer,
1764            f: glib::ffi::gpointer,
1765        ) {
1766            unsafe {
1767                let f: &F = &*(f as *const F);
1768                f(&from_glib_borrow(this))
1769            }
1770        }
1771        unsafe {
1772            let f: Box_<F> = Box_::new(f);
1773            connect_raw(
1774                self.as_ptr() as *mut _,
1775                c"notify::pages".as_ptr() as *const _,
1776                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1777                    notify_pages_trampoline::<F> as *const (),
1778                )),
1779                Box_::into_raw(f),
1780            )
1781        }
1782    }
1783
1784    #[doc(alias = "scrollable")]
1785    pub fn connect_scrollable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1786        unsafe extern "C" fn notify_scrollable_trampoline<F: Fn(&Notebook) + 'static>(
1787            this: *mut ffi::GtkNotebook,
1788            _param_spec: glib::ffi::gpointer,
1789            f: glib::ffi::gpointer,
1790        ) {
1791            unsafe {
1792                let f: &F = &*(f as *const F);
1793                f(&from_glib_borrow(this))
1794            }
1795        }
1796        unsafe {
1797            let f: Box_<F> = Box_::new(f);
1798            connect_raw(
1799                self.as_ptr() as *mut _,
1800                c"notify::scrollable".as_ptr() as *const _,
1801                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1802                    notify_scrollable_trampoline::<F> as *const (),
1803                )),
1804                Box_::into_raw(f),
1805            )
1806        }
1807    }
1808
1809    #[doc(alias = "show-border")]
1810    pub fn connect_show_border_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1811        unsafe extern "C" fn notify_show_border_trampoline<F: Fn(&Notebook) + 'static>(
1812            this: *mut ffi::GtkNotebook,
1813            _param_spec: glib::ffi::gpointer,
1814            f: glib::ffi::gpointer,
1815        ) {
1816            unsafe {
1817                let f: &F = &*(f as *const F);
1818                f(&from_glib_borrow(this))
1819            }
1820        }
1821        unsafe {
1822            let f: Box_<F> = Box_::new(f);
1823            connect_raw(
1824                self.as_ptr() as *mut _,
1825                c"notify::show-border".as_ptr() as *const _,
1826                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1827                    notify_show_border_trampoline::<F> as *const (),
1828                )),
1829                Box_::into_raw(f),
1830            )
1831        }
1832    }
1833
1834    #[doc(alias = "show-tabs")]
1835    pub fn connect_show_tabs_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1836        unsafe extern "C" fn notify_show_tabs_trampoline<F: Fn(&Notebook) + 'static>(
1837            this: *mut ffi::GtkNotebook,
1838            _param_spec: glib::ffi::gpointer,
1839            f: glib::ffi::gpointer,
1840        ) {
1841            unsafe {
1842                let f: &F = &*(f as *const F);
1843                f(&from_glib_borrow(this))
1844            }
1845        }
1846        unsafe {
1847            let f: Box_<F> = Box_::new(f);
1848            connect_raw(
1849                self.as_ptr() as *mut _,
1850                c"notify::show-tabs".as_ptr() as *const _,
1851                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1852                    notify_show_tabs_trampoline::<F> as *const (),
1853                )),
1854                Box_::into_raw(f),
1855            )
1856        }
1857    }
1858
1859    #[doc(alias = "tab-pos")]
1860    pub fn connect_tab_pos_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1861        unsafe extern "C" fn notify_tab_pos_trampoline<F: Fn(&Notebook) + 'static>(
1862            this: *mut ffi::GtkNotebook,
1863            _param_spec: glib::ffi::gpointer,
1864            f: glib::ffi::gpointer,
1865        ) {
1866            unsafe {
1867                let f: &F = &*(f as *const F);
1868                f(&from_glib_borrow(this))
1869            }
1870        }
1871        unsafe {
1872            let f: Box_<F> = Box_::new(f);
1873            connect_raw(
1874                self.as_ptr() as *mut _,
1875                c"notify::tab-pos".as_ptr() as *const _,
1876                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1877                    notify_tab_pos_trampoline::<F> as *const (),
1878                )),
1879                Box_::into_raw(f),
1880            )
1881        }
1882    }
1883}
1884
1885impl Default for Notebook {
1886    fn default() -> Self {
1887        Self::new()
1888    }
1889}
1890
1891// rustdoc-stripper-ignore-next
1892/// A [builder-pattern] type to construct [`Notebook`] objects.
1893///
1894/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1895#[must_use = "The builder must be built to be used"]
1896pub struct NotebookBuilder {
1897    builder: glib::object::ObjectBuilder<'static, Notebook>,
1898}
1899
1900impl NotebookBuilder {
1901    fn new() -> Self {
1902        Self {
1903            builder: glib::object::Object::builder(),
1904        }
1905    }
1906
1907    /// If [`true`], pressing the right mouse button on the notebook shows a page switching menu.
1908    pub fn enable_popup(self, enable_popup: bool) -> Self {
1909        Self {
1910            builder: self.builder.property("enable-popup", enable_popup),
1911        }
1912    }
1913
1914    /// Group name for tab drag and drop.
1915    pub fn group_name(self, group_name: impl Into<glib::GString>) -> Self {
1916        Self {
1917            builder: self.builder.property("group-name", group_name.into()),
1918        }
1919    }
1920
1921    /// The index of the current page.
1922    pub fn page(self, page: i32) -> Self {
1923        Self {
1924            builder: self.builder.property("page", page),
1925        }
1926    }
1927
1928    /// If [`true`], scroll arrows are added if there are too many pages to fit.
1929    pub fn scrollable(self, scrollable: bool) -> Self {
1930        Self {
1931            builder: self.builder.property("scrollable", scrollable),
1932        }
1933    }
1934
1935    /// Whether the border should be shown.
1936    pub fn show_border(self, show_border: bool) -> Self {
1937        Self {
1938            builder: self.builder.property("show-border", show_border),
1939        }
1940    }
1941
1942    /// Whether tabs should be shown.
1943    pub fn show_tabs(self, show_tabs: bool) -> Self {
1944        Self {
1945            builder: self.builder.property("show-tabs", show_tabs),
1946        }
1947    }
1948
1949    /// Which side of the notebook holds the tabs.
1950    pub fn tab_pos(self, tab_pos: PositionType) -> Self {
1951        Self {
1952            builder: self.builder.property("tab-pos", tab_pos),
1953        }
1954    }
1955
1956    /// Whether the widget or any of its descendents can accept
1957    /// the input focus.
1958    ///
1959    /// This property is meant to be set by widget implementations,
1960    /// typically in their instance init function.
1961    pub fn can_focus(self, can_focus: bool) -> Self {
1962        Self {
1963            builder: self.builder.property("can-focus", can_focus),
1964        }
1965    }
1966
1967    /// Whether the widget can receive pointer events.
1968    pub fn can_target(self, can_target: bool) -> Self {
1969        Self {
1970            builder: self.builder.property("can-target", can_target),
1971        }
1972    }
1973
1974    /// A list of css classes applied to this widget.
1975    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1976        Self {
1977            builder: self.builder.property("css-classes", css_classes.into()),
1978        }
1979    }
1980
1981    /// The name of this widget in the CSS tree.
1982    ///
1983    /// This property is meant to be set by widget implementations,
1984    /// typically in their instance init function.
1985    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1986        Self {
1987            builder: self.builder.property("css-name", css_name.into()),
1988        }
1989    }
1990
1991    /// The cursor used by @widget.
1992    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1993        Self {
1994            builder: self.builder.property("cursor", cursor.clone()),
1995        }
1996    }
1997
1998    /// Whether the widget should grab focus when it is clicked with the mouse.
1999    ///
2000    /// This property is only relevant for widgets that can take focus.
2001    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
2002        Self {
2003            builder: self.builder.property("focus-on-click", focus_on_click),
2004        }
2005    }
2006
2007    /// Whether this widget itself will accept the input focus.
2008    pub fn focusable(self, focusable: bool) -> Self {
2009        Self {
2010            builder: self.builder.property("focusable", focusable),
2011        }
2012    }
2013
2014    /// How to distribute horizontal space if widget gets extra space.
2015    pub fn halign(self, halign: Align) -> Self {
2016        Self {
2017            builder: self.builder.property("halign", halign),
2018        }
2019    }
2020
2021    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
2022    /// signal on @widget.
2023    ///
2024    /// A true value indicates that @widget can have a tooltip, in this case
2025    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
2026    /// determine whether it will provide a tooltip or not.
2027    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
2028        Self {
2029            builder: self.builder.property("has-tooltip", has_tooltip),
2030        }
2031    }
2032
2033    /// Overrides for height request of the widget.
2034    ///
2035    /// If this is -1, the natural request will be used.
2036    pub fn height_request(self, height_request: i32) -> Self {
2037        Self {
2038            builder: self.builder.property("height-request", height_request),
2039        }
2040    }
2041
2042    /// Whether to expand horizontally.
2043    pub fn hexpand(self, hexpand: bool) -> Self {
2044        Self {
2045            builder: self.builder.property("hexpand", hexpand),
2046        }
2047    }
2048
2049    /// Whether to use the `hexpand` property.
2050    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
2051        Self {
2052            builder: self.builder.property("hexpand-set", hexpand_set),
2053        }
2054    }
2055
2056    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
2057    /// the preferred size of the widget, and allocate its children.
2058    ///
2059    /// This property is meant to be set by widget implementations,
2060    /// typically in their instance init function.
2061    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
2062        Self {
2063            builder: self
2064                .builder
2065                .property("layout-manager", layout_manager.clone().upcast()),
2066        }
2067    }
2068
2069    /// Makes this widget act like a modal dialog, with respect to
2070    /// event delivery.
2071    ///
2072    /// Global event controllers will not handle events with targets
2073    /// inside the widget, unless they are set up to ignore propagation
2074    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
2075    #[cfg(feature = "v4_18")]
2076    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
2077    pub fn limit_events(self, limit_events: bool) -> Self {
2078        Self {
2079            builder: self.builder.property("limit-events", limit_events),
2080        }
2081    }
2082
2083    /// Margin on bottom side of widget.
2084    ///
2085    /// This property adds margin outside of the widget's normal size
2086    /// request, the margin will be added in addition to the size from
2087    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2088    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
2089        Self {
2090            builder: self.builder.property("margin-bottom", margin_bottom),
2091        }
2092    }
2093
2094    /// Margin on end of widget, horizontally.
2095    ///
2096    /// This property supports left-to-right and right-to-left text
2097    /// directions.
2098    ///
2099    /// This property adds margin outside of the widget's normal size
2100    /// request, the margin will be added in addition to the size from
2101    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2102    pub fn margin_end(self, margin_end: i32) -> Self {
2103        Self {
2104            builder: self.builder.property("margin-end", margin_end),
2105        }
2106    }
2107
2108    /// Margin on start of widget, horizontally.
2109    ///
2110    /// This property supports left-to-right and right-to-left text
2111    /// directions.
2112    ///
2113    /// This property adds margin outside of the widget's normal size
2114    /// request, the margin will be added in addition to the size from
2115    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2116    pub fn margin_start(self, margin_start: i32) -> Self {
2117        Self {
2118            builder: self.builder.property("margin-start", margin_start),
2119        }
2120    }
2121
2122    /// Margin on top side of widget.
2123    ///
2124    /// This property adds margin outside of the widget's normal size
2125    /// request, the margin will be added in addition to the size from
2126    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2127    pub fn margin_top(self, margin_top: i32) -> Self {
2128        Self {
2129            builder: self.builder.property("margin-top", margin_top),
2130        }
2131    }
2132
2133    /// The name of the widget.
2134    pub fn name(self, name: impl Into<glib::GString>) -> Self {
2135        Self {
2136            builder: self.builder.property("name", name.into()),
2137        }
2138    }
2139
2140    /// The requested opacity of the widget.
2141    pub fn opacity(self, opacity: f64) -> Self {
2142        Self {
2143            builder: self.builder.property("opacity", opacity),
2144        }
2145    }
2146
2147    /// How content outside the widget's content area is treated.
2148    ///
2149    /// This property is meant to be set by widget implementations,
2150    /// typically in their instance init function.
2151    pub fn overflow(self, overflow: Overflow) -> Self {
2152        Self {
2153            builder: self.builder.property("overflow", overflow),
2154        }
2155    }
2156
2157    /// Whether the widget will receive the default action when it is focused.
2158    pub fn receives_default(self, receives_default: bool) -> Self {
2159        Self {
2160            builder: self.builder.property("receives-default", receives_default),
2161        }
2162    }
2163
2164    /// Whether the widget responds to input.
2165    pub fn sensitive(self, sensitive: bool) -> Self {
2166        Self {
2167            builder: self.builder.property("sensitive", sensitive),
2168        }
2169    }
2170
2171    /// Sets the text of tooltip to be the given string, which is marked up
2172    /// with Pango markup.
2173    ///
2174    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
2175    ///
2176    /// This is a convenience property which will take care of getting the
2177    /// tooltip shown if the given string is not `NULL`:
2178    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2179    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2180    /// the default signal handler.
2181    ///
2182    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2183    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2184    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
2185        Self {
2186            builder: self
2187                .builder
2188                .property("tooltip-markup", tooltip_markup.into()),
2189        }
2190    }
2191
2192    /// Sets the text of tooltip to be the given string.
2193    ///
2194    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
2195    ///
2196    /// This is a convenience property which will take care of getting the
2197    /// tooltip shown if the given string is not `NULL`:
2198    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2199    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2200    /// the default signal handler.
2201    ///
2202    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2203    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2204    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
2205        Self {
2206            builder: self.builder.property("tooltip-text", tooltip_text.into()),
2207        }
2208    }
2209
2210    /// How to distribute vertical space if widget gets extra space.
2211    pub fn valign(self, valign: Align) -> Self {
2212        Self {
2213            builder: self.builder.property("valign", valign),
2214        }
2215    }
2216
2217    /// Whether to expand vertically.
2218    pub fn vexpand(self, vexpand: bool) -> Self {
2219        Self {
2220            builder: self.builder.property("vexpand", vexpand),
2221        }
2222    }
2223
2224    /// Whether to use the `vexpand` property.
2225    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
2226        Self {
2227            builder: self.builder.property("vexpand-set", vexpand_set),
2228        }
2229    }
2230
2231    /// Whether the widget is visible.
2232    pub fn visible(self, visible: bool) -> Self {
2233        Self {
2234            builder: self.builder.property("visible", visible),
2235        }
2236    }
2237
2238    /// Overrides for width request of the widget.
2239    ///
2240    /// If this is -1, the natural request will be used.
2241    pub fn width_request(self, width_request: i32) -> Self {
2242        Self {
2243            builder: self.builder.property("width-request", width_request),
2244        }
2245    }
2246
2247    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
2248    ///
2249    /// The accessible role cannot be changed once set.
2250    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
2251        Self {
2252            builder: self.builder.property("accessible-role", accessible_role),
2253        }
2254    }
2255
2256    // rustdoc-stripper-ignore-next
2257    /// Build the [`Notebook`].
2258    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
2259    pub fn build(self) -> Notebook {
2260        assert_initialized_main_thread!();
2261        self.builder.build()
2262    }
2263}