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 /// 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 let f: &F = &*(f as *const F);
1115 f(&from_glib_borrow(this), position)
1116 }
1117 unsafe {
1118 let f: Box_<F> = Box_::new(f);
1119 connect_raw(
1120 self.as_ptr() as *mut _,
1121 c"activate".as_ptr() as *const _,
1122 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1123 activate_trampoline::<F> as *const (),
1124 )),
1125 Box_::into_raw(f),
1126 )
1127 }
1128 }
1129
1130 #[doc(alias = "columns")]
1131 pub fn connect_columns_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1132 unsafe extern "C" fn notify_columns_trampoline<F: Fn(&ColumnView) + 'static>(
1133 this: *mut ffi::GtkColumnView,
1134 _param_spec: glib::ffi::gpointer,
1135 f: glib::ffi::gpointer,
1136 ) {
1137 let f: &F = &*(f as *const F);
1138 f(&from_glib_borrow(this))
1139 }
1140 unsafe {
1141 let f: Box_<F> = Box_::new(f);
1142 connect_raw(
1143 self.as_ptr() as *mut _,
1144 c"notify::columns".as_ptr() as *const _,
1145 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1146 notify_columns_trampoline::<F> as *const (),
1147 )),
1148 Box_::into_raw(f),
1149 )
1150 }
1151 }
1152
1153 #[doc(alias = "enable-rubberband")]
1154 pub fn connect_enable_rubberband_notify<F: Fn(&Self) + 'static>(
1155 &self,
1156 f: F,
1157 ) -> SignalHandlerId {
1158 unsafe extern "C" fn notify_enable_rubberband_trampoline<F: Fn(&ColumnView) + 'static>(
1159 this: *mut ffi::GtkColumnView,
1160 _param_spec: glib::ffi::gpointer,
1161 f: glib::ffi::gpointer,
1162 ) {
1163 let f: &F = &*(f as *const F);
1164 f(&from_glib_borrow(this))
1165 }
1166 unsafe {
1167 let f: Box_<F> = Box_::new(f);
1168 connect_raw(
1169 self.as_ptr() as *mut _,
1170 c"notify::enable-rubberband".as_ptr() as *const _,
1171 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1172 notify_enable_rubberband_trampoline::<F> as *const (),
1173 )),
1174 Box_::into_raw(f),
1175 )
1176 }
1177 }
1178
1179 #[cfg(feature = "v4_12")]
1180 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1181 #[doc(alias = "header-factory")]
1182 pub fn connect_header_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1183 unsafe extern "C" fn notify_header_factory_trampoline<F: Fn(&ColumnView) + 'static>(
1184 this: *mut ffi::GtkColumnView,
1185 _param_spec: glib::ffi::gpointer,
1186 f: glib::ffi::gpointer,
1187 ) {
1188 let f: &F = &*(f as *const F);
1189 f(&from_glib_borrow(this))
1190 }
1191 unsafe {
1192 let f: Box_<F> = Box_::new(f);
1193 connect_raw(
1194 self.as_ptr() as *mut _,
1195 c"notify::header-factory".as_ptr() as *const _,
1196 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1197 notify_header_factory_trampoline::<F> as *const (),
1198 )),
1199 Box_::into_raw(f),
1200 )
1201 }
1202 }
1203
1204 #[doc(alias = "model")]
1205 pub fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1206 unsafe extern "C" fn notify_model_trampoline<F: Fn(&ColumnView) + 'static>(
1207 this: *mut ffi::GtkColumnView,
1208 _param_spec: glib::ffi::gpointer,
1209 f: glib::ffi::gpointer,
1210 ) {
1211 let f: &F = &*(f as *const F);
1212 f(&from_glib_borrow(this))
1213 }
1214 unsafe {
1215 let f: Box_<F> = Box_::new(f);
1216 connect_raw(
1217 self.as_ptr() as *mut _,
1218 c"notify::model".as_ptr() as *const _,
1219 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1220 notify_model_trampoline::<F> as *const (),
1221 )),
1222 Box_::into_raw(f),
1223 )
1224 }
1225 }
1226
1227 #[doc(alias = "reorderable")]
1228 pub fn connect_reorderable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1229 unsafe extern "C" fn notify_reorderable_trampoline<F: Fn(&ColumnView) + 'static>(
1230 this: *mut ffi::GtkColumnView,
1231 _param_spec: glib::ffi::gpointer,
1232 f: glib::ffi::gpointer,
1233 ) {
1234 let f: &F = &*(f as *const F);
1235 f(&from_glib_borrow(this))
1236 }
1237 unsafe {
1238 let f: Box_<F> = Box_::new(f);
1239 connect_raw(
1240 self.as_ptr() as *mut _,
1241 c"notify::reorderable".as_ptr() as *const _,
1242 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1243 notify_reorderable_trampoline::<F> as *const (),
1244 )),
1245 Box_::into_raw(f),
1246 )
1247 }
1248 }
1249
1250 #[cfg(feature = "v4_12")]
1251 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1252 #[doc(alias = "row-factory")]
1253 pub fn connect_row_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1254 unsafe extern "C" fn notify_row_factory_trampoline<F: Fn(&ColumnView) + 'static>(
1255 this: *mut ffi::GtkColumnView,
1256 _param_spec: glib::ffi::gpointer,
1257 f: glib::ffi::gpointer,
1258 ) {
1259 let f: &F = &*(f as *const F);
1260 f(&from_glib_borrow(this))
1261 }
1262 unsafe {
1263 let f: Box_<F> = Box_::new(f);
1264 connect_raw(
1265 self.as_ptr() as *mut _,
1266 c"notify::row-factory".as_ptr() as *const _,
1267 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1268 notify_row_factory_trampoline::<F> as *const (),
1269 )),
1270 Box_::into_raw(f),
1271 )
1272 }
1273 }
1274
1275 #[doc(alias = "show-column-separators")]
1276 pub fn connect_show_column_separators_notify<F: Fn(&Self) + 'static>(
1277 &self,
1278 f: F,
1279 ) -> SignalHandlerId {
1280 unsafe extern "C" fn notify_show_column_separators_trampoline<
1281 F: Fn(&ColumnView) + 'static,
1282 >(
1283 this: *mut ffi::GtkColumnView,
1284 _param_spec: glib::ffi::gpointer,
1285 f: glib::ffi::gpointer,
1286 ) {
1287 let f: &F = &*(f as *const F);
1288 f(&from_glib_borrow(this))
1289 }
1290 unsafe {
1291 let f: Box_<F> = Box_::new(f);
1292 connect_raw(
1293 self.as_ptr() as *mut _,
1294 c"notify::show-column-separators".as_ptr() as *const _,
1295 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1296 notify_show_column_separators_trampoline::<F> as *const (),
1297 )),
1298 Box_::into_raw(f),
1299 )
1300 }
1301 }
1302
1303 #[doc(alias = "show-row-separators")]
1304 pub fn connect_show_row_separators_notify<F: Fn(&Self) + 'static>(
1305 &self,
1306 f: F,
1307 ) -> SignalHandlerId {
1308 unsafe extern "C" fn notify_show_row_separators_trampoline<F: Fn(&ColumnView) + 'static>(
1309 this: *mut ffi::GtkColumnView,
1310 _param_spec: glib::ffi::gpointer,
1311 f: glib::ffi::gpointer,
1312 ) {
1313 let f: &F = &*(f as *const F);
1314 f(&from_glib_borrow(this))
1315 }
1316 unsafe {
1317 let f: Box_<F> = Box_::new(f);
1318 connect_raw(
1319 self.as_ptr() as *mut _,
1320 c"notify::show-row-separators".as_ptr() as *const _,
1321 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1322 notify_show_row_separators_trampoline::<F> as *const (),
1323 )),
1324 Box_::into_raw(f),
1325 )
1326 }
1327 }
1328
1329 #[doc(alias = "single-click-activate")]
1330 pub fn connect_single_click_activate_notify<F: Fn(&Self) + 'static>(
1331 &self,
1332 f: F,
1333 ) -> SignalHandlerId {
1334 unsafe extern "C" fn notify_single_click_activate_trampoline<
1335 F: Fn(&ColumnView) + 'static,
1336 >(
1337 this: *mut ffi::GtkColumnView,
1338 _param_spec: glib::ffi::gpointer,
1339 f: glib::ffi::gpointer,
1340 ) {
1341 let f: &F = &*(f as *const F);
1342 f(&from_glib_borrow(this))
1343 }
1344 unsafe {
1345 let f: Box_<F> = Box_::new(f);
1346 connect_raw(
1347 self.as_ptr() as *mut _,
1348 c"notify::single-click-activate".as_ptr() as *const _,
1349 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1350 notify_single_click_activate_trampoline::<F> as *const (),
1351 )),
1352 Box_::into_raw(f),
1353 )
1354 }
1355 }
1356
1357 #[doc(alias = "sorter")]
1358 pub fn connect_sorter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1359 unsafe extern "C" fn notify_sorter_trampoline<F: Fn(&ColumnView) + 'static>(
1360 this: *mut ffi::GtkColumnView,
1361 _param_spec: glib::ffi::gpointer,
1362 f: glib::ffi::gpointer,
1363 ) {
1364 let f: &F = &*(f as *const F);
1365 f(&from_glib_borrow(this))
1366 }
1367 unsafe {
1368 let f: Box_<F> = Box_::new(f);
1369 connect_raw(
1370 self.as_ptr() as *mut _,
1371 c"notify::sorter".as_ptr() as *const _,
1372 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1373 notify_sorter_trampoline::<F> as *const (),
1374 )),
1375 Box_::into_raw(f),
1376 )
1377 }
1378 }
1379
1380 #[cfg(feature = "v4_12")]
1381 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1382 #[doc(alias = "tab-behavior")]
1383 pub fn connect_tab_behavior_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1384 unsafe extern "C" fn notify_tab_behavior_trampoline<F: Fn(&ColumnView) + 'static>(
1385 this: *mut ffi::GtkColumnView,
1386 _param_spec: glib::ffi::gpointer,
1387 f: glib::ffi::gpointer,
1388 ) {
1389 let f: &F = &*(f as *const F);
1390 f(&from_glib_borrow(this))
1391 }
1392 unsafe {
1393 let f: Box_<F> = Box_::new(f);
1394 connect_raw(
1395 self.as_ptr() as *mut _,
1396 c"notify::tab-behavior".as_ptr() as *const _,
1397 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1398 notify_tab_behavior_trampoline::<F> as *const (),
1399 )),
1400 Box_::into_raw(f),
1401 )
1402 }
1403 }
1404}
1405
1406impl Default for ColumnView {
1407 fn default() -> Self {
1408 glib::object::Object::new::<Self>()
1409 }
1410}
1411
1412// rustdoc-stripper-ignore-next
1413/// A [builder-pattern] type to construct [`ColumnView`] objects.
1414///
1415/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1416#[must_use = "The builder must be built to be used"]
1417pub struct ColumnViewBuilder {
1418 builder: glib::object::ObjectBuilder<'static, ColumnView>,
1419}
1420
1421impl ColumnViewBuilder {
1422 fn new() -> Self {
1423 Self {
1424 builder: glib::object::Object::builder(),
1425 }
1426 }
1427
1428 /// Allow rubberband selection.
1429 pub fn enable_rubberband(self, enable_rubberband: bool) -> Self {
1430 Self {
1431 builder: self
1432 .builder
1433 .property("enable-rubberband", enable_rubberband),
1434 }
1435 }
1436
1437 /// Factory for creating header widgets.
1438 ///
1439 /// The factory must be for configuring [`ListHeader`][crate::ListHeader] objects.
1440 #[cfg(feature = "v4_12")]
1441 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1442 pub fn header_factory(self, header_factory: &impl IsA<ListItemFactory>) -> Self {
1443 Self {
1444 builder: self
1445 .builder
1446 .property("header-factory", header_factory.clone().upcast()),
1447 }
1448 }
1449
1450 /// Model for the items displayed.
1451 pub fn model(self, model: &impl IsA<SelectionModel>) -> Self {
1452 Self {
1453 builder: self.builder.property("model", model.clone().upcast()),
1454 }
1455 }
1456
1457 /// Whether columns are reorderable.
1458 pub fn reorderable(self, reorderable: bool) -> Self {
1459 Self {
1460 builder: self.builder.property("reorderable", reorderable),
1461 }
1462 }
1463
1464 /// The factory used for configuring rows.
1465 ///
1466 /// The factory must be for configuring [`ColumnViewRow`][crate::ColumnViewRow] objects.
1467 #[cfg(feature = "v4_12")]
1468 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1469 pub fn row_factory(self, row_factory: &impl IsA<ListItemFactory>) -> Self {
1470 Self {
1471 builder: self
1472 .builder
1473 .property("row-factory", row_factory.clone().upcast()),
1474 }
1475 }
1476
1477 /// Show separators between columns.
1478 pub fn show_column_separators(self, show_column_separators: bool) -> Self {
1479 Self {
1480 builder: self
1481 .builder
1482 .property("show-column-separators", show_column_separators),
1483 }
1484 }
1485
1486 /// Show separators between rows.
1487 pub fn show_row_separators(self, show_row_separators: bool) -> Self {
1488 Self {
1489 builder: self
1490 .builder
1491 .property("show-row-separators", show_row_separators),
1492 }
1493 }
1494
1495 /// Activate rows on single click and select them on hover.
1496 pub fn single_click_activate(self, single_click_activate: bool) -> Self {
1497 Self {
1498 builder: self
1499 .builder
1500 .property("single-click-activate", single_click_activate),
1501 }
1502 }
1503
1504 /// Behavior of the <kbd>Tab</kbd> key
1505 #[cfg(feature = "v4_12")]
1506 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1507 pub fn tab_behavior(self, tab_behavior: ListTabBehavior) -> Self {
1508 Self {
1509 builder: self.builder.property("tab-behavior", tab_behavior),
1510 }
1511 }
1512
1513 /// Whether the widget or any of its descendents can accept
1514 /// the input focus.
1515 ///
1516 /// This property is meant to be set by widget implementations,
1517 /// typically in their instance init function.
1518 pub fn can_focus(self, can_focus: bool) -> Self {
1519 Self {
1520 builder: self.builder.property("can-focus", can_focus),
1521 }
1522 }
1523
1524 /// Whether the widget can receive pointer events.
1525 pub fn can_target(self, can_target: bool) -> Self {
1526 Self {
1527 builder: self.builder.property("can-target", can_target),
1528 }
1529 }
1530
1531 /// A list of css classes applied to this widget.
1532 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1533 Self {
1534 builder: self.builder.property("css-classes", css_classes.into()),
1535 }
1536 }
1537
1538 /// The name of this widget in the CSS tree.
1539 ///
1540 /// This property is meant to be set by widget implementations,
1541 /// typically in their instance init function.
1542 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1543 Self {
1544 builder: self.builder.property("css-name", css_name.into()),
1545 }
1546 }
1547
1548 /// The cursor used by @widget.
1549 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1550 Self {
1551 builder: self.builder.property("cursor", cursor.clone()),
1552 }
1553 }
1554
1555 /// Whether the widget should grab focus when it is clicked with the mouse.
1556 ///
1557 /// This property is only relevant for widgets that can take focus.
1558 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1559 Self {
1560 builder: self.builder.property("focus-on-click", focus_on_click),
1561 }
1562 }
1563
1564 /// Whether this widget itself will accept the input focus.
1565 pub fn focusable(self, focusable: bool) -> Self {
1566 Self {
1567 builder: self.builder.property("focusable", focusable),
1568 }
1569 }
1570
1571 /// How to distribute horizontal space if widget gets extra space.
1572 pub fn halign(self, halign: Align) -> Self {
1573 Self {
1574 builder: self.builder.property("halign", halign),
1575 }
1576 }
1577
1578 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1579 /// signal on @widget.
1580 ///
1581 /// A true value indicates that @widget can have a tooltip, in this case
1582 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1583 /// determine whether it will provide a tooltip or not.
1584 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1585 Self {
1586 builder: self.builder.property("has-tooltip", has_tooltip),
1587 }
1588 }
1589
1590 /// Overrides for height request of the widget.
1591 ///
1592 /// If this is -1, the natural request will be used.
1593 pub fn height_request(self, height_request: i32) -> Self {
1594 Self {
1595 builder: self.builder.property("height-request", height_request),
1596 }
1597 }
1598
1599 /// Whether to expand horizontally.
1600 pub fn hexpand(self, hexpand: bool) -> Self {
1601 Self {
1602 builder: self.builder.property("hexpand", hexpand),
1603 }
1604 }
1605
1606 /// Whether to use the `hexpand` property.
1607 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1608 Self {
1609 builder: self.builder.property("hexpand-set", hexpand_set),
1610 }
1611 }
1612
1613 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1614 /// the preferred size of the widget, and allocate its children.
1615 ///
1616 /// This property is meant to be set by widget implementations,
1617 /// typically in their instance init function.
1618 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1619 Self {
1620 builder: self
1621 .builder
1622 .property("layout-manager", layout_manager.clone().upcast()),
1623 }
1624 }
1625
1626 /// Makes this widget act like a modal dialog, with respect to
1627 /// event delivery.
1628 ///
1629 /// Global event controllers will not handle events with targets
1630 /// inside the widget, unless they are set up to ignore propagation
1631 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1632 #[cfg(feature = "v4_18")]
1633 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1634 pub fn limit_events(self, limit_events: bool) -> Self {
1635 Self {
1636 builder: self.builder.property("limit-events", limit_events),
1637 }
1638 }
1639
1640 /// Margin on bottom side of widget.
1641 ///
1642 /// This property adds margin outside of the widget's normal size
1643 /// request, the margin will be added in addition to the size from
1644 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1645 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1646 Self {
1647 builder: self.builder.property("margin-bottom", margin_bottom),
1648 }
1649 }
1650
1651 /// Margin on end of widget, horizontally.
1652 ///
1653 /// This property supports left-to-right and right-to-left text
1654 /// directions.
1655 ///
1656 /// This property adds margin outside of the widget's normal size
1657 /// request, the margin will be added in addition to the size from
1658 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1659 pub fn margin_end(self, margin_end: i32) -> Self {
1660 Self {
1661 builder: self.builder.property("margin-end", margin_end),
1662 }
1663 }
1664
1665 /// Margin on start of widget, horizontally.
1666 ///
1667 /// This property supports left-to-right and right-to-left text
1668 /// directions.
1669 ///
1670 /// This property adds margin outside of the widget's normal size
1671 /// request, the margin will be added in addition to the size from
1672 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1673 pub fn margin_start(self, margin_start: i32) -> Self {
1674 Self {
1675 builder: self.builder.property("margin-start", margin_start),
1676 }
1677 }
1678
1679 /// Margin on top side of widget.
1680 ///
1681 /// This property adds margin outside of the widget's normal size
1682 /// request, the margin will be added in addition to the size from
1683 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1684 pub fn margin_top(self, margin_top: i32) -> Self {
1685 Self {
1686 builder: self.builder.property("margin-top", margin_top),
1687 }
1688 }
1689
1690 /// The name of the widget.
1691 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1692 Self {
1693 builder: self.builder.property("name", name.into()),
1694 }
1695 }
1696
1697 /// The requested opacity of the widget.
1698 pub fn opacity(self, opacity: f64) -> Self {
1699 Self {
1700 builder: self.builder.property("opacity", opacity),
1701 }
1702 }
1703
1704 /// How content outside the widget's content area is treated.
1705 ///
1706 /// This property is meant to be set by widget implementations,
1707 /// typically in their instance init function.
1708 pub fn overflow(self, overflow: Overflow) -> Self {
1709 Self {
1710 builder: self.builder.property("overflow", overflow),
1711 }
1712 }
1713
1714 /// Whether the widget will receive the default action when it is focused.
1715 pub fn receives_default(self, receives_default: bool) -> Self {
1716 Self {
1717 builder: self.builder.property("receives-default", receives_default),
1718 }
1719 }
1720
1721 /// Whether the widget responds to input.
1722 pub fn sensitive(self, sensitive: bool) -> Self {
1723 Self {
1724 builder: self.builder.property("sensitive", sensitive),
1725 }
1726 }
1727
1728 /// Sets the text of tooltip to be the given string, which is marked up
1729 /// with Pango markup.
1730 ///
1731 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1732 ///
1733 /// This is a convenience property which will take care of getting the
1734 /// tooltip shown if the given string is not `NULL`:
1735 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1736 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1737 /// the default signal handler.
1738 ///
1739 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1740 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1741 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1742 Self {
1743 builder: self
1744 .builder
1745 .property("tooltip-markup", tooltip_markup.into()),
1746 }
1747 }
1748
1749 /// Sets the text of tooltip to be the given string.
1750 ///
1751 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1752 ///
1753 /// This is a convenience property which will take care of getting the
1754 /// tooltip shown if the given string is not `NULL`:
1755 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1756 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1757 /// the default signal handler.
1758 ///
1759 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1760 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1761 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1762 Self {
1763 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1764 }
1765 }
1766
1767 /// How to distribute vertical space if widget gets extra space.
1768 pub fn valign(self, valign: Align) -> Self {
1769 Self {
1770 builder: self.builder.property("valign", valign),
1771 }
1772 }
1773
1774 /// Whether to expand vertically.
1775 pub fn vexpand(self, vexpand: bool) -> Self {
1776 Self {
1777 builder: self.builder.property("vexpand", vexpand),
1778 }
1779 }
1780
1781 /// Whether to use the `vexpand` property.
1782 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1783 Self {
1784 builder: self.builder.property("vexpand-set", vexpand_set),
1785 }
1786 }
1787
1788 /// Whether the widget is visible.
1789 pub fn visible(self, visible: bool) -> Self {
1790 Self {
1791 builder: self.builder.property("visible", visible),
1792 }
1793 }
1794
1795 /// Overrides for width request of the widget.
1796 ///
1797 /// If this is -1, the natural request will be used.
1798 pub fn width_request(self, width_request: i32) -> Self {
1799 Self {
1800 builder: self.builder.property("width-request", width_request),
1801 }
1802 }
1803
1804 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1805 ///
1806 /// The accessible role cannot be changed once set.
1807 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1808 Self {
1809 builder: self.builder.property("accessible-role", accessible_role),
1810 }
1811 }
1812
1813 /// Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget.
1814 ///
1815 /// This adjustment is shared between the scrollable widget and its parent.
1816 pub fn hadjustment(self, hadjustment: &impl IsA<Adjustment>) -> Self {
1817 Self {
1818 builder: self
1819 .builder
1820 .property("hadjustment", hadjustment.clone().upcast()),
1821 }
1822 }
1823
1824 /// Determines when horizontal scrolling should start.
1825 pub fn hscroll_policy(self, hscroll_policy: ScrollablePolicy) -> Self {
1826 Self {
1827 builder: self.builder.property("hscroll-policy", hscroll_policy),
1828 }
1829 }
1830
1831 /// Vertical [`Adjustment`][crate::Adjustment] of the scrollable widget.
1832 ///
1833 /// This adjustment is shared between the scrollable widget and its parent.
1834 pub fn vadjustment(self, vadjustment: &impl IsA<Adjustment>) -> Self {
1835 Self {
1836 builder: self
1837 .builder
1838 .property("vadjustment", vadjustment.clone().upcast()),
1839 }
1840 }
1841
1842 /// Determines when vertical scrolling should start.
1843 pub fn vscroll_policy(self, vscroll_policy: ScrollablePolicy) -> Self {
1844 Self {
1845 builder: self.builder.property("vscroll-policy", vscroll_policy),
1846 }
1847 }
1848
1849 // rustdoc-stripper-ignore-next
1850 /// Build the [`ColumnView`].
1851 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1852 pub fn build(self) -> ColumnView {
1853 assert_initialized_main_thread!();
1854 self.builder.build()
1855 }
1856}