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