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