gtk/auto/container.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#![allow(deprecated)]
5
6use crate::{Adjustment, Buildable, ResizeMode, Widget, WidgetPath, ffi};
7use glib::{
8 object::ObjectType as _,
9 prelude::*,
10 signal::{SignalHandlerId, connect_raw},
11 translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16 ///
17 /// ]|
18 ///
19 /// This is an Abstract Base Class, you cannot instantiate it.
20 ///
21 /// ## Properties
22 ///
23 ///
24 /// #### `border-width`
25 /// Readable | Writable
26 ///
27 ///
28 /// #### `child`
29 /// Writable
30 ///
31 ///
32 /// #### `resize-mode`
33 /// Readable | Writable
34 /// <details><summary><h4>Widget</h4></summary>
35 ///
36 ///
37 /// #### `app-paintable`
38 /// Readable | Writable
39 ///
40 ///
41 /// #### `can-default`
42 /// Readable | Writable
43 ///
44 ///
45 /// #### `can-focus`
46 /// Readable | Writable
47 ///
48 ///
49 /// #### `composite-child`
50 /// Readable
51 ///
52 ///
53 /// #### `double-buffered`
54 /// Whether the widget is double buffered.
55 ///
56 /// Readable | Writable
57 ///
58 ///
59 /// #### `events`
60 /// Readable | Writable
61 ///
62 ///
63 /// #### `expand`
64 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
65 ///
66 /// Readable | Writable
67 ///
68 ///
69 /// #### `focus-on-click`
70 /// Whether the widget should grab focus when it is clicked with the mouse.
71 ///
72 /// This property is only relevant for widgets that can take focus.
73 ///
74 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
75 /// GtkComboBox) implemented this property individually.
76 ///
77 /// Readable | Writable
78 ///
79 ///
80 /// #### `halign`
81 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
82 ///
83 /// Readable | Writable
84 ///
85 ///
86 /// #### `has-default`
87 /// Readable | Writable
88 ///
89 ///
90 /// #### `has-focus`
91 /// Readable | Writable
92 ///
93 ///
94 /// #### `has-tooltip`
95 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
96 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
97 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
98 /// whether it will provide a tooltip or not.
99 ///
100 /// Note that setting this property to [`true`] for the first time will change
101 /// the event masks of the GdkWindows of this widget to include leave-notify
102 /// and motion-notify events. This cannot and will not be undone when the
103 /// property is set to [`false`] again.
104 ///
105 /// Readable | Writable
106 ///
107 ///
108 /// #### `height-request`
109 /// Readable | Writable
110 ///
111 ///
112 /// #### `hexpand`
113 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
114 ///
115 /// Readable | Writable
116 ///
117 ///
118 /// #### `hexpand-set`
119 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
120 ///
121 /// Readable | Writable
122 ///
123 ///
124 /// #### `is-focus`
125 /// Readable | Writable
126 ///
127 ///
128 /// #### `margin`
129 /// Sets all four sides' margin at once. If read, returns max
130 /// margin on any side.
131 ///
132 /// Readable | Writable
133 ///
134 ///
135 /// #### `margin-bottom`
136 /// Margin on bottom side of widget.
137 ///
138 /// This property adds margin outside of the widget's normal size
139 /// request, the margin will be added in addition to the size from
140 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
141 ///
142 /// Readable | Writable
143 ///
144 ///
145 /// #### `margin-end`
146 /// Margin on end of widget, horizontally. This property supports
147 /// left-to-right and right-to-left text directions.
148 ///
149 /// This property adds margin outside of the widget's normal size
150 /// request, the margin will be added in addition to the size from
151 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
152 ///
153 /// Readable | Writable
154 ///
155 ///
156 /// #### `margin-left`
157 /// Margin on left side of widget.
158 ///
159 /// This property adds margin outside of the widget's normal size
160 /// request, the margin will be added in addition to the size from
161 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
162 ///
163 /// Readable | Writable
164 ///
165 ///
166 /// #### `margin-right`
167 /// Margin on right side of widget.
168 ///
169 /// This property adds margin outside of the widget's normal size
170 /// request, the margin will be added in addition to the size from
171 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
172 ///
173 /// Readable | Writable
174 ///
175 ///
176 /// #### `margin-start`
177 /// Margin on start of widget, horizontally. This property supports
178 /// left-to-right and right-to-left text directions.
179 ///
180 /// This property adds margin outside of the widget's normal size
181 /// request, the margin will be added in addition to the size from
182 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
183 ///
184 /// Readable | Writable
185 ///
186 ///
187 /// #### `margin-top`
188 /// Margin on top side of widget.
189 ///
190 /// This property adds margin outside of the widget's normal size
191 /// request, the margin will be added in addition to the size from
192 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
193 ///
194 /// Readable | Writable
195 ///
196 ///
197 /// #### `name`
198 /// Readable | Writable
199 ///
200 ///
201 /// #### `no-show-all`
202 /// Readable | Writable
203 ///
204 ///
205 /// #### `opacity`
206 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
207 /// more details about window opacity.
208 ///
209 /// Before 3.8 this was only available in GtkWindow
210 ///
211 /// Readable | Writable
212 ///
213 ///
214 /// #### `parent`
215 /// Readable | Writable
216 ///
217 ///
218 /// #### `receives-default`
219 /// Readable | Writable
220 ///
221 ///
222 /// #### `scale-factor`
223 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
224 /// more details about widget scaling.
225 ///
226 /// Readable
227 ///
228 ///
229 /// #### `sensitive`
230 /// Readable | Writable
231 ///
232 ///
233 /// #### `style`
234 /// The style of the widget, which contains information about how it will look (colors, etc).
235 ///
236 /// Readable | Writable
237 ///
238 ///
239 /// #### `tooltip-markup`
240 /// Sets the text of tooltip to be the given string, which is marked up
241 /// with the [Pango text markup language][PangoMarkupFormat].
242 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
243 ///
244 /// This is a convenience property which will take care of getting the
245 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
246 /// will automatically be set to [`true`] and there will be taken care of
247 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
248 ///
249 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
250 /// are set, the last one wins.
251 ///
252 /// Readable | Writable
253 ///
254 ///
255 /// #### `tooltip-text`
256 /// Sets the text of tooltip to be the given string.
257 ///
258 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
259 ///
260 /// This is a convenience property which will take care of getting the
261 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
262 /// will automatically be set to [`true`] and there will be taken care of
263 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
264 ///
265 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
266 /// are set, the last one wins.
267 ///
268 /// Readable | Writable
269 ///
270 ///
271 /// #### `valign`
272 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
273 ///
274 /// Readable | Writable
275 ///
276 ///
277 /// #### `vexpand`
278 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
279 ///
280 /// Readable | Writable
281 ///
282 ///
283 /// #### `vexpand-set`
284 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
285 ///
286 /// Readable | Writable
287 ///
288 ///
289 /// #### `visible`
290 /// Readable | Writable
291 ///
292 ///
293 /// #### `width-request`
294 /// Readable | Writable
295 ///
296 ///
297 /// #### `window`
298 /// The widget's window if it is realized, [`None`] otherwise.
299 ///
300 /// Readable
301 /// </details>
302 ///
303 /// ## Signals
304 ///
305 ///
306 /// #### `add`
307 ///
308 ///
309 ///
310 /// #### `check-resize`
311 ///
312 ///
313 ///
314 /// #### `remove`
315 ///
316 ///
317 ///
318 /// #### `set-focus-child`
319 ///
320 /// <details><summary><h4>Widget</h4></summary>
321 ///
322 ///
323 /// #### `accel-closures-changed`
324 ///
325 ///
326 ///
327 /// #### `button-press-event`
328 /// The ::button-press-event signal will be emitted when a button
329 /// (typically from a mouse) is pressed.
330 ///
331 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
332 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
333 ///
334 /// This signal will be sent to the grab widget if there is one.
335 ///
336 ///
337 ///
338 ///
339 /// #### `button-release-event`
340 /// The ::button-release-event signal will be emitted when a button
341 /// (typically from a mouse) is released.
342 ///
343 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
344 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
345 ///
346 /// This signal will be sent to the grab widget if there is one.
347 ///
348 ///
349 ///
350 ///
351 /// #### `can-activate-accel`
352 /// Determines whether an accelerator that activates the signal
353 /// identified by `signal_id` can currently be activated.
354 /// This signal is present to allow applications and derived
355 /// widgets to override the default [`Widget`][crate::Widget] handling
356 /// for determining whether an accelerator can be activated.
357 ///
358 ///
359 ///
360 ///
361 /// #### `child-notify`
362 /// The ::child-notify signal is emitted for each
363 /// [child property][child-properties] that has
364 /// changed on an object. The signal's detail holds the property name.
365 ///
366 /// Detailed
367 ///
368 ///
369 /// #### `composited-changed`
370 /// The ::composited-changed signal is emitted when the composited
371 /// status of `widgets` screen changes.
372 /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
373 ///
374 /// Action
375 ///
376 ///
377 /// #### `configure-event`
378 /// The ::configure-event signal will be emitted when the size, position or
379 /// stacking of the `widget`'s window has changed.
380 ///
381 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
382 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
383 /// automatically for all new windows.
384 ///
385 ///
386 ///
387 ///
388 /// #### `damage-event`
389 /// Emitted when a redirected window belonging to `widget` gets drawn into.
390 /// The region/area members of the event shows what area of the redirected
391 /// drawable was drawn into.
392 ///
393 ///
394 ///
395 ///
396 /// #### `delete-event`
397 /// The ::delete-event signal is emitted if a user requests that
398 /// a toplevel window is closed. The default handler for this signal
399 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
400 /// this signal will cause the window to be hidden instead, so that
401 /// it can later be shown again without reconstructing it.
402 ///
403 ///
404 ///
405 ///
406 /// #### `destroy`
407 /// Signals that all holders of a reference to the widget should release
408 /// the reference that they hold. May result in finalization of the widget
409 /// if all references are released.
410 ///
411 /// This signal is not suitable for saving widget state.
412 ///
413 ///
414 ///
415 ///
416 /// #### `destroy-event`
417 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
418 /// You rarely get this signal, because most widgets disconnect themselves
419 /// from their window before they destroy it, so no widget owns the
420 /// window at destroy time.
421 ///
422 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
423 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
424 /// automatically for all new windows.
425 ///
426 ///
427 ///
428 ///
429 /// #### `direction-changed`
430 /// The ::direction-changed signal is emitted when the text direction
431 /// of a widget changes.
432 ///
433 ///
434 ///
435 ///
436 /// #### `drag-begin`
437 /// The ::drag-begin signal is emitted on the drag source when a drag is
438 /// started. A typical reason to connect to this signal is to set up a
439 /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
440 ///
441 /// Note that some widgets set up a drag icon in the default handler of
442 /// this signal, so you may have to use `g_signal_connect_after()` to
443 /// override what the default handler did.
444 ///
445 ///
446 ///
447 ///
448 /// #### `drag-data-delete`
449 /// The ::drag-data-delete signal is emitted on the drag source when a drag
450 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
451 /// handler is responsible for deleting the data that has been dropped. What
452 /// "delete" means depends on the context of the drag operation.
453 ///
454 ///
455 ///
456 ///
457 /// #### `drag-data-get`
458 /// The ::drag-data-get signal is emitted on the drag source when the drop
459 /// site requests the data which is dragged. It is the responsibility of
460 /// the signal handler to fill `data` with the data in the format which
461 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
462 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
463 ///
464 ///
465 ///
466 ///
467 /// #### `drag-data-received`
468 /// format == 8))
469 /// {
470 /// GdkDragAction action;
471 ///
472 /// // handle data here
473 ///
474 /// action = gdk_drag_context_get_selected_action (context);
475 /// if (action == GDK_ACTION_ASK)
476 /// {
477 /// GtkWidget *dialog;
478 /// gint response;
479 ///
480 /// dialog = gtk_message_dialog_new (NULL,
481 /// GTK_DIALOG_MODAL |
482 /// GTK_DIALOG_DESTROY_WITH_PARENT,
483 /// GTK_MESSAGE_INFO,
484 /// GTK_BUTTONS_YES_NO,
485 /// "Move the data ?\n");
486 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
487 /// gtk_widget_destroy (dialog);
488 ///
489 /// if (response == GTK_RESPONSE_YES)
490 /// action = GDK_ACTION_MOVE;
491 /// else
492 /// action = GDK_ACTION_COPY;
493 /// }
494 ///
495 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
496 /// }
497 /// else
498 /// gtk_drag_finish (context, FALSE, FALSE, time);
499 /// }
500 /// ]|
501 ///
502 ///
503 ///
504 ///
505 /// #### `drag-drop`
506 /// The ::drag-drop signal is emitted on the drop site when the user drops
507 /// the data onto the widget. The signal handler must determine whether
508 /// the cursor position is in a drop zone or not. If it is not in a drop
509 /// zone, it returns [`false`] and no further processing is necessary.
510 /// Otherwise, the handler returns [`true`]. In this case, the handler must
511 /// ensure that `gtk_drag_finish()` is called to let the source know that
512 /// the drop is done. The call to `gtk_drag_finish()` can be done either
513 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
514 /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
515 /// or more of the supported targets.
516 ///
517 ///
518 ///
519 ///
520 /// #### `drag-end`
521 /// The ::drag-end signal is emitted on the drag source when a drag is
522 /// finished. A typical reason to connect to this signal is to undo
523 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
524 ///
525 ///
526 ///
527 ///
528 /// #### `drag-failed`
529 /// The ::drag-failed signal is emitted on the drag source when a drag has
530 /// failed. The signal handler may hook custom code to handle a failed DnD
531 /// operation based on the type of error, it returns [`true`] is the failure has
532 /// been already handled (not showing the default "drag operation failed"
533 /// animation), otherwise it returns [`false`].
534 ///
535 ///
536 ///
537 ///
538 /// #### `drag-leave`
539 /// The ::drag-leave signal is emitted on the drop site when the cursor
540 /// leaves the widget. A typical reason to connect to this signal is to
541 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
542 /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
543 ///
544 ///
545 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
546 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
547 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
548 ///
549 ///
550 ///
551 ///
552 /// #### `drag-motion`
553 /// suggested_action,
554 /// time);
555 /// }
556 /// else
557 /// {
558 /// // accept the drop
559 /// }
560 /// }
561 /// ]|
562 ///
563 ///
564 ///
565 ///
566 /// #### `draw`
567 /// This signal is emitted when a widget is supposed to render itself.
568 /// The `widget`'s top left corner must be painted at the origin of
569 /// the passed in context and be sized to the values returned by
570 /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
571 /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
572 ///
573 /// Signal handlers connected to this signal can modify the cairo
574 /// context passed as `cr` in any way they like and don't need to
575 /// restore it. The signal emission takes care of calling `cairo_save()`
576 /// before and `cairo_restore()` after invoking the handler.
577 ///
578 /// The signal handler will get a `cr` with a clip region already set to the
579 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
580 /// widgets that want to avoid redrawing themselves completely can get the full
581 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
582 /// get a finer-grained representation of the dirty region with
583 /// `cairo_copy_clip_rectangle_list()`.
584 ///
585 ///
586 ///
587 ///
588 /// #### `enter-notify-event`
589 /// The ::enter-notify-event will be emitted when the pointer enters
590 /// the `widget`'s window.
591 ///
592 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
593 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
594 ///
595 /// This signal will be sent to the grab widget if there is one.
596 ///
597 ///
598 ///
599 ///
600 /// #### `event`
601 /// The GTK+ main loop will emit three signals for each GDK event delivered
602 /// to a widget: one generic ::event signal, another, more specific,
603 /// signal that matches the type of event delivered (e.g.
604 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
605 /// [`event-after`][struct@crate::Widget#event-after] signal.
606 ///
607 ///
608 ///
609 ///
610 /// #### `event-after`
611 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
612 /// the second more specific signal, ::event-after will be emitted
613 /// regardless of the previous two signals handlers return values.
614 ///
615 ///
616 ///
617 ///
618 /// #### `focus`
619 ///
620 ///
621 ///
622 /// #### `focus-in-event`
623 /// The ::focus-in-event signal will be emitted when the keyboard focus
624 /// enters the `widget`'s window.
625 ///
626 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
627 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
628 ///
629 ///
630 ///
631 ///
632 /// #### `focus-out-event`
633 /// The ::focus-out-event signal will be emitted when the keyboard focus
634 /// leaves the `widget`'s window.
635 ///
636 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
637 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
638 ///
639 ///
640 ///
641 ///
642 /// #### `grab-broken-event`
643 /// Emitted when a pointer or keyboard grab on a window belonging
644 /// to `widget` gets broken.
645 ///
646 /// On X11, this happens when the grab window becomes unviewable
647 /// (i.e. it or one of its ancestors is unmapped), or if the same
648 /// application grabs the pointer or keyboard again.
649 ///
650 ///
651 ///
652 ///
653 /// #### `grab-focus`
654 /// Action
655 ///
656 ///
657 /// #### `grab-notify`
658 /// The ::grab-notify signal is emitted when a widget becomes
659 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
660 /// another widget, or when it becomes unshadowed due to a grab
661 /// being removed.
662 ///
663 /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
664 /// grab widget in the grab stack of its window group is not
665 /// its ancestor.
666 ///
667 ///
668 ///
669 ///
670 /// #### `hide`
671 /// The ::hide signal is emitted when `widget` is hidden, for example with
672 /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
673 ///
674 ///
675 ///
676 ///
677 /// #### `hierarchy-changed`
678 /// The ::hierarchy-changed signal is emitted when the
679 /// anchored state of a widget changes. A widget is
680 /// “anchored” when its toplevel
681 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
682 /// a widget changes from un-anchored to anchored or vice-versa.
683 ///
684 ///
685 ///
686 ///
687 /// #### `key-press-event`
688 /// The ::key-press-event signal is emitted when a key is pressed. The signal
689 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
690 ///
691 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
692 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
693 ///
694 /// This signal will be sent to the grab widget if there is one.
695 ///
696 ///
697 ///
698 ///
699 /// #### `key-release-event`
700 /// The ::key-release-event signal is emitted when a key is released.
701 ///
702 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
703 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
704 ///
705 /// This signal will be sent to the grab widget if there is one.
706 ///
707 ///
708 ///
709 ///
710 /// #### `keynav-failed`
711 /// Gets emitted if keyboard navigation fails.
712 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
713 ///
714 ///
715 ///
716 ///
717 /// #### `leave-notify-event`
718 /// The ::leave-notify-event will be emitted when the pointer leaves
719 /// the `widget`'s window.
720 ///
721 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
722 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
723 ///
724 /// This signal will be sent to the grab widget if there is one.
725 ///
726 ///
727 ///
728 ///
729 /// #### `map`
730 /// The ::map signal is emitted when `widget` is going to be mapped, that is
731 /// when the widget is visible (which is controlled with
732 /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
733 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
734 /// be emitted.
735 ///
736 /// The ::map signal can be used to determine whether a widget will be drawn,
737 /// for instance it can resume an animation that was stopped during the
738 /// emission of [`unmap`][struct@crate::Widget#unmap].
739 ///
740 ///
741 ///
742 ///
743 /// #### `map-event`
744 /// The ::map-event signal will be emitted when the `widget`'s window is
745 /// mapped. A window is mapped when it becomes visible on the screen.
746 ///
747 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
748 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
749 /// automatically for all new windows.
750 ///
751 ///
752 ///
753 ///
754 /// #### `mnemonic-activate`
755 /// The default handler for this signal activates `widget` if `group_cycling`
756 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
757 ///
758 ///
759 ///
760 ///
761 /// #### `motion-notify-event`
762 /// The ::motion-notify-event signal is emitted when the pointer moves
763 /// over the widget's [`gdk::Window`][crate::gdk::Window].
764 ///
765 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
766 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
767 ///
768 /// This signal will be sent to the grab widget if there is one.
769 ///
770 ///
771 ///
772 ///
773 /// #### `move-focus`
774 /// Action
775 ///
776 ///
777 /// #### `parent-set`
778 /// The ::parent-set signal is emitted when a new parent
779 /// has been set on a widget.
780 ///
781 ///
782 ///
783 ///
784 /// #### `popup-menu`
785 /// This signal gets emitted whenever a widget should pop up a context
786 /// menu. This usually happens through the standard key binding mechanism;
787 /// by pressing a certain key while a widget is focused, the user can cause
788 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
789 /// a menu with clipboard commands. See the
790 /// [Popup Menu Migration Checklist][checklist-popup-menu]
791 /// for an example of how to use this signal.
792 ///
793 /// Action
794 ///
795 ///
796 /// #### `property-notify-event`
797 /// The ::property-notify-event signal will be emitted when a property on
798 /// the `widget`'s window has been changed or deleted.
799 ///
800 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
801 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
802 ///
803 ///
804 ///
805 ///
806 /// #### `proximity-in-event`
807 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
808 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
809 ///
810 /// This signal will be sent to the grab widget if there is one.
811 ///
812 ///
813 ///
814 ///
815 /// #### `proximity-out-event`
816 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
817 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
818 ///
819 /// This signal will be sent to the grab widget if there is one.
820 ///
821 ///
822 ///
823 ///
824 /// #### `query-tooltip`
825 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
826 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
827 /// focus in keyboard mode.
828 ///
829 /// Using the given coordinates, the signal handler should determine
830 /// whether a tooltip should be shown for `widget`. If this is the case
831 /// [`true`] should be returned, [`false`] otherwise. Note that if
832 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
833 /// should not be used.
834 ///
835 /// The signal handler is free to manipulate `tooltip` with the therefore
836 /// destined function calls.
837 ///
838 ///
839 ///
840 ///
841 /// #### `realize`
842 /// The ::realize signal is emitted when `widget` is associated with a
843 /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
844 /// widget has been mapped (that is, it is going to be drawn).
845 ///
846 ///
847 ///
848 ///
849 /// #### `screen-changed`
850 /// The ::screen-changed signal gets emitted when the
851 /// screen of a widget has changed.
852 ///
853 ///
854 ///
855 ///
856 /// #### `scroll-event`
857 /// The ::scroll-event signal is emitted when a button in the 4 to 7
858 /// range is pressed. Wheel mice are usually configured to generate
859 /// button press events for buttons 4 and 5 when the wheel is turned.
860 ///
861 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
862 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
863 ///
864 /// This signal will be sent to the grab widget if there is one.
865 ///
866 ///
867 ///
868 ///
869 /// #### `selection-clear-event`
870 /// The ::selection-clear-event signal will be emitted when the
871 /// the `widget`'s window has lost ownership of a selection.
872 ///
873 ///
874 ///
875 ///
876 /// #### `selection-get`
877 ///
878 ///
879 ///
880 /// #### `selection-notify-event`
881 ///
882 ///
883 ///
884 /// #### `selection-received`
885 ///
886 ///
887 ///
888 /// #### `selection-request-event`
889 /// The ::selection-request-event signal will be emitted when
890 /// another client requests ownership of the selection owned by
891 /// the `widget`'s window.
892 ///
893 ///
894 ///
895 ///
896 /// #### `show`
897 /// The ::show signal is emitted when `widget` is shown, for example with
898 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
899 ///
900 ///
901 ///
902 ///
903 /// #### `show-help`
904 /// Action
905 ///
906 ///
907 /// #### `size-allocate`
908 ///
909 ///
910 ///
911 /// #### `state-changed`
912 /// The ::state-changed signal is emitted when the widget state changes.
913 /// See `gtk_widget_get_state()`.
914 ///
915 ///
916 ///
917 ///
918 /// #### `state-flags-changed`
919 /// The ::state-flags-changed signal is emitted when the widget state
920 /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
921 ///
922 ///
923 ///
924 ///
925 /// #### `style-set`
926 /// The ::style-set signal is emitted when a new style has been set
927 /// on a widget. Note that style-modifying functions like
928 /// `gtk_widget_modify_base()` also cause this signal to be emitted.
929 ///
930 /// Note that this signal is emitted for changes to the deprecated
931 /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
932 /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
933 ///
934 ///
935 ///
936 ///
937 /// #### `style-updated`
938 /// The ::style-updated signal is a convenience signal that is emitted when the
939 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
940 /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
941 ///
942 /// Note that style-modifying functions like `gtk_widget_override_color()` also
943 /// cause this signal to be emitted.
944 ///
945 ///
946 ///
947 ///
948 /// #### `touch-event`
949 ///
950 ///
951 ///
952 /// #### `unmap`
953 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
954 /// means that either it or any of its parents up to the toplevel widget have
955 /// been set as hidden.
956 ///
957 /// As ::unmap indicates that a widget will not be shown any longer, it can be
958 /// used to, for example, stop an animation on the widget.
959 ///
960 ///
961 ///
962 ///
963 /// #### `unmap-event`
964 /// The ::unmap-event signal will be emitted when the `widget`'s window is
965 /// unmapped. A window is unmapped when it becomes invisible on the screen.
966 ///
967 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
968 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
969 /// automatically for all new windows.
970 ///
971 ///
972 ///
973 ///
974 /// #### `unrealize`
975 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
976 /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
977 /// called or the widget has been unmapped (that is, it is going to be
978 /// hidden).
979 ///
980 ///
981 ///
982 ///
983 /// #### `visibility-notify-event`
984 /// The ::visibility-notify-event will be emitted when the `widget`'s
985 /// window is obscured or unobscured.
986 ///
987 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
988 /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
989 ///
990 ///
991 ///
992 ///
993 /// #### `window-state-event`
994 /// The ::window-state-event will be emitted when the state of the
995 /// toplevel window associated to the `widget` changes.
996 ///
997 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
998 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
999 /// this mask automatically for all new windows.
1000 ///
1001 ///
1002 /// </details>
1003 ///
1004 /// # Implements
1005 ///
1006 /// [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
1007 #[doc(alias = "GtkContainer")]
1008 pub struct Container(Object<ffi::GtkContainer, ffi::GtkContainerClass>) @extends Widget, @implements Buildable;
1009
1010 match fn {
1011 type_ => || ffi::gtk_container_get_type(),
1012 }
1013}
1014
1015impl Container {
1016 pub const NONE: Option<&'static Container> = None;
1017}
1018
1019/// Trait containing all [`struct@Container`] methods.
1020///
1021/// # Implementors
1022///
1023/// [`Bin`][struct@crate::Bin], [`Box`][struct@crate::Box], [`Container`][struct@crate::Container], [`Fixed`][struct@crate::Fixed], [`FlowBox`][struct@crate::FlowBox], [`Grid`][struct@crate::Grid], [`HeaderBar`][struct@crate::HeaderBar], [`IconView`][struct@crate::IconView], [`Layout`][struct@crate::Layout], [`ListBox`][struct@crate::ListBox], [`MenuShell`][struct@crate::MenuShell], [`Notebook`][struct@crate::Notebook], [`Paned`][struct@crate::Paned], [`Socket`][struct@crate::Socket], [`Stack`][struct@crate::Stack], [`TextView`][struct@crate::TextView], [`ToolItemGroup`][struct@crate::ToolItemGroup], [`ToolPalette`][struct@crate::ToolPalette], [`Toolbar`][struct@crate::Toolbar], [`TreeView`][struct@crate::TreeView]
1024pub trait ContainerExt: IsA<Container> + 'static {
1025 /// Adds `widget` to `self`. Typically used for simple containers
1026 /// such as [`Window`][crate::Window], [`Frame`][crate::Frame], or [`Button`][crate::Button]; for more complicated
1027 /// layout containers such as [`Box`][crate::Box] or [`Grid`][crate::Grid], this function will
1028 /// pick default packing parameters that may not be correct. So
1029 /// consider functions such as [`BoxExt::pack_start()`][crate::prelude::BoxExt::pack_start()] and
1030 /// [`GridExt::attach()`][crate::prelude::GridExt::attach()] as an alternative to [`add()`][Self::add()] in
1031 /// those cases. A widget may be added to only one container at a time;
1032 /// you can’t place the same widget inside two different containers.
1033 ///
1034 /// Note that some containers, such as [`ScrolledWindow`][crate::ScrolledWindow] or [`ListBox`][crate::ListBox],
1035 /// may add intermediate children between the added widget and the
1036 /// container.
1037 /// ## `widget`
1038 /// a widget to be placed inside `self`
1039 #[doc(alias = "gtk_container_add")]
1040 fn add(&self, widget: &impl IsA<Widget>) {
1041 unsafe {
1042 ffi::gtk_container_add(
1043 self.as_ref().to_glib_none().0,
1044 widget.as_ref().to_glib_none().0,
1045 );
1046 }
1047 }
1048
1049 //#[doc(alias = "gtk_container_add_with_properties")]
1050 //fn add_with_properties(&self, widget: &impl IsA<Widget>, first_prop_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
1051 // unsafe { TODO: call ffi:gtk_container_add_with_properties() }
1052 //}
1053
1054 #[doc(alias = "gtk_container_check_resize")]
1055 fn check_resize(&self) {
1056 unsafe {
1057 ffi::gtk_container_check_resize(self.as_ref().to_glib_none().0);
1058 }
1059 }
1060
1061 //#[doc(alias = "gtk_container_child_get")]
1062 //fn child_get(&self, child: &impl IsA<Widget>, first_prop_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
1063 // unsafe { TODO: call ffi:gtk_container_child_get() }
1064 //}
1065
1066 //#[doc(alias = "gtk_container_child_get_valist")]
1067 //fn child_get_valist(&self, child: &impl IsA<Widget>, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
1068 // unsafe { TODO: call ffi:gtk_container_child_get_valist() }
1069 //}
1070
1071 /// Emits a [`child-notify`][struct@crate::Widget#child-notify] signal for the
1072 /// [child property][child-properties]
1073 /// `child_property` on the child.
1074 ///
1075 /// This is an analogue of [`ObjectExt::notify()`][crate::glib::prelude::ObjectExt::notify()] for child properties.
1076 ///
1077 /// Also see [`WidgetExt::child_notify()`][crate::prelude::WidgetExt::child_notify()].
1078 /// ## `child`
1079 /// the child widget
1080 /// ## `child_property`
1081 /// the name of a child property installed on
1082 /// the class of `self`
1083 #[doc(alias = "gtk_container_child_notify")]
1084 fn child_notify(&self, child: &impl IsA<Widget>, child_property: &str) {
1085 unsafe {
1086 ffi::gtk_container_child_notify(
1087 self.as_ref().to_glib_none().0,
1088 child.as_ref().to_glib_none().0,
1089 child_property.to_glib_none().0,
1090 );
1091 }
1092 }
1093
1094 /// Emits a [`child-notify`][struct@crate::Widget#child-notify] signal for the
1095 /// [child property][child-properties] specified by
1096 /// `pspec` on the child.
1097 ///
1098 /// This is an analogue of [`ObjectExt::notify_by_pspec()`][crate::glib::prelude::ObjectExt::notify_by_pspec()] for child properties.
1099 /// ## `child`
1100 /// the child widget
1101 /// ## `pspec`
1102 /// the [`glib::ParamSpec`][crate::glib::ParamSpec] of a child property instealled on
1103 /// the class of `self`
1104 #[doc(alias = "gtk_container_child_notify_by_pspec")]
1105 fn child_notify_by_pspec(&self, child: &impl IsA<Widget>, pspec: impl AsRef<glib::ParamSpec>) {
1106 unsafe {
1107 ffi::gtk_container_child_notify_by_pspec(
1108 self.as_ref().to_glib_none().0,
1109 child.as_ref().to_glib_none().0,
1110 pspec.as_ref().to_glib_none().0,
1111 );
1112 }
1113 }
1114
1115 //#[doc(alias = "gtk_container_child_set")]
1116 //fn child_set(&self, child: &impl IsA<Widget>, first_prop_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
1117 // unsafe { TODO: call ffi:gtk_container_child_set() }
1118 //}
1119
1120 //#[doc(alias = "gtk_container_child_set_valist")]
1121 //fn child_set_valist(&self, child: &impl IsA<Widget>, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
1122 // unsafe { TODO: call ffi:gtk_container_child_set_valist() }
1123 //}
1124
1125 /// Returns the type of the children supported by the container.
1126 ///
1127 /// Note that this may return `G_TYPE_NONE` to indicate that no more
1128 /// children can be added, e.g. for a [`Paned`][crate::Paned] which already has two
1129 /// children.
1130 ///
1131 /// # Returns
1132 ///
1133 /// a `GType`.
1134 #[doc(alias = "gtk_container_child_type")]
1135 fn child_type(&self) -> glib::types::Type {
1136 unsafe {
1137 from_glib(ffi::gtk_container_child_type(
1138 self.as_ref().to_glib_none().0,
1139 ))
1140 }
1141 }
1142
1143 /// Invokes `callback` on each direct child of `self`, including
1144 /// children that are considered “internal” (implementation details
1145 /// of the container). “Internal” children generally weren’t added
1146 /// by the user of the container, but were added by the container
1147 /// implementation itself.
1148 ///
1149 /// Most applications should use [`foreach()`][Self::foreach()], rather
1150 /// than [`forall()`][Self::forall()].
1151 /// ## `callback`
1152 /// a callback
1153 /// ## `callback_data`
1154 /// callback user data
1155 #[doc(alias = "gtk_container_forall")]
1156 fn forall<P: FnMut(&Widget)>(&self, callback: P) {
1157 let mut callback_data: P = callback;
1158 unsafe extern "C" fn callback_func<P: FnMut(&Widget)>(
1159 widget: *mut ffi::GtkWidget,
1160 data: glib::ffi::gpointer,
1161 ) {
1162 unsafe {
1163 let widget = from_glib_borrow(widget);
1164 let callback = data as *mut P;
1165 (*callback)(&widget)
1166 }
1167 }
1168 let callback = Some(callback_func::<P> as _);
1169 let super_callback0: &mut P = &mut callback_data;
1170 unsafe {
1171 ffi::gtk_container_forall(
1172 self.as_ref().to_glib_none().0,
1173 callback,
1174 super_callback0 as *mut _ as *mut _,
1175 );
1176 }
1177 }
1178
1179 /// Invokes `callback` on each non-internal child of `self`.
1180 /// See [`forall()`][Self::forall()] for details on what constitutes
1181 /// an “internal” child. For all practical purposes, this function
1182 /// should iterate over precisely those child widgets that were
1183 /// added to the container by the application with explicit `add()`
1184 /// calls.
1185 ///
1186 /// It is permissible to remove the child from the `callback` handler.
1187 ///
1188 /// Most applications should use [`foreach()`][Self::foreach()],
1189 /// rather than [`forall()`][Self::forall()].
1190 /// ## `callback`
1191 /// a callback
1192 /// ## `callback_data`
1193 /// callback user data
1194 #[doc(alias = "gtk_container_foreach")]
1195 fn foreach<P: FnMut(&Widget)>(&self, callback: P) {
1196 let mut callback_data: P = callback;
1197 unsafe extern "C" fn callback_func<P: FnMut(&Widget)>(
1198 widget: *mut ffi::GtkWidget,
1199 data: glib::ffi::gpointer,
1200 ) {
1201 unsafe {
1202 let widget = from_glib_borrow(widget);
1203 let callback = data as *mut P;
1204 (*callback)(&widget)
1205 }
1206 }
1207 let callback = Some(callback_func::<P> as _);
1208 let super_callback0: &mut P = &mut callback_data;
1209 unsafe {
1210 ffi::gtk_container_foreach(
1211 self.as_ref().to_glib_none().0,
1212 callback,
1213 super_callback0 as *mut _ as *mut _,
1214 );
1215 }
1216 }
1217
1218 /// Retrieves the border width of the container. See
1219 /// [`set_border_width()`][Self::set_border_width()].
1220 ///
1221 /// # Returns
1222 ///
1223 /// the current border width
1224 #[doc(alias = "gtk_container_get_border_width")]
1225 #[doc(alias = "get_border_width")]
1226 #[doc(alias = "border-width")]
1227 fn border_width(&self) -> u32 {
1228 unsafe { ffi::gtk_container_get_border_width(self.as_ref().to_glib_none().0) }
1229 }
1230
1231 /// Returns the container’s non-internal children. See
1232 /// [`forall()`][Self::forall()] for details on what constitutes an "internal" child.
1233 ///
1234 /// # Returns
1235 ///
1236 /// a newly-allocated list of the container’s non-internal children.
1237 #[doc(alias = "gtk_container_get_children")]
1238 #[doc(alias = "get_children")]
1239 fn children(&self) -> Vec<Widget> {
1240 unsafe {
1241 FromGlibPtrContainer::from_glib_container(ffi::gtk_container_get_children(
1242 self.as_ref().to_glib_none().0,
1243 ))
1244 }
1245 }
1246
1247 //#[cfg_attr(feature = "v3_24", deprecated = "Since 3.24")]
1248 //#[allow(deprecated)]
1249 //#[doc(alias = "gtk_container_get_focus_chain")]
1250 //#[doc(alias = "get_focus_chain")]
1251 //fn focus_chain(&self, focusable_widgets: /*Unimplemented*/Vec<Widget>) -> bool {
1252 // unsafe { TODO: call ffi:gtk_container_get_focus_chain() }
1253 //}
1254
1255 /// Returns the current focus child widget inside `self`. This is not the
1256 /// currently focused widget. That can be obtained by calling
1257 /// [`GtkWindowExt::focused_widget()`][crate::prelude::GtkWindowExt::focused_widget()].
1258 ///
1259 /// # Returns
1260 ///
1261 /// The child widget which will receive the
1262 /// focus inside `self` when the `self` is focused,
1263 /// or [`None`] if none is set.
1264 #[doc(alias = "gtk_container_get_focus_child")]
1265 #[doc(alias = "get_focus_child")]
1266 fn focus_child(&self) -> Option<Widget> {
1267 unsafe {
1268 from_glib_none(ffi::gtk_container_get_focus_child(
1269 self.as_ref().to_glib_none().0,
1270 ))
1271 }
1272 }
1273
1274 /// Retrieves the horizontal focus adjustment for the container. See
1275 /// gtk_container_set_focus_hadjustment ().
1276 ///
1277 /// # Returns
1278 ///
1279 /// the horizontal focus adjustment, or [`None`] if
1280 /// none has been set.
1281 #[doc(alias = "gtk_container_get_focus_hadjustment")]
1282 #[doc(alias = "get_focus_hadjustment")]
1283 fn focus_hadjustment(&self) -> Option<Adjustment> {
1284 unsafe {
1285 from_glib_none(ffi::gtk_container_get_focus_hadjustment(
1286 self.as_ref().to_glib_none().0,
1287 ))
1288 }
1289 }
1290
1291 /// Retrieves the vertical focus adjustment for the container. See
1292 /// [`set_focus_vadjustment()`][Self::set_focus_vadjustment()].
1293 ///
1294 /// # Returns
1295 ///
1296 /// the vertical focus adjustment, or
1297 /// [`None`] if none has been set.
1298 #[doc(alias = "gtk_container_get_focus_vadjustment")]
1299 #[doc(alias = "get_focus_vadjustment")]
1300 fn focus_vadjustment(&self) -> Option<Adjustment> {
1301 unsafe {
1302 from_glib_none(ffi::gtk_container_get_focus_vadjustment(
1303 self.as_ref().to_glib_none().0,
1304 ))
1305 }
1306 }
1307
1308 /// Returns a newly created widget path representing all the widget hierarchy
1309 /// from the toplevel down to and including `child`.
1310 /// ## `child`
1311 /// a child of `self`
1312 ///
1313 /// # Returns
1314 ///
1315 /// A newly created [`WidgetPath`][crate::WidgetPath]
1316 #[doc(alias = "gtk_container_get_path_for_child")]
1317 #[doc(alias = "get_path_for_child")]
1318 fn path_for_child(&self, child: &impl IsA<Widget>) -> Option<WidgetPath> {
1319 unsafe {
1320 from_glib_full(ffi::gtk_container_get_path_for_child(
1321 self.as_ref().to_glib_none().0,
1322 child.as_ref().to_glib_none().0,
1323 ))
1324 }
1325 }
1326
1327 /// When a container receives a call to the draw function, it must send
1328 /// synthetic [`draw`][struct@crate::Widget#draw] calls to all children that don’t have their
1329 /// own `GdkWindows`. This function provides a convenient way of doing this.
1330 /// A container, when it receives a call to its [`draw`][struct@crate::Widget#draw] function,
1331 /// calls [`propagate_draw()`][Self::propagate_draw()] once for each child, passing in
1332 /// the `cr` the container received.
1333 ///
1334 /// [`propagate_draw()`][Self::propagate_draw()] takes care of translating the origin of `cr`,
1335 /// and deciding whether the draw needs to be sent to the child. It is a
1336 /// convenient and optimized way of getting the same effect as calling
1337 /// [`WidgetExt::draw()`][crate::prelude::WidgetExt::draw()] on the child directly.
1338 ///
1339 /// In most cases, a container can simply either inherit the
1340 /// [`draw`][struct@crate::Widget#draw] implementation from [`Container`][crate::Container], or do some drawing
1341 /// and then chain to the ::draw implementation from [`Container`][crate::Container].
1342 /// ## `child`
1343 /// a child of `self`
1344 /// ## `cr`
1345 /// Cairo context as passed to the container. If you want to use `cr`
1346 /// in container’s draw function, consider using `cairo_save()` and
1347 /// `cairo_restore()` before calling this function.
1348 #[doc(alias = "gtk_container_propagate_draw")]
1349 fn propagate_draw(&self, child: &impl IsA<Widget>, cr: &cairo::Context) {
1350 unsafe {
1351 ffi::gtk_container_propagate_draw(
1352 self.as_ref().to_glib_none().0,
1353 child.as_ref().to_glib_none().0,
1354 mut_override(cr.to_glib_none().0),
1355 );
1356 }
1357 }
1358
1359 /// Removes `widget` from `self`. `widget` must be inside `self`.
1360 /// Note that `self` will own a reference to `widget`, and that this
1361 /// may be the last reference held; so removing a widget from its
1362 /// container can destroy that widget. If you want to use `widget`
1363 /// again, you need to add a reference to it before removing it from
1364 /// a container, using `g_object_ref()`. If you don’t want to use `widget`
1365 /// again it’s usually more efficient to simply destroy it directly
1366 /// using `gtk_widget_destroy()` since this will remove it from the
1367 /// container and help break any circular reference count cycles.
1368 /// ## `widget`
1369 /// a current child of `self`
1370 #[doc(alias = "gtk_container_remove")]
1371 fn remove(&self, widget: &impl IsA<Widget>) {
1372 unsafe {
1373 ffi::gtk_container_remove(
1374 self.as_ref().to_glib_none().0,
1375 widget.as_ref().to_glib_none().0,
1376 );
1377 }
1378 }
1379
1380 /// Sets the border width of the container.
1381 ///
1382 /// The border width of a container is the amount of space to leave
1383 /// around the outside of the container. The only exception to this is
1384 /// [`Window`][crate::Window]; because toplevel windows can’t leave space outside,
1385 /// they leave the space inside. The border is added on all sides of
1386 /// the container. To add space to only one side, use a specific
1387 /// [`margin`][struct@crate::Widget#margin] property on the child widget, for example
1388 /// [`margin-top`][struct@crate::Widget#margin-top].
1389 /// ## `border_width`
1390 /// amount of blank space to leave outside
1391 /// the container. Valid values are in the range 0-65535 pixels.
1392 #[doc(alias = "gtk_container_set_border_width")]
1393 #[doc(alias = "border-width")]
1394 fn set_border_width(&self, border_width: u32) {
1395 unsafe {
1396 ffi::gtk_container_set_border_width(self.as_ref().to_glib_none().0, border_width);
1397 }
1398 }
1399
1400 /// Sets a focus chain, overriding the one computed automatically by GTK+.
1401 ///
1402 /// In principle each widget in the chain should be a descendant of the
1403 /// container, but this is not enforced by this method, since it’s allowed
1404 /// to set the focus chain before you pack the widgets, or have a widget
1405 /// in the chain that isn’t always packed. The necessary checks are done
1406 /// when the focus chain is actually traversed.
1407 ///
1408 /// # Deprecated since 3.24
1409 ///
1410 /// For overriding focus behavior, use the
1411 /// GtkWidgetClass::focus signal.
1412 /// ## `focusable_widgets`
1413 ///
1414 /// the new focus chain
1415 #[cfg_attr(feature = "v3_24", deprecated = "Since 3.24")]
1416 #[allow(deprecated)]
1417 #[doc(alias = "gtk_container_set_focus_chain")]
1418 fn set_focus_chain(&self, focusable_widgets: &[Widget]) {
1419 unsafe {
1420 ffi::gtk_container_set_focus_chain(
1421 self.as_ref().to_glib_none().0,
1422 focusable_widgets.to_glib_none().0,
1423 );
1424 }
1425 }
1426
1427 /// Sets, or unsets if `child` is [`None`], the focused child of `self`.
1428 ///
1429 /// This function emits the GtkContainer::set_focus_child signal of
1430 /// `self`. Implementations of [`Container`][crate::Container] can override the
1431 /// default behaviour by overriding the class closure of this signal.
1432 ///
1433 /// This is function is mostly meant to be used by widgets. Applications can use
1434 /// [`WidgetExt::grab_focus()`][crate::prelude::WidgetExt::grab_focus()] to manually set the focus to a specific widget.
1435 /// ## `child`
1436 /// a [`Widget`][crate::Widget], or [`None`]
1437 #[doc(alias = "gtk_container_set_focus_child")]
1438 fn set_focus_child(&self, child: Option<&impl IsA<Widget>>) {
1439 unsafe {
1440 ffi::gtk_container_set_focus_child(
1441 self.as_ref().to_glib_none().0,
1442 child.map(|p| p.as_ref()).to_glib_none().0,
1443 );
1444 }
1445 }
1446
1447 /// Hooks up an adjustment to focus handling in a container, so when a child
1448 /// of the container is focused, the adjustment is scrolled to show that
1449 /// widget. This function sets the horizontal alignment.
1450 /// See [`ScrolledWindowExt::hadjustment()`][crate::prelude::ScrolledWindowExt::hadjustment()] for a typical way of obtaining
1451 /// the adjustment and [`set_focus_vadjustment()`][Self::set_focus_vadjustment()] for setting
1452 /// the vertical adjustment.
1453 ///
1454 /// The adjustments have to be in pixel units and in the same coordinate
1455 /// system as the allocation for immediate children of the container.
1456 /// ## `adjustment`
1457 /// an adjustment which should be adjusted when the focus is
1458 /// moved among the descendents of `self`
1459 #[doc(alias = "gtk_container_set_focus_hadjustment")]
1460 fn set_focus_hadjustment(&self, adjustment: &impl IsA<Adjustment>) {
1461 unsafe {
1462 ffi::gtk_container_set_focus_hadjustment(
1463 self.as_ref().to_glib_none().0,
1464 adjustment.as_ref().to_glib_none().0,
1465 );
1466 }
1467 }
1468
1469 /// Hooks up an adjustment to focus handling in a container, so when a
1470 /// child of the container is focused, the adjustment is scrolled to
1471 /// show that widget. This function sets the vertical alignment. See
1472 /// [`ScrolledWindowExt::vadjustment()`][crate::prelude::ScrolledWindowExt::vadjustment()] for a typical way of obtaining
1473 /// the adjustment and [`set_focus_hadjustment()`][Self::set_focus_hadjustment()] for setting
1474 /// the horizontal adjustment.
1475 ///
1476 /// The adjustments have to be in pixel units and in the same coordinate
1477 /// system as the allocation for immediate children of the container.
1478 /// ## `adjustment`
1479 /// an adjustment which should be adjusted when the focus
1480 /// is moved among the descendents of `self`
1481 #[doc(alias = "gtk_container_set_focus_vadjustment")]
1482 fn set_focus_vadjustment(&self, adjustment: &impl IsA<Adjustment>) {
1483 unsafe {
1484 ffi::gtk_container_set_focus_vadjustment(
1485 self.as_ref().to_glib_none().0,
1486 adjustment.as_ref().to_glib_none().0,
1487 );
1488 }
1489 }
1490
1491 /// Removes a focus chain explicitly set with [`set_focus_chain()`][Self::set_focus_chain()].
1492 ///
1493 /// # Deprecated since 3.24
1494 ///
1495 /// For overriding focus behavior, use the
1496 /// GtkWidgetClass::focus signal.
1497 #[cfg_attr(feature = "v3_24", deprecated = "Since 3.24")]
1498 #[allow(deprecated)]
1499 #[doc(alias = "gtk_container_unset_focus_chain")]
1500 fn unset_focus_chain(&self) {
1501 unsafe {
1502 ffi::gtk_container_unset_focus_chain(self.as_ref().to_glib_none().0);
1503 }
1504 }
1505
1506 fn set_child<P: IsA<Widget>>(&self, child: Option<&P>) {
1507 ObjectExt::set_property(self.as_ref(), "child", child)
1508 }
1509
1510 #[doc(alias = "resize-mode")]
1511 fn resize_mode(&self) -> ResizeMode {
1512 ObjectExt::property(self.as_ref(), "resize-mode")
1513 }
1514
1515 #[doc(alias = "resize-mode")]
1516 fn set_resize_mode(&self, resize_mode: ResizeMode) {
1517 ObjectExt::set_property(self.as_ref(), "resize-mode", resize_mode)
1518 }
1519
1520 #[doc(alias = "add")]
1521 fn connect_add<F: Fn(&Self, &Widget) + 'static>(&self, f: F) -> SignalHandlerId {
1522 unsafe extern "C" fn add_trampoline<P: IsA<Container>, F: Fn(&P, &Widget) + 'static>(
1523 this: *mut ffi::GtkContainer,
1524 object: *mut ffi::GtkWidget,
1525 f: glib::ffi::gpointer,
1526 ) {
1527 unsafe {
1528 let f: &F = &*(f as *const F);
1529 f(
1530 Container::from_glib_borrow(this).unsafe_cast_ref(),
1531 &from_glib_borrow(object),
1532 )
1533 }
1534 }
1535 unsafe {
1536 let f: Box_<F> = Box_::new(f);
1537 connect_raw(
1538 self.as_ptr() as *mut _,
1539 c"add".as_ptr(),
1540 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1541 add_trampoline::<Self, F> as *const (),
1542 )),
1543 Box_::into_raw(f),
1544 )
1545 }
1546 }
1547
1548 #[doc(alias = "check-resize")]
1549 fn connect_check_resize<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1550 unsafe extern "C" fn check_resize_trampoline<P: IsA<Container>, F: Fn(&P) + 'static>(
1551 this: *mut ffi::GtkContainer,
1552 f: glib::ffi::gpointer,
1553 ) {
1554 unsafe {
1555 let f: &F = &*(f as *const F);
1556 f(Container::from_glib_borrow(this).unsafe_cast_ref())
1557 }
1558 }
1559 unsafe {
1560 let f: Box_<F> = Box_::new(f);
1561 connect_raw(
1562 self.as_ptr() as *mut _,
1563 c"check-resize".as_ptr(),
1564 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1565 check_resize_trampoline::<Self, F> as *const (),
1566 )),
1567 Box_::into_raw(f),
1568 )
1569 }
1570 }
1571
1572 #[doc(alias = "remove")]
1573 fn connect_remove<F: Fn(&Self, &Widget) + 'static>(&self, f: F) -> SignalHandlerId {
1574 unsafe extern "C" fn remove_trampoline<P: IsA<Container>, F: Fn(&P, &Widget) + 'static>(
1575 this: *mut ffi::GtkContainer,
1576 object: *mut ffi::GtkWidget,
1577 f: glib::ffi::gpointer,
1578 ) {
1579 unsafe {
1580 let f: &F = &*(f as *const F);
1581 f(
1582 Container::from_glib_borrow(this).unsafe_cast_ref(),
1583 &from_glib_borrow(object),
1584 )
1585 }
1586 }
1587 unsafe {
1588 let f: Box_<F> = Box_::new(f);
1589 connect_raw(
1590 self.as_ptr() as *mut _,
1591 c"remove".as_ptr(),
1592 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1593 remove_trampoline::<Self, F> as *const (),
1594 )),
1595 Box_::into_raw(f),
1596 )
1597 }
1598 }
1599
1600 #[doc(alias = "set-focus-child")]
1601 fn connect_set_focus_child<F: Fn(&Self, &Widget) + 'static>(&self, f: F) -> SignalHandlerId {
1602 unsafe extern "C" fn set_focus_child_trampoline<
1603 P: IsA<Container>,
1604 F: Fn(&P, &Widget) + 'static,
1605 >(
1606 this: *mut ffi::GtkContainer,
1607 object: *mut ffi::GtkWidget,
1608 f: glib::ffi::gpointer,
1609 ) {
1610 unsafe {
1611 let f: &F = &*(f as *const F);
1612 f(
1613 Container::from_glib_borrow(this).unsafe_cast_ref(),
1614 &from_glib_borrow(object),
1615 )
1616 }
1617 }
1618 unsafe {
1619 let f: Box_<F> = Box_::new(f);
1620 connect_raw(
1621 self.as_ptr() as *mut _,
1622 c"set-focus-child".as_ptr(),
1623 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1624 set_focus_child_trampoline::<Self, F> as *const (),
1625 )),
1626 Box_::into_raw(f),
1627 )
1628 }
1629 }
1630
1631 #[doc(alias = "border-width")]
1632 fn connect_border_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1633 unsafe extern "C" fn notify_border_width_trampoline<
1634 P: IsA<Container>,
1635 F: Fn(&P) + 'static,
1636 >(
1637 this: *mut ffi::GtkContainer,
1638 _param_spec: glib::ffi::gpointer,
1639 f: glib::ffi::gpointer,
1640 ) {
1641 unsafe {
1642 let f: &F = &*(f as *const F);
1643 f(Container::from_glib_borrow(this).unsafe_cast_ref())
1644 }
1645 }
1646 unsafe {
1647 let f: Box_<F> = Box_::new(f);
1648 connect_raw(
1649 self.as_ptr() as *mut _,
1650 c"notify::border-width".as_ptr(),
1651 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1652 notify_border_width_trampoline::<Self, F> as *const (),
1653 )),
1654 Box_::into_raw(f),
1655 )
1656 }
1657 }
1658
1659 #[doc(alias = "child")]
1660 fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1661 unsafe extern "C" fn notify_child_trampoline<P: IsA<Container>, F: Fn(&P) + 'static>(
1662 this: *mut ffi::GtkContainer,
1663 _param_spec: glib::ffi::gpointer,
1664 f: glib::ffi::gpointer,
1665 ) {
1666 unsafe {
1667 let f: &F = &*(f as *const F);
1668 f(Container::from_glib_borrow(this).unsafe_cast_ref())
1669 }
1670 }
1671 unsafe {
1672 let f: Box_<F> = Box_::new(f);
1673 connect_raw(
1674 self.as_ptr() as *mut _,
1675 c"notify::child".as_ptr(),
1676 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1677 notify_child_trampoline::<Self, F> as *const (),
1678 )),
1679 Box_::into_raw(f),
1680 )
1681 }
1682 }
1683
1684 #[doc(alias = "resize-mode")]
1685 fn connect_resize_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1686 unsafe extern "C" fn notify_resize_mode_trampoline<
1687 P: IsA<Container>,
1688 F: Fn(&P) + 'static,
1689 >(
1690 this: *mut ffi::GtkContainer,
1691 _param_spec: glib::ffi::gpointer,
1692 f: glib::ffi::gpointer,
1693 ) {
1694 unsafe {
1695 let f: &F = &*(f as *const F);
1696 f(Container::from_glib_borrow(this).unsafe_cast_ref())
1697 }
1698 }
1699 unsafe {
1700 let f: Box_<F> = Box_::new(f);
1701 connect_raw(
1702 self.as_ptr() as *mut _,
1703 c"notify::resize-mode".as_ptr(),
1704 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1705 notify_resize_mode_trampoline::<Self, F> as *const (),
1706 )),
1707 Box_::into_raw(f),
1708 )
1709 }
1710 }
1711}
1712
1713impl<O: IsA<Container>> ContainerExt for O {}