gtk4/auto/column_view.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6 ffi, Accessible, AccessibleRole, Adjustment, Align, Buildable, ColumnViewColumn,
7 ConstraintTarget, LayoutManager, Overflow, Scrollable, ScrollablePolicy, SelectionModel,
8 SortType, Sorter, Widget,
9};
10#[cfg(feature = "v4_12")]
11#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
12use crate::{ListItemFactory, ListScrollFlags, ListTabBehavior, ScrollInfo};
13use glib::{
14 object::ObjectType as _,
15 prelude::*,
16 signal::{connect_raw, SignalHandlerId},
17 translate::*,
18};
19use std::boxed::Box as Box_;
20
21glib::wrapper! {
22 /// [`ColumnView`][crate::ColumnView] presents a large dynamic list of items using multiple columns
23 /// with headers.
24 ///
25 /// [`ColumnView`][crate::ColumnView] uses the factories of its columns to generate a cell widget for
26 /// each column, for each visible item and displays them together as the row for
27 /// this item.
28 ///
29 /// The [`show-row-separators`][struct@crate::ColumnView#show-row-separators] and
30 /// [`show-column-separators`][struct@crate::ColumnView#show-column-separators] properties offer a simple way
31 /// to display separators between the rows or columns.
32 ///
33 /// [`ColumnView`][crate::ColumnView] 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::ColumnView#enable-rubberband].
37 ///
38 /// The column view supports sorting that can be customized by the user by
39 /// clicking on column headers. To set this up, the [`Sorter`][crate::Sorter] returned by
40 /// [`sorter()`][Self::sorter()] must be attached to a sort model for the
41 /// data that the view is showing, and the columns must have sorters attached to
42 /// them by calling [`ColumnViewColumn::set_sorter()`][crate::ColumnViewColumn::set_sorter()]. The initial sort
43 /// order can be set with [`sort_by_column()`][Self::sort_by_column()].
44 ///
45 /// The column view also supports interactive resizing and reordering of
46 /// columns, via Drag-and-Drop of the column headers. This can be enabled or
47 /// disabled with the [`reorderable`][struct@crate::ColumnView#reorderable] and
48 /// [`resizable`][struct@crate::ColumnViewColumn#resizable] properties.
49 ///
50 /// To learn more about the list widget framework, see the
51 /// [overview](section-list-widget.html).
52 ///
53 /// # CSS nodes
54 ///
55 /// ```text
56 /// columnview[.column-separators][.rich-list][.navigation-sidebar][.data-table]
57 /// ├── header
58 /// │ ├── <column header>
59 /// ┊ ┊
60 /// │ ╰── <column header>
61 /// │
62 /// ├── listview
63 /// │
64 /// ┊
65 /// ╰── [rubberband]
66 /// ```
67 ///
68 /// [`ColumnView`][crate::ColumnView] uses a single CSS node named columnview. It may carry the
69 /// .column-separators style class, when [`show-column-separators`][struct@crate::ColumnView#show-column-separators]
70 /// property is set. Header widgets appear below a node with name header.
71 /// The rows are contained in a [`ListView`][crate::ListView] widget, so there is a listview
72 /// node with the same structure as for a standalone [`ListView`][crate::ListView] widget.
73 /// If [`show-row-separators`][struct@crate::ColumnView#show-row-separators] is set, it will be passed
74 /// on to the list view, causing its CSS node to carry the .separators style class.
75 /// For rubberband selection, a node with name rubberband is used.
76 ///
77 /// The main columnview node may also carry style classes to select
78 /// the style of [list presentation](section-list-widget.html#list-styles):
79 /// .rich-list, .navigation-sidebar or .data-table.
80 ///
81 /// # Accessibility
82 ///
83 /// [`ColumnView`][crate::ColumnView] uses the [`AccessibleRole::TreeGrid`][crate::AccessibleRole::TreeGrid] role, header title
84 /// widgets are using the [`AccessibleRole::ColumnHeader`][crate::AccessibleRole::ColumnHeader] role. The row widgets
85 /// are using the [`AccessibleRole::Row`][crate::AccessibleRole::Row] role, and individual cells are using
86 /// the [`AccessibleRole::GridCell`][crate::AccessibleRole::GridCell] role
87 ///
88 /// ## Properties
89 ///
90 ///
91 /// #### `columns`
92 /// The list of columns.
93 ///
94 /// Readable
95 ///
96 ///
97 /// #### `enable-rubberband`
98 /// Allow rubberband selection.
99 ///
100 /// Readable | Writeable
101 ///
102 ///
103 /// #### `header-factory`
104 /// Factory for creating header widgets.
105 ///
106 /// The factory must be for configuring [`ListHeader`][crate::ListHeader] objects.
107 ///
108 /// Readable | Writeable
109 ///
110 ///
111 /// #### `model`
112 /// Model for the items displayed.
113 ///
114 /// Readable | Writeable
115 ///
116 ///
117 /// #### `reorderable`
118 /// Whether columns are reorderable.
119 ///
120 /// Readable | Writeable
121 ///
122 ///
123 /// #### `row-factory`
124 /// The factory used for configuring rows.
125 ///
126 /// The factory must be for configuring [`ColumnViewRow`][crate::ColumnViewRow] objects.
127 ///
128 /// Readable | Writeable
129 ///
130 ///
131 /// #### `show-column-separators`
132 /// Show separators between columns.
133 ///
134 /// Readable | Writeable
135 ///
136 ///
137 /// #### `show-row-separators`
138 /// Show separators between rows.
139 ///
140 /// Readable | Writeable
141 ///
142 ///
143 /// #### `single-click-activate`
144 /// Activate rows on single click and select them on hover.
145 ///
146 /// Readable | Writeable
147 ///
148 ///
149 /// #### `sorter`
150 /// Sorter with the sorting choices of the user.
151 ///
152 /// Readable
153 ///
154 ///
155 /// #### `tab-behavior`
156 /// Behavior of the <kbd>Tab</kbd> key
157 ///
158 /// Readable | Writeable
159 /// <details><summary><h4>Widget</h4></summary>
160 ///
161 ///
162 /// #### `can-focus`
163 /// Whether the widget or any of its descendents can accept
164 /// the input focus.
165 ///
166 /// This property is meant to be set by widget implementations,
167 /// typically in their instance init function.
168 ///
169 /// Readable | Writeable
170 ///
171 ///
172 /// #### `can-target`
173 /// Whether the widget can receive pointer events.
174 ///
175 /// Readable | Writeable
176 ///
177 ///
178 /// #### `css-classes`
179 /// A list of css classes applied to this widget.
180 ///
181 /// Readable | Writeable
182 ///
183 ///
184 /// #### `css-name`
185 /// The name of this widget in the CSS tree.
186 ///
187 /// This property is meant to be set by widget implementations,
188 /// typically in their instance init function.
189 ///
190 /// Readable | Writeable | Construct Only
191 ///
192 ///
193 /// #### `cursor`
194 /// The cursor used by @widget.
195 ///
196 /// Readable | Writeable
197 ///
198 ///
199 /// #### `focus-on-click`
200 /// Whether the widget should grab focus when it is clicked with the mouse.
201 ///
202 /// This property is only relevant for widgets that can take focus.
203 ///
204 /// Readable | Writeable
205 ///
206 ///
207 /// #### `focusable`
208 /// Whether this widget itself will accept the input focus.
209 ///
210 /// Readable | Writeable
211 ///
212 ///
213 /// #### `halign`
214 /// How to distribute horizontal space if widget gets extra space.
215 ///
216 /// Readable | Writeable
217 ///
218 ///
219 /// #### `has-default`
220 /// Whether the widget is the default widget.
221 ///
222 /// Readable
223 ///
224 ///
225 /// #### `has-focus`
226 /// Whether the widget has the input focus.
227 ///
228 /// Readable
229 ///
230 ///
231 /// #### `has-tooltip`
232 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
233 /// signal on @widget.
234 ///
235 /// A true value indicates that @widget can have a tooltip, in this case
236 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
237 /// determine whether it will provide a tooltip or not.
238 ///
239 /// Readable | Writeable
240 ///
241 ///
242 /// #### `height-request`
243 /// Overrides for height request of the widget.
244 ///
245 /// If this is -1, the natural request will be used.
246 ///
247 /// Readable | Writeable
248 ///
249 ///
250 /// #### `hexpand`
251 /// Whether to expand horizontally.
252 ///
253 /// Readable | Writeable
254 ///
255 ///
256 /// #### `hexpand-set`
257 /// Whether to use the `hexpand` property.
258 ///
259 /// Readable | Writeable
260 ///
261 ///
262 /// #### `layout-manager`
263 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
264 /// the preferred size of the widget, and allocate its children.
265 ///
266 /// This property is meant to be set by widget implementations,
267 /// typically in their instance init function.
268 ///
269 /// Readable | Writeable
270 ///
271 ///
272 /// #### `limit-events`
273 /// Makes this widget act like a modal dialog, with respect to
274 /// event delivery.
275 ///
276 /// Global event controllers will not handle events with targets
277 /// inside the widget, unless they are set up to ignore propagation
278 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
279 ///
280 /// Readable | Writeable
281 ///
282 ///
283 /// #### `margin-bottom`
284 /// Margin on bottom side of widget.
285 ///
286 /// This property adds margin outside of the widget's normal size
287 /// request, the margin will be added in addition to the size from
288 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
289 ///
290 /// Readable | Writeable
291 ///
292 ///
293 /// #### `margin-end`
294 /// Margin on end of widget, horizontally.
295 ///
296 /// This property supports left-to-right and right-to-left text
297 /// directions.
298 ///
299 /// This property adds margin outside of the widget's normal size
300 /// request, the margin will be added in addition to the size from
301 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
302 ///
303 /// Readable | Writeable
304 ///
305 ///
306 /// #### `margin-start`
307 /// Margin on start of widget, horizontally.
308 ///
309 /// This property supports left-to-right and right-to-left text
310 /// directions.
311 ///
312 /// This property adds margin outside of the widget's normal size
313 /// request, the margin will be added in addition to the size from
314 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
315 ///
316 /// Readable | Writeable
317 ///
318 ///
319 /// #### `margin-top`
320 /// Margin on top side of widget.
321 ///
322 /// This property adds margin outside of the widget's normal size
323 /// request, the margin will be added in addition to the size from
324 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
325 ///
326 /// Readable | Writeable
327 ///
328 ///
329 /// #### `name`
330 /// The name of the widget.
331 ///
332 /// Readable | Writeable
333 ///
334 ///
335 /// #### `opacity`
336 /// The requested opacity of the widget.
337 ///
338 /// Readable | Writeable
339 ///
340 ///
341 /// #### `overflow`
342 /// How content outside the widget's content area is treated.
343 ///
344 /// This property is meant to be set by widget implementations,
345 /// typically in their instance init function.
346 ///
347 /// Readable | Writeable
348 ///
349 ///
350 /// #### `parent`
351 /// The parent widget of this widget.
352 ///
353 /// Readable
354 ///
355 ///
356 /// #### `receives-default`
357 /// Whether the widget will receive the default action when it is focused.
358 ///
359 /// Readable | Writeable
360 ///
361 ///
362 /// #### `root`
363 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
364 ///
365 /// This will be `NULL` if the widget is not contained in a root widget.
366 ///
367 /// Readable
368 ///
369 ///
370 /// #### `scale-factor`
371 /// The scale factor of the widget.
372 ///
373 /// Readable
374 ///
375 ///
376 /// #### `sensitive`
377 /// Whether the widget responds to input.
378 ///
379 /// Readable | Writeable
380 ///
381 ///
382 /// #### `tooltip-markup`
383 /// Sets the text of tooltip to be the given string, which is marked up
384 /// with Pango markup.
385 ///
386 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
387 ///
388 /// This is a convenience property which will take care of getting the
389 /// tooltip shown if the given string is not `NULL`:
390 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
391 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
392 /// the default signal handler.
393 ///
394 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
395 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
396 ///
397 /// Readable | Writeable
398 ///
399 ///
400 /// #### `tooltip-text`
401 /// Sets the text of tooltip to be the given string.
402 ///
403 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
404 ///
405 /// This is a convenience property which will take care of getting the
406 /// tooltip shown if the given string is not `NULL`:
407 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
408 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
409 /// the default signal handler.
410 ///
411 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
412 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
413 ///
414 /// Readable | Writeable
415 ///
416 ///
417 /// #### `valign`
418 /// How to distribute vertical space if widget gets extra space.
419 ///
420 /// Readable | Writeable
421 ///
422 ///
423 /// #### `vexpand`
424 /// Whether to expand vertically.
425 ///
426 /// Readable | Writeable
427 ///
428 ///
429 /// #### `vexpand-set`
430 /// Whether to use the `vexpand` property.
431 ///
432 /// Readable | Writeable
433 ///
434 ///
435 /// #### `visible`
436 /// Whether the widget is visible.
437 ///
438 /// Readable | Writeable
439 ///
440 ///
441 /// #### `width-request`
442 /// Overrides for width request of the widget.
443 ///
444 /// If this is -1, the natural request will be used.
445 ///
446 /// Readable | Writeable
447 /// </details>
448 /// <details><summary><h4>Accessible</h4></summary>
449 ///
450 ///
451 /// #### `accessible-role`
452 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
453 ///
454 /// The accessible role cannot be changed once set.
455 ///
456 /// Readable | Writeable
457 /// </details>
458 /// <details><summary><h4>Scrollable</h4></summary>
459 ///
460 ///
461 /// #### `hadjustment`
462 /// Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget.
463 ///
464 /// This adjustment is shared between the scrollable widget and its parent.
465 ///
466 /// Readable | Writeable | Construct
467 ///
468 ///
469 /// #### `hscroll-policy`
470 /// Determines when horizontal scrolling should start.
471 ///
472 /// Readable | Writeable
473 ///
474 ///
475 /// #### `vadjustment`
476 /// Vertical [`Adjustment`][crate::Adjustment] of the scrollable widget.
477 ///
478 /// This adjustment is shared between the scrollable widget and its parent.
479 ///
480 /// Readable | Writeable | Construct
481 ///
482 ///
483 /// #### `vscroll-policy`
484 /// Determines when vertical scrolling should start.
485 ///
486 /// Readable | Writeable
487 /// </details>
488 ///
489 /// ## Signals
490 ///
491 ///
492 /// #### `activate`
493 /// Emitted when a row has been activated by the user, usually via activating
494 /// the GtkListBase|list.activate-item action.
495 ///
496 /// This allows for a convenient way to handle activation in a columnview.
497 /// See [`ListItemExt::set_activatable()`][crate::prelude::ListItemExt::set_activatable()] for details on how to use this
498 /// signal.
499 ///
500 ///
501 /// <details><summary><h4>Widget</h4></summary>
502 ///
503 ///
504 /// #### `destroy`
505 /// Signals that all holders of a reference to the widget should release
506 /// the reference that they hold.
507 ///
508 /// May result in finalization of the widget if all references are released.
509 ///
510 /// This signal is not suitable for saving widget state.
511 ///
512 ///
513 ///
514 ///
515 /// #### `direction-changed`
516 /// Emitted when the text direction of a widget changes.
517 ///
518 ///
519 ///
520 ///
521 /// #### `hide`
522 /// Emitted when @widget is hidden.
523 ///
524 ///
525 ///
526 ///
527 /// #### `keynav-failed`
528 /// Emitted if keyboard navigation fails.
529 ///
530 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
531 ///
532 ///
533 ///
534 ///
535 /// #### `map`
536 /// Emitted when @widget is going to be mapped.
537 ///
538 /// A widget is mapped when the widget is visible (which is controlled with
539 /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
540 /// are also visible.
541 ///
542 /// The `::map` signal can be used to determine whether a widget will be drawn,
543 /// for instance it can resume an animation that was stopped during the
544 /// emission of [`unmap`][struct@crate::Widget#unmap].
545 ///
546 ///
547 ///
548 ///
549 /// #### `mnemonic-activate`
550 /// Emitted when a widget is activated via a mnemonic.
551 ///
552 /// The default handler for this signal activates @widget if @group_cycling
553 /// is false, or just makes @widget grab focus if @group_cycling is true.
554 ///
555 ///
556 ///
557 ///
558 /// #### `move-focus`
559 /// Emitted when the focus is moved.
560 ///
561 /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
562 ///
563 /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
564 /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
565 ///
566 /// Action
567 ///
568 ///
569 /// #### `query-tooltip`
570 /// Emitted when the widget’s tooltip is about to be shown.
571 ///
572 /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
573 /// is true and the hover timeout has expired with the cursor hovering
574 /// above @widget; or emitted when @widget got focus in keyboard mode.
575 ///
576 /// Using the given coordinates, the signal handler should determine
577 /// whether a tooltip should be shown for @widget. If this is the case
578 /// true should be returned, false otherwise. Note that if @keyboard_mode
579 /// is true, the values of @x and @y are undefined and should not be used.
580 ///
581 /// The signal handler is free to manipulate @tooltip with the therefore
582 /// destined function calls.
583 ///
584 ///
585 ///
586 ///
587 /// #### `realize`
588 /// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
589 ///
590 /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
591 /// or the widget has been mapped (that is, it is going to be drawn).
592 ///
593 ///
594 ///
595 ///
596 /// #### `show`
597 /// Emitted when @widget is shown.
598 ///
599 ///
600 ///
601 ///
602 /// #### `state-flags-changed`
603 /// Emitted when the widget state changes.
604 ///
605 /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
606 ///
607 ///
608 ///
609 ///
610 /// #### `unmap`
611 /// Emitted when @widget is going to be unmapped.
612 ///
613 /// A widget is unmapped when either it or any of its parents up to the
614 /// toplevel widget have been set as hidden.
615 ///
616 /// As `::unmap` indicates that a widget will not be shown any longer,
617 /// it can be used to, for example, stop an animation on the widget.
618 ///
619 ///
620 ///
621 ///
622 /// #### `unrealize`
623 /// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
624 ///
625 /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
626 /// or the widget has been unmapped (that is, it is going to be hidden).
627 ///
628 ///
629 /// </details>
630 ///
631 /// # Implements
632 ///
633 /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`ScrollableExt`][trait@crate::prelude::ScrollableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
634 #[doc(alias = "GtkColumnView")]
635 pub struct ColumnView(Object<ffi::GtkColumnView, ffi::GtkColumnViewClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Scrollable;
636
637 match fn {
638 type_ => || ffi::gtk_column_view_get_type(),
639 }
640}
641
642impl ColumnView {
643 /// Creates a new [`ColumnView`][crate::ColumnView].
644 ///
645 /// You most likely want to call [`append_column()`][Self::append_column()]
646 /// to add columns next.
647 /// ## `model`
648 /// the list model to use
649 ///
650 /// # Returns
651 ///
652 /// a new [`ColumnView`][crate::ColumnView]
653 #[doc(alias = "gtk_column_view_new")]
654 pub fn new(model: Option<impl IsA<SelectionModel>>) -> ColumnView {
655 assert_initialized_main_thread!();
656 unsafe {
657 Widget::from_glib_none(ffi::gtk_column_view_new(
658 model.map(|p| p.upcast()).into_glib_ptr(),
659 ))
660 .unsafe_cast()
661 }
662 }
663
664 // rustdoc-stripper-ignore-next
665 /// Creates a new builder-pattern struct instance to construct [`ColumnView`] objects.
666 ///
667 /// This method returns an instance of [`ColumnViewBuilder`](crate::builders::ColumnViewBuilder) which can be used to create [`ColumnView`] objects.
668 pub fn builder() -> ColumnViewBuilder {
669 ColumnViewBuilder::new()
670 }
671
672 /// Appends the @column to the end of the columns in @self.
673 /// ## `column`
674 /// a [`ColumnViewColumn`][crate::ColumnViewColumn] that hasn't been added to a
675 /// [`ColumnView`][crate::ColumnView] yet
676 #[doc(alias = "gtk_column_view_append_column")]
677 pub fn append_column(&self, column: &ColumnViewColumn) {
678 unsafe {
679 ffi::gtk_column_view_append_column(self.to_glib_none().0, column.to_glib_none().0);
680 }
681 }
682
683 /// Gets the list of columns in this column view.
684 ///
685 /// This list is constant over the lifetime of @self and can be used to
686 /// monitor changes to the columns of @self by connecting to the
687 /// ::items-changed signal.
688 ///
689 /// # Returns
690 ///
691 /// The list managing the columns
692 #[doc(alias = "gtk_column_view_get_columns")]
693 #[doc(alias = "get_columns")]
694 pub fn columns(&self) -> gio::ListModel {
695 unsafe { from_glib_none(ffi::gtk_column_view_get_columns(self.to_glib_none().0)) }
696 }
697
698 /// Returns whether rows can be selected by dragging with the mouse.
699 ///
700 /// # Returns
701 ///
702 /// [`true`] if rubberband selection is enabled
703 #[doc(alias = "gtk_column_view_get_enable_rubberband")]
704 #[doc(alias = "get_enable_rubberband")]
705 #[doc(alias = "enable-rubberband")]
706 pub fn enables_rubberband(&self) -> bool {
707 unsafe {
708 from_glib(ffi::gtk_column_view_get_enable_rubberband(
709 self.to_glib_none().0,
710 ))
711 }
712 }
713
714 /// Gets the factory that's currently used to populate section headers.
715 ///
716 /// # Returns
717 ///
718 /// The factory in use
719 #[cfg(feature = "v4_12")]
720 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
721 #[doc(alias = "gtk_column_view_get_header_factory")]
722 #[doc(alias = "get_header_factory")]
723 #[doc(alias = "header-factory")]
724 pub fn header_factory(&self) -> Option<ListItemFactory> {
725 unsafe {
726 from_glib_none(ffi::gtk_column_view_get_header_factory(
727 self.to_glib_none().0,
728 ))
729 }
730 }
731
732 /// Gets the model that's currently used to read the items displayed.
733 ///
734 /// # Returns
735 ///
736 /// The model in use
737 #[doc(alias = "gtk_column_view_get_model")]
738 #[doc(alias = "get_model")]
739 pub fn model(&self) -> Option<SelectionModel> {
740 unsafe { from_glib_none(ffi::gtk_column_view_get_model(self.to_glib_none().0)) }
741 }
742
743 /// Returns whether columns are reorderable.
744 ///
745 /// # Returns
746 ///
747 /// [`true`] if columns are reorderable
748 #[doc(alias = "gtk_column_view_get_reorderable")]
749 #[doc(alias = "get_reorderable")]
750 #[doc(alias = "reorderable")]
751 pub fn is_reorderable(&self) -> bool {
752 unsafe { from_glib(ffi::gtk_column_view_get_reorderable(self.to_glib_none().0)) }
753 }
754
755 /// Gets the factory set via [`set_row_factory()`][Self::set_row_factory()].
756 ///
757 /// # Returns
758 ///
759 /// The factory
760 #[cfg(feature = "v4_12")]
761 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
762 #[doc(alias = "gtk_column_view_get_row_factory")]
763 #[doc(alias = "get_row_factory")]
764 #[doc(alias = "row-factory")]
765 pub fn row_factory(&self) -> Option<ListItemFactory> {
766 unsafe { from_glib_none(ffi::gtk_column_view_get_row_factory(self.to_glib_none().0)) }
767 }
768
769 /// Returns whether the list should show separators
770 /// between columns.
771 ///
772 /// # Returns
773 ///
774 /// [`true`] if the list shows column separators
775 #[doc(alias = "gtk_column_view_get_show_column_separators")]
776 #[doc(alias = "get_show_column_separators")]
777 #[doc(alias = "show-column-separators")]
778 pub fn shows_column_separators(&self) -> bool {
779 unsafe {
780 from_glib(ffi::gtk_column_view_get_show_column_separators(
781 self.to_glib_none().0,
782 ))
783 }
784 }
785
786 /// Returns whether the list should show separators
787 /// between rows.
788 ///
789 /// # Returns
790 ///
791 /// [`true`] if the list shows separators
792 #[doc(alias = "gtk_column_view_get_show_row_separators")]
793 #[doc(alias = "get_show_row_separators")]
794 #[doc(alias = "show-row-separators")]
795 pub fn shows_row_separators(&self) -> bool {
796 unsafe {
797 from_glib(ffi::gtk_column_view_get_show_row_separators(
798 self.to_glib_none().0,
799 ))
800 }
801 }
802
803 /// Returns whether rows will be activated on single click and
804 /// selected on hover.
805 ///
806 /// # Returns
807 ///
808 /// [`true`] if rows are activated on single click
809 #[doc(alias = "gtk_column_view_get_single_click_activate")]
810 #[doc(alias = "get_single_click_activate")]
811 #[doc(alias = "single-click-activate")]
812 pub fn is_single_click_activate(&self) -> bool {
813 unsafe {
814 from_glib(ffi::gtk_column_view_get_single_click_activate(
815 self.to_glib_none().0,
816 ))
817 }
818 }
819
820 /// Returns a special sorter that reflects the users sorting
821 /// choices in the column view.
822 ///
823 /// To allow users to customizable sorting by clicking on column
824 /// headers, this sorter needs to be set on the sort model underneath
825 /// the model that is displayed by the view.
826 ///
827 /// See [`ColumnViewColumn::set_sorter()`][crate::ColumnViewColumn::set_sorter()] for setting up
828 /// per-column sorting.
829 ///
830 /// Here is an example:
831 /// **⚠️ The following code is in c ⚠️**
832 ///
833 /// ```c
834 /// gtk_column_view_column_set_sorter (column, sorter);
835 /// gtk_column_view_append_column (view, column);
836 /// sorter = g_object_ref (gtk_column_view_get_sorter (view)));
837 /// model = gtk_sort_list_model_new (store, sorter);
838 /// selection = gtk_no_selection_new (model);
839 /// gtk_column_view_set_model (view, selection);
840 /// ```
841 ///
842 /// # Returns
843 ///
844 /// the [`Sorter`][crate::Sorter] of @self
845 #[doc(alias = "gtk_column_view_get_sorter")]
846 #[doc(alias = "get_sorter")]
847 pub fn sorter(&self) -> Option<Sorter> {
848 unsafe { from_glib_none(ffi::gtk_column_view_get_sorter(self.to_glib_none().0)) }
849 }
850
851 /// Gets the behavior set for the <kbd>Tab</kbd> key.
852 ///
853 /// # Returns
854 ///
855 /// The behavior of the <kbd>Tab</kbd> key
856 #[cfg(feature = "v4_12")]
857 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
858 #[doc(alias = "gtk_column_view_get_tab_behavior")]
859 #[doc(alias = "get_tab_behavior")]
860 #[doc(alias = "tab-behavior")]
861 pub fn tab_behavior(&self) -> ListTabBehavior {
862 unsafe { from_glib(ffi::gtk_column_view_get_tab_behavior(self.to_glib_none().0)) }
863 }
864
865 /// Inserts a column at the given position in the columns of @self.
866 ///
867 /// If @column is already a column of @self, it will be repositioned.
868 /// ## `position`
869 /// the position to insert @column at
870 /// ## `column`
871 /// the [`ColumnViewColumn`][crate::ColumnViewColumn] to insert
872 #[doc(alias = "gtk_column_view_insert_column")]
873 pub fn insert_column(&self, position: u32, column: &ColumnViewColumn) {
874 unsafe {
875 ffi::gtk_column_view_insert_column(
876 self.to_glib_none().0,
877 position,
878 column.to_glib_none().0,
879 );
880 }
881 }
882
883 /// Removes the @column from the list of columns of @self.
884 /// ## `column`
885 /// a [`ColumnViewColumn`][crate::ColumnViewColumn] that's part of @self
886 #[doc(alias = "gtk_column_view_remove_column")]
887 pub fn remove_column(&self, column: &ColumnViewColumn) {
888 unsafe {
889 ffi::gtk_column_view_remove_column(self.to_glib_none().0, column.to_glib_none().0);
890 }
891 }
892
893 /// Scroll to the row at the given position - or cell if a column is
894 /// given - and performs the actions specified in @flags.
895 ///
896 /// This function works no matter if the listview is shown or focused.
897 /// If it isn't, then the changes will take effect once that happens.
898 /// ## `pos`
899 /// position of the item. Must be less than the number of
900 /// items in the view.
901 /// ## `column`
902 /// The column to scroll to
903 /// or [`None`] to not scroll columns.
904 /// ## `flags`
905 /// actions to perform
906 /// ## `scroll`
907 /// details of how to perform
908 /// the scroll operation or [`None`] to scroll into view
909 #[cfg(feature = "v4_12")]
910 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
911 #[doc(alias = "gtk_column_view_scroll_to")]
912 pub fn scroll_to(
913 &self,
914 pos: u32,
915 column: Option<&ColumnViewColumn>,
916 flags: ListScrollFlags,
917 scroll: Option<ScrollInfo>,
918 ) {
919 unsafe {
920 ffi::gtk_column_view_scroll_to(
921 self.to_glib_none().0,
922 pos,
923 column.to_glib_none().0,
924 flags.into_glib(),
925 scroll.into_glib_ptr(),
926 );
927 }
928 }
929
930 /// Sets whether selections can be changed by dragging with the mouse.
931 /// ## `enable_rubberband`
932 /// [`true`] to enable rubberband selection
933 #[doc(alias = "gtk_column_view_set_enable_rubberband")]
934 #[doc(alias = "enable-rubberband")]
935 pub fn set_enable_rubberband(&self, enable_rubberband: bool) {
936 unsafe {
937 ffi::gtk_column_view_set_enable_rubberband(
938 self.to_glib_none().0,
939 enable_rubberband.into_glib(),
940 );
941 }
942 }
943
944 /// Sets the [`ListItemFactory`][crate::ListItemFactory] to use for populating the
945 /// [`ListHeader`][crate::ListHeader] objects used in section headers.
946 ///
947 /// If this factory is set to [`None`], the list will not show
948 /// section headers.
949 /// ## `factory`
950 /// the factory to use
951 #[cfg(feature = "v4_12")]
952 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
953 #[doc(alias = "gtk_column_view_set_header_factory")]
954 #[doc(alias = "header-factory")]
955 pub fn set_header_factory(&self, factory: Option<&impl IsA<ListItemFactory>>) {
956 unsafe {
957 ffi::gtk_column_view_set_header_factory(
958 self.to_glib_none().0,
959 factory.map(|p| p.as_ref()).to_glib_none().0,
960 );
961 }
962 }
963
964 /// Sets the model to use.
965 ///
966 /// This must be a [`SelectionModel`][crate::SelectionModel].
967 /// ## `model`
968 /// the model to use
969 #[doc(alias = "gtk_column_view_set_model")]
970 #[doc(alias = "model")]
971 pub fn set_model(&self, model: Option<&impl IsA<SelectionModel>>) {
972 unsafe {
973 ffi::gtk_column_view_set_model(
974 self.to_glib_none().0,
975 model.map(|p| p.as_ref()).to_glib_none().0,
976 );
977 }
978 }
979
980 /// Sets whether columns should be reorderable by dragging.
981 /// ## `reorderable`
982 /// whether columns should be reorderable
983 #[doc(alias = "gtk_column_view_set_reorderable")]
984 #[doc(alias = "reorderable")]
985 pub fn set_reorderable(&self, reorderable: bool) {
986 unsafe {
987 ffi::gtk_column_view_set_reorderable(self.to_glib_none().0, reorderable.into_glib());
988 }
989 }
990
991 /// Sets the factory used for configuring rows. The factory must be for configuring
992 /// [`ColumnViewRow`][crate::ColumnViewRow] objects.
993 ///
994 /// If this factory is not set - which is the default - then the defaults will be used.
995 ///
996 /// This factory is not used to set the widgets displayed in the individual cells. For
997 /// that see `GtkColumnViewColumn::set_factory()` and [`ColumnViewCell`][crate::ColumnViewCell].
998 /// ## `factory`
999 /// The row factory
1000 #[cfg(feature = "v4_12")]
1001 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1002 #[doc(alias = "gtk_column_view_set_row_factory")]
1003 #[doc(alias = "row-factory")]
1004 pub fn set_row_factory(&self, factory: Option<&impl IsA<ListItemFactory>>) {
1005 unsafe {
1006 ffi::gtk_column_view_set_row_factory(
1007 self.to_glib_none().0,
1008 factory.map(|p| p.as_ref()).to_glib_none().0,
1009 );
1010 }
1011 }
1012
1013 /// Sets whether the list should show separators
1014 /// between columns.
1015 /// ## `show_column_separators`
1016 /// [`true`] to show column separators
1017 #[doc(alias = "gtk_column_view_set_show_column_separators")]
1018 #[doc(alias = "show-column-separators")]
1019 pub fn set_show_column_separators(&self, show_column_separators: bool) {
1020 unsafe {
1021 ffi::gtk_column_view_set_show_column_separators(
1022 self.to_glib_none().0,
1023 show_column_separators.into_glib(),
1024 );
1025 }
1026 }
1027
1028 /// Sets whether the list should show separators
1029 /// between rows.
1030 /// ## `show_row_separators`
1031 /// [`true`] to show row separators
1032 #[doc(alias = "gtk_column_view_set_show_row_separators")]
1033 #[doc(alias = "show-row-separators")]
1034 pub fn set_show_row_separators(&self, show_row_separators: bool) {
1035 unsafe {
1036 ffi::gtk_column_view_set_show_row_separators(
1037 self.to_glib_none().0,
1038 show_row_separators.into_glib(),
1039 );
1040 }
1041 }
1042
1043 /// Sets whether rows should be activated on single click and
1044 /// selected on hover.
1045 /// ## `single_click_activate`
1046 /// [`true`] to activate items on single click
1047 #[doc(alias = "gtk_column_view_set_single_click_activate")]
1048 #[doc(alias = "single-click-activate")]
1049 pub fn set_single_click_activate(&self, single_click_activate: bool) {
1050 unsafe {
1051 ffi::gtk_column_view_set_single_click_activate(
1052 self.to_glib_none().0,
1053 single_click_activate.into_glib(),
1054 );
1055 }
1056 }
1057
1058 /// Sets the behavior of the <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys.
1059 /// ## `tab_behavior`
1060 /// The desired tab behavior
1061 #[cfg(feature = "v4_12")]
1062 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1063 #[doc(alias = "gtk_column_view_set_tab_behavior")]
1064 #[doc(alias = "tab-behavior")]
1065 pub fn set_tab_behavior(&self, tab_behavior: ListTabBehavior) {
1066 unsafe {
1067 ffi::gtk_column_view_set_tab_behavior(self.to_glib_none().0, tab_behavior.into_glib());
1068 }
1069 }
1070
1071 /// Sets the sorting of the view.
1072 ///
1073 /// This function should be used to set up the initial sorting.
1074 /// At runtime, users can change the sorting of a column view
1075 /// by clicking on the list headers.
1076 ///
1077 /// This call only has an effect if the sorter returned by
1078 /// [`sorter()`][Self::sorter()] is set on a sort model,
1079 /// and [`ColumnViewColumn::set_sorter()`][crate::ColumnViewColumn::set_sorter()] has been called
1080 /// on @column to associate a sorter with the column.
1081 ///
1082 /// If @column is [`None`], the view will be unsorted.
1083 /// ## `column`
1084 /// the [`ColumnViewColumn`][crate::ColumnViewColumn] to sort by
1085 /// ## `direction`
1086 /// the direction to sort in
1087 #[doc(alias = "gtk_column_view_sort_by_column")]
1088 pub fn sort_by_column(&self, column: Option<&ColumnViewColumn>, direction: SortType) {
1089 unsafe {
1090 ffi::gtk_column_view_sort_by_column(
1091 self.to_glib_none().0,
1092 column.to_glib_none().0,
1093 direction.into_glib(),
1094 );
1095 }
1096 }
1097
1098 /// Emitted when a row has been activated by the user, usually via activating
1099 /// the GtkListBase|list.activate-item action.
1100 ///
1101 /// This allows for a convenient way to handle activation in a columnview.
1102 /// See [`ListItemExt::set_activatable()`][crate::prelude::ListItemExt::set_activatable()] for details on how to use this
1103 /// signal.
1104 /// ## `position`
1105 /// position of item to activate
1106 #[doc(alias = "activate")]
1107 pub fn connect_activate<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId {
1108 unsafe extern "C" fn activate_trampoline<F: Fn(&ColumnView, u32) + 'static>(
1109 this: *mut ffi::GtkColumnView,
1110 position: std::ffi::c_uint,
1111 f: glib::ffi::gpointer,
1112 ) {
1113 let f: &F = &*(f as *const F);
1114 f(&from_glib_borrow(this), position)
1115 }
1116 unsafe {
1117 let f: Box_<F> = Box_::new(f);
1118 connect_raw(
1119 self.as_ptr() as *mut _,
1120 b"activate\0".as_ptr() as *const _,
1121 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1122 activate_trampoline::<F> as *const (),
1123 )),
1124 Box_::into_raw(f),
1125 )
1126 }
1127 }
1128
1129 #[doc(alias = "columns")]
1130 pub fn connect_columns_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1131 unsafe extern "C" fn notify_columns_trampoline<F: Fn(&ColumnView) + 'static>(
1132 this: *mut ffi::GtkColumnView,
1133 _param_spec: glib::ffi::gpointer,
1134 f: glib::ffi::gpointer,
1135 ) {
1136 let f: &F = &*(f as *const F);
1137 f(&from_glib_borrow(this))
1138 }
1139 unsafe {
1140 let f: Box_<F> = Box_::new(f);
1141 connect_raw(
1142 self.as_ptr() as *mut _,
1143 b"notify::columns\0".as_ptr() as *const _,
1144 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1145 notify_columns_trampoline::<F> as *const (),
1146 )),
1147 Box_::into_raw(f),
1148 )
1149 }
1150 }
1151
1152 #[doc(alias = "enable-rubberband")]
1153 pub fn connect_enable_rubberband_notify<F: Fn(&Self) + 'static>(
1154 &self,
1155 f: F,
1156 ) -> SignalHandlerId {
1157 unsafe extern "C" fn notify_enable_rubberband_trampoline<F: Fn(&ColumnView) + 'static>(
1158 this: *mut ffi::GtkColumnView,
1159 _param_spec: glib::ffi::gpointer,
1160 f: glib::ffi::gpointer,
1161 ) {
1162 let f: &F = &*(f as *const F);
1163 f(&from_glib_borrow(this))
1164 }
1165 unsafe {
1166 let f: Box_<F> = Box_::new(f);
1167 connect_raw(
1168 self.as_ptr() as *mut _,
1169 b"notify::enable-rubberband\0".as_ptr() as *const _,
1170 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1171 notify_enable_rubberband_trampoline::<F> as *const (),
1172 )),
1173 Box_::into_raw(f),
1174 )
1175 }
1176 }
1177
1178 #[cfg(feature = "v4_12")]
1179 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1180 #[doc(alias = "header-factory")]
1181 pub fn connect_header_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1182 unsafe extern "C" fn notify_header_factory_trampoline<F: Fn(&ColumnView) + 'static>(
1183 this: *mut ffi::GtkColumnView,
1184 _param_spec: glib::ffi::gpointer,
1185 f: glib::ffi::gpointer,
1186 ) {
1187 let f: &F = &*(f as *const F);
1188 f(&from_glib_borrow(this))
1189 }
1190 unsafe {
1191 let f: Box_<F> = Box_::new(f);
1192 connect_raw(
1193 self.as_ptr() as *mut _,
1194 b"notify::header-factory\0".as_ptr() as *const _,
1195 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1196 notify_header_factory_trampoline::<F> as *const (),
1197 )),
1198 Box_::into_raw(f),
1199 )
1200 }
1201 }
1202
1203 #[doc(alias = "model")]
1204 pub fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1205 unsafe extern "C" fn notify_model_trampoline<F: Fn(&ColumnView) + 'static>(
1206 this: *mut ffi::GtkColumnView,
1207 _param_spec: glib::ffi::gpointer,
1208 f: glib::ffi::gpointer,
1209 ) {
1210 let f: &F = &*(f as *const F);
1211 f(&from_glib_borrow(this))
1212 }
1213 unsafe {
1214 let f: Box_<F> = Box_::new(f);
1215 connect_raw(
1216 self.as_ptr() as *mut _,
1217 b"notify::model\0".as_ptr() as *const _,
1218 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1219 notify_model_trampoline::<F> as *const (),
1220 )),
1221 Box_::into_raw(f),
1222 )
1223 }
1224 }
1225
1226 #[doc(alias = "reorderable")]
1227 pub fn connect_reorderable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1228 unsafe extern "C" fn notify_reorderable_trampoline<F: Fn(&ColumnView) + 'static>(
1229 this: *mut ffi::GtkColumnView,
1230 _param_spec: glib::ffi::gpointer,
1231 f: glib::ffi::gpointer,
1232 ) {
1233 let f: &F = &*(f as *const F);
1234 f(&from_glib_borrow(this))
1235 }
1236 unsafe {
1237 let f: Box_<F> = Box_::new(f);
1238 connect_raw(
1239 self.as_ptr() as *mut _,
1240 b"notify::reorderable\0".as_ptr() as *const _,
1241 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1242 notify_reorderable_trampoline::<F> as *const (),
1243 )),
1244 Box_::into_raw(f),
1245 )
1246 }
1247 }
1248
1249 #[cfg(feature = "v4_12")]
1250 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1251 #[doc(alias = "row-factory")]
1252 pub fn connect_row_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1253 unsafe extern "C" fn notify_row_factory_trampoline<F: Fn(&ColumnView) + 'static>(
1254 this: *mut ffi::GtkColumnView,
1255 _param_spec: glib::ffi::gpointer,
1256 f: glib::ffi::gpointer,
1257 ) {
1258 let f: &F = &*(f as *const F);
1259 f(&from_glib_borrow(this))
1260 }
1261 unsafe {
1262 let f: Box_<F> = Box_::new(f);
1263 connect_raw(
1264 self.as_ptr() as *mut _,
1265 b"notify::row-factory\0".as_ptr() as *const _,
1266 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1267 notify_row_factory_trampoline::<F> as *const (),
1268 )),
1269 Box_::into_raw(f),
1270 )
1271 }
1272 }
1273
1274 #[doc(alias = "show-column-separators")]
1275 pub fn connect_show_column_separators_notify<F: Fn(&Self) + 'static>(
1276 &self,
1277 f: F,
1278 ) -> SignalHandlerId {
1279 unsafe extern "C" fn notify_show_column_separators_trampoline<
1280 F: Fn(&ColumnView) + 'static,
1281 >(
1282 this: *mut ffi::GtkColumnView,
1283 _param_spec: glib::ffi::gpointer,
1284 f: glib::ffi::gpointer,
1285 ) {
1286 let f: &F = &*(f as *const F);
1287 f(&from_glib_borrow(this))
1288 }
1289 unsafe {
1290 let f: Box_<F> = Box_::new(f);
1291 connect_raw(
1292 self.as_ptr() as *mut _,
1293 b"notify::show-column-separators\0".as_ptr() as *const _,
1294 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1295 notify_show_column_separators_trampoline::<F> as *const (),
1296 )),
1297 Box_::into_raw(f),
1298 )
1299 }
1300 }
1301
1302 #[doc(alias = "show-row-separators")]
1303 pub fn connect_show_row_separators_notify<F: Fn(&Self) + 'static>(
1304 &self,
1305 f: F,
1306 ) -> SignalHandlerId {
1307 unsafe extern "C" fn notify_show_row_separators_trampoline<F: Fn(&ColumnView) + 'static>(
1308 this: *mut ffi::GtkColumnView,
1309 _param_spec: glib::ffi::gpointer,
1310 f: glib::ffi::gpointer,
1311 ) {
1312 let f: &F = &*(f as *const F);
1313 f(&from_glib_borrow(this))
1314 }
1315 unsafe {
1316 let f: Box_<F> = Box_::new(f);
1317 connect_raw(
1318 self.as_ptr() as *mut _,
1319 b"notify::show-row-separators\0".as_ptr() as *const _,
1320 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1321 notify_show_row_separators_trampoline::<F> as *const (),
1322 )),
1323 Box_::into_raw(f),
1324 )
1325 }
1326 }
1327
1328 #[doc(alias = "single-click-activate")]
1329 pub fn connect_single_click_activate_notify<F: Fn(&Self) + 'static>(
1330 &self,
1331 f: F,
1332 ) -> SignalHandlerId {
1333 unsafe extern "C" fn notify_single_click_activate_trampoline<
1334 F: Fn(&ColumnView) + 'static,
1335 >(
1336 this: *mut ffi::GtkColumnView,
1337 _param_spec: glib::ffi::gpointer,
1338 f: glib::ffi::gpointer,
1339 ) {
1340 let f: &F = &*(f as *const F);
1341 f(&from_glib_borrow(this))
1342 }
1343 unsafe {
1344 let f: Box_<F> = Box_::new(f);
1345 connect_raw(
1346 self.as_ptr() as *mut _,
1347 b"notify::single-click-activate\0".as_ptr() as *const _,
1348 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1349 notify_single_click_activate_trampoline::<F> as *const (),
1350 )),
1351 Box_::into_raw(f),
1352 )
1353 }
1354 }
1355
1356 #[doc(alias = "sorter")]
1357 pub fn connect_sorter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1358 unsafe extern "C" fn notify_sorter_trampoline<F: Fn(&ColumnView) + 'static>(
1359 this: *mut ffi::GtkColumnView,
1360 _param_spec: glib::ffi::gpointer,
1361 f: glib::ffi::gpointer,
1362 ) {
1363 let f: &F = &*(f as *const F);
1364 f(&from_glib_borrow(this))
1365 }
1366 unsafe {
1367 let f: Box_<F> = Box_::new(f);
1368 connect_raw(
1369 self.as_ptr() as *mut _,
1370 b"notify::sorter\0".as_ptr() as *const _,
1371 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1372 notify_sorter_trampoline::<F> as *const (),
1373 )),
1374 Box_::into_raw(f),
1375 )
1376 }
1377 }
1378
1379 #[cfg(feature = "v4_12")]
1380 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1381 #[doc(alias = "tab-behavior")]
1382 pub fn connect_tab_behavior_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1383 unsafe extern "C" fn notify_tab_behavior_trampoline<F: Fn(&ColumnView) + 'static>(
1384 this: *mut ffi::GtkColumnView,
1385 _param_spec: glib::ffi::gpointer,
1386 f: glib::ffi::gpointer,
1387 ) {
1388 let f: &F = &*(f as *const F);
1389 f(&from_glib_borrow(this))
1390 }
1391 unsafe {
1392 let f: Box_<F> = Box_::new(f);
1393 connect_raw(
1394 self.as_ptr() as *mut _,
1395 b"notify::tab-behavior\0".as_ptr() as *const _,
1396 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1397 notify_tab_behavior_trampoline::<F> as *const (),
1398 )),
1399 Box_::into_raw(f),
1400 )
1401 }
1402 }
1403}
1404
1405impl Default for ColumnView {
1406 fn default() -> Self {
1407 glib::object::Object::new::<Self>()
1408 }
1409}
1410
1411// rustdoc-stripper-ignore-next
1412/// A [builder-pattern] type to construct [`ColumnView`] objects.
1413///
1414/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1415#[must_use = "The builder must be built to be used"]
1416pub struct ColumnViewBuilder {
1417 builder: glib::object::ObjectBuilder<'static, ColumnView>,
1418}
1419
1420impl ColumnViewBuilder {
1421 fn new() -> Self {
1422 Self {
1423 builder: glib::object::Object::builder(),
1424 }
1425 }
1426
1427 /// Allow rubberband selection.
1428 pub fn enable_rubberband(self, enable_rubberband: bool) -> Self {
1429 Self {
1430 builder: self
1431 .builder
1432 .property("enable-rubberband", enable_rubberband),
1433 }
1434 }
1435
1436 /// Factory for creating header widgets.
1437 ///
1438 /// The factory must be for configuring [`ListHeader`][crate::ListHeader] objects.
1439 #[cfg(feature = "v4_12")]
1440 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1441 pub fn header_factory(self, header_factory: &impl IsA<ListItemFactory>) -> Self {
1442 Self {
1443 builder: self
1444 .builder
1445 .property("header-factory", header_factory.clone().upcast()),
1446 }
1447 }
1448
1449 /// Model for the items displayed.
1450 pub fn model(self, model: &impl IsA<SelectionModel>) -> Self {
1451 Self {
1452 builder: self.builder.property("model", model.clone().upcast()),
1453 }
1454 }
1455
1456 /// Whether columns are reorderable.
1457 pub fn reorderable(self, reorderable: bool) -> Self {
1458 Self {
1459 builder: self.builder.property("reorderable", reorderable),
1460 }
1461 }
1462
1463 /// The factory used for configuring rows.
1464 ///
1465 /// The factory must be for configuring [`ColumnViewRow`][crate::ColumnViewRow] objects.
1466 #[cfg(feature = "v4_12")]
1467 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1468 pub fn row_factory(self, row_factory: &impl IsA<ListItemFactory>) -> Self {
1469 Self {
1470 builder: self
1471 .builder
1472 .property("row-factory", row_factory.clone().upcast()),
1473 }
1474 }
1475
1476 /// Show separators between columns.
1477 pub fn show_column_separators(self, show_column_separators: bool) -> Self {
1478 Self {
1479 builder: self
1480 .builder
1481 .property("show-column-separators", show_column_separators),
1482 }
1483 }
1484
1485 /// Show separators between rows.
1486 pub fn show_row_separators(self, show_row_separators: bool) -> Self {
1487 Self {
1488 builder: self
1489 .builder
1490 .property("show-row-separators", show_row_separators),
1491 }
1492 }
1493
1494 /// Activate rows on single click and select them on hover.
1495 pub fn single_click_activate(self, single_click_activate: bool) -> Self {
1496 Self {
1497 builder: self
1498 .builder
1499 .property("single-click-activate", single_click_activate),
1500 }
1501 }
1502
1503 /// Behavior of the <kbd>Tab</kbd> key
1504 #[cfg(feature = "v4_12")]
1505 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1506 pub fn tab_behavior(self, tab_behavior: ListTabBehavior) -> Self {
1507 Self {
1508 builder: self.builder.property("tab-behavior", tab_behavior),
1509 }
1510 }
1511
1512 /// Whether the widget or any of its descendents can accept
1513 /// the input focus.
1514 ///
1515 /// This property is meant to be set by widget implementations,
1516 /// typically in their instance init function.
1517 pub fn can_focus(self, can_focus: bool) -> Self {
1518 Self {
1519 builder: self.builder.property("can-focus", can_focus),
1520 }
1521 }
1522
1523 /// Whether the widget can receive pointer events.
1524 pub fn can_target(self, can_target: bool) -> Self {
1525 Self {
1526 builder: self.builder.property("can-target", can_target),
1527 }
1528 }
1529
1530 /// A list of css classes applied to this widget.
1531 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1532 Self {
1533 builder: self.builder.property("css-classes", css_classes.into()),
1534 }
1535 }
1536
1537 /// The name of this widget in the CSS tree.
1538 ///
1539 /// This property is meant to be set by widget implementations,
1540 /// typically in their instance init function.
1541 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1542 Self {
1543 builder: self.builder.property("css-name", css_name.into()),
1544 }
1545 }
1546
1547 /// The cursor used by @widget.
1548 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1549 Self {
1550 builder: self.builder.property("cursor", cursor.clone()),
1551 }
1552 }
1553
1554 /// Whether the widget should grab focus when it is clicked with the mouse.
1555 ///
1556 /// This property is only relevant for widgets that can take focus.
1557 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1558 Self {
1559 builder: self.builder.property("focus-on-click", focus_on_click),
1560 }
1561 }
1562
1563 /// Whether this widget itself will accept the input focus.
1564 pub fn focusable(self, focusable: bool) -> Self {
1565 Self {
1566 builder: self.builder.property("focusable", focusable),
1567 }
1568 }
1569
1570 /// How to distribute horizontal space if widget gets extra space.
1571 pub fn halign(self, halign: Align) -> Self {
1572 Self {
1573 builder: self.builder.property("halign", halign),
1574 }
1575 }
1576
1577 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1578 /// signal on @widget.
1579 ///
1580 /// A true value indicates that @widget can have a tooltip, in this case
1581 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1582 /// determine whether it will provide a tooltip or not.
1583 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1584 Self {
1585 builder: self.builder.property("has-tooltip", has_tooltip),
1586 }
1587 }
1588
1589 /// Overrides for height request of the widget.
1590 ///
1591 /// If this is -1, the natural request will be used.
1592 pub fn height_request(self, height_request: i32) -> Self {
1593 Self {
1594 builder: self.builder.property("height-request", height_request),
1595 }
1596 }
1597
1598 /// Whether to expand horizontally.
1599 pub fn hexpand(self, hexpand: bool) -> Self {
1600 Self {
1601 builder: self.builder.property("hexpand", hexpand),
1602 }
1603 }
1604
1605 /// Whether to use the `hexpand` property.
1606 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1607 Self {
1608 builder: self.builder.property("hexpand-set", hexpand_set),
1609 }
1610 }
1611
1612 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1613 /// the preferred size of the widget, and allocate its children.
1614 ///
1615 /// This property is meant to be set by widget implementations,
1616 /// typically in their instance init function.
1617 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1618 Self {
1619 builder: self
1620 .builder
1621 .property("layout-manager", layout_manager.clone().upcast()),
1622 }
1623 }
1624
1625 /// Makes this widget act like a modal dialog, with respect to
1626 /// event delivery.
1627 ///
1628 /// Global event controllers will not handle events with targets
1629 /// inside the widget, unless they are set up to ignore propagation
1630 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1631 #[cfg(feature = "v4_18")]
1632 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1633 pub fn limit_events(self, limit_events: bool) -> Self {
1634 Self {
1635 builder: self.builder.property("limit-events", limit_events),
1636 }
1637 }
1638
1639 /// Margin on bottom side of widget.
1640 ///
1641 /// This property adds margin outside of the widget's normal size
1642 /// request, the margin will be added in addition to the size from
1643 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1644 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1645 Self {
1646 builder: self.builder.property("margin-bottom", margin_bottom),
1647 }
1648 }
1649
1650 /// Margin on end of widget, horizontally.
1651 ///
1652 /// This property supports left-to-right and right-to-left text
1653 /// directions.
1654 ///
1655 /// This property adds margin outside of the widget's normal size
1656 /// request, the margin will be added in addition to the size from
1657 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1658 pub fn margin_end(self, margin_end: i32) -> Self {
1659 Self {
1660 builder: self.builder.property("margin-end", margin_end),
1661 }
1662 }
1663
1664 /// Margin on start of widget, horizontally.
1665 ///
1666 /// This property supports left-to-right and right-to-left text
1667 /// directions.
1668 ///
1669 /// This property adds margin outside of the widget's normal size
1670 /// request, the margin will be added in addition to the size from
1671 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1672 pub fn margin_start(self, margin_start: i32) -> Self {
1673 Self {
1674 builder: self.builder.property("margin-start", margin_start),
1675 }
1676 }
1677
1678 /// Margin on top side of widget.
1679 ///
1680 /// This property adds margin outside of the widget's normal size
1681 /// request, the margin will be added in addition to the size from
1682 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1683 pub fn margin_top(self, margin_top: i32) -> Self {
1684 Self {
1685 builder: self.builder.property("margin-top", margin_top),
1686 }
1687 }
1688
1689 /// The name of the widget.
1690 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1691 Self {
1692 builder: self.builder.property("name", name.into()),
1693 }
1694 }
1695
1696 /// The requested opacity of the widget.
1697 pub fn opacity(self, opacity: f64) -> Self {
1698 Self {
1699 builder: self.builder.property("opacity", opacity),
1700 }
1701 }
1702
1703 /// How content outside the widget's content area is treated.
1704 ///
1705 /// This property is meant to be set by widget implementations,
1706 /// typically in their instance init function.
1707 pub fn overflow(self, overflow: Overflow) -> Self {
1708 Self {
1709 builder: self.builder.property("overflow", overflow),
1710 }
1711 }
1712
1713 /// Whether the widget will receive the default action when it is focused.
1714 pub fn receives_default(self, receives_default: bool) -> Self {
1715 Self {
1716 builder: self.builder.property("receives-default", receives_default),
1717 }
1718 }
1719
1720 /// Whether the widget responds to input.
1721 pub fn sensitive(self, sensitive: bool) -> Self {
1722 Self {
1723 builder: self.builder.property("sensitive", sensitive),
1724 }
1725 }
1726
1727 /// Sets the text of tooltip to be the given string, which is marked up
1728 /// with Pango markup.
1729 ///
1730 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1731 ///
1732 /// This is a convenience property which will take care of getting the
1733 /// tooltip shown if the given string is not `NULL`:
1734 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1735 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1736 /// the default signal handler.
1737 ///
1738 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1739 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1740 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1741 Self {
1742 builder: self
1743 .builder
1744 .property("tooltip-markup", tooltip_markup.into()),
1745 }
1746 }
1747
1748 /// Sets the text of tooltip to be the given string.
1749 ///
1750 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1751 ///
1752 /// This is a convenience property which will take care of getting the
1753 /// tooltip shown if the given string is not `NULL`:
1754 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1755 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1756 /// the default signal handler.
1757 ///
1758 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1759 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1760 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1761 Self {
1762 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1763 }
1764 }
1765
1766 /// How to distribute vertical space if widget gets extra space.
1767 pub fn valign(self, valign: Align) -> Self {
1768 Self {
1769 builder: self.builder.property("valign", valign),
1770 }
1771 }
1772
1773 /// Whether to expand vertically.
1774 pub fn vexpand(self, vexpand: bool) -> Self {
1775 Self {
1776 builder: self.builder.property("vexpand", vexpand),
1777 }
1778 }
1779
1780 /// Whether to use the `vexpand` property.
1781 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1782 Self {
1783 builder: self.builder.property("vexpand-set", vexpand_set),
1784 }
1785 }
1786
1787 /// Whether the widget is visible.
1788 pub fn visible(self, visible: bool) -> Self {
1789 Self {
1790 builder: self.builder.property("visible", visible),
1791 }
1792 }
1793
1794 /// Overrides for width request of the widget.
1795 ///
1796 /// If this is -1, the natural request will be used.
1797 pub fn width_request(self, width_request: i32) -> Self {
1798 Self {
1799 builder: self.builder.property("width-request", width_request),
1800 }
1801 }
1802
1803 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1804 ///
1805 /// The accessible role cannot be changed once set.
1806 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1807 Self {
1808 builder: self.builder.property("accessible-role", accessible_role),
1809 }
1810 }
1811
1812 /// Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget.
1813 ///
1814 /// This adjustment is shared between the scrollable widget and its parent.
1815 pub fn hadjustment(self, hadjustment: &impl IsA<Adjustment>) -> Self {
1816 Self {
1817 builder: self
1818 .builder
1819 .property("hadjustment", hadjustment.clone().upcast()),
1820 }
1821 }
1822
1823 /// Determines when horizontal scrolling should start.
1824 pub fn hscroll_policy(self, hscroll_policy: ScrollablePolicy) -> Self {
1825 Self {
1826 builder: self.builder.property("hscroll-policy", hscroll_policy),
1827 }
1828 }
1829
1830 /// Vertical [`Adjustment`][crate::Adjustment] of the scrollable widget.
1831 ///
1832 /// This adjustment is shared between the scrollable widget and its parent.
1833 pub fn vadjustment(self, vadjustment: &impl IsA<Adjustment>) -> Self {
1834 Self {
1835 builder: self
1836 .builder
1837 .property("vadjustment", vadjustment.clone().upcast()),
1838 }
1839 }
1840
1841 /// Determines when vertical scrolling should start.
1842 pub fn vscroll_policy(self, vscroll_policy: ScrollablePolicy) -> Self {
1843 Self {
1844 builder: self.builder.property("vscroll-policy", vscroll_policy),
1845 }
1846 }
1847
1848 // rustdoc-stripper-ignore-next
1849 /// Build the [`ColumnView`].
1850 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1851 pub fn build(self) -> ColumnView {
1852 assert_initialized_main_thread!();
1853 self.builder.build()
1854 }
1855}