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