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