gtk/auto/list_box.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 Adjustment, Align, Buildable, Container, ListBoxRow, MovementStep, ResizeMode, SelectionMode,
7 Widget, ffi,
8};
9use glib::{
10 object::ObjectType as _,
11 prelude::*,
12 signal::{SignalHandlerId, connect_raw},
13 translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18 ///
19 /// list
20 /// ╰── row[.activatable]
21 /// ]|
22 ///
23 /// GtkListBox uses a single CSS node named list. Each GtkListBoxRow uses
24 /// a single CSS node named row. The row nodes get the .activatable
25 /// style class added when appropriate.
26 ///
27 /// ## Properties
28 ///
29 ///
30 /// #### `activate-on-single-click`
31 /// Readable | Writable
32 ///
33 ///
34 /// #### `selection-mode`
35 /// Readable | Writable
36 /// <details><summary><h4>Container</h4></summary>
37 ///
38 ///
39 /// #### `border-width`
40 /// Readable | Writable
41 ///
42 ///
43 /// #### `child`
44 /// Writable
45 ///
46 ///
47 /// #### `resize-mode`
48 /// Readable | Writable
49 /// </details>
50 /// <details><summary><h4>Widget</h4></summary>
51 ///
52 ///
53 /// #### `app-paintable`
54 /// Readable | Writable
55 ///
56 ///
57 /// #### `can-default`
58 /// Readable | Writable
59 ///
60 ///
61 /// #### `can-focus`
62 /// Readable | Writable
63 ///
64 ///
65 /// #### `composite-child`
66 /// Readable
67 ///
68 ///
69 /// #### `double-buffered`
70 /// Whether the widget is double buffered.
71 ///
72 /// Readable | Writable
73 ///
74 ///
75 /// #### `events`
76 /// Readable | Writable
77 ///
78 ///
79 /// #### `expand`
80 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
81 ///
82 /// Readable | Writable
83 ///
84 ///
85 /// #### `focus-on-click`
86 /// Whether the widget should grab focus when it is clicked with the mouse.
87 ///
88 /// This property is only relevant for widgets that can take focus.
89 ///
90 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
91 /// GtkComboBox) implemented this property individually.
92 ///
93 /// Readable | Writable
94 ///
95 ///
96 /// #### `halign`
97 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
98 ///
99 /// Readable | Writable
100 ///
101 ///
102 /// #### `has-default`
103 /// Readable | Writable
104 ///
105 ///
106 /// #### `has-focus`
107 /// Readable | Writable
108 ///
109 ///
110 /// #### `has-tooltip`
111 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
112 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
113 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
114 /// whether it will provide a tooltip or not.
115 ///
116 /// Note that setting this property to [`true`] for the first time will change
117 /// the event masks of the GdkWindows of this widget to include leave-notify
118 /// and motion-notify events. This cannot and will not be undone when the
119 /// property is set to [`false`] again.
120 ///
121 /// Readable | Writable
122 ///
123 ///
124 /// #### `height-request`
125 /// Readable | Writable
126 ///
127 ///
128 /// #### `hexpand`
129 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
130 ///
131 /// Readable | Writable
132 ///
133 ///
134 /// #### `hexpand-set`
135 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
136 ///
137 /// Readable | Writable
138 ///
139 ///
140 /// #### `is-focus`
141 /// Readable | Writable
142 ///
143 ///
144 /// #### `margin`
145 /// Sets all four sides' margin at once. If read, returns max
146 /// margin on any side.
147 ///
148 /// Readable | Writable
149 ///
150 ///
151 /// #### `margin-bottom`
152 /// Margin on bottom side of widget.
153 ///
154 /// This property adds margin outside of the widget's normal size
155 /// request, the margin will be added in addition to the size from
156 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
157 ///
158 /// Readable | Writable
159 ///
160 ///
161 /// #### `margin-end`
162 /// Margin on end of widget, horizontally. This property supports
163 /// left-to-right and right-to-left text directions.
164 ///
165 /// This property adds margin outside of the widget's normal size
166 /// request, the margin will be added in addition to the size from
167 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
168 ///
169 /// Readable | Writable
170 ///
171 ///
172 /// #### `margin-left`
173 /// Margin on left side of widget.
174 ///
175 /// This property adds margin outside of the widget's normal size
176 /// request, the margin will be added in addition to the size from
177 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
178 ///
179 /// Readable | Writable
180 ///
181 ///
182 /// #### `margin-right`
183 /// Margin on right side of widget.
184 ///
185 /// This property adds margin outside of the widget's normal size
186 /// request, the margin will be added in addition to the size from
187 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
188 ///
189 /// Readable | Writable
190 ///
191 ///
192 /// #### `margin-start`
193 /// Margin on start of widget, horizontally. This property supports
194 /// left-to-right and right-to-left text directions.
195 ///
196 /// This property adds margin outside of the widget's normal size
197 /// request, the margin will be added in addition to the size from
198 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
199 ///
200 /// Readable | Writable
201 ///
202 ///
203 /// #### `margin-top`
204 /// Margin on top side of widget.
205 ///
206 /// This property adds margin outside of the widget's normal size
207 /// request, the margin will be added in addition to the size from
208 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
209 ///
210 /// Readable | Writable
211 ///
212 ///
213 /// #### `name`
214 /// Readable | Writable
215 ///
216 ///
217 /// #### `no-show-all`
218 /// Readable | Writable
219 ///
220 ///
221 /// #### `opacity`
222 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
223 /// more details about window opacity.
224 ///
225 /// Before 3.8 this was only available in GtkWindow
226 ///
227 /// Readable | Writable
228 ///
229 ///
230 /// #### `parent`
231 /// Readable | Writable
232 ///
233 ///
234 /// #### `receives-default`
235 /// Readable | Writable
236 ///
237 ///
238 /// #### `scale-factor`
239 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
240 /// more details about widget scaling.
241 ///
242 /// Readable
243 ///
244 ///
245 /// #### `sensitive`
246 /// Readable | Writable
247 ///
248 ///
249 /// #### `style`
250 /// The style of the widget, which contains information about how it will look (colors, etc).
251 ///
252 /// Readable | Writable
253 ///
254 ///
255 /// #### `tooltip-markup`
256 /// Sets the text of tooltip to be the given string, which is marked up
257 /// with the [Pango text markup language][PangoMarkupFormat].
258 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
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 /// #### `tooltip-text`
272 /// Sets the text of tooltip to be the given string.
273 ///
274 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
275 ///
276 /// This is a convenience property which will take care of getting the
277 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
278 /// will automatically be set to [`true`] and there will be taken care of
279 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
280 ///
281 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
282 /// are set, the last one wins.
283 ///
284 /// Readable | Writable
285 ///
286 ///
287 /// #### `valign`
288 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
289 ///
290 /// Readable | Writable
291 ///
292 ///
293 /// #### `vexpand`
294 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
295 ///
296 /// Readable | Writable
297 ///
298 ///
299 /// #### `vexpand-set`
300 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
301 ///
302 /// Readable | Writable
303 ///
304 ///
305 /// #### `visible`
306 /// Readable | Writable
307 ///
308 ///
309 /// #### `width-request`
310 /// Readable | Writable
311 ///
312 ///
313 /// #### `window`
314 /// The widget's window if it is realized, [`None`] otherwise.
315 ///
316 /// Readable
317 /// </details>
318 ///
319 /// ## Signals
320 ///
321 ///
322 /// #### `activate-cursor-row`
323 /// Action
324 ///
325 ///
326 /// #### `move-cursor`
327 /// Action
328 ///
329 ///
330 /// #### `row-activated`
331 /// The ::row-activated signal is emitted when a row has been activated by the user.
332 ///
333 ///
334 ///
335 ///
336 /// #### `row-selected`
337 /// The ::row-selected signal is emitted when a new row is selected, or
338 /// (with a [`None`] `row`) when the selection is cleared.
339 ///
340 /// When the `box_` is using [`SelectionMode::Multiple`][crate::SelectionMode::Multiple], this signal will not
341 /// give you the full picture of selection changes, and you should use
342 /// the [`selected-rows-changed`][struct@crate::ListBox#selected-rows-changed] signal instead.
343 ///
344 ///
345 ///
346 ///
347 /// #### `select-all`
348 /// The ::select-all signal is a [keybinding signal][GtkBindingSignal]
349 /// which gets emitted to select all children of the box, if the selection
350 /// mode permits it.
351 ///
352 /// The default bindings for this signal is Ctrl-a.
353 ///
354 /// Action
355 ///
356 ///
357 /// #### `selected-rows-changed`
358 /// The ::selected-rows-changed signal is emitted when the
359 /// set of selected rows changes.
360 ///
361 ///
362 ///
363 ///
364 /// #### `toggle-cursor-row`
365 /// Action
366 ///
367 ///
368 /// #### `unselect-all`
369 /// The ::unselect-all signal is a [keybinding signal][GtkBindingSignal]
370 /// which gets emitted to unselect all children of the box, if the selection
371 /// mode permits it.
372 ///
373 /// The default bindings for this signal is Ctrl-Shift-a.
374 ///
375 /// Action
376 /// <details><summary><h4>Container</h4></summary>
377 ///
378 ///
379 /// #### `add`
380 ///
381 ///
382 ///
383 /// #### `check-resize`
384 ///
385 ///
386 ///
387 /// #### `remove`
388 ///
389 ///
390 ///
391 /// #### `set-focus-child`
392 ///
393 /// </details>
394 /// <details><summary><h4>Widget</h4></summary>
395 ///
396 ///
397 /// #### `accel-closures-changed`
398 ///
399 ///
400 ///
401 /// #### `button-press-event`
402 /// The ::button-press-event signal will be emitted when a button
403 /// (typically from a mouse) is pressed.
404 ///
405 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
406 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
407 ///
408 /// This signal will be sent to the grab widget if there is one.
409 ///
410 ///
411 ///
412 ///
413 /// #### `button-release-event`
414 /// The ::button-release-event signal will be emitted when a button
415 /// (typically from a mouse) is released.
416 ///
417 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
418 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
419 ///
420 /// This signal will be sent to the grab widget if there is one.
421 ///
422 ///
423 ///
424 ///
425 /// #### `can-activate-accel`
426 /// Determines whether an accelerator that activates the signal
427 /// identified by `signal_id` can currently be activated.
428 /// This signal is present to allow applications and derived
429 /// widgets to override the default [`Widget`][crate::Widget] handling
430 /// for determining whether an accelerator can be activated.
431 ///
432 ///
433 ///
434 ///
435 /// #### `child-notify`
436 /// The ::child-notify signal is emitted for each
437 /// [child property][child-properties] that has
438 /// changed on an object. The signal's detail holds the property name.
439 ///
440 /// Detailed
441 ///
442 ///
443 /// #### `composited-changed`
444 /// The ::composited-changed signal is emitted when the composited
445 /// status of `widgets` screen changes.
446 /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
447 ///
448 /// Action
449 ///
450 ///
451 /// #### `configure-event`
452 /// The ::configure-event signal will be emitted when the size, position or
453 /// stacking of the `widget`'s window has changed.
454 ///
455 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
456 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
457 /// automatically for all new windows.
458 ///
459 ///
460 ///
461 ///
462 /// #### `damage-event`
463 /// Emitted when a redirected window belonging to `widget` gets drawn into.
464 /// The region/area members of the event shows what area of the redirected
465 /// drawable was drawn into.
466 ///
467 ///
468 ///
469 ///
470 /// #### `delete-event`
471 /// The ::delete-event signal is emitted if a user requests that
472 /// a toplevel window is closed. The default handler for this signal
473 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
474 /// this signal will cause the window to be hidden instead, so that
475 /// it can later be shown again without reconstructing it.
476 ///
477 ///
478 ///
479 ///
480 /// #### `destroy`
481 /// Signals that all holders of a reference to the widget should release
482 /// the reference that they hold. May result in finalization of the widget
483 /// if all references are released.
484 ///
485 /// This signal is not suitable for saving widget state.
486 ///
487 ///
488 ///
489 ///
490 /// #### `destroy-event`
491 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
492 /// You rarely get this signal, because most widgets disconnect themselves
493 /// from their window before they destroy it, so no widget owns the
494 /// window at destroy time.
495 ///
496 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
497 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
498 /// automatically for all new windows.
499 ///
500 ///
501 ///
502 ///
503 /// #### `direction-changed`
504 /// The ::direction-changed signal is emitted when the text direction
505 /// of a widget changes.
506 ///
507 ///
508 ///
509 ///
510 /// #### `drag-begin`
511 /// The ::drag-begin signal is emitted on the drag source when a drag is
512 /// started. A typical reason to connect to this signal is to set up a
513 /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
514 ///
515 /// Note that some widgets set up a drag icon in the default handler of
516 /// this signal, so you may have to use `g_signal_connect_after()` to
517 /// override what the default handler did.
518 ///
519 ///
520 ///
521 ///
522 /// #### `drag-data-delete`
523 /// The ::drag-data-delete signal is emitted on the drag source when a drag
524 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
525 /// handler is responsible for deleting the data that has been dropped. What
526 /// "delete" means depends on the context of the drag operation.
527 ///
528 ///
529 ///
530 ///
531 /// #### `drag-data-get`
532 /// The ::drag-data-get signal is emitted on the drag source when the drop
533 /// site requests the data which is dragged. It is the responsibility of
534 /// the signal handler to fill `data` with the data in the format which
535 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
536 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
537 ///
538 ///
539 ///
540 ///
541 /// #### `drag-data-received`
542 /// format == 8))
543 /// {
544 /// GdkDragAction action;
545 ///
546 /// // handle data here
547 ///
548 /// action = gdk_drag_context_get_selected_action (context);
549 /// if (action == GDK_ACTION_ASK)
550 /// {
551 /// GtkWidget *dialog;
552 /// gint response;
553 ///
554 /// dialog = gtk_message_dialog_new (NULL,
555 /// GTK_DIALOG_MODAL |
556 /// GTK_DIALOG_DESTROY_WITH_PARENT,
557 /// GTK_MESSAGE_INFO,
558 /// GTK_BUTTONS_YES_NO,
559 /// "Move the data ?\n");
560 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
561 /// gtk_widget_destroy (dialog);
562 ///
563 /// if (response == GTK_RESPONSE_YES)
564 /// action = GDK_ACTION_MOVE;
565 /// else
566 /// action = GDK_ACTION_COPY;
567 /// }
568 ///
569 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
570 /// }
571 /// else
572 /// gtk_drag_finish (context, FALSE, FALSE, time);
573 /// }
574 /// ]|
575 ///
576 ///
577 ///
578 ///
579 /// #### `drag-drop`
580 /// The ::drag-drop signal is emitted on the drop site when the user drops
581 /// the data onto the widget. The signal handler must determine whether
582 /// the cursor position is in a drop zone or not. If it is not in a drop
583 /// zone, it returns [`false`] and no further processing is necessary.
584 /// Otherwise, the handler returns [`true`]. In this case, the handler must
585 /// ensure that `gtk_drag_finish()` is called to let the source know that
586 /// the drop is done. The call to `gtk_drag_finish()` can be done either
587 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
588 /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
589 /// or more of the supported targets.
590 ///
591 ///
592 ///
593 ///
594 /// #### `drag-end`
595 /// The ::drag-end signal is emitted on the drag source when a drag is
596 /// finished. A typical reason to connect to this signal is to undo
597 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
598 ///
599 ///
600 ///
601 ///
602 /// #### `drag-failed`
603 /// The ::drag-failed signal is emitted on the drag source when a drag has
604 /// failed. The signal handler may hook custom code to handle a failed DnD
605 /// operation based on the type of error, it returns [`true`] is the failure has
606 /// been already handled (not showing the default "drag operation failed"
607 /// animation), otherwise it returns [`false`].
608 ///
609 ///
610 ///
611 ///
612 /// #### `drag-leave`
613 /// The ::drag-leave signal is emitted on the drop site when the cursor
614 /// leaves the widget. A typical reason to connect to this signal is to
615 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
616 /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
617 ///
618 ///
619 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
620 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
621 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
622 ///
623 ///
624 ///
625 ///
626 /// #### `drag-motion`
627 /// suggested_action,
628 /// time);
629 /// }
630 /// else
631 /// {
632 /// // accept the drop
633 /// }
634 /// }
635 /// ]|
636 ///
637 ///
638 ///
639 ///
640 /// #### `draw`
641 /// This signal is emitted when a widget is supposed to render itself.
642 /// The `widget`'s top left corner must be painted at the origin of
643 /// the passed in context and be sized to the values returned by
644 /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
645 /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
646 ///
647 /// Signal handlers connected to this signal can modify the cairo
648 /// context passed as `cr` in any way they like and don't need to
649 /// restore it. The signal emission takes care of calling `cairo_save()`
650 /// before and `cairo_restore()` after invoking the handler.
651 ///
652 /// The signal handler will get a `cr` with a clip region already set to the
653 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
654 /// widgets that want to avoid redrawing themselves completely can get the full
655 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
656 /// get a finer-grained representation of the dirty region with
657 /// `cairo_copy_clip_rectangle_list()`.
658 ///
659 ///
660 ///
661 ///
662 /// #### `enter-notify-event`
663 /// The ::enter-notify-event will be emitted when the pointer enters
664 /// the `widget`'s window.
665 ///
666 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
667 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
668 ///
669 /// This signal will be sent to the grab widget if there is one.
670 ///
671 ///
672 ///
673 ///
674 /// #### `event`
675 /// The GTK+ main loop will emit three signals for each GDK event delivered
676 /// to a widget: one generic ::event signal, another, more specific,
677 /// signal that matches the type of event delivered (e.g.
678 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
679 /// [`event-after`][struct@crate::Widget#event-after] signal.
680 ///
681 ///
682 ///
683 ///
684 /// #### `event-after`
685 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
686 /// the second more specific signal, ::event-after will be emitted
687 /// regardless of the previous two signals handlers return values.
688 ///
689 ///
690 ///
691 ///
692 /// #### `focus`
693 ///
694 ///
695 ///
696 /// #### `focus-in-event`
697 /// The ::focus-in-event signal will be emitted when the keyboard focus
698 /// enters the `widget`'s window.
699 ///
700 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
701 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
702 ///
703 ///
704 ///
705 ///
706 /// #### `focus-out-event`
707 /// The ::focus-out-event signal will be emitted when the keyboard focus
708 /// leaves the `widget`'s window.
709 ///
710 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
711 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
712 ///
713 ///
714 ///
715 ///
716 /// #### `grab-broken-event`
717 /// Emitted when a pointer or keyboard grab on a window belonging
718 /// to `widget` gets broken.
719 ///
720 /// On X11, this happens when the grab window becomes unviewable
721 /// (i.e. it or one of its ancestors is unmapped), or if the same
722 /// application grabs the pointer or keyboard again.
723 ///
724 ///
725 ///
726 ///
727 /// #### `grab-focus`
728 /// Action
729 ///
730 ///
731 /// #### `grab-notify`
732 /// The ::grab-notify signal is emitted when a widget becomes
733 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
734 /// another widget, or when it becomes unshadowed due to a grab
735 /// being removed.
736 ///
737 /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
738 /// grab widget in the grab stack of its window group is not
739 /// its ancestor.
740 ///
741 ///
742 ///
743 ///
744 /// #### `hide`
745 /// The ::hide signal is emitted when `widget` is hidden, for example with
746 /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
747 ///
748 ///
749 ///
750 ///
751 /// #### `hierarchy-changed`
752 /// The ::hierarchy-changed signal is emitted when the
753 /// anchored state of a widget changes. A widget is
754 /// “anchored” when its toplevel
755 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
756 /// a widget changes from un-anchored to anchored or vice-versa.
757 ///
758 ///
759 ///
760 ///
761 /// #### `key-press-event`
762 /// The ::key-press-event signal is emitted when a key is pressed. The signal
763 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
764 ///
765 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
766 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
767 ///
768 /// This signal will be sent to the grab widget if there is one.
769 ///
770 ///
771 ///
772 ///
773 /// #### `key-release-event`
774 /// The ::key-release-event signal is emitted when a key is released.
775 ///
776 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
777 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
778 ///
779 /// This signal will be sent to the grab widget if there is one.
780 ///
781 ///
782 ///
783 ///
784 /// #### `keynav-failed`
785 /// Gets emitted if keyboard navigation fails.
786 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
787 ///
788 ///
789 ///
790 ///
791 /// #### `leave-notify-event`
792 /// The ::leave-notify-event will be emitted when the pointer leaves
793 /// the `widget`'s window.
794 ///
795 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
796 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
797 ///
798 /// This signal will be sent to the grab widget if there is one.
799 ///
800 ///
801 ///
802 ///
803 /// #### `map`
804 /// The ::map signal is emitted when `widget` is going to be mapped, that is
805 /// when the widget is visible (which is controlled with
806 /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
807 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
808 /// be emitted.
809 ///
810 /// The ::map signal can be used to determine whether a widget will be drawn,
811 /// for instance it can resume an animation that was stopped during the
812 /// emission of [`unmap`][struct@crate::Widget#unmap].
813 ///
814 ///
815 ///
816 ///
817 /// #### `map-event`
818 /// The ::map-event signal will be emitted when the `widget`'s window is
819 /// mapped. A window is mapped when it becomes visible on the screen.
820 ///
821 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
822 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
823 /// automatically for all new windows.
824 ///
825 ///
826 ///
827 ///
828 /// #### `mnemonic-activate`
829 /// The default handler for this signal activates `widget` if `group_cycling`
830 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
831 ///
832 ///
833 ///
834 ///
835 /// #### `motion-notify-event`
836 /// The ::motion-notify-event signal is emitted when the pointer moves
837 /// over the widget's [`gdk::Window`][crate::gdk::Window].
838 ///
839 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
840 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
841 ///
842 /// This signal will be sent to the grab widget if there is one.
843 ///
844 ///
845 ///
846 ///
847 /// #### `move-focus`
848 /// Action
849 ///
850 ///
851 /// #### `parent-set`
852 /// The ::parent-set signal is emitted when a new parent
853 /// has been set on a widget.
854 ///
855 ///
856 ///
857 ///
858 /// #### `popup-menu`
859 /// This signal gets emitted whenever a widget should pop up a context
860 /// menu. This usually happens through the standard key binding mechanism;
861 /// by pressing a certain key while a widget is focused, the user can cause
862 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
863 /// a menu with clipboard commands. See the
864 /// [Popup Menu Migration Checklist][checklist-popup-menu]
865 /// for an example of how to use this signal.
866 ///
867 /// Action
868 ///
869 ///
870 /// #### `property-notify-event`
871 /// The ::property-notify-event signal will be emitted when a property on
872 /// the `widget`'s window has been changed or deleted.
873 ///
874 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
875 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
876 ///
877 ///
878 ///
879 ///
880 /// #### `proximity-in-event`
881 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
882 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
883 ///
884 /// This signal will be sent to the grab widget if there is one.
885 ///
886 ///
887 ///
888 ///
889 /// #### `proximity-out-event`
890 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
891 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
892 ///
893 /// This signal will be sent to the grab widget if there is one.
894 ///
895 ///
896 ///
897 ///
898 /// #### `query-tooltip`
899 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
900 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
901 /// focus in keyboard mode.
902 ///
903 /// Using the given coordinates, the signal handler should determine
904 /// whether a tooltip should be shown for `widget`. If this is the case
905 /// [`true`] should be returned, [`false`] otherwise. Note that if
906 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
907 /// should not be used.
908 ///
909 /// The signal handler is free to manipulate `tooltip` with the therefore
910 /// destined function calls.
911 ///
912 ///
913 ///
914 ///
915 /// #### `realize`
916 /// The ::realize signal is emitted when `widget` is associated with a
917 /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
918 /// widget has been mapped (that is, it is going to be drawn).
919 ///
920 ///
921 ///
922 ///
923 /// #### `screen-changed`
924 /// The ::screen-changed signal gets emitted when the
925 /// screen of a widget has changed.
926 ///
927 ///
928 ///
929 ///
930 /// #### `scroll-event`
931 /// The ::scroll-event signal is emitted when a button in the 4 to 7
932 /// range is pressed. Wheel mice are usually configured to generate
933 /// button press events for buttons 4 and 5 when the wheel is turned.
934 ///
935 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
936 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
937 ///
938 /// This signal will be sent to the grab widget if there is one.
939 ///
940 ///
941 ///
942 ///
943 /// #### `selection-clear-event`
944 /// The ::selection-clear-event signal will be emitted when the
945 /// the `widget`'s window has lost ownership of a selection.
946 ///
947 ///
948 ///
949 ///
950 /// #### `selection-get`
951 ///
952 ///
953 ///
954 /// #### `selection-notify-event`
955 ///
956 ///
957 ///
958 /// #### `selection-received`
959 ///
960 ///
961 ///
962 /// #### `selection-request-event`
963 /// The ::selection-request-event signal will be emitted when
964 /// another client requests ownership of the selection owned by
965 /// the `widget`'s window.
966 ///
967 ///
968 ///
969 ///
970 /// #### `show`
971 /// The ::show signal is emitted when `widget` is shown, for example with
972 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
973 ///
974 ///
975 ///
976 ///
977 /// #### `show-help`
978 /// Action
979 ///
980 ///
981 /// #### `size-allocate`
982 ///
983 ///
984 ///
985 /// #### `state-changed`
986 /// The ::state-changed signal is emitted when the widget state changes.
987 /// See `gtk_widget_get_state()`.
988 ///
989 ///
990 ///
991 ///
992 /// #### `state-flags-changed`
993 /// The ::state-flags-changed signal is emitted when the widget state
994 /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
995 ///
996 ///
997 ///
998 ///
999 /// #### `style-set`
1000 /// The ::style-set signal is emitted when a new style has been set
1001 /// on a widget. Note that style-modifying functions like
1002 /// `gtk_widget_modify_base()` also cause this signal to be emitted.
1003 ///
1004 /// Note that this signal is emitted for changes to the deprecated
1005 /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
1006 /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
1007 ///
1008 ///
1009 ///
1010 ///
1011 /// #### `style-updated`
1012 /// The ::style-updated signal is a convenience signal that is emitted when the
1013 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
1014 /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
1015 ///
1016 /// Note that style-modifying functions like `gtk_widget_override_color()` also
1017 /// cause this signal to be emitted.
1018 ///
1019 ///
1020 ///
1021 ///
1022 /// #### `touch-event`
1023 ///
1024 ///
1025 ///
1026 /// #### `unmap`
1027 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
1028 /// means that either it or any of its parents up to the toplevel widget have
1029 /// been set as hidden.
1030 ///
1031 /// As ::unmap indicates that a widget will not be shown any longer, it can be
1032 /// used to, for example, stop an animation on the widget.
1033 ///
1034 ///
1035 ///
1036 ///
1037 /// #### `unmap-event`
1038 /// The ::unmap-event signal will be emitted when the `widget`'s window is
1039 /// unmapped. A window is unmapped when it becomes invisible on the screen.
1040 ///
1041 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1042 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1043 /// automatically for all new windows.
1044 ///
1045 ///
1046 ///
1047 ///
1048 /// #### `unrealize`
1049 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
1050 /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
1051 /// called or the widget has been unmapped (that is, it is going to be
1052 /// hidden).
1053 ///
1054 ///
1055 ///
1056 ///
1057 /// #### `visibility-notify-event`
1058 /// The ::visibility-notify-event will be emitted when the `widget`'s
1059 /// window is obscured or unobscured.
1060 ///
1061 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1062 /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
1063 ///
1064 ///
1065 ///
1066 ///
1067 /// #### `window-state-event`
1068 /// The ::window-state-event will be emitted when the state of the
1069 /// toplevel window associated to the `widget` changes.
1070 ///
1071 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
1072 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
1073 /// this mask automatically for all new windows.
1074 ///
1075 ///
1076 /// </details>
1077 ///
1078 /// # Implements
1079 ///
1080 /// [`ListBoxExt`][trait@crate::prelude::ListBoxExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ListBoxExtManual`][trait@crate::prelude::ListBoxExtManual], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
1081 #[doc(alias = "GtkListBox")]
1082 pub struct ListBox(Object<ffi::GtkListBox, ffi::GtkListBoxClass>) @extends Container, Widget, @implements Buildable;
1083
1084 match fn {
1085 type_ => || ffi::gtk_list_box_get_type(),
1086 }
1087}
1088
1089impl ListBox {
1090 pub const NONE: Option<&'static ListBox> = None;
1091
1092 /// Creates a new [`ListBox`][crate::ListBox] container.
1093 ///
1094 /// # Returns
1095 ///
1096 /// a new [`ListBox`][crate::ListBox]
1097 #[doc(alias = "gtk_list_box_new")]
1098 pub fn new() -> ListBox {
1099 assert_initialized_main_thread!();
1100 unsafe { Widget::from_glib_none(ffi::gtk_list_box_new()).unsafe_cast() }
1101 }
1102
1103 // rustdoc-stripper-ignore-next
1104 /// Creates a new builder-pattern struct instance to construct [`ListBox`] objects.
1105 ///
1106 /// This method returns an instance of [`ListBoxBuilder`](crate::builders::ListBoxBuilder) which can be used to create [`ListBox`] objects.
1107 pub fn builder() -> ListBoxBuilder {
1108 ListBoxBuilder::new()
1109 }
1110}
1111
1112impl Default for ListBox {
1113 fn default() -> Self {
1114 Self::new()
1115 }
1116}
1117
1118// rustdoc-stripper-ignore-next
1119/// A [builder-pattern] type to construct [`ListBox`] objects.
1120///
1121/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1122#[must_use = "The builder must be built to be used"]
1123pub struct ListBoxBuilder {
1124 builder: glib::object::ObjectBuilder<'static, ListBox>,
1125}
1126
1127impl ListBoxBuilder {
1128 fn new() -> Self {
1129 Self {
1130 builder: glib::object::Object::builder(),
1131 }
1132 }
1133
1134 pub fn activate_on_single_click(self, activate_on_single_click: bool) -> Self {
1135 Self {
1136 builder: self
1137 .builder
1138 .property("activate-on-single-click", activate_on_single_click),
1139 }
1140 }
1141
1142 pub fn selection_mode(self, selection_mode: SelectionMode) -> Self {
1143 Self {
1144 builder: self.builder.property("selection-mode", selection_mode),
1145 }
1146 }
1147
1148 pub fn border_width(self, border_width: u32) -> Self {
1149 Self {
1150 builder: self.builder.property("border-width", border_width),
1151 }
1152 }
1153
1154 pub fn child(self, child: &impl IsA<Widget>) -> Self {
1155 Self {
1156 builder: self.builder.property("child", child.clone().upcast()),
1157 }
1158 }
1159
1160 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
1161 Self {
1162 builder: self.builder.property("resize-mode", resize_mode),
1163 }
1164 }
1165
1166 pub fn app_paintable(self, app_paintable: bool) -> Self {
1167 Self {
1168 builder: self.builder.property("app-paintable", app_paintable),
1169 }
1170 }
1171
1172 pub fn can_default(self, can_default: bool) -> Self {
1173 Self {
1174 builder: self.builder.property("can-default", can_default),
1175 }
1176 }
1177
1178 pub fn can_focus(self, can_focus: bool) -> Self {
1179 Self {
1180 builder: self.builder.property("can-focus", can_focus),
1181 }
1182 }
1183
1184 pub fn events(self, events: gdk::EventMask) -> Self {
1185 Self {
1186 builder: self.builder.property("events", events),
1187 }
1188 }
1189
1190 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
1191 pub fn expand(self, expand: bool) -> Self {
1192 Self {
1193 builder: self.builder.property("expand", expand),
1194 }
1195 }
1196
1197 /// Whether the widget should grab focus when it is clicked with the mouse.
1198 ///
1199 /// This property is only relevant for widgets that can take focus.
1200 ///
1201 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
1202 /// GtkComboBox) implemented this property individually.
1203 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1204 Self {
1205 builder: self.builder.property("focus-on-click", focus_on_click),
1206 }
1207 }
1208
1209 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
1210 pub fn halign(self, halign: Align) -> Self {
1211 Self {
1212 builder: self.builder.property("halign", halign),
1213 }
1214 }
1215
1216 pub fn has_default(self, has_default: bool) -> Self {
1217 Self {
1218 builder: self.builder.property("has-default", has_default),
1219 }
1220 }
1221
1222 pub fn has_focus(self, has_focus: bool) -> Self {
1223 Self {
1224 builder: self.builder.property("has-focus", has_focus),
1225 }
1226 }
1227
1228 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
1229 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
1230 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
1231 /// whether it will provide a tooltip or not.
1232 ///
1233 /// Note that setting this property to [`true`] for the first time will change
1234 /// the event masks of the GdkWindows of this widget to include leave-notify
1235 /// and motion-notify events. This cannot and will not be undone when the
1236 /// property is set to [`false`] again.
1237 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1238 Self {
1239 builder: self.builder.property("has-tooltip", has_tooltip),
1240 }
1241 }
1242
1243 pub fn height_request(self, height_request: i32) -> Self {
1244 Self {
1245 builder: self.builder.property("height-request", height_request),
1246 }
1247 }
1248
1249 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
1250 pub fn hexpand(self, hexpand: bool) -> Self {
1251 Self {
1252 builder: self.builder.property("hexpand", hexpand),
1253 }
1254 }
1255
1256 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1257 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1258 Self {
1259 builder: self.builder.property("hexpand-set", hexpand_set),
1260 }
1261 }
1262
1263 pub fn is_focus(self, is_focus: bool) -> Self {
1264 Self {
1265 builder: self.builder.property("is-focus", is_focus),
1266 }
1267 }
1268
1269 /// Sets all four sides' margin at once. If read, returns max
1270 /// margin on any side.
1271 pub fn margin(self, margin: i32) -> Self {
1272 Self {
1273 builder: self.builder.property("margin", margin),
1274 }
1275 }
1276
1277 /// Margin on bottom side of widget.
1278 ///
1279 /// This property adds margin outside of the widget's normal size
1280 /// request, the margin will be added in addition to the size from
1281 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1282 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1283 Self {
1284 builder: self.builder.property("margin-bottom", margin_bottom),
1285 }
1286 }
1287
1288 /// Margin on end of widget, horizontally. This property supports
1289 /// left-to-right and right-to-left text directions.
1290 ///
1291 /// This property adds margin outside of the widget's normal size
1292 /// request, the margin will be added in addition to the size from
1293 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1294 pub fn margin_end(self, margin_end: i32) -> Self {
1295 Self {
1296 builder: self.builder.property("margin-end", margin_end),
1297 }
1298 }
1299
1300 /// Margin on start of widget, horizontally. This property supports
1301 /// left-to-right and right-to-left text directions.
1302 ///
1303 /// This property adds margin outside of the widget's normal size
1304 /// request, the margin will be added in addition to the size from
1305 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1306 pub fn margin_start(self, margin_start: i32) -> Self {
1307 Self {
1308 builder: self.builder.property("margin-start", margin_start),
1309 }
1310 }
1311
1312 /// Margin on top side of widget.
1313 ///
1314 /// This property adds margin outside of the widget's normal size
1315 /// request, the margin will be added in addition to the size from
1316 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1317 pub fn margin_top(self, margin_top: i32) -> Self {
1318 Self {
1319 builder: self.builder.property("margin-top", margin_top),
1320 }
1321 }
1322
1323 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1324 Self {
1325 builder: self.builder.property("name", name.into()),
1326 }
1327 }
1328
1329 pub fn no_show_all(self, no_show_all: bool) -> Self {
1330 Self {
1331 builder: self.builder.property("no-show-all", no_show_all),
1332 }
1333 }
1334
1335 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1336 /// more details about window opacity.
1337 ///
1338 /// Before 3.8 this was only available in GtkWindow
1339 pub fn opacity(self, opacity: f64) -> Self {
1340 Self {
1341 builder: self.builder.property("opacity", opacity),
1342 }
1343 }
1344
1345 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1346 Self {
1347 builder: self.builder.property("parent", parent.clone().upcast()),
1348 }
1349 }
1350
1351 pub fn receives_default(self, receives_default: bool) -> Self {
1352 Self {
1353 builder: self.builder.property("receives-default", receives_default),
1354 }
1355 }
1356
1357 pub fn sensitive(self, sensitive: bool) -> Self {
1358 Self {
1359 builder: self.builder.property("sensitive", sensitive),
1360 }
1361 }
1362
1363 /// Sets the text of tooltip to be the given string, which is marked up
1364 /// with the [Pango text markup language][PangoMarkupFormat].
1365 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1366 ///
1367 /// This is a convenience property which will take care of getting the
1368 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1369 /// will automatically be set to [`true`] and there will be taken care of
1370 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1371 ///
1372 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1373 /// are set, the last one wins.
1374 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1375 Self {
1376 builder: self
1377 .builder
1378 .property("tooltip-markup", tooltip_markup.into()),
1379 }
1380 }
1381
1382 /// Sets the text of tooltip to be the given string.
1383 ///
1384 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1385 ///
1386 /// This is a convenience property which will take care of getting the
1387 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1388 /// will automatically be set to [`true`] and there will be taken care of
1389 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1390 ///
1391 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1392 /// are set, the last one wins.
1393 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1394 Self {
1395 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1396 }
1397 }
1398
1399 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1400 pub fn valign(self, valign: Align) -> Self {
1401 Self {
1402 builder: self.builder.property("valign", valign),
1403 }
1404 }
1405
1406 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1407 pub fn vexpand(self, vexpand: bool) -> Self {
1408 Self {
1409 builder: self.builder.property("vexpand", vexpand),
1410 }
1411 }
1412
1413 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1414 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1415 Self {
1416 builder: self.builder.property("vexpand-set", vexpand_set),
1417 }
1418 }
1419
1420 pub fn visible(self, visible: bool) -> Self {
1421 Self {
1422 builder: self.builder.property("visible", visible),
1423 }
1424 }
1425
1426 pub fn width_request(self, width_request: i32) -> Self {
1427 Self {
1428 builder: self.builder.property("width-request", width_request),
1429 }
1430 }
1431
1432 // rustdoc-stripper-ignore-next
1433 /// Build the [`ListBox`].
1434 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1435 pub fn build(self) -> ListBox {
1436 assert_initialized_main_thread!();
1437 self.builder.build()
1438 }
1439}
1440
1441/// Trait containing all [`struct@ListBox`] methods.
1442///
1443/// # Implementors
1444///
1445/// [`ListBox`][struct@crate::ListBox]
1446pub trait ListBoxExt: IsA<ListBox> + 'static {
1447 /// Binds `model` to `self`.
1448 ///
1449 /// If `self` was already bound to a model, that previous binding is
1450 /// destroyed.
1451 ///
1452 /// The contents of `self` are cleared and then filled with widgets that
1453 /// represent items from `model`. `self` is updated whenever `model` changes.
1454 /// If `model` is [`None`], `self` is left empty.
1455 ///
1456 /// It is undefined to add or remove widgets directly (for example, with
1457 /// [`insert()`][Self::insert()] or [`ContainerExt::add()`][crate::prelude::ContainerExt::add()]) while `self` is bound to a
1458 /// model.
1459 ///
1460 /// Note that using a model is incompatible with the filtering and sorting
1461 /// functionality in GtkListBox. When using a model, filtering and sorting
1462 /// should be implemented by the model.
1463 /// ## `model`
1464 /// the [`gio::ListModel`][crate::gio::ListModel] to be bound to `self`
1465 /// ## `create_widget_func`
1466 /// a function that creates widgets for items
1467 /// or [`None`] in case you also passed [`None`] as `model`
1468 #[doc(alias = "gtk_list_box_bind_model")]
1469 fn bind_model<P: Fn(&glib::Object) -> Widget + 'static>(
1470 &self,
1471 model: Option<&impl IsA<gio::ListModel>>,
1472 create_widget_func: P,
1473 ) {
1474 let create_widget_func_data: Box_<P> = Box_::new(create_widget_func);
1475 unsafe extern "C" fn create_widget_func_func<P: Fn(&glib::Object) -> Widget + 'static>(
1476 item: *mut glib::gobject_ffi::GObject,
1477 user_data: glib::ffi::gpointer,
1478 ) -> *mut ffi::GtkWidget {
1479 unsafe {
1480 let item = from_glib_borrow(item);
1481 let callback = &*(user_data as *mut P);
1482 (*callback)(&item).to_glib_full()
1483 }
1484 }
1485 let create_widget_func = Some(create_widget_func_func::<P> as _);
1486 unsafe extern "C" fn user_data_free_func_func<P: Fn(&glib::Object) -> Widget + 'static>(
1487 data: glib::ffi::gpointer,
1488 ) {
1489 unsafe {
1490 let _callback = Box_::from_raw(data as *mut P);
1491 }
1492 }
1493 let destroy_call4 = Some(user_data_free_func_func::<P> as _);
1494 let super_callback0: Box_<P> = create_widget_func_data;
1495 unsafe {
1496 ffi::gtk_list_box_bind_model(
1497 self.as_ref().to_glib_none().0,
1498 model.map(|p| p.as_ref()).to_glib_none().0,
1499 create_widget_func,
1500 Box_::into_raw(super_callback0) as *mut _,
1501 destroy_call4,
1502 );
1503 }
1504 }
1505
1506 /// This is a helper function for implementing DnD onto a [`ListBox`][crate::ListBox].
1507 /// The passed in `row` will be highlighted via [`WidgetExt::drag_highlight()`][crate::prelude::WidgetExt::drag_highlight()],
1508 /// and any previously highlighted row will be unhighlighted.
1509 ///
1510 /// The row will also be unhighlighted when the widget gets
1511 /// a drag leave event.
1512 /// ## `row`
1513 /// a [`ListBoxRow`][crate::ListBoxRow]
1514 #[doc(alias = "gtk_list_box_drag_highlight_row")]
1515 fn drag_highlight_row(&self, row: &impl IsA<ListBoxRow>) {
1516 unsafe {
1517 ffi::gtk_list_box_drag_highlight_row(
1518 self.as_ref().to_glib_none().0,
1519 row.as_ref().to_glib_none().0,
1520 );
1521 }
1522 }
1523
1524 /// If a row has previously been highlighted via [`drag_highlight_row()`][Self::drag_highlight_row()]
1525 /// it will have the highlight removed.
1526 #[doc(alias = "gtk_list_box_drag_unhighlight_row")]
1527 fn drag_unhighlight_row(&self) {
1528 unsafe {
1529 ffi::gtk_list_box_drag_unhighlight_row(self.as_ref().to_glib_none().0);
1530 }
1531 }
1532
1533 /// Returns whether rows activate on single clicks.
1534 ///
1535 /// # Returns
1536 ///
1537 /// [`true`] if rows are activated on single click, [`false`] otherwise
1538 #[doc(alias = "gtk_list_box_get_activate_on_single_click")]
1539 #[doc(alias = "get_activate_on_single_click")]
1540 #[doc(alias = "activate-on-single-click")]
1541 fn activates_on_single_click(&self) -> bool {
1542 unsafe {
1543 from_glib(ffi::gtk_list_box_get_activate_on_single_click(
1544 self.as_ref().to_glib_none().0,
1545 ))
1546 }
1547 }
1548
1549 /// Gets the adjustment (if any) that the widget uses to
1550 /// for vertical scrolling.
1551 ///
1552 /// # Returns
1553 ///
1554 /// the adjustment
1555 #[doc(alias = "gtk_list_box_get_adjustment")]
1556 #[doc(alias = "get_adjustment")]
1557 fn adjustment(&self) -> Option<Adjustment> {
1558 unsafe {
1559 from_glib_none(ffi::gtk_list_box_get_adjustment(
1560 self.as_ref().to_glib_none().0,
1561 ))
1562 }
1563 }
1564
1565 /// Gets the n-th child in the list (not counting headers).
1566 /// If `_index` is negative or larger than the number of items in the
1567 /// list, [`None`] is returned.
1568 /// ## `index_`
1569 /// the index of the row
1570 ///
1571 /// # Returns
1572 ///
1573 /// the child [`Widget`][crate::Widget] or [`None`]
1574 #[doc(alias = "gtk_list_box_get_row_at_index")]
1575 #[doc(alias = "get_row_at_index")]
1576 fn row_at_index(&self, index_: i32) -> Option<ListBoxRow> {
1577 unsafe {
1578 from_glib_none(ffi::gtk_list_box_get_row_at_index(
1579 self.as_ref().to_glib_none().0,
1580 index_,
1581 ))
1582 }
1583 }
1584
1585 /// Gets the row at the `y` position.
1586 /// ## `y`
1587 /// position
1588 ///
1589 /// # Returns
1590 ///
1591 /// the row or [`None`]
1592 /// in case no row exists for the given y coordinate.
1593 #[doc(alias = "gtk_list_box_get_row_at_y")]
1594 #[doc(alias = "get_row_at_y")]
1595 fn row_at_y(&self, y: i32) -> Option<ListBoxRow> {
1596 unsafe {
1597 from_glib_none(ffi::gtk_list_box_get_row_at_y(
1598 self.as_ref().to_glib_none().0,
1599 y,
1600 ))
1601 }
1602 }
1603
1604 /// Gets the selected row.
1605 ///
1606 /// Note that the box may allow multiple selection, in which
1607 /// case you should use [`selected_foreach()`][Self::selected_foreach()] to
1608 /// find all selected rows.
1609 ///
1610 /// # Returns
1611 ///
1612 /// the selected row
1613 #[doc(alias = "gtk_list_box_get_selected_row")]
1614 #[doc(alias = "get_selected_row")]
1615 fn selected_row(&self) -> Option<ListBoxRow> {
1616 unsafe {
1617 from_glib_none(ffi::gtk_list_box_get_selected_row(
1618 self.as_ref().to_glib_none().0,
1619 ))
1620 }
1621 }
1622
1623 /// Creates a list of all selected children.
1624 ///
1625 /// # Returns
1626 ///
1627 ///
1628 /// A `GList` containing the [`Widget`][crate::Widget] for each selected child.
1629 /// Free with `g_list_free()` when done.
1630 #[doc(alias = "gtk_list_box_get_selected_rows")]
1631 #[doc(alias = "get_selected_rows")]
1632 fn selected_rows(&self) -> Vec<ListBoxRow> {
1633 unsafe {
1634 FromGlibPtrContainer::from_glib_container(ffi::gtk_list_box_get_selected_rows(
1635 self.as_ref().to_glib_none().0,
1636 ))
1637 }
1638 }
1639
1640 /// Gets the selection mode of the listbox.
1641 ///
1642 /// # Returns
1643 ///
1644 /// a [`SelectionMode`][crate::SelectionMode]
1645 #[doc(alias = "gtk_list_box_get_selection_mode")]
1646 #[doc(alias = "get_selection_mode")]
1647 #[doc(alias = "selection-mode")]
1648 fn selection_mode(&self) -> SelectionMode {
1649 unsafe {
1650 from_glib(ffi::gtk_list_box_get_selection_mode(
1651 self.as_ref().to_glib_none().0,
1652 ))
1653 }
1654 }
1655
1656 /// Insert the `child` into the `self` at `position`. If a sort function is
1657 /// set, the widget will actually be inserted at the calculated position and
1658 /// this function has the same effect of [`ContainerExt::add()`][crate::prelude::ContainerExt::add()].
1659 ///
1660 /// If `position` is -1, or larger than the total number of items in the
1661 /// `self`, then the `child` will be appended to the end.
1662 /// ## `child`
1663 /// the [`Widget`][crate::Widget] to add
1664 /// ## `position`
1665 /// the position to insert `child` in
1666 #[doc(alias = "gtk_list_box_insert")]
1667 fn insert(&self, child: &impl IsA<Widget>, position: i32) {
1668 unsafe {
1669 ffi::gtk_list_box_insert(
1670 self.as_ref().to_glib_none().0,
1671 child.as_ref().to_glib_none().0,
1672 position,
1673 );
1674 }
1675 }
1676
1677 /// Update the filtering for all rows. Call this when result
1678 /// of the filter function on the `self` is changed due
1679 /// to an external factor. For instance, this would be used
1680 /// if the filter function just looked for a specific search
1681 /// string and the entry with the search string has changed.
1682 #[doc(alias = "gtk_list_box_invalidate_filter")]
1683 fn invalidate_filter(&self) {
1684 unsafe {
1685 ffi::gtk_list_box_invalidate_filter(self.as_ref().to_glib_none().0);
1686 }
1687 }
1688
1689 /// Update the separators for all rows. Call this when result
1690 /// of the header function on the `self` is changed due
1691 /// to an external factor.
1692 #[doc(alias = "gtk_list_box_invalidate_headers")]
1693 fn invalidate_headers(&self) {
1694 unsafe {
1695 ffi::gtk_list_box_invalidate_headers(self.as_ref().to_glib_none().0);
1696 }
1697 }
1698
1699 /// Update the sorting for all rows. Call this when result
1700 /// of the sort function on the `self` is changed due
1701 /// to an external factor.
1702 #[doc(alias = "gtk_list_box_invalidate_sort")]
1703 fn invalidate_sort(&self) {
1704 unsafe {
1705 ffi::gtk_list_box_invalidate_sort(self.as_ref().to_glib_none().0);
1706 }
1707 }
1708
1709 /// Prepend a widget to the list. If a sort function is set, the widget will
1710 /// actually be inserted at the calculated position and this function has the
1711 /// same effect of [`ContainerExt::add()`][crate::prelude::ContainerExt::add()].
1712 /// ## `child`
1713 /// the [`Widget`][crate::Widget] to add
1714 #[doc(alias = "gtk_list_box_prepend")]
1715 fn prepend(&self, child: &impl IsA<Widget>) {
1716 unsafe {
1717 ffi::gtk_list_box_prepend(
1718 self.as_ref().to_glib_none().0,
1719 child.as_ref().to_glib_none().0,
1720 );
1721 }
1722 }
1723
1724 /// Select all children of `self`, if the selection mode allows it.
1725 #[doc(alias = "gtk_list_box_select_all")]
1726 fn select_all(&self) {
1727 unsafe {
1728 ffi::gtk_list_box_select_all(self.as_ref().to_glib_none().0);
1729 }
1730 }
1731
1732 /// Make `row` the currently selected row.
1733 /// ## `row`
1734 /// The row to select or [`None`]
1735 #[doc(alias = "gtk_list_box_select_row")]
1736 fn select_row(&self, row: Option<&impl IsA<ListBoxRow>>) {
1737 unsafe {
1738 ffi::gtk_list_box_select_row(
1739 self.as_ref().to_glib_none().0,
1740 row.map(|p| p.as_ref()).to_glib_none().0,
1741 );
1742 }
1743 }
1744
1745 /// Calls a function for each selected child.
1746 ///
1747 /// Note that the selection cannot be modified from within this function.
1748 /// ## `func`
1749 /// the function to call for each selected child
1750 #[doc(alias = "gtk_list_box_selected_foreach")]
1751 fn selected_foreach<P: FnMut(&ListBox, &ListBoxRow)>(&self, func: P) {
1752 let mut func_data: P = func;
1753 unsafe extern "C" fn func_func<P: FnMut(&ListBox, &ListBoxRow)>(
1754 box_: *mut ffi::GtkListBox,
1755 row: *mut ffi::GtkListBoxRow,
1756 user_data: glib::ffi::gpointer,
1757 ) {
1758 unsafe {
1759 let box_ = from_glib_borrow(box_);
1760 let row = from_glib_borrow(row);
1761 let callback = user_data as *mut P;
1762 (*callback)(&box_, &row)
1763 }
1764 }
1765 let func = Some(func_func::<P> as _);
1766 let super_callback0: &mut P = &mut func_data;
1767 unsafe {
1768 ffi::gtk_list_box_selected_foreach(
1769 self.as_ref().to_glib_none().0,
1770 func,
1771 super_callback0 as *mut _ as *mut _,
1772 );
1773 }
1774 }
1775
1776 /// If `single` is [`true`], rows will be activated when you click on them,
1777 /// otherwise you need to double-click.
1778 /// ## `single`
1779 /// a boolean
1780 #[doc(alias = "gtk_list_box_set_activate_on_single_click")]
1781 #[doc(alias = "activate-on-single-click")]
1782 fn set_activate_on_single_click(&self, single: bool) {
1783 unsafe {
1784 ffi::gtk_list_box_set_activate_on_single_click(
1785 self.as_ref().to_glib_none().0,
1786 single.into_glib(),
1787 );
1788 }
1789 }
1790
1791 /// Sets the adjustment (if any) that the widget uses to
1792 /// for vertical scrolling. For instance, this is used
1793 /// to get the page size for PageUp/Down key handling.
1794 ///
1795 /// In the normal case when the `self` is packed inside
1796 /// a [`ScrolledWindow`][crate::ScrolledWindow] the adjustment from that will
1797 /// be picked up automatically, so there is no need
1798 /// to manually do that.
1799 /// ## `adjustment`
1800 /// the adjustment, or [`None`]
1801 #[doc(alias = "gtk_list_box_set_adjustment")]
1802 fn set_adjustment(&self, adjustment: Option<&impl IsA<Adjustment>>) {
1803 unsafe {
1804 ffi::gtk_list_box_set_adjustment(
1805 self.as_ref().to_glib_none().0,
1806 adjustment.map(|p| p.as_ref()).to_glib_none().0,
1807 );
1808 }
1809 }
1810
1811 /// By setting a filter function on the `self` one can decide dynamically which
1812 /// of the rows to show. For instance, to implement a search function on a list that
1813 /// filters the original list to only show the matching rows.
1814 ///
1815 /// The `filter_func` will be called for each row after the call, and it will
1816 /// continue to be called each time a row changes (via [`ListBoxRowExt::changed()`][crate::prelude::ListBoxRowExt::changed()]) or
1817 /// when [`invalidate_filter()`][Self::invalidate_filter()] is called.
1818 ///
1819 /// Note that using a filter function is incompatible with using a model
1820 /// (see [`bind_model()`][Self::bind_model()]).
1821 /// ## `filter_func`
1822 /// callback that lets you filter which rows to show
1823 #[doc(alias = "gtk_list_box_set_filter_func")]
1824 fn set_filter_func(&self, filter_func: Option<Box_<dyn Fn(&ListBoxRow) -> bool + 'static>>) {
1825 let filter_func_data: Box_<Option<Box_<dyn Fn(&ListBoxRow) -> bool + 'static>>> =
1826 Box_::new(filter_func);
1827 unsafe extern "C" fn filter_func_func(
1828 row: *mut ffi::GtkListBoxRow,
1829 user_data: glib::ffi::gpointer,
1830 ) -> glib::ffi::gboolean {
1831 unsafe {
1832 let row = from_glib_borrow(row);
1833 let callback =
1834 &*(user_data as *mut Option<Box_<dyn Fn(&ListBoxRow) -> bool + 'static>>);
1835 if let Some(ref callback) = *callback {
1836 callback(&row)
1837 } else {
1838 panic!("cannot get closure...")
1839 }
1840 .into_glib()
1841 }
1842 }
1843 let filter_func = if filter_func_data.is_some() {
1844 Some(filter_func_func as _)
1845 } else {
1846 None
1847 };
1848 unsafe extern "C" fn destroy_func(data: glib::ffi::gpointer) {
1849 unsafe {
1850 let _callback = Box_::from_raw(
1851 data as *mut Option<Box_<dyn Fn(&ListBoxRow) -> bool + 'static>>,
1852 );
1853 }
1854 }
1855 let destroy_call3 = Some(destroy_func as _);
1856 let super_callback0: Box_<Option<Box_<dyn Fn(&ListBoxRow) -> bool + 'static>>> =
1857 filter_func_data;
1858 unsafe {
1859 ffi::gtk_list_box_set_filter_func(
1860 self.as_ref().to_glib_none().0,
1861 filter_func,
1862 Box_::into_raw(super_callback0) as *mut _,
1863 destroy_call3,
1864 );
1865 }
1866 }
1867
1868 /// By setting a header function on the `self` one can dynamically add headers
1869 /// in front of rows, depending on the contents of the row and its position in the list.
1870 /// For instance, one could use it to add headers in front of the first item of a
1871 /// new kind, in a list sorted by the kind.
1872 ///
1873 /// The `update_header` can look at the current header widget using [`ListBoxRowExt::header()`][crate::prelude::ListBoxRowExt::header()]
1874 /// and either update the state of the widget as needed, or set a new one using
1875 /// [`ListBoxRowExt::set_header()`][crate::prelude::ListBoxRowExt::set_header()]. If no header is needed, set the header to [`None`].
1876 ///
1877 /// Note that you may get many calls `update_header` to this for a particular row when e.g.
1878 /// changing things that don’t affect the header. In this case it is important for performance
1879 /// to not blindly replace an existing header with an identical one.
1880 ///
1881 /// The `update_header` function will be called for each row after the call, and it will
1882 /// continue to be called each time a row changes (via [`ListBoxRowExt::changed()`][crate::prelude::ListBoxRowExt::changed()]) and when
1883 /// the row before changes (either by [`ListBoxRowExt::changed()`][crate::prelude::ListBoxRowExt::changed()] on the previous row, or when
1884 /// the previous row becomes a different row). It is also called for all rows when
1885 /// [`invalidate_headers()`][Self::invalidate_headers()] is called.
1886 /// ## `update_header`
1887 /// callback that lets you add row headers
1888 #[doc(alias = "gtk_list_box_set_header_func")]
1889 fn set_header_func(
1890 &self,
1891 update_header: Option<Box_<dyn Fn(&ListBoxRow, Option<&ListBoxRow>) + 'static>>,
1892 ) {
1893 let update_header_data: Box_<
1894 Option<Box_<dyn Fn(&ListBoxRow, Option<&ListBoxRow>) + 'static>>,
1895 > = Box_::new(update_header);
1896 unsafe extern "C" fn update_header_func(
1897 row: *mut ffi::GtkListBoxRow,
1898 before: *mut ffi::GtkListBoxRow,
1899 user_data: glib::ffi::gpointer,
1900 ) {
1901 unsafe {
1902 let row = from_glib_borrow(row);
1903 let before: Borrowed<Option<ListBoxRow>> = from_glib_borrow(before);
1904 let callback = &*(user_data
1905 as *mut Option<Box_<dyn Fn(&ListBoxRow, Option<&ListBoxRow>) + 'static>>);
1906 if let Some(ref callback) = *callback {
1907 callback(&row, before.as_ref().as_ref())
1908 } else {
1909 panic!("cannot get closure...")
1910 }
1911 }
1912 }
1913 let update_header = if update_header_data.is_some() {
1914 Some(update_header_func as _)
1915 } else {
1916 None
1917 };
1918 unsafe extern "C" fn destroy_func(data: glib::ffi::gpointer) {
1919 unsafe {
1920 let _callback = Box_::from_raw(
1921 data as *mut Option<Box_<dyn Fn(&ListBoxRow, Option<&ListBoxRow>) + 'static>>,
1922 );
1923 }
1924 }
1925 let destroy_call3 = Some(destroy_func as _);
1926 let super_callback0: Box_<
1927 Option<Box_<dyn Fn(&ListBoxRow, Option<&ListBoxRow>) + 'static>>,
1928 > = update_header_data;
1929 unsafe {
1930 ffi::gtk_list_box_set_header_func(
1931 self.as_ref().to_glib_none().0,
1932 update_header,
1933 Box_::into_raw(super_callback0) as *mut _,
1934 destroy_call3,
1935 );
1936 }
1937 }
1938
1939 /// Sets the placeholder widget that is shown in the list when
1940 /// it doesn't display any visible children.
1941 /// ## `placeholder`
1942 /// a [`Widget`][crate::Widget] or [`None`]
1943 #[doc(alias = "gtk_list_box_set_placeholder")]
1944 fn set_placeholder(&self, placeholder: Option<&impl IsA<Widget>>) {
1945 unsafe {
1946 ffi::gtk_list_box_set_placeholder(
1947 self.as_ref().to_glib_none().0,
1948 placeholder.map(|p| p.as_ref()).to_glib_none().0,
1949 );
1950 }
1951 }
1952
1953 /// Sets how selection works in the listbox.
1954 /// See [`SelectionMode`][crate::SelectionMode] for details.
1955 /// ## `mode`
1956 /// The [`SelectionMode`][crate::SelectionMode]
1957 #[doc(alias = "gtk_list_box_set_selection_mode")]
1958 #[doc(alias = "selection-mode")]
1959 fn set_selection_mode(&self, mode: SelectionMode) {
1960 unsafe {
1961 ffi::gtk_list_box_set_selection_mode(self.as_ref().to_glib_none().0, mode.into_glib());
1962 }
1963 }
1964
1965 /// By setting a sort function on the `self` one can dynamically reorder the rows
1966 /// of the list, based on the contents of the rows.
1967 ///
1968 /// The `sort_func` will be called for each row after the call, and will continue to
1969 /// be called each time a row changes (via [`ListBoxRowExt::changed()`][crate::prelude::ListBoxRowExt::changed()]) and when
1970 /// [`invalidate_sort()`][Self::invalidate_sort()] is called.
1971 ///
1972 /// Note that using a sort function is incompatible with using a model
1973 /// (see [`bind_model()`][Self::bind_model()]).
1974 /// ## `sort_func`
1975 /// the sort function
1976 #[doc(alias = "gtk_list_box_set_sort_func")]
1977 fn set_sort_func(
1978 &self,
1979 sort_func: Option<Box_<dyn Fn(&ListBoxRow, &ListBoxRow) -> i32 + 'static>>,
1980 ) {
1981 let sort_func_data: Box_<Option<Box_<dyn Fn(&ListBoxRow, &ListBoxRow) -> i32 + 'static>>> =
1982 Box_::new(sort_func);
1983 unsafe extern "C" fn sort_func_func(
1984 row1: *mut ffi::GtkListBoxRow,
1985 row2: *mut ffi::GtkListBoxRow,
1986 user_data: glib::ffi::gpointer,
1987 ) -> std::ffi::c_int {
1988 unsafe {
1989 let row1 = from_glib_borrow(row1);
1990 let row2 = from_glib_borrow(row2);
1991 let callback = &*(user_data
1992 as *mut Option<Box_<dyn Fn(&ListBoxRow, &ListBoxRow) -> i32 + 'static>>);
1993 if let Some(ref callback) = *callback {
1994 callback(&row1, &row2)
1995 } else {
1996 panic!("cannot get closure...")
1997 }
1998 }
1999 }
2000 let sort_func = if sort_func_data.is_some() {
2001 Some(sort_func_func as _)
2002 } else {
2003 None
2004 };
2005 unsafe extern "C" fn destroy_func(data: glib::ffi::gpointer) {
2006 unsafe {
2007 let _callback = Box_::from_raw(
2008 data as *mut Option<Box_<dyn Fn(&ListBoxRow, &ListBoxRow) -> i32 + 'static>>,
2009 );
2010 }
2011 }
2012 let destroy_call3 = Some(destroy_func as _);
2013 let super_callback0: Box_<Option<Box_<dyn Fn(&ListBoxRow, &ListBoxRow) -> i32 + 'static>>> =
2014 sort_func_data;
2015 unsafe {
2016 ffi::gtk_list_box_set_sort_func(
2017 self.as_ref().to_glib_none().0,
2018 sort_func,
2019 Box_::into_raw(super_callback0) as *mut _,
2020 destroy_call3,
2021 );
2022 }
2023 }
2024
2025 /// Unselect all children of `self`, if the selection mode allows it.
2026 #[doc(alias = "gtk_list_box_unselect_all")]
2027 fn unselect_all(&self) {
2028 unsafe {
2029 ffi::gtk_list_box_unselect_all(self.as_ref().to_glib_none().0);
2030 }
2031 }
2032
2033 /// Unselects a single row of `self`, if the selection mode allows it.
2034 /// ## `row`
2035 /// the row to unselected
2036 #[doc(alias = "gtk_list_box_unselect_row")]
2037 fn unselect_row(&self, row: &impl IsA<ListBoxRow>) {
2038 unsafe {
2039 ffi::gtk_list_box_unselect_row(
2040 self.as_ref().to_glib_none().0,
2041 row.as_ref().to_glib_none().0,
2042 );
2043 }
2044 }
2045
2046 #[doc(alias = "activate-cursor-row")]
2047 fn connect_activate_cursor_row<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2048 unsafe extern "C" fn activate_cursor_row_trampoline<
2049 P: IsA<ListBox>,
2050 F: Fn(&P) + 'static,
2051 >(
2052 this: *mut ffi::GtkListBox,
2053 f: glib::ffi::gpointer,
2054 ) {
2055 unsafe {
2056 let f: &F = &*(f as *const F);
2057 f(ListBox::from_glib_borrow(this).unsafe_cast_ref())
2058 }
2059 }
2060 unsafe {
2061 let f: Box_<F> = Box_::new(f);
2062 connect_raw(
2063 self.as_ptr() as *mut _,
2064 c"activate-cursor-row".as_ptr(),
2065 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2066 activate_cursor_row_trampoline::<Self, F> as *const (),
2067 )),
2068 Box_::into_raw(f),
2069 )
2070 }
2071 }
2072
2073 fn emit_activate_cursor_row(&self) {
2074 self.emit_by_name::<()>("activate-cursor-row", &[]);
2075 }
2076
2077 #[doc(alias = "move-cursor")]
2078 fn connect_move_cursor<F: Fn(&Self, MovementStep, i32) + 'static>(
2079 &self,
2080 f: F,
2081 ) -> SignalHandlerId {
2082 unsafe extern "C" fn move_cursor_trampoline<
2083 P: IsA<ListBox>,
2084 F: Fn(&P, MovementStep, i32) + 'static,
2085 >(
2086 this: *mut ffi::GtkListBox,
2087 object: ffi::GtkMovementStep,
2088 p0: std::ffi::c_int,
2089 f: glib::ffi::gpointer,
2090 ) {
2091 unsafe {
2092 let f: &F = &*(f as *const F);
2093 f(
2094 ListBox::from_glib_borrow(this).unsafe_cast_ref(),
2095 from_glib(object),
2096 p0,
2097 )
2098 }
2099 }
2100 unsafe {
2101 let f: Box_<F> = Box_::new(f);
2102 connect_raw(
2103 self.as_ptr() as *mut _,
2104 c"move-cursor".as_ptr(),
2105 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2106 move_cursor_trampoline::<Self, F> as *const (),
2107 )),
2108 Box_::into_raw(f),
2109 )
2110 }
2111 }
2112
2113 fn emit_move_cursor(&self, object: MovementStep, p0: i32) {
2114 self.emit_by_name::<()>("move-cursor", &[&object, &p0]);
2115 }
2116
2117 /// The ::row-activated signal is emitted when a row has been activated by the user.
2118 /// ## `row`
2119 /// the activated row
2120 #[doc(alias = "row-activated")]
2121 fn connect_row_activated<F: Fn(&Self, &ListBoxRow) + 'static>(&self, f: F) -> SignalHandlerId {
2122 unsafe extern "C" fn row_activated_trampoline<
2123 P: IsA<ListBox>,
2124 F: Fn(&P, &ListBoxRow) + 'static,
2125 >(
2126 this: *mut ffi::GtkListBox,
2127 row: *mut ffi::GtkListBoxRow,
2128 f: glib::ffi::gpointer,
2129 ) {
2130 unsafe {
2131 let f: &F = &*(f as *const F);
2132 f(
2133 ListBox::from_glib_borrow(this).unsafe_cast_ref(),
2134 &from_glib_borrow(row),
2135 )
2136 }
2137 }
2138 unsafe {
2139 let f: Box_<F> = Box_::new(f);
2140 connect_raw(
2141 self.as_ptr() as *mut _,
2142 c"row-activated".as_ptr(),
2143 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2144 row_activated_trampoline::<Self, F> as *const (),
2145 )),
2146 Box_::into_raw(f),
2147 )
2148 }
2149 }
2150
2151 /// The ::row-selected signal is emitted when a new row is selected, or
2152 /// (with a [`None`] `row`) when the selection is cleared.
2153 ///
2154 /// When the `box_` is using [`SelectionMode::Multiple`][crate::SelectionMode::Multiple], this signal will not
2155 /// give you the full picture of selection changes, and you should use
2156 /// the [`selected-rows-changed`][struct@crate::ListBox#selected-rows-changed] signal instead.
2157 /// ## `row`
2158 /// the selected row
2159 #[doc(alias = "row-selected")]
2160 fn connect_row_selected<F: Fn(&Self, Option<&ListBoxRow>) + 'static>(
2161 &self,
2162 f: F,
2163 ) -> SignalHandlerId {
2164 unsafe extern "C" fn row_selected_trampoline<
2165 P: IsA<ListBox>,
2166 F: Fn(&P, Option<&ListBoxRow>) + 'static,
2167 >(
2168 this: *mut ffi::GtkListBox,
2169 row: *mut ffi::GtkListBoxRow,
2170 f: glib::ffi::gpointer,
2171 ) {
2172 unsafe {
2173 let f: &F = &*(f as *const F);
2174 f(
2175 ListBox::from_glib_borrow(this).unsafe_cast_ref(),
2176 Option::<ListBoxRow>::from_glib_borrow(row)
2177 .as_ref()
2178 .as_ref(),
2179 )
2180 }
2181 }
2182 unsafe {
2183 let f: Box_<F> = Box_::new(f);
2184 connect_raw(
2185 self.as_ptr() as *mut _,
2186 c"row-selected".as_ptr(),
2187 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2188 row_selected_trampoline::<Self, F> as *const (),
2189 )),
2190 Box_::into_raw(f),
2191 )
2192 }
2193 }
2194
2195 /// The ::select-all signal is a [keybinding signal][GtkBindingSignal]
2196 /// which gets emitted to select all children of the box, if the selection
2197 /// mode permits it.
2198 ///
2199 /// The default bindings for this signal is Ctrl-a.
2200 #[doc(alias = "select-all")]
2201 fn connect_select_all<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2202 unsafe extern "C" fn select_all_trampoline<P: IsA<ListBox>, F: Fn(&P) + 'static>(
2203 this: *mut ffi::GtkListBox,
2204 f: glib::ffi::gpointer,
2205 ) {
2206 unsafe {
2207 let f: &F = &*(f as *const F);
2208 f(ListBox::from_glib_borrow(this).unsafe_cast_ref())
2209 }
2210 }
2211 unsafe {
2212 let f: Box_<F> = Box_::new(f);
2213 connect_raw(
2214 self.as_ptr() as *mut _,
2215 c"select-all".as_ptr(),
2216 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2217 select_all_trampoline::<Self, F> as *const (),
2218 )),
2219 Box_::into_raw(f),
2220 )
2221 }
2222 }
2223
2224 fn emit_select_all(&self) {
2225 self.emit_by_name::<()>("select-all", &[]);
2226 }
2227
2228 /// The ::selected-rows-changed signal is emitted when the
2229 /// set of selected rows changes.
2230 #[doc(alias = "selected-rows-changed")]
2231 fn connect_selected_rows_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2232 unsafe extern "C" fn selected_rows_changed_trampoline<
2233 P: IsA<ListBox>,
2234 F: Fn(&P) + 'static,
2235 >(
2236 this: *mut ffi::GtkListBox,
2237 f: glib::ffi::gpointer,
2238 ) {
2239 unsafe {
2240 let f: &F = &*(f as *const F);
2241 f(ListBox::from_glib_borrow(this).unsafe_cast_ref())
2242 }
2243 }
2244 unsafe {
2245 let f: Box_<F> = Box_::new(f);
2246 connect_raw(
2247 self.as_ptr() as *mut _,
2248 c"selected-rows-changed".as_ptr(),
2249 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2250 selected_rows_changed_trampoline::<Self, F> as *const (),
2251 )),
2252 Box_::into_raw(f),
2253 )
2254 }
2255 }
2256
2257 #[doc(alias = "toggle-cursor-row")]
2258 fn connect_toggle_cursor_row<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2259 unsafe extern "C" fn toggle_cursor_row_trampoline<P: IsA<ListBox>, F: Fn(&P) + 'static>(
2260 this: *mut ffi::GtkListBox,
2261 f: glib::ffi::gpointer,
2262 ) {
2263 unsafe {
2264 let f: &F = &*(f as *const F);
2265 f(ListBox::from_glib_borrow(this).unsafe_cast_ref())
2266 }
2267 }
2268 unsafe {
2269 let f: Box_<F> = Box_::new(f);
2270 connect_raw(
2271 self.as_ptr() as *mut _,
2272 c"toggle-cursor-row".as_ptr(),
2273 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2274 toggle_cursor_row_trampoline::<Self, F> as *const (),
2275 )),
2276 Box_::into_raw(f),
2277 )
2278 }
2279 }
2280
2281 fn emit_toggle_cursor_row(&self) {
2282 self.emit_by_name::<()>("toggle-cursor-row", &[]);
2283 }
2284
2285 /// The ::unselect-all signal is a [keybinding signal][GtkBindingSignal]
2286 /// which gets emitted to unselect all children of the box, if the selection
2287 /// mode permits it.
2288 ///
2289 /// The default bindings for this signal is Ctrl-Shift-a.
2290 #[doc(alias = "unselect-all")]
2291 fn connect_unselect_all<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2292 unsafe extern "C" fn unselect_all_trampoline<P: IsA<ListBox>, F: Fn(&P) + 'static>(
2293 this: *mut ffi::GtkListBox,
2294 f: glib::ffi::gpointer,
2295 ) {
2296 unsafe {
2297 let f: &F = &*(f as *const F);
2298 f(ListBox::from_glib_borrow(this).unsafe_cast_ref())
2299 }
2300 }
2301 unsafe {
2302 let f: Box_<F> = Box_::new(f);
2303 connect_raw(
2304 self.as_ptr() as *mut _,
2305 c"unselect-all".as_ptr(),
2306 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2307 unselect_all_trampoline::<Self, F> as *const (),
2308 )),
2309 Box_::into_raw(f),
2310 )
2311 }
2312 }
2313
2314 fn emit_unselect_all(&self) {
2315 self.emit_by_name::<()>("unselect-all", &[]);
2316 }
2317
2318 #[doc(alias = "activate-on-single-click")]
2319 fn connect_activate_on_single_click_notify<F: Fn(&Self) + 'static>(
2320 &self,
2321 f: F,
2322 ) -> SignalHandlerId {
2323 unsafe extern "C" fn notify_activate_on_single_click_trampoline<
2324 P: IsA<ListBox>,
2325 F: Fn(&P) + 'static,
2326 >(
2327 this: *mut ffi::GtkListBox,
2328 _param_spec: glib::ffi::gpointer,
2329 f: glib::ffi::gpointer,
2330 ) {
2331 unsafe {
2332 let f: &F = &*(f as *const F);
2333 f(ListBox::from_glib_borrow(this).unsafe_cast_ref())
2334 }
2335 }
2336 unsafe {
2337 let f: Box_<F> = Box_::new(f);
2338 connect_raw(
2339 self.as_ptr() as *mut _,
2340 c"notify::activate-on-single-click".as_ptr(),
2341 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2342 notify_activate_on_single_click_trampoline::<Self, F> as *const (),
2343 )),
2344 Box_::into_raw(f),
2345 )
2346 }
2347 }
2348
2349 #[doc(alias = "selection-mode")]
2350 fn connect_selection_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2351 unsafe extern "C" fn notify_selection_mode_trampoline<
2352 P: IsA<ListBox>,
2353 F: Fn(&P) + 'static,
2354 >(
2355 this: *mut ffi::GtkListBox,
2356 _param_spec: glib::ffi::gpointer,
2357 f: glib::ffi::gpointer,
2358 ) {
2359 unsafe {
2360 let f: &F = &*(f as *const F);
2361 f(ListBox::from_glib_borrow(this).unsafe_cast_ref())
2362 }
2363 }
2364 unsafe {
2365 let f: Box_<F> = Box_::new(f);
2366 connect_raw(
2367 self.as_ptr() as *mut _,
2368 c"notify::selection-mode".as_ptr(),
2369 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2370 notify_selection_mode_trampoline::<Self, F> as *const (),
2371 )),
2372 Box_::into_raw(f),
2373 )
2374 }
2375 }
2376}
2377
2378impl<O: IsA<ListBox>> ListBoxExt for O {}