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