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 /// Emitted when the widget’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 /// Changes the tab label for @child.
1098 ///
1099 /// If [`None`] is specified for @tab_label, then the page will
1100 /// have the label “page N”.
1101 /// ## `child`
1102 /// the page
1103 /// ## `tab_label`
1104 /// the tab label widget to use, or [`None`]
1105 /// for default tab label
1106 #[doc(alias = "gtk_notebook_set_tab_label")]
1107 pub fn set_tab_label(&self, child: &impl IsA<Widget>, tab_label: Option<&impl IsA<Widget>>) {
1108 unsafe {
1109 ffi::gtk_notebook_set_tab_label(
1110 self.to_glib_none().0,
1111 child.as_ref().to_glib_none().0,
1112 tab_label.map(|p| p.as_ref()).to_glib_none().0,
1113 );
1114 }
1115 }
1116
1117 /// Creates a new label and sets it as the tab label for the page
1118 /// containing @child.
1119 /// ## `child`
1120 /// the page
1121 /// ## `tab_text`
1122 /// the label text
1123 #[doc(alias = "gtk_notebook_set_tab_label_text")]
1124 pub fn set_tab_label_text(&self, child: &impl IsA<Widget>, tab_text: &str) {
1125 unsafe {
1126 ffi::gtk_notebook_set_tab_label_text(
1127 self.to_glib_none().0,
1128 child.as_ref().to_glib_none().0,
1129 tab_text.to_glib_none().0,
1130 );
1131 }
1132 }
1133
1134 /// Sets the edge at which the tabs are drawn.
1135 /// ## `pos`
1136 /// the edge to draw the tabs at
1137 #[doc(alias = "gtk_notebook_set_tab_pos")]
1138 #[doc(alias = "tab-pos")]
1139 pub fn set_tab_pos(&self, pos: PositionType) {
1140 unsafe {
1141 ffi::gtk_notebook_set_tab_pos(self.to_glib_none().0, pos.into_glib());
1142 }
1143 }
1144
1145 /// Sets whether the notebook tab can be reordered
1146 /// via drag and drop or not.
1147 /// ## `child`
1148 /// a child [`Widget`][crate::Widget]
1149 /// ## `reorderable`
1150 /// whether the tab is reorderable or not
1151 #[doc(alias = "gtk_notebook_set_tab_reorderable")]
1152 pub fn set_tab_reorderable(&self, child: &impl IsA<Widget>, reorderable: bool) {
1153 unsafe {
1154 ffi::gtk_notebook_set_tab_reorderable(
1155 self.to_glib_none().0,
1156 child.as_ref().to_glib_none().0,
1157 reorderable.into_glib(),
1158 );
1159 }
1160 }
1161
1162 /// If [`true`], pressing the right mouse button on the notebook shows a page switching menu.
1163 #[doc(alias = "enable-popup")]
1164 pub fn enables_popup(&self) -> bool {
1165 ObjectExt::property(self, "enable-popup")
1166 }
1167
1168 /// If [`true`], pressing the right mouse button on the notebook shows a page switching menu.
1169 #[doc(alias = "enable-popup")]
1170 pub fn set_enable_popup(&self, enable_popup: bool) {
1171 ObjectExt::set_property(self, "enable-popup", enable_popup)
1172 }
1173
1174 /// .
1175 /// ## `page`
1176 /// the page index
1177 ///
1178 /// # Returns
1179 ///
1180 /// whether the page was changed
1181 #[doc(alias = "change-current-page")]
1182 pub fn connect_change_current_page<F: Fn(&Self, i32) -> bool + 'static>(
1183 &self,
1184 f: F,
1185 ) -> SignalHandlerId {
1186 unsafe extern "C" fn change_current_page_trampoline<
1187 F: Fn(&Notebook, i32) -> bool + 'static,
1188 >(
1189 this: *mut ffi::GtkNotebook,
1190 page: std::ffi::c_int,
1191 f: glib::ffi::gpointer,
1192 ) -> glib::ffi::gboolean {
1193 unsafe {
1194 let f: &F = &*(f as *const F);
1195 f(&from_glib_borrow(this), page).into_glib()
1196 }
1197 }
1198 unsafe {
1199 let f: Box_<F> = Box_::new(f);
1200 connect_raw(
1201 self.as_ptr() as *mut _,
1202 c"change-current-page".as_ptr(),
1203 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1204 change_current_page_trampoline::<F> as *const (),
1205 )),
1206 Box_::into_raw(f),
1207 )
1208 }
1209 }
1210
1211 pub fn emit_change_current_page(&self, page: i32) -> bool {
1212 self.emit_by_name("change-current-page", &[&page])
1213 }
1214
1215 /// The ::create-window signal is emitted when a detachable
1216 /// tab is dropped on the root window.
1217 ///
1218 /// A handler for this signal can create a window containing
1219 /// a notebook where the tab will be attached. It is also
1220 /// responsible for moving/resizing the window and adding the
1221 /// necessary properties to the notebook (e.g. the
1222 /// [`Notebook`][crate::Notebook]:group-name ).
1223 /// ## `page`
1224 /// the tab of @notebook that is being detached
1225 ///
1226 /// # Returns
1227 ///
1228 /// a [`Notebook`][crate::Notebook] that
1229 /// @page should be added to
1230 #[doc(alias = "create-window")]
1231 pub fn connect_create_window<F: Fn(&Self, &Widget) -> Option<Notebook> + 'static>(
1232 &self,
1233 f: F,
1234 ) -> SignalHandlerId {
1235 unsafe extern "C" fn create_window_trampoline<
1236 F: Fn(&Notebook, &Widget) -> Option<Notebook> + 'static,
1237 >(
1238 this: *mut ffi::GtkNotebook,
1239 page: *mut ffi::GtkWidget,
1240 f: glib::ffi::gpointer,
1241 ) -> *mut ffi::GtkNotebook {
1242 unsafe {
1243 let f: &F = &*(f as *const F);
1244 f(&from_glib_borrow(this), &from_glib_borrow(page)) /*Not checked*/
1245 .to_glib_none()
1246 .0
1247 }
1248 }
1249 unsafe {
1250 let f: Box_<F> = Box_::new(f);
1251 connect_raw(
1252 self.as_ptr() as *mut _,
1253 c"create-window".as_ptr(),
1254 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1255 create_window_trampoline::<F> as *const (),
1256 )),
1257 Box_::into_raw(f),
1258 )
1259 }
1260 }
1261
1262 /// Emitted when a tab should be focused.
1263 /// ## `tab`
1264 /// the notebook tab
1265 ///
1266 /// # Returns
1267 ///
1268 /// whether the tab has been focused
1269 #[doc(alias = "focus-tab")]
1270 pub fn connect_focus_tab<F: Fn(&Self, NotebookTab) -> bool + 'static>(
1271 &self,
1272 f: F,
1273 ) -> SignalHandlerId {
1274 unsafe extern "C" fn focus_tab_trampoline<
1275 F: Fn(&Notebook, NotebookTab) -> bool + 'static,
1276 >(
1277 this: *mut ffi::GtkNotebook,
1278 tab: ffi::GtkNotebookTab,
1279 f: glib::ffi::gpointer,
1280 ) -> glib::ffi::gboolean {
1281 unsafe {
1282 let f: &F = &*(f as *const F);
1283 f(&from_glib_borrow(this), from_glib(tab)).into_glib()
1284 }
1285 }
1286 unsafe {
1287 let f: Box_<F> = Box_::new(f);
1288 connect_raw(
1289 self.as_ptr() as *mut _,
1290 c"focus-tab".as_ptr(),
1291 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1292 focus_tab_trampoline::<F> as *const (),
1293 )),
1294 Box_::into_raw(f),
1295 )
1296 }
1297 }
1298
1299 pub fn emit_focus_tab(&self, tab: NotebookTab) -> bool {
1300 self.emit_by_name("focus-tab", &[&tab])
1301 }
1302
1303 /// .
1304 /// ## `direction`
1305 /// the direction to move the focus
1306 #[doc(alias = "move-focus-out")]
1307 pub fn connect_move_focus_out<F: Fn(&Self, DirectionType) + 'static>(
1308 &self,
1309 f: F,
1310 ) -> SignalHandlerId {
1311 unsafe extern "C" fn move_focus_out_trampoline<
1312 F: Fn(&Notebook, DirectionType) + 'static,
1313 >(
1314 this: *mut ffi::GtkNotebook,
1315 direction: ffi::GtkDirectionType,
1316 f: glib::ffi::gpointer,
1317 ) {
1318 unsafe {
1319 let f: &F = &*(f as *const F);
1320 f(&from_glib_borrow(this), from_glib(direction))
1321 }
1322 }
1323 unsafe {
1324 let f: Box_<F> = Box_::new(f);
1325 connect_raw(
1326 self.as_ptr() as *mut _,
1327 c"move-focus-out".as_ptr(),
1328 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1329 move_focus_out_trampoline::<F> as *const (),
1330 )),
1331 Box_::into_raw(f),
1332 )
1333 }
1334 }
1335
1336 pub fn emit_move_focus_out(&self, direction: DirectionType) {
1337 self.emit_by_name::<()>("move-focus-out", &[&direction]);
1338 }
1339
1340 /// the ::page-added signal is emitted in the notebook
1341 /// right after a page is added to the notebook.
1342 /// ## `child`
1343 /// the child [`Widget`][crate::Widget] affected
1344 /// ## `page_num`
1345 /// the new page number for @child
1346 #[doc(alias = "page-added")]
1347 pub fn connect_page_added<F: Fn(&Self, &Widget, u32) + 'static>(
1348 &self,
1349 f: F,
1350 ) -> SignalHandlerId {
1351 unsafe extern "C" fn page_added_trampoline<F: Fn(&Notebook, &Widget, u32) + 'static>(
1352 this: *mut ffi::GtkNotebook,
1353 child: *mut ffi::GtkWidget,
1354 page_num: std::ffi::c_uint,
1355 f: glib::ffi::gpointer,
1356 ) {
1357 unsafe {
1358 let f: &F = &*(f as *const F);
1359 f(&from_glib_borrow(this), &from_glib_borrow(child), page_num)
1360 }
1361 }
1362 unsafe {
1363 let f: Box_<F> = Box_::new(f);
1364 connect_raw(
1365 self.as_ptr() as *mut _,
1366 c"page-added".as_ptr(),
1367 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1368 page_added_trampoline::<F> as *const (),
1369 )),
1370 Box_::into_raw(f),
1371 )
1372 }
1373 }
1374
1375 /// the ::page-removed signal is emitted in the notebook
1376 /// right after a page is removed from the notebook.
1377 /// ## `child`
1378 /// the child [`Widget`][crate::Widget] affected
1379 /// ## `page_num`
1380 /// the @child page number
1381 #[doc(alias = "page-removed")]
1382 pub fn connect_page_removed<F: Fn(&Self, &Widget, u32) + 'static>(
1383 &self,
1384 f: F,
1385 ) -> SignalHandlerId {
1386 unsafe extern "C" fn page_removed_trampoline<F: Fn(&Notebook, &Widget, u32) + 'static>(
1387 this: *mut ffi::GtkNotebook,
1388 child: *mut ffi::GtkWidget,
1389 page_num: std::ffi::c_uint,
1390 f: glib::ffi::gpointer,
1391 ) {
1392 unsafe {
1393 let f: &F = &*(f as *const F);
1394 f(&from_glib_borrow(this), &from_glib_borrow(child), page_num)
1395 }
1396 }
1397 unsafe {
1398 let f: Box_<F> = Box_::new(f);
1399 connect_raw(
1400 self.as_ptr() as *mut _,
1401 c"page-removed".as_ptr(),
1402 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1403 page_removed_trampoline::<F> as *const (),
1404 )),
1405 Box_::into_raw(f),
1406 )
1407 }
1408 }
1409
1410 /// the ::page-reordered signal is emitted in the notebook
1411 /// right after a page has been reordered.
1412 /// ## `child`
1413 /// the child [`Widget`][crate::Widget] affected
1414 /// ## `page_num`
1415 /// the new page number for @child
1416 #[doc(alias = "page-reordered")]
1417 pub fn connect_page_reordered<F: Fn(&Self, &Widget, u32) + 'static>(
1418 &self,
1419 f: F,
1420 ) -> SignalHandlerId {
1421 unsafe extern "C" fn page_reordered_trampoline<F: Fn(&Notebook, &Widget, u32) + 'static>(
1422 this: *mut ffi::GtkNotebook,
1423 child: *mut ffi::GtkWidget,
1424 page_num: std::ffi::c_uint,
1425 f: glib::ffi::gpointer,
1426 ) {
1427 unsafe {
1428 let f: &F = &*(f as *const F);
1429 f(&from_glib_borrow(this), &from_glib_borrow(child), page_num)
1430 }
1431 }
1432 unsafe {
1433 let f: Box_<F> = Box_::new(f);
1434 connect_raw(
1435 self.as_ptr() as *mut _,
1436 c"page-reordered".as_ptr(),
1437 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1438 page_reordered_trampoline::<F> as *const (),
1439 )),
1440 Box_::into_raw(f),
1441 )
1442 }
1443 }
1444
1445 /// .
1446 /// ## `direction`
1447 /// the direction to move the tab
1448 /// ## `move_to_last`
1449 /// whether to move to the last position
1450 ///
1451 /// # Returns
1452 ///
1453 /// whether the tab was moved.
1454 #[doc(alias = "reorder-tab")]
1455 pub fn connect_reorder_tab<F: Fn(&Self, DirectionType, bool) -> bool + 'static>(
1456 &self,
1457 f: F,
1458 ) -> SignalHandlerId {
1459 unsafe extern "C" fn reorder_tab_trampoline<
1460 F: Fn(&Notebook, DirectionType, bool) -> bool + 'static,
1461 >(
1462 this: *mut ffi::GtkNotebook,
1463 direction: ffi::GtkDirectionType,
1464 move_to_last: glib::ffi::gboolean,
1465 f: glib::ffi::gpointer,
1466 ) -> glib::ffi::gboolean {
1467 unsafe {
1468 let f: &F = &*(f as *const F);
1469 f(
1470 &from_glib_borrow(this),
1471 from_glib(direction),
1472 from_glib(move_to_last),
1473 )
1474 .into_glib()
1475 }
1476 }
1477 unsafe {
1478 let f: Box_<F> = Box_::new(f);
1479 connect_raw(
1480 self.as_ptr() as *mut _,
1481 c"reorder-tab".as_ptr(),
1482 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1483 reorder_tab_trampoline::<F> as *const (),
1484 )),
1485 Box_::into_raw(f),
1486 )
1487 }
1488 }
1489
1490 pub fn emit_reorder_tab(&self, direction: DirectionType, move_to_last: bool) -> bool {
1491 self.emit_by_name("reorder-tab", &[&direction, &move_to_last])
1492 }
1493
1494 /// .
1495 /// ## `move_focus`
1496 /// whether to move focus
1497 ///
1498 /// # Returns
1499 ///
1500 /// whether the page was selected
1501 #[doc(alias = "select-page")]
1502 pub fn connect_select_page<F: Fn(&Self, bool) -> bool + 'static>(
1503 &self,
1504 f: F,
1505 ) -> SignalHandlerId {
1506 unsafe extern "C" fn select_page_trampoline<F: Fn(&Notebook, bool) -> bool + 'static>(
1507 this: *mut ffi::GtkNotebook,
1508 move_focus: glib::ffi::gboolean,
1509 f: glib::ffi::gpointer,
1510 ) -> glib::ffi::gboolean {
1511 unsafe {
1512 let f: &F = &*(f as *const F);
1513 f(&from_glib_borrow(this), from_glib(move_focus)).into_glib()
1514 }
1515 }
1516 unsafe {
1517 let f: Box_<F> = Box_::new(f);
1518 connect_raw(
1519 self.as_ptr() as *mut _,
1520 c"select-page".as_ptr(),
1521 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1522 select_page_trampoline::<F> as *const (),
1523 )),
1524 Box_::into_raw(f),
1525 )
1526 }
1527 }
1528
1529 pub fn emit_select_page(&self, move_focus: bool) -> bool {
1530 self.emit_by_name("select-page", &[&move_focus])
1531 }
1532
1533 /// Emitted when the user or a function changes the current page.
1534 /// ## `page`
1535 /// the new current page
1536 /// ## `page_num`
1537 /// the index of the page
1538 #[doc(alias = "switch-page")]
1539 pub fn connect_switch_page<F: Fn(&Self, &Widget, u32) + 'static>(
1540 &self,
1541 f: F,
1542 ) -> SignalHandlerId {
1543 unsafe extern "C" fn switch_page_trampoline<F: Fn(&Notebook, &Widget, u32) + 'static>(
1544 this: *mut ffi::GtkNotebook,
1545 page: *mut ffi::GtkWidget,
1546 page_num: std::ffi::c_uint,
1547 f: glib::ffi::gpointer,
1548 ) {
1549 unsafe {
1550 let f: &F = &*(f as *const F);
1551 f(&from_glib_borrow(this), &from_glib_borrow(page), page_num)
1552 }
1553 }
1554 unsafe {
1555 let f: Box_<F> = Box_::new(f);
1556 connect_raw(
1557 self.as_ptr() as *mut _,
1558 c"switch-page".as_ptr(),
1559 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1560 switch_page_trampoline::<F> as *const (),
1561 )),
1562 Box_::into_raw(f),
1563 )
1564 }
1565 }
1566
1567 #[doc(alias = "enable-popup")]
1568 pub fn connect_enable_popup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1569 unsafe extern "C" fn notify_enable_popup_trampoline<F: Fn(&Notebook) + 'static>(
1570 this: *mut ffi::GtkNotebook,
1571 _param_spec: glib::ffi::gpointer,
1572 f: glib::ffi::gpointer,
1573 ) {
1574 unsafe {
1575 let f: &F = &*(f as *const F);
1576 f(&from_glib_borrow(this))
1577 }
1578 }
1579 unsafe {
1580 let f: Box_<F> = Box_::new(f);
1581 connect_raw(
1582 self.as_ptr() as *mut _,
1583 c"notify::enable-popup".as_ptr(),
1584 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1585 notify_enable_popup_trampoline::<F> as *const (),
1586 )),
1587 Box_::into_raw(f),
1588 )
1589 }
1590 }
1591
1592 #[doc(alias = "group-name")]
1593 pub fn connect_group_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1594 unsafe extern "C" fn notify_group_name_trampoline<F: Fn(&Notebook) + 'static>(
1595 this: *mut ffi::GtkNotebook,
1596 _param_spec: glib::ffi::gpointer,
1597 f: glib::ffi::gpointer,
1598 ) {
1599 unsafe {
1600 let f: &F = &*(f as *const F);
1601 f(&from_glib_borrow(this))
1602 }
1603 }
1604 unsafe {
1605 let f: Box_<F> = Box_::new(f);
1606 connect_raw(
1607 self.as_ptr() as *mut _,
1608 c"notify::group-name".as_ptr(),
1609 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1610 notify_group_name_trampoline::<F> as *const (),
1611 )),
1612 Box_::into_raw(f),
1613 )
1614 }
1615 }
1616
1617 #[doc(alias = "page")]
1618 pub fn connect_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1619 unsafe extern "C" fn notify_page_trampoline<F: Fn(&Notebook) + 'static>(
1620 this: *mut ffi::GtkNotebook,
1621 _param_spec: glib::ffi::gpointer,
1622 f: glib::ffi::gpointer,
1623 ) {
1624 unsafe {
1625 let f: &F = &*(f as *const F);
1626 f(&from_glib_borrow(this))
1627 }
1628 }
1629 unsafe {
1630 let f: Box_<F> = Box_::new(f);
1631 connect_raw(
1632 self.as_ptr() as *mut _,
1633 c"notify::page".as_ptr(),
1634 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1635 notify_page_trampoline::<F> as *const (),
1636 )),
1637 Box_::into_raw(f),
1638 )
1639 }
1640 }
1641
1642 #[doc(alias = "pages")]
1643 pub fn connect_pages_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1644 unsafe extern "C" fn notify_pages_trampoline<F: Fn(&Notebook) + 'static>(
1645 this: *mut ffi::GtkNotebook,
1646 _param_spec: glib::ffi::gpointer,
1647 f: glib::ffi::gpointer,
1648 ) {
1649 unsafe {
1650 let f: &F = &*(f as *const F);
1651 f(&from_glib_borrow(this))
1652 }
1653 }
1654 unsafe {
1655 let f: Box_<F> = Box_::new(f);
1656 connect_raw(
1657 self.as_ptr() as *mut _,
1658 c"notify::pages".as_ptr(),
1659 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1660 notify_pages_trampoline::<F> as *const (),
1661 )),
1662 Box_::into_raw(f),
1663 )
1664 }
1665 }
1666
1667 #[doc(alias = "scrollable")]
1668 pub fn connect_scrollable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1669 unsafe extern "C" fn notify_scrollable_trampoline<F: Fn(&Notebook) + 'static>(
1670 this: *mut ffi::GtkNotebook,
1671 _param_spec: glib::ffi::gpointer,
1672 f: glib::ffi::gpointer,
1673 ) {
1674 unsafe {
1675 let f: &F = &*(f as *const F);
1676 f(&from_glib_borrow(this))
1677 }
1678 }
1679 unsafe {
1680 let f: Box_<F> = Box_::new(f);
1681 connect_raw(
1682 self.as_ptr() as *mut _,
1683 c"notify::scrollable".as_ptr(),
1684 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1685 notify_scrollable_trampoline::<F> as *const (),
1686 )),
1687 Box_::into_raw(f),
1688 )
1689 }
1690 }
1691
1692 #[doc(alias = "show-border")]
1693 pub fn connect_show_border_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1694 unsafe extern "C" fn notify_show_border_trampoline<F: Fn(&Notebook) + 'static>(
1695 this: *mut ffi::GtkNotebook,
1696 _param_spec: glib::ffi::gpointer,
1697 f: glib::ffi::gpointer,
1698 ) {
1699 unsafe {
1700 let f: &F = &*(f as *const F);
1701 f(&from_glib_borrow(this))
1702 }
1703 }
1704 unsafe {
1705 let f: Box_<F> = Box_::new(f);
1706 connect_raw(
1707 self.as_ptr() as *mut _,
1708 c"notify::show-border".as_ptr(),
1709 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1710 notify_show_border_trampoline::<F> as *const (),
1711 )),
1712 Box_::into_raw(f),
1713 )
1714 }
1715 }
1716
1717 #[doc(alias = "show-tabs")]
1718 pub fn connect_show_tabs_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1719 unsafe extern "C" fn notify_show_tabs_trampoline<F: Fn(&Notebook) + 'static>(
1720 this: *mut ffi::GtkNotebook,
1721 _param_spec: glib::ffi::gpointer,
1722 f: glib::ffi::gpointer,
1723 ) {
1724 unsafe {
1725 let f: &F = &*(f as *const F);
1726 f(&from_glib_borrow(this))
1727 }
1728 }
1729 unsafe {
1730 let f: Box_<F> = Box_::new(f);
1731 connect_raw(
1732 self.as_ptr() as *mut _,
1733 c"notify::show-tabs".as_ptr(),
1734 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1735 notify_show_tabs_trampoline::<F> as *const (),
1736 )),
1737 Box_::into_raw(f),
1738 )
1739 }
1740 }
1741
1742 #[doc(alias = "tab-pos")]
1743 pub fn connect_tab_pos_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1744 unsafe extern "C" fn notify_tab_pos_trampoline<F: Fn(&Notebook) + 'static>(
1745 this: *mut ffi::GtkNotebook,
1746 _param_spec: glib::ffi::gpointer,
1747 f: glib::ffi::gpointer,
1748 ) {
1749 unsafe {
1750 let f: &F = &*(f as *const F);
1751 f(&from_glib_borrow(this))
1752 }
1753 }
1754 unsafe {
1755 let f: Box_<F> = Box_::new(f);
1756 connect_raw(
1757 self.as_ptr() as *mut _,
1758 c"notify::tab-pos".as_ptr(),
1759 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1760 notify_tab_pos_trampoline::<F> as *const (),
1761 )),
1762 Box_::into_raw(f),
1763 )
1764 }
1765 }
1766}
1767
1768impl Default for Notebook {
1769 fn default() -> Self {
1770 Self::new()
1771 }
1772}
1773
1774// rustdoc-stripper-ignore-next
1775/// A [builder-pattern] type to construct [`Notebook`] objects.
1776///
1777/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1778#[must_use = "The builder must be built to be used"]
1779pub struct NotebookBuilder {
1780 builder: glib::object::ObjectBuilder<'static, Notebook>,
1781}
1782
1783impl NotebookBuilder {
1784 fn new() -> Self {
1785 Self {
1786 builder: glib::object::Object::builder(),
1787 }
1788 }
1789
1790 /// If [`true`], pressing the right mouse button on the notebook shows a page switching menu.
1791 pub fn enable_popup(self, enable_popup: bool) -> Self {
1792 Self {
1793 builder: self.builder.property("enable-popup", enable_popup),
1794 }
1795 }
1796
1797 /// Group name for tab drag and drop.
1798 pub fn group_name(self, group_name: impl Into<glib::GString>) -> Self {
1799 Self {
1800 builder: self.builder.property("group-name", group_name.into()),
1801 }
1802 }
1803
1804 /// The index of the current page.
1805 pub fn page(self, page: i32) -> Self {
1806 Self {
1807 builder: self.builder.property("page", page),
1808 }
1809 }
1810
1811 /// If [`true`], scroll arrows are added if there are too many pages to fit.
1812 pub fn scrollable(self, scrollable: bool) -> Self {
1813 Self {
1814 builder: self.builder.property("scrollable", scrollable),
1815 }
1816 }
1817
1818 /// Whether the border should be shown.
1819 pub fn show_border(self, show_border: bool) -> Self {
1820 Self {
1821 builder: self.builder.property("show-border", show_border),
1822 }
1823 }
1824
1825 /// Whether tabs should be shown.
1826 pub fn show_tabs(self, show_tabs: bool) -> Self {
1827 Self {
1828 builder: self.builder.property("show-tabs", show_tabs),
1829 }
1830 }
1831
1832 /// Which side of the notebook holds the tabs.
1833 pub fn tab_pos(self, tab_pos: PositionType) -> Self {
1834 Self {
1835 builder: self.builder.property("tab-pos", tab_pos),
1836 }
1837 }
1838
1839 /// Whether the widget or any of its descendents can accept
1840 /// the input focus.
1841 ///
1842 /// This property is meant to be set by widget implementations,
1843 /// typically in their instance init function.
1844 pub fn can_focus(self, can_focus: bool) -> Self {
1845 Self {
1846 builder: self.builder.property("can-focus", can_focus),
1847 }
1848 }
1849
1850 /// Whether the widget can receive pointer events.
1851 pub fn can_target(self, can_target: bool) -> Self {
1852 Self {
1853 builder: self.builder.property("can-target", can_target),
1854 }
1855 }
1856
1857 /// A list of css classes applied to this widget.
1858 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1859 Self {
1860 builder: self.builder.property("css-classes", css_classes.into()),
1861 }
1862 }
1863
1864 /// The name of this widget in the CSS tree.
1865 ///
1866 /// This property is meant to be set by widget implementations,
1867 /// typically in their instance init function.
1868 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1869 Self {
1870 builder: self.builder.property("css-name", css_name.into()),
1871 }
1872 }
1873
1874 /// The cursor used by @widget.
1875 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1876 Self {
1877 builder: self.builder.property("cursor", cursor.clone()),
1878 }
1879 }
1880
1881 /// Whether the widget should grab focus when it is clicked with the mouse.
1882 ///
1883 /// This property is only relevant for widgets that can take focus.
1884 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1885 Self {
1886 builder: self.builder.property("focus-on-click", focus_on_click),
1887 }
1888 }
1889
1890 /// Whether this widget itself will accept the input focus.
1891 pub fn focusable(self, focusable: bool) -> Self {
1892 Self {
1893 builder: self.builder.property("focusable", focusable),
1894 }
1895 }
1896
1897 /// How to distribute horizontal space if widget gets extra space.
1898 pub fn halign(self, halign: Align) -> Self {
1899 Self {
1900 builder: self.builder.property("halign", halign),
1901 }
1902 }
1903
1904 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1905 /// signal on @widget.
1906 ///
1907 /// A true value indicates that @widget can have a tooltip, in this case
1908 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1909 /// determine whether it will provide a tooltip or not.
1910 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1911 Self {
1912 builder: self.builder.property("has-tooltip", has_tooltip),
1913 }
1914 }
1915
1916 /// Overrides for height request of the widget.
1917 ///
1918 /// If this is -1, the natural request will be used.
1919 pub fn height_request(self, height_request: i32) -> Self {
1920 Self {
1921 builder: self.builder.property("height-request", height_request),
1922 }
1923 }
1924
1925 /// Whether to expand horizontally.
1926 pub fn hexpand(self, hexpand: bool) -> Self {
1927 Self {
1928 builder: self.builder.property("hexpand", hexpand),
1929 }
1930 }
1931
1932 /// Whether to use the `hexpand` property.
1933 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1934 Self {
1935 builder: self.builder.property("hexpand-set", hexpand_set),
1936 }
1937 }
1938
1939 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1940 /// the preferred size of the widget, and allocate its children.
1941 ///
1942 /// This property is meant to be set by widget implementations,
1943 /// typically in their instance init function.
1944 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1945 Self {
1946 builder: self
1947 .builder
1948 .property("layout-manager", layout_manager.clone().upcast()),
1949 }
1950 }
1951
1952 /// Makes this widget act like a modal dialog, with respect to
1953 /// event delivery.
1954 ///
1955 /// Global event controllers will not handle events with targets
1956 /// inside the widget, unless they are set up to ignore propagation
1957 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1958 #[cfg(feature = "v4_18")]
1959 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1960 pub fn limit_events(self, limit_events: bool) -> Self {
1961 Self {
1962 builder: self.builder.property("limit-events", limit_events),
1963 }
1964 }
1965
1966 /// Margin on bottom side of widget.
1967 ///
1968 /// This property adds margin outside of the widget's normal size
1969 /// request, the margin will be added in addition to the size from
1970 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1971 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1972 Self {
1973 builder: self.builder.property("margin-bottom", margin_bottom),
1974 }
1975 }
1976
1977 /// Margin on end of widget, horizontally.
1978 ///
1979 /// This property supports left-to-right and right-to-left text
1980 /// directions.
1981 ///
1982 /// This property adds margin outside of the widget's normal size
1983 /// request, the margin will be added in addition to the size from
1984 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1985 pub fn margin_end(self, margin_end: i32) -> Self {
1986 Self {
1987 builder: self.builder.property("margin-end", margin_end),
1988 }
1989 }
1990
1991 /// Margin on start of widget, horizontally.
1992 ///
1993 /// This property supports left-to-right and right-to-left text
1994 /// directions.
1995 ///
1996 /// This property adds margin outside of the widget's normal size
1997 /// request, the margin will be added in addition to the size from
1998 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1999 pub fn margin_start(self, margin_start: i32) -> Self {
2000 Self {
2001 builder: self.builder.property("margin-start", margin_start),
2002 }
2003 }
2004
2005 /// Margin on top side of widget.
2006 ///
2007 /// This property adds margin outside of the widget's normal size
2008 /// request, the margin will be added in addition to the size from
2009 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2010 pub fn margin_top(self, margin_top: i32) -> Self {
2011 Self {
2012 builder: self.builder.property("margin-top", margin_top),
2013 }
2014 }
2015
2016 /// The name of the widget.
2017 pub fn name(self, name: impl Into<glib::GString>) -> Self {
2018 Self {
2019 builder: self.builder.property("name", name.into()),
2020 }
2021 }
2022
2023 /// The requested opacity of the widget.
2024 pub fn opacity(self, opacity: f64) -> Self {
2025 Self {
2026 builder: self.builder.property("opacity", opacity),
2027 }
2028 }
2029
2030 /// How content outside the widget's content area is treated.
2031 ///
2032 /// This property is meant to be set by widget implementations,
2033 /// typically in their instance init function.
2034 pub fn overflow(self, overflow: Overflow) -> Self {
2035 Self {
2036 builder: self.builder.property("overflow", overflow),
2037 }
2038 }
2039
2040 /// Whether the widget will receive the default action when it is focused.
2041 pub fn receives_default(self, receives_default: bool) -> Self {
2042 Self {
2043 builder: self.builder.property("receives-default", receives_default),
2044 }
2045 }
2046
2047 /// Whether the widget responds to input.
2048 pub fn sensitive(self, sensitive: bool) -> Self {
2049 Self {
2050 builder: self.builder.property("sensitive", sensitive),
2051 }
2052 }
2053
2054 /// Sets the text of tooltip to be the given string, which is marked up
2055 /// with Pango markup.
2056 ///
2057 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
2058 ///
2059 /// This is a convenience property which will take care of getting the
2060 /// tooltip shown if the given string is not `NULL`:
2061 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2062 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2063 /// the default signal handler.
2064 ///
2065 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2066 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2067 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
2068 Self {
2069 builder: self
2070 .builder
2071 .property("tooltip-markup", tooltip_markup.into()),
2072 }
2073 }
2074
2075 /// Sets the text of tooltip to be the given string.
2076 ///
2077 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
2078 ///
2079 /// This is a convenience property which will take care of getting the
2080 /// tooltip shown if the given string is not `NULL`:
2081 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2082 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2083 /// the default signal handler.
2084 ///
2085 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2086 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2087 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
2088 Self {
2089 builder: self.builder.property("tooltip-text", tooltip_text.into()),
2090 }
2091 }
2092
2093 /// How to distribute vertical space if widget gets extra space.
2094 pub fn valign(self, valign: Align) -> Self {
2095 Self {
2096 builder: self.builder.property("valign", valign),
2097 }
2098 }
2099
2100 /// Whether to expand vertically.
2101 pub fn vexpand(self, vexpand: bool) -> Self {
2102 Self {
2103 builder: self.builder.property("vexpand", vexpand),
2104 }
2105 }
2106
2107 /// Whether to use the `vexpand` property.
2108 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
2109 Self {
2110 builder: self.builder.property("vexpand-set", vexpand_set),
2111 }
2112 }
2113
2114 /// Whether the widget is visible.
2115 pub fn visible(self, visible: bool) -> Self {
2116 Self {
2117 builder: self.builder.property("visible", visible),
2118 }
2119 }
2120
2121 /// Overrides for width request of the widget.
2122 ///
2123 /// If this is -1, the natural request will be used.
2124 pub fn width_request(self, width_request: i32) -> Self {
2125 Self {
2126 builder: self.builder.property("width-request", width_request),
2127 }
2128 }
2129
2130 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
2131 ///
2132 /// The accessible role cannot be changed once set.
2133 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
2134 Self {
2135 builder: self.builder.property("accessible-role", accessible_role),
2136 }
2137 }
2138
2139 // rustdoc-stripper-ignore-next
2140 /// Build the [`Notebook`].
2141 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
2142 pub fn build(self) -> Notebook {
2143 assert_initialized_main_thread!();
2144 self.builder.build()
2145 }
2146}