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