gtk4/auto/grid_view.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6 ffi, Accessible, AccessibleRole, Adjustment, Align, Buildable, ConstraintTarget, LayoutManager,
7 ListBase, ListItemFactory, Orientable, Orientation, Overflow, Scrollable, ScrollablePolicy,
8 SelectionModel, Widget,
9};
10#[cfg(feature = "v4_12")]
11#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
12use crate::{ListScrollFlags, ListTabBehavior, ScrollInfo};
13use glib::{
14 object::ObjectType as _,
15 prelude::*,
16 signal::{connect_raw, SignalHandlerId},
17 translate::*,
18};
19use std::boxed::Box as Box_;
20
21glib::wrapper! {
22 /// [`GridView`][crate::GridView] presents a large dynamic grid of items.
23 ///
24 /// [`GridView`][crate::GridView] uses its factory to generate one child widget for each
25 /// visible item and shows them in a grid. The orientation of the grid view
26 /// determines if the grid reflows vertically or horizontally.
27 ///
28 /// [`GridView`][crate::GridView] allows the user to select items according to the selection
29 /// characteristics of the model. For models that allow multiple selected items,
30 /// it is possible to turn on _rubberband selection_, using
31 /// [`enable-rubberband`][struct@crate::GridView#enable-rubberband].
32 ///
33 /// To learn more about the list widget framework, see the
34 /// [overview](section-list-widget.html).
35 ///
36 /// # Actions
37 ///
38 /// [`GridView`][crate::GridView] defines a set of built-in actions:
39 ///
40 /// - `list.activate-item` activates the item at given position by emitting the
41 /// the [`activate`][struct@crate::GridView#activate] signal.
42 ///
43 /// # CSS nodes
44 ///
45 /// ```text
46 /// gridview
47 /// ├── child[.activatable]
48 /// │
49 /// ├── child[.activatable]
50 /// │
51 /// ┊
52 /// ╰── [rubberband]
53 /// ```
54 ///
55 /// [`GridView`][crate::GridView] uses a single CSS node with name `gridview`. Each child uses
56 /// a single CSS node with name `child`. If the [`activatable`][struct@crate::ListItem#activatable]
57 /// property is set, the corresponding row will have the `.activatable` style
58 /// class. For rubberband selection, a subnode with name `rubberband` is used.
59 ///
60 /// # Accessibility
61 ///
62 /// [`GridView`][crate::GridView] uses the [`AccessibleRole::Grid`][crate::AccessibleRole::Grid] role, and the items
63 /// use the [`AccessibleRole::GridCell`][crate::AccessibleRole::GridCell] role.
64 ///
65 /// ## Properties
66 ///
67 ///
68 /// #### `enable-rubberband`
69 /// Allow rubberband selection.
70 ///
71 /// Readable | Writeable
72 ///
73 ///
74 /// #### `factory`
75 /// Factory for populating list items.
76 ///
77 /// The factory must be for configuring [`ListItem`][crate::ListItem] objects.
78 ///
79 /// Readable | Writeable
80 ///
81 ///
82 /// #### `max-columns`
83 /// Maximum number of columns per row.
84 ///
85 /// If this number is smaller than [`min-columns`][struct@crate::GridView#min-columns],
86 /// that value is used instead.
87 ///
88 /// Readable | Writeable
89 ///
90 ///
91 /// #### `min-columns`
92 /// Minimum number of columns per row.
93 ///
94 /// Readable | Writeable
95 ///
96 ///
97 /// #### `model`
98 /// Model for the items displayed.
99 ///
100 /// Readable | Writeable
101 ///
102 ///
103 /// #### `single-click-activate`
104 /// Activate rows on single click and select them on hover.
105 ///
106 /// Readable | Writeable
107 ///
108 ///
109 /// #### `tab-behavior`
110 /// Behavior of the <kbd>Tab</kbd> key
111 ///
112 /// Readable | Writeable
113 /// <details><summary><h4>ListBase</h4></summary>
114 ///
115 ///
116 /// #### `orientation`
117 /// The orientation of the list. See GtkOrientable:orientation
118 /// for details.
119 ///
120 /// Readable | Writeable
121 /// </details>
122 /// <details><summary><h4>Widget</h4></summary>
123 ///
124 ///
125 /// #### `can-focus`
126 /// Whether the widget or any of its descendents can accept
127 /// the input focus.
128 ///
129 /// This property is meant to be set by widget implementations,
130 /// typically in their instance init function.
131 ///
132 /// Readable | Writeable
133 ///
134 ///
135 /// #### `can-target`
136 /// Whether the widget can receive pointer events.
137 ///
138 /// Readable | Writeable
139 ///
140 ///
141 /// #### `css-classes`
142 /// A list of css classes applied to this widget.
143 ///
144 /// Readable | Writeable
145 ///
146 ///
147 /// #### `css-name`
148 /// The name of this widget in the CSS tree.
149 ///
150 /// This property is meant to be set by widget implementations,
151 /// typically in their instance init function.
152 ///
153 /// Readable | Writeable | Construct Only
154 ///
155 ///
156 /// #### `cursor`
157 /// The cursor used by @widget.
158 ///
159 /// Readable | Writeable
160 ///
161 ///
162 /// #### `focus-on-click`
163 /// Whether the widget should grab focus when it is clicked with the mouse.
164 ///
165 /// This property is only relevant for widgets that can take focus.
166 ///
167 /// Readable | Writeable
168 ///
169 ///
170 /// #### `focusable`
171 /// Whether this widget itself will accept the input focus.
172 ///
173 /// Readable | Writeable
174 ///
175 ///
176 /// #### `halign`
177 /// How to distribute horizontal space if widget gets extra space.
178 ///
179 /// Readable | Writeable
180 ///
181 ///
182 /// #### `has-default`
183 /// Whether the widget is the default widget.
184 ///
185 /// Readable
186 ///
187 ///
188 /// #### `has-focus`
189 /// Whether the widget has the input focus.
190 ///
191 /// Readable
192 ///
193 ///
194 /// #### `has-tooltip`
195 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
196 /// signal on @widget.
197 ///
198 /// A true value indicates that @widget can have a tooltip, in this case
199 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
200 /// determine whether it will provide a tooltip or not.
201 ///
202 /// Readable | Writeable
203 ///
204 ///
205 /// #### `height-request`
206 /// Overrides for height request of the widget.
207 ///
208 /// If this is -1, the natural request will be used.
209 ///
210 /// Readable | Writeable
211 ///
212 ///
213 /// #### `hexpand`
214 /// Whether to expand horizontally.
215 ///
216 /// Readable | Writeable
217 ///
218 ///
219 /// #### `hexpand-set`
220 /// Whether to use the `hexpand` property.
221 ///
222 /// Readable | Writeable
223 ///
224 ///
225 /// #### `layout-manager`
226 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
227 /// the preferred size of the widget, and allocate its children.
228 ///
229 /// This property is meant to be set by widget implementations,
230 /// typically in their instance init function.
231 ///
232 /// Readable | Writeable
233 ///
234 ///
235 /// #### `limit-events`
236 /// Makes this widget act like a modal dialog, with respect to
237 /// event delivery.
238 ///
239 /// Global event controllers will not handle events with targets
240 /// inside the widget, unless they are set up to ignore propagation
241 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
242 ///
243 /// Readable | Writeable
244 ///
245 ///
246 /// #### `margin-bottom`
247 /// Margin on bottom side of widget.
248 ///
249 /// This property adds margin outside of the widget's normal size
250 /// request, the margin will be added in addition to the size from
251 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
252 ///
253 /// Readable | Writeable
254 ///
255 ///
256 /// #### `margin-end`
257 /// Margin on end of widget, horizontally.
258 ///
259 /// This property supports left-to-right and right-to-left text
260 /// directions.
261 ///
262 /// This property adds margin outside of the widget's normal size
263 /// request, the margin will be added in addition to the size from
264 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
265 ///
266 /// Readable | Writeable
267 ///
268 ///
269 /// #### `margin-start`
270 /// Margin on start of widget, horizontally.
271 ///
272 /// This property supports left-to-right and right-to-left text
273 /// directions.
274 ///
275 /// This property adds margin outside of the widget's normal size
276 /// request, the margin will be added in addition to the size from
277 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
278 ///
279 /// Readable | Writeable
280 ///
281 ///
282 /// #### `margin-top`
283 /// Margin on top side of widget.
284 ///
285 /// This property adds margin outside of the widget's normal size
286 /// request, the margin will be added in addition to the size from
287 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
288 ///
289 /// Readable | Writeable
290 ///
291 ///
292 /// #### `name`
293 /// The name of the widget.
294 ///
295 /// Readable | Writeable
296 ///
297 ///
298 /// #### `opacity`
299 /// The requested opacity of the widget.
300 ///
301 /// Readable | Writeable
302 ///
303 ///
304 /// #### `overflow`
305 /// How content outside the widget's content area is treated.
306 ///
307 /// This property is meant to be set by widget implementations,
308 /// typically in their instance init function.
309 ///
310 /// Readable | Writeable
311 ///
312 ///
313 /// #### `parent`
314 /// The parent widget of this widget.
315 ///
316 /// Readable
317 ///
318 ///
319 /// #### `receives-default`
320 /// Whether the widget will receive the default action when it is focused.
321 ///
322 /// Readable | Writeable
323 ///
324 ///
325 /// #### `root`
326 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
327 ///
328 /// This will be `NULL` if the widget is not contained in a root widget.
329 ///
330 /// Readable
331 ///
332 ///
333 /// #### `scale-factor`
334 /// The scale factor of the widget.
335 ///
336 /// Readable
337 ///
338 ///
339 /// #### `sensitive`
340 /// Whether the widget responds to input.
341 ///
342 /// Readable | Writeable
343 ///
344 ///
345 /// #### `tooltip-markup`
346 /// Sets the text of tooltip to be the given string, which is marked up
347 /// with Pango markup.
348 ///
349 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
350 ///
351 /// This is a convenience property which will take care of getting the
352 /// tooltip shown if the given string is not `NULL`:
353 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
354 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
355 /// the default signal handler.
356 ///
357 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
358 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
359 ///
360 /// Readable | Writeable
361 ///
362 ///
363 /// #### `tooltip-text`
364 /// Sets the text of tooltip to be the given string.
365 ///
366 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
367 ///
368 /// This is a convenience property which will take care of getting the
369 /// tooltip shown if the given string is not `NULL`:
370 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
371 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
372 /// the default signal handler.
373 ///
374 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
375 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
376 ///
377 /// Readable | Writeable
378 ///
379 ///
380 /// #### `valign`
381 /// How to distribute vertical space if widget gets extra space.
382 ///
383 /// Readable | Writeable
384 ///
385 ///
386 /// #### `vexpand`
387 /// Whether to expand vertically.
388 ///
389 /// Readable | Writeable
390 ///
391 ///
392 /// #### `vexpand-set`
393 /// Whether to use the `vexpand` property.
394 ///
395 /// Readable | Writeable
396 ///
397 ///
398 /// #### `visible`
399 /// Whether the widget is visible.
400 ///
401 /// Readable | Writeable
402 ///
403 ///
404 /// #### `width-request`
405 /// Overrides for width request of the widget.
406 ///
407 /// If this is -1, the natural request will be used.
408 ///
409 /// Readable | Writeable
410 /// </details>
411 /// <details><summary><h4>Accessible</h4></summary>
412 ///
413 ///
414 /// #### `accessible-role`
415 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
416 ///
417 /// The accessible role cannot be changed once set.
418 ///
419 /// Readable | Writeable
420 /// </details>
421 /// <details><summary><h4>Orientable</h4></summary>
422 ///
423 ///
424 /// #### `orientation`
425 /// The orientation of the orientable.
426 ///
427 /// Readable | Writeable
428 /// </details>
429 /// <details><summary><h4>Scrollable</h4></summary>
430 ///
431 ///
432 /// #### `hadjustment`
433 /// Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget.
434 ///
435 /// This adjustment is shared between the scrollable widget and its parent.
436 ///
437 /// Readable | Writeable | Construct
438 ///
439 ///
440 /// #### `hscroll-policy`
441 /// Determines when horizontal scrolling should start.
442 ///
443 /// Readable | Writeable
444 ///
445 ///
446 /// #### `vadjustment`
447 /// Vertical [`Adjustment`][crate::Adjustment] of the scrollable widget.
448 ///
449 /// This adjustment is shared between the scrollable widget and its parent.
450 ///
451 /// Readable | Writeable | Construct
452 ///
453 ///
454 /// #### `vscroll-policy`
455 /// Determines when vertical scrolling should start.
456 ///
457 /// Readable | Writeable
458 /// </details>
459 ///
460 /// ## Signals
461 ///
462 ///
463 /// #### `activate`
464 /// Emitted when a cell has been activated by the user,
465 /// usually via activating the GtkGridView|list.activate-item action.
466 ///
467 /// This allows for a convenient way to handle activation in a gridview.
468 /// See [`activatable`][struct@crate::ListItem#activatable] for details on how to use
469 /// this signal.
470 ///
471 ///
472 /// <details><summary><h4>Widget</h4></summary>
473 ///
474 ///
475 /// #### `destroy`
476 /// Signals that all holders of a reference to the widget should release
477 /// the reference that they hold.
478 ///
479 /// May result in finalization of the widget if all references are released.
480 ///
481 /// This signal is not suitable for saving widget state.
482 ///
483 ///
484 ///
485 ///
486 /// #### `direction-changed`
487 /// Emitted when the text direction of a widget changes.
488 ///
489 ///
490 ///
491 ///
492 /// #### `hide`
493 /// Emitted when @widget is hidden.
494 ///
495 ///
496 ///
497 ///
498 /// #### `keynav-failed`
499 /// Emitted if keyboard navigation fails.
500 ///
501 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
502 ///
503 ///
504 ///
505 ///
506 /// #### `map`
507 /// Emitted when @widget is going to be mapped.
508 ///
509 /// A widget is mapped when the widget is visible (which is controlled with
510 /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
511 /// are also visible.
512 ///
513 /// The `::map` signal can be used to determine whether a widget will be drawn,
514 /// for instance it can resume an animation that was stopped during the
515 /// emission of [`unmap`][struct@crate::Widget#unmap].
516 ///
517 ///
518 ///
519 ///
520 /// #### `mnemonic-activate`
521 /// Emitted when a widget is activated via a mnemonic.
522 ///
523 /// The default handler for this signal activates @widget if @group_cycling
524 /// is false, or just makes @widget grab focus if @group_cycling is true.
525 ///
526 ///
527 ///
528 ///
529 /// #### `move-focus`
530 /// Emitted when the focus is moved.
531 ///
532 /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
533 ///
534 /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
535 /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
536 ///
537 /// Action
538 ///
539 ///
540 /// #### `query-tooltip`
541 /// Emitted when the widget’s tooltip is about to be shown.
542 ///
543 /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
544 /// is true and the hover timeout has expired with the cursor hovering
545 /// above @widget; or emitted when @widget got focus in keyboard mode.
546 ///
547 /// Using the given coordinates, the signal handler should determine
548 /// whether a tooltip should be shown for @widget. If this is the case
549 /// true should be returned, false otherwise. Note that if @keyboard_mode
550 /// is true, the values of @x and @y are undefined and should not be used.
551 ///
552 /// The signal handler is free to manipulate @tooltip with the therefore
553 /// destined function calls.
554 ///
555 ///
556 ///
557 ///
558 /// #### `realize`
559 /// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
560 ///
561 /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
562 /// or the widget has been mapped (that is, it is going to be drawn).
563 ///
564 ///
565 ///
566 ///
567 /// #### `show`
568 /// Emitted when @widget is shown.
569 ///
570 ///
571 ///
572 ///
573 /// #### `state-flags-changed`
574 /// Emitted when the widget state changes.
575 ///
576 /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
577 ///
578 ///
579 ///
580 ///
581 /// #### `unmap`
582 /// Emitted when @widget is going to be unmapped.
583 ///
584 /// A widget is unmapped when either it or any of its parents up to the
585 /// toplevel widget have been set as hidden.
586 ///
587 /// As `::unmap` indicates that a widget will not be shown any longer,
588 /// it can be used to, for example, stop an animation on the widget.
589 ///
590 ///
591 ///
592 ///
593 /// #### `unrealize`
594 /// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
595 ///
596 /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
597 /// or the widget has been unmapped (that is, it is going to be hidden).
598 ///
599 ///
600 /// </details>
601 ///
602 /// # Implements
603 ///
604 /// [`ListBaseExt`][trait@crate::prelude::ListBaseExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`ScrollableExt`][trait@crate::prelude::ScrollableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
605 #[doc(alias = "GtkGridView")]
606 pub struct GridView(Object<ffi::GtkGridView, ffi::GtkGridViewClass>) @extends ListBase, Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable, Scrollable;
607
608 match fn {
609 type_ => || ffi::gtk_grid_view_get_type(),
610 }
611}
612
613impl GridView {
614 /// Creates a new [`GridView`][crate::GridView] that uses the given @factory for
615 /// mapping items to widgets.
616 ///
617 /// The function takes ownership of the
618 /// arguments, so you can write code like
619 /// **⚠️ The following code is in c ⚠️**
620 ///
621 /// ```c
622 /// grid_view = gtk_grid_view_new (create_model (),
623 /// gtk_builder_list_item_factory_new_from_resource ("/resource.ui"));
624 /// ```
625 /// ## `model`
626 /// the model to use
627 /// ## `factory`
628 /// The factory to populate items with
629 ///
630 /// # Returns
631 ///
632 /// a new [`GridView`][crate::GridView] using the given @model and @factory
633 #[doc(alias = "gtk_grid_view_new")]
634 pub fn new(
635 model: Option<impl IsA<SelectionModel>>,
636 factory: Option<impl IsA<ListItemFactory>>,
637 ) -> GridView {
638 assert_initialized_main_thread!();
639 unsafe {
640 Widget::from_glib_none(ffi::gtk_grid_view_new(
641 model.map(|p| p.upcast()).into_glib_ptr(),
642 factory.map(|p| p.upcast()).into_glib_ptr(),
643 ))
644 .unsafe_cast()
645 }
646 }
647
648 // rustdoc-stripper-ignore-next
649 /// Creates a new builder-pattern struct instance to construct [`GridView`] objects.
650 ///
651 /// This method returns an instance of [`GridViewBuilder`](crate::builders::GridViewBuilder) which can be used to create [`GridView`] objects.
652 pub fn builder() -> GridViewBuilder {
653 GridViewBuilder::new()
654 }
655
656 /// Returns whether rows can be selected by dragging with the mouse.
657 ///
658 /// # Returns
659 ///
660 /// [`true`] if rubberband selection is enabled
661 #[doc(alias = "gtk_grid_view_get_enable_rubberband")]
662 #[doc(alias = "get_enable_rubberband")]
663 #[doc(alias = "enable-rubberband")]
664 pub fn enables_rubberband(&self) -> bool {
665 unsafe {
666 from_glib(ffi::gtk_grid_view_get_enable_rubberband(
667 self.to_glib_none().0,
668 ))
669 }
670 }
671
672 /// Gets the factory that's currently used to populate list items.
673 ///
674 /// # Returns
675 ///
676 /// The factory in use
677 #[doc(alias = "gtk_grid_view_get_factory")]
678 #[doc(alias = "get_factory")]
679 pub fn factory(&self) -> Option<ListItemFactory> {
680 unsafe { from_glib_none(ffi::gtk_grid_view_get_factory(self.to_glib_none().0)) }
681 }
682
683 /// Gets the maximum number of columns that the grid will use.
684 ///
685 /// # Returns
686 ///
687 /// The maximum number of columns
688 #[doc(alias = "gtk_grid_view_get_max_columns")]
689 #[doc(alias = "get_max_columns")]
690 #[doc(alias = "max-columns")]
691 pub fn max_columns(&self) -> u32 {
692 unsafe { ffi::gtk_grid_view_get_max_columns(self.to_glib_none().0) }
693 }
694
695 /// Gets the minimum number of columns that the grid will use.
696 ///
697 /// # Returns
698 ///
699 /// The minimum number of columns
700 #[doc(alias = "gtk_grid_view_get_min_columns")]
701 #[doc(alias = "get_min_columns")]
702 #[doc(alias = "min-columns")]
703 pub fn min_columns(&self) -> u32 {
704 unsafe { ffi::gtk_grid_view_get_min_columns(self.to_glib_none().0) }
705 }
706
707 /// Gets the model that's currently used to read the items displayed.
708 ///
709 /// # Returns
710 ///
711 /// The model in use
712 #[doc(alias = "gtk_grid_view_get_model")]
713 #[doc(alias = "get_model")]
714 pub fn model(&self) -> Option<SelectionModel> {
715 unsafe { from_glib_none(ffi::gtk_grid_view_get_model(self.to_glib_none().0)) }
716 }
717
718 /// Returns whether items will be activated on single click and
719 /// selected on hover.
720 ///
721 /// # Returns
722 ///
723 /// [`true`] if items are activated on single click
724 #[doc(alias = "gtk_grid_view_get_single_click_activate")]
725 #[doc(alias = "get_single_click_activate")]
726 #[doc(alias = "single-click-activate")]
727 pub fn is_single_click_activate(&self) -> bool {
728 unsafe {
729 from_glib(ffi::gtk_grid_view_get_single_click_activate(
730 self.to_glib_none().0,
731 ))
732 }
733 }
734
735 /// Gets the behavior set for the <kbd>Tab</kbd> key.
736 ///
737 /// # Returns
738 ///
739 /// The behavior of the <kbd>Tab</kbd> key
740 #[cfg(feature = "v4_12")]
741 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
742 #[doc(alias = "gtk_grid_view_get_tab_behavior")]
743 #[doc(alias = "get_tab_behavior")]
744 #[doc(alias = "tab-behavior")]
745 pub fn tab_behavior(&self) -> ListTabBehavior {
746 unsafe { from_glib(ffi::gtk_grid_view_get_tab_behavior(self.to_glib_none().0)) }
747 }
748
749 /// Scrolls to the item at the given position and performs the actions
750 /// specified in @flags.
751 ///
752 /// This function works no matter if the gridview is shown or focused.
753 /// If it isn't, then the changes will take effect once that happens.
754 /// ## `pos`
755 /// position of the item. Must be less than the number of
756 /// items in the view.
757 /// ## `flags`
758 /// actions to perform
759 /// ## `scroll`
760 /// details of how to perform
761 /// the scroll operation or [`None`] to scroll into view
762 #[cfg(feature = "v4_12")]
763 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
764 #[doc(alias = "gtk_grid_view_scroll_to")]
765 pub fn scroll_to(&self, pos: u32, flags: ListScrollFlags, scroll: Option<ScrollInfo>) {
766 unsafe {
767 ffi::gtk_grid_view_scroll_to(
768 self.to_glib_none().0,
769 pos,
770 flags.into_glib(),
771 scroll.into_glib_ptr(),
772 );
773 }
774 }
775
776 /// Sets whether selections can be changed by dragging with the mouse.
777 /// ## `enable_rubberband`
778 /// [`true`] to enable rubberband selection
779 #[doc(alias = "gtk_grid_view_set_enable_rubberband")]
780 #[doc(alias = "enable-rubberband")]
781 pub fn set_enable_rubberband(&self, enable_rubberband: bool) {
782 unsafe {
783 ffi::gtk_grid_view_set_enable_rubberband(
784 self.to_glib_none().0,
785 enable_rubberband.into_glib(),
786 );
787 }
788 }
789
790 /// Sets the [`ListItemFactory`][crate::ListItemFactory] to use for populating list items.
791 /// ## `factory`
792 /// the factory to use
793 #[doc(alias = "gtk_grid_view_set_factory")]
794 #[doc(alias = "factory")]
795 pub fn set_factory(&self, factory: Option<&impl IsA<ListItemFactory>>) {
796 unsafe {
797 ffi::gtk_grid_view_set_factory(
798 self.to_glib_none().0,
799 factory.map(|p| p.as_ref()).to_glib_none().0,
800 );
801 }
802 }
803
804 /// Sets the maximum number of columns to use.
805 ///
806 /// This number must be at least 1.
807 ///
808 /// If @max_columns is smaller than the minimum set via
809 /// [`set_min_columns()`][Self::set_min_columns()], that value is used instead.
810 /// ## `max_columns`
811 /// The maximum number of columns
812 #[doc(alias = "gtk_grid_view_set_max_columns")]
813 #[doc(alias = "max-columns")]
814 pub fn set_max_columns(&self, max_columns: u32) {
815 unsafe {
816 ffi::gtk_grid_view_set_max_columns(self.to_glib_none().0, max_columns);
817 }
818 }
819
820 /// Sets the minimum number of columns to use.
821 ///
822 /// This number must be at least 1.
823 ///
824 /// If @min_columns is smaller than the minimum set via
825 /// [`set_max_columns()`][Self::set_max_columns()], that value is ignored.
826 /// ## `min_columns`
827 /// The minimum number of columns
828 #[doc(alias = "gtk_grid_view_set_min_columns")]
829 #[doc(alias = "min-columns")]
830 pub fn set_min_columns(&self, min_columns: u32) {
831 unsafe {
832 ffi::gtk_grid_view_set_min_columns(self.to_glib_none().0, min_columns);
833 }
834 }
835
836 /// Sets the model to use.
837 ///
838 /// This must be a [`SelectionModel`][crate::SelectionModel].
839 /// ## `model`
840 /// the model to use
841 #[doc(alias = "gtk_grid_view_set_model")]
842 #[doc(alias = "model")]
843 pub fn set_model(&self, model: Option<&impl IsA<SelectionModel>>) {
844 unsafe {
845 ffi::gtk_grid_view_set_model(
846 self.to_glib_none().0,
847 model.map(|p| p.as_ref()).to_glib_none().0,
848 );
849 }
850 }
851
852 /// Sets whether items should be activated on single click and
853 /// selected on hover.
854 /// ## `single_click_activate`
855 /// [`true`] to activate items on single click
856 #[doc(alias = "gtk_grid_view_set_single_click_activate")]
857 #[doc(alias = "single-click-activate")]
858 pub fn set_single_click_activate(&self, single_click_activate: bool) {
859 unsafe {
860 ffi::gtk_grid_view_set_single_click_activate(
861 self.to_glib_none().0,
862 single_click_activate.into_glib(),
863 );
864 }
865 }
866
867 /// Sets the behavior of the <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys.
868 /// ## `tab_behavior`
869 /// The desired tab behavior
870 #[cfg(feature = "v4_12")]
871 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
872 #[doc(alias = "gtk_grid_view_set_tab_behavior")]
873 #[doc(alias = "tab-behavior")]
874 pub fn set_tab_behavior(&self, tab_behavior: ListTabBehavior) {
875 unsafe {
876 ffi::gtk_grid_view_set_tab_behavior(self.to_glib_none().0, tab_behavior.into_glib());
877 }
878 }
879
880 /// Emitted when a cell has been activated by the user,
881 /// usually via activating the GtkGridView|list.activate-item action.
882 ///
883 /// This allows for a convenient way to handle activation in a gridview.
884 /// See [`activatable`][struct@crate::ListItem#activatable] for details on how to use
885 /// this signal.
886 /// ## `position`
887 /// position of item to activate
888 #[doc(alias = "activate")]
889 pub fn connect_activate<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId {
890 unsafe extern "C" fn activate_trampoline<F: Fn(&GridView, u32) + 'static>(
891 this: *mut ffi::GtkGridView,
892 position: std::ffi::c_uint,
893 f: glib::ffi::gpointer,
894 ) {
895 let f: &F = &*(f as *const F);
896 f(&from_glib_borrow(this), position)
897 }
898 unsafe {
899 let f: Box_<F> = Box_::new(f);
900 connect_raw(
901 self.as_ptr() as *mut _,
902 b"activate\0".as_ptr() as *const _,
903 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
904 activate_trampoline::<F> as *const (),
905 )),
906 Box_::into_raw(f),
907 )
908 }
909 }
910
911 #[doc(alias = "enable-rubberband")]
912 pub fn connect_enable_rubberband_notify<F: Fn(&Self) + 'static>(
913 &self,
914 f: F,
915 ) -> SignalHandlerId {
916 unsafe extern "C" fn notify_enable_rubberband_trampoline<F: Fn(&GridView) + 'static>(
917 this: *mut ffi::GtkGridView,
918 _param_spec: glib::ffi::gpointer,
919 f: glib::ffi::gpointer,
920 ) {
921 let f: &F = &*(f as *const F);
922 f(&from_glib_borrow(this))
923 }
924 unsafe {
925 let f: Box_<F> = Box_::new(f);
926 connect_raw(
927 self.as_ptr() as *mut _,
928 b"notify::enable-rubberband\0".as_ptr() as *const _,
929 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
930 notify_enable_rubberband_trampoline::<F> as *const (),
931 )),
932 Box_::into_raw(f),
933 )
934 }
935 }
936
937 #[doc(alias = "factory")]
938 pub fn connect_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
939 unsafe extern "C" fn notify_factory_trampoline<F: Fn(&GridView) + 'static>(
940 this: *mut ffi::GtkGridView,
941 _param_spec: glib::ffi::gpointer,
942 f: glib::ffi::gpointer,
943 ) {
944 let f: &F = &*(f as *const F);
945 f(&from_glib_borrow(this))
946 }
947 unsafe {
948 let f: Box_<F> = Box_::new(f);
949 connect_raw(
950 self.as_ptr() as *mut _,
951 b"notify::factory\0".as_ptr() as *const _,
952 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
953 notify_factory_trampoline::<F> as *const (),
954 )),
955 Box_::into_raw(f),
956 )
957 }
958 }
959
960 #[doc(alias = "max-columns")]
961 pub fn connect_max_columns_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
962 unsafe extern "C" fn notify_max_columns_trampoline<F: Fn(&GridView) + 'static>(
963 this: *mut ffi::GtkGridView,
964 _param_spec: glib::ffi::gpointer,
965 f: glib::ffi::gpointer,
966 ) {
967 let f: &F = &*(f as *const F);
968 f(&from_glib_borrow(this))
969 }
970 unsafe {
971 let f: Box_<F> = Box_::new(f);
972 connect_raw(
973 self.as_ptr() as *mut _,
974 b"notify::max-columns\0".as_ptr() as *const _,
975 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
976 notify_max_columns_trampoline::<F> as *const (),
977 )),
978 Box_::into_raw(f),
979 )
980 }
981 }
982
983 #[doc(alias = "min-columns")]
984 pub fn connect_min_columns_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
985 unsafe extern "C" fn notify_min_columns_trampoline<F: Fn(&GridView) + 'static>(
986 this: *mut ffi::GtkGridView,
987 _param_spec: glib::ffi::gpointer,
988 f: glib::ffi::gpointer,
989 ) {
990 let f: &F = &*(f as *const F);
991 f(&from_glib_borrow(this))
992 }
993 unsafe {
994 let f: Box_<F> = Box_::new(f);
995 connect_raw(
996 self.as_ptr() as *mut _,
997 b"notify::min-columns\0".as_ptr() as *const _,
998 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
999 notify_min_columns_trampoline::<F> as *const (),
1000 )),
1001 Box_::into_raw(f),
1002 )
1003 }
1004 }
1005
1006 #[doc(alias = "model")]
1007 pub fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1008 unsafe extern "C" fn notify_model_trampoline<F: Fn(&GridView) + 'static>(
1009 this: *mut ffi::GtkGridView,
1010 _param_spec: glib::ffi::gpointer,
1011 f: glib::ffi::gpointer,
1012 ) {
1013 let f: &F = &*(f as *const F);
1014 f(&from_glib_borrow(this))
1015 }
1016 unsafe {
1017 let f: Box_<F> = Box_::new(f);
1018 connect_raw(
1019 self.as_ptr() as *mut _,
1020 b"notify::model\0".as_ptr() as *const _,
1021 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1022 notify_model_trampoline::<F> as *const (),
1023 )),
1024 Box_::into_raw(f),
1025 )
1026 }
1027 }
1028
1029 #[doc(alias = "single-click-activate")]
1030 pub fn connect_single_click_activate_notify<F: Fn(&Self) + 'static>(
1031 &self,
1032 f: F,
1033 ) -> SignalHandlerId {
1034 unsafe extern "C" fn notify_single_click_activate_trampoline<F: Fn(&GridView) + 'static>(
1035 this: *mut ffi::GtkGridView,
1036 _param_spec: glib::ffi::gpointer,
1037 f: glib::ffi::gpointer,
1038 ) {
1039 let f: &F = &*(f as *const F);
1040 f(&from_glib_borrow(this))
1041 }
1042 unsafe {
1043 let f: Box_<F> = Box_::new(f);
1044 connect_raw(
1045 self.as_ptr() as *mut _,
1046 b"notify::single-click-activate\0".as_ptr() as *const _,
1047 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1048 notify_single_click_activate_trampoline::<F> as *const (),
1049 )),
1050 Box_::into_raw(f),
1051 )
1052 }
1053 }
1054
1055 #[cfg(feature = "v4_12")]
1056 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1057 #[doc(alias = "tab-behavior")]
1058 pub fn connect_tab_behavior_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1059 unsafe extern "C" fn notify_tab_behavior_trampoline<F: Fn(&GridView) + 'static>(
1060 this: *mut ffi::GtkGridView,
1061 _param_spec: glib::ffi::gpointer,
1062 f: glib::ffi::gpointer,
1063 ) {
1064 let f: &F = &*(f as *const F);
1065 f(&from_glib_borrow(this))
1066 }
1067 unsafe {
1068 let f: Box_<F> = Box_::new(f);
1069 connect_raw(
1070 self.as_ptr() as *mut _,
1071 b"notify::tab-behavior\0".as_ptr() as *const _,
1072 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1073 notify_tab_behavior_trampoline::<F> as *const (),
1074 )),
1075 Box_::into_raw(f),
1076 )
1077 }
1078 }
1079}
1080
1081impl Default for GridView {
1082 fn default() -> Self {
1083 glib::object::Object::new::<Self>()
1084 }
1085}
1086
1087// rustdoc-stripper-ignore-next
1088/// A [builder-pattern] type to construct [`GridView`] objects.
1089///
1090/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1091#[must_use = "The builder must be built to be used"]
1092pub struct GridViewBuilder {
1093 builder: glib::object::ObjectBuilder<'static, GridView>,
1094}
1095
1096impl GridViewBuilder {
1097 fn new() -> Self {
1098 Self {
1099 builder: glib::object::Object::builder(),
1100 }
1101 }
1102
1103 /// Allow rubberband selection.
1104 pub fn enable_rubberband(self, enable_rubberband: bool) -> Self {
1105 Self {
1106 builder: self
1107 .builder
1108 .property("enable-rubberband", enable_rubberband),
1109 }
1110 }
1111
1112 /// Factory for populating list items.
1113 ///
1114 /// The factory must be for configuring [`ListItem`][crate::ListItem] objects.
1115 pub fn factory(self, factory: &impl IsA<ListItemFactory>) -> Self {
1116 Self {
1117 builder: self.builder.property("factory", factory.clone().upcast()),
1118 }
1119 }
1120
1121 /// Maximum number of columns per row.
1122 ///
1123 /// If this number is smaller than [`min-columns`][struct@crate::GridView#min-columns],
1124 /// that value is used instead.
1125 pub fn max_columns(self, max_columns: u32) -> Self {
1126 Self {
1127 builder: self.builder.property("max-columns", max_columns),
1128 }
1129 }
1130
1131 /// Minimum number of columns per row.
1132 pub fn min_columns(self, min_columns: u32) -> Self {
1133 Self {
1134 builder: self.builder.property("min-columns", min_columns),
1135 }
1136 }
1137
1138 /// Model for the items displayed.
1139 pub fn model(self, model: &impl IsA<SelectionModel>) -> Self {
1140 Self {
1141 builder: self.builder.property("model", model.clone().upcast()),
1142 }
1143 }
1144
1145 /// Activate rows on single click and select them on hover.
1146 pub fn single_click_activate(self, single_click_activate: bool) -> Self {
1147 Self {
1148 builder: self
1149 .builder
1150 .property("single-click-activate", single_click_activate),
1151 }
1152 }
1153
1154 /// Behavior of the <kbd>Tab</kbd> key
1155 #[cfg(feature = "v4_12")]
1156 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1157 pub fn tab_behavior(self, tab_behavior: ListTabBehavior) -> Self {
1158 Self {
1159 builder: self.builder.property("tab-behavior", tab_behavior),
1160 }
1161 }
1162
1163 /// The orientation of the list. See GtkOrientable:orientation
1164 /// for details.
1165 pub fn orientation(self, orientation: Orientation) -> Self {
1166 Self {
1167 builder: self.builder.property("orientation", orientation),
1168 }
1169 }
1170
1171 /// Whether the widget or any of its descendents can accept
1172 /// the input focus.
1173 ///
1174 /// This property is meant to be set by widget implementations,
1175 /// typically in their instance init function.
1176 pub fn can_focus(self, can_focus: bool) -> Self {
1177 Self {
1178 builder: self.builder.property("can-focus", can_focus),
1179 }
1180 }
1181
1182 /// Whether the widget can receive pointer events.
1183 pub fn can_target(self, can_target: bool) -> Self {
1184 Self {
1185 builder: self.builder.property("can-target", can_target),
1186 }
1187 }
1188
1189 /// A list of css classes applied to this widget.
1190 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1191 Self {
1192 builder: self.builder.property("css-classes", css_classes.into()),
1193 }
1194 }
1195
1196 /// The name of this widget in the CSS tree.
1197 ///
1198 /// This property is meant to be set by widget implementations,
1199 /// typically in their instance init function.
1200 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1201 Self {
1202 builder: self.builder.property("css-name", css_name.into()),
1203 }
1204 }
1205
1206 /// The cursor used by @widget.
1207 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1208 Self {
1209 builder: self.builder.property("cursor", cursor.clone()),
1210 }
1211 }
1212
1213 /// Whether the widget should grab focus when it is clicked with the mouse.
1214 ///
1215 /// This property is only relevant for widgets that can take focus.
1216 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1217 Self {
1218 builder: self.builder.property("focus-on-click", focus_on_click),
1219 }
1220 }
1221
1222 /// Whether this widget itself will accept the input focus.
1223 pub fn focusable(self, focusable: bool) -> Self {
1224 Self {
1225 builder: self.builder.property("focusable", focusable),
1226 }
1227 }
1228
1229 /// How to distribute horizontal space if widget gets extra space.
1230 pub fn halign(self, halign: Align) -> Self {
1231 Self {
1232 builder: self.builder.property("halign", halign),
1233 }
1234 }
1235
1236 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1237 /// signal on @widget.
1238 ///
1239 /// A true value indicates that @widget can have a tooltip, in this case
1240 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1241 /// determine whether it will provide a tooltip or not.
1242 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1243 Self {
1244 builder: self.builder.property("has-tooltip", has_tooltip),
1245 }
1246 }
1247
1248 /// Overrides for height request of the widget.
1249 ///
1250 /// If this is -1, the natural request will be used.
1251 pub fn height_request(self, height_request: i32) -> Self {
1252 Self {
1253 builder: self.builder.property("height-request", height_request),
1254 }
1255 }
1256
1257 /// Whether to expand horizontally.
1258 pub fn hexpand(self, hexpand: bool) -> Self {
1259 Self {
1260 builder: self.builder.property("hexpand", hexpand),
1261 }
1262 }
1263
1264 /// Whether to use the `hexpand` property.
1265 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1266 Self {
1267 builder: self.builder.property("hexpand-set", hexpand_set),
1268 }
1269 }
1270
1271 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1272 /// the preferred size of the widget, and allocate its children.
1273 ///
1274 /// This property is meant to be set by widget implementations,
1275 /// typically in their instance init function.
1276 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1277 Self {
1278 builder: self
1279 .builder
1280 .property("layout-manager", layout_manager.clone().upcast()),
1281 }
1282 }
1283
1284 /// Makes this widget act like a modal dialog, with respect to
1285 /// event delivery.
1286 ///
1287 /// Global event controllers will not handle events with targets
1288 /// inside the widget, unless they are set up to ignore propagation
1289 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1290 #[cfg(feature = "v4_18")]
1291 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1292 pub fn limit_events(self, limit_events: bool) -> Self {
1293 Self {
1294 builder: self.builder.property("limit-events", limit_events),
1295 }
1296 }
1297
1298 /// Margin on bottom side of widget.
1299 ///
1300 /// This property adds margin outside of the widget's normal size
1301 /// request, the margin will be added in addition to the size from
1302 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1303 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1304 Self {
1305 builder: self.builder.property("margin-bottom", margin_bottom),
1306 }
1307 }
1308
1309 /// Margin on end of widget, horizontally.
1310 ///
1311 /// This property supports left-to-right and right-to-left text
1312 /// directions.
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_end(self, margin_end: i32) -> Self {
1318 Self {
1319 builder: self.builder.property("margin-end", margin_end),
1320 }
1321 }
1322
1323 /// Margin on start of widget, horizontally.
1324 ///
1325 /// This property supports left-to-right and right-to-left text
1326 /// directions.
1327 ///
1328 /// This property adds margin outside of the widget's normal size
1329 /// request, the margin will be added in addition to the size from
1330 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1331 pub fn margin_start(self, margin_start: i32) -> Self {
1332 Self {
1333 builder: self.builder.property("margin-start", margin_start),
1334 }
1335 }
1336
1337 /// Margin on top side of widget.
1338 ///
1339 /// This property adds margin outside of the widget's normal size
1340 /// request, the margin will be added in addition to the size from
1341 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1342 pub fn margin_top(self, margin_top: i32) -> Self {
1343 Self {
1344 builder: self.builder.property("margin-top", margin_top),
1345 }
1346 }
1347
1348 /// The name of the widget.
1349 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1350 Self {
1351 builder: self.builder.property("name", name.into()),
1352 }
1353 }
1354
1355 /// The requested opacity of the widget.
1356 pub fn opacity(self, opacity: f64) -> Self {
1357 Self {
1358 builder: self.builder.property("opacity", opacity),
1359 }
1360 }
1361
1362 /// How content outside the widget's content area is treated.
1363 ///
1364 /// This property is meant to be set by widget implementations,
1365 /// typically in their instance init function.
1366 pub fn overflow(self, overflow: Overflow) -> Self {
1367 Self {
1368 builder: self.builder.property("overflow", overflow),
1369 }
1370 }
1371
1372 /// Whether the widget will receive the default action when it is focused.
1373 pub fn receives_default(self, receives_default: bool) -> Self {
1374 Self {
1375 builder: self.builder.property("receives-default", receives_default),
1376 }
1377 }
1378
1379 /// Whether the widget responds to input.
1380 pub fn sensitive(self, sensitive: bool) -> Self {
1381 Self {
1382 builder: self.builder.property("sensitive", sensitive),
1383 }
1384 }
1385
1386 /// Sets the text of tooltip to be the given string, which is marked up
1387 /// with Pango markup.
1388 ///
1389 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1390 ///
1391 /// This is a convenience property which will take care of getting the
1392 /// tooltip shown if the given string is not `NULL`:
1393 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1394 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1395 /// the default signal handler.
1396 ///
1397 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1398 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1399 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1400 Self {
1401 builder: self
1402 .builder
1403 .property("tooltip-markup", tooltip_markup.into()),
1404 }
1405 }
1406
1407 /// Sets the text of tooltip to be the given string.
1408 ///
1409 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1410 ///
1411 /// This is a convenience property which will take care of getting the
1412 /// tooltip shown if the given string is not `NULL`:
1413 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1414 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1415 /// the default signal handler.
1416 ///
1417 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1418 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1419 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1420 Self {
1421 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1422 }
1423 }
1424
1425 /// How to distribute vertical space if widget gets extra space.
1426 pub fn valign(self, valign: Align) -> Self {
1427 Self {
1428 builder: self.builder.property("valign", valign),
1429 }
1430 }
1431
1432 /// Whether to expand vertically.
1433 pub fn vexpand(self, vexpand: bool) -> Self {
1434 Self {
1435 builder: self.builder.property("vexpand", vexpand),
1436 }
1437 }
1438
1439 /// Whether to use the `vexpand` property.
1440 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1441 Self {
1442 builder: self.builder.property("vexpand-set", vexpand_set),
1443 }
1444 }
1445
1446 /// Whether the widget is visible.
1447 pub fn visible(self, visible: bool) -> Self {
1448 Self {
1449 builder: self.builder.property("visible", visible),
1450 }
1451 }
1452
1453 /// Overrides for width request of the widget.
1454 ///
1455 /// If this is -1, the natural request will be used.
1456 pub fn width_request(self, width_request: i32) -> Self {
1457 Self {
1458 builder: self.builder.property("width-request", width_request),
1459 }
1460 }
1461
1462 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1463 ///
1464 /// The accessible role cannot be changed once set.
1465 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1466 Self {
1467 builder: self.builder.property("accessible-role", accessible_role),
1468 }
1469 }
1470
1471 /// Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget.
1472 ///
1473 /// This adjustment is shared between the scrollable widget and its parent.
1474 pub fn hadjustment(self, hadjustment: &impl IsA<Adjustment>) -> Self {
1475 Self {
1476 builder: self
1477 .builder
1478 .property("hadjustment", hadjustment.clone().upcast()),
1479 }
1480 }
1481
1482 /// Determines when horizontal scrolling should start.
1483 pub fn hscroll_policy(self, hscroll_policy: ScrollablePolicy) -> Self {
1484 Self {
1485 builder: self.builder.property("hscroll-policy", hscroll_policy),
1486 }
1487 }
1488
1489 /// Vertical [`Adjustment`][crate::Adjustment] of the scrollable widget.
1490 ///
1491 /// This adjustment is shared between the scrollable widget and its parent.
1492 pub fn vadjustment(self, vadjustment: &impl IsA<Adjustment>) -> Self {
1493 Self {
1494 builder: self
1495 .builder
1496 .property("vadjustment", vadjustment.clone().upcast()),
1497 }
1498 }
1499
1500 /// Determines when vertical scrolling should start.
1501 pub fn vscroll_policy(self, vscroll_policy: ScrollablePolicy) -> Self {
1502 Self {
1503 builder: self.builder.property("vscroll-policy", vscroll_policy),
1504 }
1505 }
1506
1507 // rustdoc-stripper-ignore-next
1508 /// Build the [`GridView`].
1509 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1510 pub fn build(self) -> GridView {
1511 assert_initialized_main_thread!();
1512 self.builder.build()
1513 }
1514}