gtk4/auto/cell_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#![allow(deprecated)]
5
6use crate::{
7 Accessible, AccessibleRole, Align, Buildable, CellArea, CellAreaContext, CellLayout,
8 ConstraintTarget, LayoutManager, Orientable, Orientation, Overflow, TreeModel, TreePath,
9 Widget, ffi,
10};
11use glib::{
12 prelude::*,
13 signal::{SignalHandlerId, connect_raw},
14 translate::*,
15};
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19 /// List views use widgets to display their contents.
20 /// You can use [`Box`][crate::Box] instead
21 /// A widget displaying a single row of a GtkTreeModel
22 ///
23 /// A [`CellView`][crate::CellView] displays a single row of a [`TreeModel`][crate::TreeModel] using a [`CellArea`][crate::CellArea]
24 /// and [`CellAreaContext`][crate::CellAreaContext]. A [`CellAreaContext`][crate::CellAreaContext] can be provided to the
25 /// [`CellView`][crate::CellView] at construction time in order to keep the cellview in context
26 /// of a group of cell views, this ensures that the renderers displayed will
27 /// be properly aligned with each other (like the aligned cells in the menus
28 /// of [`ComboBox`][crate::ComboBox]).
29 ///
30 /// [`CellView`][crate::CellView] is [`Orientable`][crate::Orientable] in order to decide in which orientation
31 /// the underlying [`CellAreaContext`][crate::CellAreaContext] should be allocated. Taking the [`ComboBox`][crate::ComboBox]
32 /// menu as an example, cellviews should be oriented horizontally if the menus are
33 /// listed top-to-bottom and thus all share the same width but may have separate
34 /// individual heights (left-to-right menus should be allocated vertically since
35 /// they all share the same height but may have variable widths).
36 ///
37 /// ## CSS nodes
38 ///
39 /// GtkCellView has a single CSS node with name cellview.
40 ///
41 /// ## Properties
42 ///
43 ///
44 /// #### `cell-area`
45 /// The [`CellArea`][crate::CellArea] rendering cells
46 ///
47 /// If no area is specified when creating the cell view with gtk_cell_view_new_with_context()
48 /// a horizontally oriented [`CellArea`][crate::CellArea]Box will be used.
49 ///
50 /// since 3.0
51 ///
52 /// Readable | Writeable | Construct Only
53 ///
54 ///
55 /// #### `cell-area-context`
56 /// The [`CellAreaContext`][crate::CellAreaContext] used to compute the geometry of the cell view.
57 ///
58 /// A group of cell views can be assigned the same context in order to
59 /// ensure the sizes and cell alignments match across all the views with
60 /// the same context.
61 ///
62 /// [`ComboBox`][crate::ComboBox] menus uses this to assign the same context to all cell views
63 /// in the menu items for a single menu (each submenu creates its own
64 /// context since the size of each submenu does not depend on parent
65 /// or sibling menus).
66 ///
67 /// since 3.0
68 ///
69 /// Readable | Writeable | Construct Only
70 ///
71 ///
72 /// #### `draw-sensitive`
73 /// Whether all cells should be draw as sensitive for this view regardless
74 /// of the actual cell properties (used to make menus with submenus appear
75 /// sensitive when the items in submenus might be insensitive).
76 ///
77 /// since 3.0
78 ///
79 /// Readable | Writeable
80 ///
81 ///
82 /// #### `fit-model`
83 /// Whether the view should request enough space to always fit
84 /// the size of every row in the model (used by the combo box to
85 /// ensure the combo box size doesn't change when different items
86 /// are selected).
87 ///
88 /// since 3.0
89 ///
90 /// Readable | Writeable
91 ///
92 ///
93 /// #### `model`
94 /// The model for cell view
95 ///
96 /// since 2.10
97 ///
98 /// Readable | Writeable
99 /// <details><summary><h4>Widget</h4></summary>
100 ///
101 ///
102 /// #### `can-focus`
103 /// Whether the widget or any of its descendents can accept
104 /// the input focus.
105 ///
106 /// This property is meant to be set by widget implementations,
107 /// typically in their instance init function.
108 ///
109 /// Readable | Writeable
110 ///
111 ///
112 /// #### `can-target`
113 /// Whether the widget can receive pointer events.
114 ///
115 /// Readable | Writeable
116 ///
117 ///
118 /// #### `css-classes`
119 /// A list of css classes applied to this widget.
120 ///
121 /// Readable | Writeable
122 ///
123 ///
124 /// #### `css-name`
125 /// The name of this widget in the CSS tree.
126 ///
127 /// This property is meant to be set by widget implementations,
128 /// typically in their instance init function.
129 ///
130 /// Readable | Writeable | Construct Only
131 ///
132 ///
133 /// #### `cursor`
134 /// The cursor used by @widget.
135 ///
136 /// Readable | Writeable
137 ///
138 ///
139 /// #### `focus-on-click`
140 /// Whether the widget should grab focus when it is clicked with the mouse.
141 ///
142 /// This property is only relevant for widgets that can take focus.
143 ///
144 /// Readable | Writeable
145 ///
146 ///
147 /// #### `focusable`
148 /// Whether this widget itself will accept the input focus.
149 ///
150 /// Readable | Writeable
151 ///
152 ///
153 /// #### `halign`
154 /// How to distribute horizontal space if widget gets extra space.
155 ///
156 /// Readable | Writeable
157 ///
158 ///
159 /// #### `has-default`
160 /// Whether the widget is the default widget.
161 ///
162 /// Readable
163 ///
164 ///
165 /// #### `has-focus`
166 /// Whether the widget has the input focus.
167 ///
168 /// Readable
169 ///
170 ///
171 /// #### `has-tooltip`
172 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
173 /// signal on @widget.
174 ///
175 /// A true value indicates that @widget can have a tooltip, in this case
176 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
177 /// determine whether it will provide a tooltip or not.
178 ///
179 /// Readable | Writeable
180 ///
181 ///
182 /// #### `height-request`
183 /// Overrides for height request of the widget.
184 ///
185 /// If this is -1, the natural request will be used.
186 ///
187 /// Readable | Writeable
188 ///
189 ///
190 /// #### `hexpand`
191 /// Whether to expand horizontally.
192 ///
193 /// Readable | Writeable
194 ///
195 ///
196 /// #### `hexpand-set`
197 /// Whether to use the `hexpand` property.
198 ///
199 /// Readable | Writeable
200 ///
201 ///
202 /// #### `layout-manager`
203 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
204 /// the preferred size of the widget, and allocate its children.
205 ///
206 /// This property is meant to be set by widget implementations,
207 /// typically in their instance init function.
208 ///
209 /// Readable | Writeable
210 ///
211 ///
212 /// #### `limit-events`
213 /// Makes this widget act like a modal dialog, with respect to
214 /// event delivery.
215 ///
216 /// Global event controllers will not handle events with targets
217 /// inside the widget, unless they are set up to ignore propagation
218 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
219 ///
220 /// Readable | Writeable
221 ///
222 ///
223 /// #### `margin-bottom`
224 /// Margin on bottom side of widget.
225 ///
226 /// This property adds margin outside of the widget's normal size
227 /// request, the margin will be added in addition to the size from
228 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
229 ///
230 /// Readable | Writeable
231 ///
232 ///
233 /// #### `margin-end`
234 /// Margin on end of widget, horizontally.
235 ///
236 /// This property supports left-to-right and right-to-left text
237 /// directions.
238 ///
239 /// This property adds margin outside of the widget's normal size
240 /// request, the margin will be added in addition to the size from
241 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
242 ///
243 /// Readable | Writeable
244 ///
245 ///
246 /// #### `margin-start`
247 /// Margin on start of widget, horizontally.
248 ///
249 /// This property supports left-to-right and right-to-left text
250 /// directions.
251 ///
252 /// This property adds margin outside of the widget's normal size
253 /// request, the margin will be added in addition to the size from
254 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
255 ///
256 /// Readable | Writeable
257 ///
258 ///
259 /// #### `margin-top`
260 /// Margin on top side of widget.
261 ///
262 /// This property adds margin outside of the widget's normal size
263 /// request, the margin will be added in addition to the size from
264 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
265 ///
266 /// Readable | Writeable
267 ///
268 ///
269 /// #### `name`
270 /// The name of the widget.
271 ///
272 /// Readable | Writeable
273 ///
274 ///
275 /// #### `opacity`
276 /// The requested opacity of the widget.
277 ///
278 /// Readable | Writeable
279 ///
280 ///
281 /// #### `overflow`
282 /// How content outside the widget's content area is treated.
283 ///
284 /// This property is meant to be set by widget implementations,
285 /// typically in their instance init function.
286 ///
287 /// Readable | Writeable
288 ///
289 ///
290 /// #### `parent`
291 /// The parent widget of this widget.
292 ///
293 /// Readable
294 ///
295 ///
296 /// #### `receives-default`
297 /// Whether the widget will receive the default action when it is focused.
298 ///
299 /// Readable | Writeable
300 ///
301 ///
302 /// #### `root`
303 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
304 ///
305 /// This will be `NULL` if the widget is not contained in a root widget.
306 ///
307 /// Readable
308 ///
309 ///
310 /// #### `scale-factor`
311 /// The scale factor of the widget.
312 ///
313 /// Readable
314 ///
315 ///
316 /// #### `sensitive`
317 /// Whether the widget responds to input.
318 ///
319 /// Readable | Writeable
320 ///
321 ///
322 /// #### `tooltip-markup`
323 /// Sets the text of tooltip to be the given string, which is marked up
324 /// with Pango markup.
325 ///
326 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
327 ///
328 /// This is a convenience property which will take care of getting the
329 /// tooltip shown if the given string is not `NULL`:
330 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
331 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
332 /// the default signal handler.
333 ///
334 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
335 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
336 ///
337 /// Readable | Writeable
338 ///
339 ///
340 /// #### `tooltip-text`
341 /// Sets the text of tooltip to be the given string.
342 ///
343 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
344 ///
345 /// This is a convenience property which will take care of getting the
346 /// tooltip shown if the given string is not `NULL`:
347 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
348 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
349 /// the default signal handler.
350 ///
351 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
352 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
353 ///
354 /// Readable | Writeable
355 ///
356 ///
357 /// #### `valign`
358 /// How to distribute vertical space if widget gets extra space.
359 ///
360 /// Readable | Writeable
361 ///
362 ///
363 /// #### `vexpand`
364 /// Whether to expand vertically.
365 ///
366 /// Readable | Writeable
367 ///
368 ///
369 /// #### `vexpand-set`
370 /// Whether to use the `vexpand` property.
371 ///
372 /// Readable | Writeable
373 ///
374 ///
375 /// #### `visible`
376 /// Whether the widget is visible.
377 ///
378 /// Readable | Writeable
379 ///
380 ///
381 /// #### `width-request`
382 /// Overrides for width request of the widget.
383 ///
384 /// If this is -1, the natural request will be used.
385 ///
386 /// Readable | Writeable
387 /// </details>
388 /// <details><summary><h4>Accessible</h4></summary>
389 ///
390 ///
391 /// #### `accessible-role`
392 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
393 ///
394 /// The accessible role cannot be changed once set.
395 ///
396 /// Readable | Writeable
397 /// </details>
398 /// <details><summary><h4>Orientable</h4></summary>
399 ///
400 ///
401 /// #### `orientation`
402 /// The orientation of the orientable.
403 ///
404 /// Readable | Writeable
405 /// </details>
406 ///
407 /// # Implements
408 ///
409 /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`CellLayoutExt`][trait@crate::prelude::CellLayoutExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual], [`CellLayoutExtManual`][trait@crate::prelude::CellLayoutExtManual]
410 #[doc(alias = "GtkCellView")]
411 pub struct CellView(Object<ffi::GtkCellView>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, CellLayout, Orientable;
412
413 match fn {
414 type_ => || ffi::gtk_cell_view_get_type(),
415 }
416}
417
418impl CellView {
419 /// Creates a new [`CellView`][crate::CellView] widget.
420 ///
421 /// # Deprecated since 4.10
422 ///
423 ///
424 /// # Returns
425 ///
426 /// A newly created [`CellView`][crate::CellView] widget.
427 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
428 #[allow(deprecated)]
429 #[doc(alias = "gtk_cell_view_new")]
430 pub fn new() -> CellView {
431 assert_initialized_main_thread!();
432 unsafe { Widget::from_glib_none(ffi::gtk_cell_view_new()).unsafe_cast() }
433 }
434
435 /// Creates a new [`CellView`][crate::CellView] widget with a specific [`CellArea`][crate::CellArea]
436 /// to layout cells and a specific [`CellAreaContext`][crate::CellAreaContext].
437 ///
438 /// Specifying the same context for a handful of cells lets
439 /// the underlying area synchronize the geometry for those cells,
440 /// in this way alignments with cellviews for other rows are
441 /// possible.
442 ///
443 /// # Deprecated since 4.10
444 ///
445 /// ## `area`
446 /// the [`CellArea`][crate::CellArea] to layout cells
447 /// ## `context`
448 /// the [`CellAreaContext`][crate::CellAreaContext] in which to calculate cell geometry
449 ///
450 /// # Returns
451 ///
452 /// A newly created [`CellView`][crate::CellView] widget.
453 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
454 #[allow(deprecated)]
455 #[doc(alias = "gtk_cell_view_new_with_context")]
456 #[doc(alias = "new_with_context")]
457 pub fn with_context(
458 area: &impl IsA<CellArea>,
459 context: &impl IsA<CellAreaContext>,
460 ) -> CellView {
461 skip_assert_initialized!();
462 unsafe {
463 Widget::from_glib_none(ffi::gtk_cell_view_new_with_context(
464 area.as_ref().to_glib_none().0,
465 context.as_ref().to_glib_none().0,
466 ))
467 .unsafe_cast()
468 }
469 }
470
471 /// Creates a new [`CellView`][crate::CellView] widget, adds a [`CellRendererText`][crate::CellRendererText]
472 /// to it, and makes it show @markup. The text can be marked up with
473 /// the [Pango text markup language](https://docs.gtk.org/Pango/pango_markup.html).
474 ///
475 /// # Deprecated since 4.10
476 ///
477 /// ## `markup`
478 /// the text to display in the cell view
479 ///
480 /// # Returns
481 ///
482 /// A newly created [`CellView`][crate::CellView] widget.
483 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
484 #[allow(deprecated)]
485 #[doc(alias = "gtk_cell_view_new_with_markup")]
486 #[doc(alias = "new_with_markup")]
487 pub fn with_markup(markup: &str) -> CellView {
488 assert_initialized_main_thread!();
489 unsafe {
490 Widget::from_glib_none(ffi::gtk_cell_view_new_with_markup(markup.to_glib_none().0))
491 .unsafe_cast()
492 }
493 }
494
495 /// Creates a new [`CellView`][crate::CellView] widget, adds a [`CellRendererText`][crate::CellRendererText]
496 /// to it, and makes it show @text.
497 ///
498 /// # Deprecated since 4.10
499 ///
500 /// ## `text`
501 /// the text to display in the cell view
502 ///
503 /// # Returns
504 ///
505 /// A newly created [`CellView`][crate::CellView] widget.
506 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
507 #[allow(deprecated)]
508 #[doc(alias = "gtk_cell_view_new_with_text")]
509 #[doc(alias = "new_with_text")]
510 pub fn with_text(text: &str) -> CellView {
511 assert_initialized_main_thread!();
512 unsafe {
513 Widget::from_glib_none(ffi::gtk_cell_view_new_with_text(text.to_glib_none().0))
514 .unsafe_cast()
515 }
516 }
517
518 /// Creates a new [`CellView`][crate::CellView] widget, adds a [`CellRendererPixbuf`][crate::CellRendererPixbuf]
519 /// to it, and makes it show @texture.
520 ///
521 /// # Deprecated since 4.10
522 ///
523 /// ## `texture`
524 /// the image to display in the cell view
525 ///
526 /// # Returns
527 ///
528 /// A newly created [`CellView`][crate::CellView] widget.
529 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
530 #[allow(deprecated)]
531 #[doc(alias = "gtk_cell_view_new_with_texture")]
532 #[doc(alias = "new_with_texture")]
533 pub fn with_texture(texture: &impl IsA<gdk::Texture>) -> CellView {
534 assert_initialized_main_thread!();
535 unsafe {
536 Widget::from_glib_none(ffi::gtk_cell_view_new_with_texture(
537 texture.as_ref().to_glib_none().0,
538 ))
539 .unsafe_cast()
540 }
541 }
542
543 // rustdoc-stripper-ignore-next
544 /// Creates a new builder-pattern struct instance to construct [`CellView`] objects.
545 ///
546 /// This method returns an instance of [`CellViewBuilder`](crate::builders::CellViewBuilder) which can be used to create [`CellView`] objects.
547 pub fn builder() -> CellViewBuilder {
548 CellViewBuilder::new()
549 }
550
551 /// Returns a [`TreePath`][crate::TreePath] referring to the currently
552 /// displayed row. If no row is currently displayed,
553 /// [`None`] is returned.
554 ///
555 /// # Deprecated since 4.10
556 ///
557 ///
558 /// # Returns
559 ///
560 /// the currently displayed row
561 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
562 #[allow(deprecated)]
563 #[doc(alias = "gtk_cell_view_get_displayed_row")]
564 #[doc(alias = "get_displayed_row")]
565 pub fn displayed_row(&self) -> Option<TreePath> {
566 unsafe { from_glib_full(ffi::gtk_cell_view_get_displayed_row(self.to_glib_none().0)) }
567 }
568
569 /// Gets whether @self is configured to draw all of its
570 /// cells in a sensitive state.
571 ///
572 /// # Deprecated since 4.10
573 ///
574 ///
575 /// # Returns
576 ///
577 /// whether @self draws all of its
578 /// cells in a sensitive state
579 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
580 #[allow(deprecated)]
581 #[doc(alias = "gtk_cell_view_get_draw_sensitive")]
582 #[doc(alias = "get_draw_sensitive")]
583 #[doc(alias = "draw-sensitive")]
584 pub fn draws_sensitive(&self) -> bool {
585 unsafe { from_glib(ffi::gtk_cell_view_get_draw_sensitive(self.to_glib_none().0)) }
586 }
587
588 /// Gets whether @self is configured to request space
589 /// to fit the entire [`TreeModel`][crate::TreeModel].
590 ///
591 /// # Deprecated since 4.10
592 ///
593 ///
594 /// # Returns
595 ///
596 /// whether @self requests space to fit
597 /// the entire [`TreeModel`][crate::TreeModel].
598 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
599 #[allow(deprecated)]
600 #[doc(alias = "gtk_cell_view_get_fit_model")]
601 #[doc(alias = "get_fit_model")]
602 #[doc(alias = "fit-model")]
603 pub fn fits_model(&self) -> bool {
604 unsafe { from_glib(ffi::gtk_cell_view_get_fit_model(self.to_glib_none().0)) }
605 }
606
607 /// Returns the model for @self. If no model is used [`None`] is
608 /// returned.
609 ///
610 /// # Deprecated since 4.10
611 ///
612 ///
613 /// # Returns
614 ///
615 /// a [`TreeModel`][crate::TreeModel] used
616 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
617 #[allow(deprecated)]
618 #[doc(alias = "gtk_cell_view_get_model")]
619 #[doc(alias = "get_model")]
620 pub fn model(&self) -> Option<TreeModel> {
621 unsafe { from_glib_none(ffi::gtk_cell_view_get_model(self.to_glib_none().0)) }
622 }
623
624 /// Sets the row of the model that is currently displayed
625 /// by the [`CellView`][crate::CellView]. If the path is unset, then the
626 /// contents of the cellview “stick” at their last value;
627 /// this is not normally a desired result, but may be
628 /// a needed intermediate state if say, the model for
629 /// the [`CellView`][crate::CellView] becomes temporarily empty.
630 ///
631 /// # Deprecated since 4.10
632 ///
633 /// ## `path`
634 /// a [`TreePath`][crate::TreePath] or [`None`] to unset.
635 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
636 #[allow(deprecated)]
637 #[doc(alias = "gtk_cell_view_set_displayed_row")]
638 pub fn set_displayed_row(&self, path: Option<&TreePath>) {
639 unsafe {
640 ffi::gtk_cell_view_set_displayed_row(
641 self.to_glib_none().0,
642 mut_override(path.to_glib_none().0),
643 );
644 }
645 }
646
647 /// Sets whether @self should draw all of its
648 /// cells in a sensitive state, this is used by [`ComboBox`][crate::ComboBox] menus
649 /// to ensure that rows with insensitive cells that contain
650 /// children appear sensitive in the parent menu item.
651 ///
652 /// # Deprecated since 4.10
653 ///
654 /// ## `draw_sensitive`
655 /// whether to draw all cells in a sensitive state.
656 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
657 #[allow(deprecated)]
658 #[doc(alias = "gtk_cell_view_set_draw_sensitive")]
659 #[doc(alias = "draw-sensitive")]
660 pub fn set_draw_sensitive(&self, draw_sensitive: bool) {
661 unsafe {
662 ffi::gtk_cell_view_set_draw_sensitive(
663 self.to_glib_none().0,
664 draw_sensitive.into_glib(),
665 );
666 }
667 }
668
669 /// Sets whether @self should request space to fit the entire [`TreeModel`][crate::TreeModel].
670 ///
671 /// This is used by [`ComboBox`][crate::ComboBox] to ensure that the cell view displayed on
672 /// the combo box’s button always gets enough space and does not resize
673 /// when selection changes.
674 ///
675 /// # Deprecated since 4.10
676 ///
677 /// ## `fit_model`
678 /// whether @self should request space for the whole model.
679 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
680 #[allow(deprecated)]
681 #[doc(alias = "gtk_cell_view_set_fit_model")]
682 #[doc(alias = "fit-model")]
683 pub fn set_fit_model(&self, fit_model: bool) {
684 unsafe {
685 ffi::gtk_cell_view_set_fit_model(self.to_glib_none().0, fit_model.into_glib());
686 }
687 }
688
689 /// Sets the model for @self. If @self already has a model
690 /// set, it will remove it before setting the new model. If @model is
691 /// [`None`], then it will unset the old model.
692 ///
693 /// # Deprecated since 4.10
694 ///
695 /// ## `model`
696 /// a [`TreeModel`][crate::TreeModel]
697 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
698 #[allow(deprecated)]
699 #[doc(alias = "gtk_cell_view_set_model")]
700 #[doc(alias = "model")]
701 pub fn set_model(&self, model: Option<&impl IsA<TreeModel>>) {
702 unsafe {
703 ffi::gtk_cell_view_set_model(
704 self.to_glib_none().0,
705 model.map(|p| p.as_ref()).to_glib_none().0,
706 );
707 }
708 }
709
710 /// The [`CellArea`][crate::CellArea] rendering cells
711 ///
712 /// If no area is specified when creating the cell view with gtk_cell_view_new_with_context()
713 /// a horizontally oriented [`CellArea`][crate::CellArea]Box will be used.
714 ///
715 /// since 3.0
716 #[doc(alias = "cell-area")]
717 pub fn cell_area(&self) -> Option<CellArea> {
718 ObjectExt::property(self, "cell-area")
719 }
720
721 /// The [`CellAreaContext`][crate::CellAreaContext] used to compute the geometry of the cell view.
722 ///
723 /// A group of cell views can be assigned the same context in order to
724 /// ensure the sizes and cell alignments match across all the views with
725 /// the same context.
726 ///
727 /// [`ComboBox`][crate::ComboBox] menus uses this to assign the same context to all cell views
728 /// in the menu items for a single menu (each submenu creates its own
729 /// context since the size of each submenu does not depend on parent
730 /// or sibling menus).
731 ///
732 /// since 3.0
733 #[doc(alias = "cell-area-context")]
734 pub fn cell_area_context(&self) -> Option<CellAreaContext> {
735 ObjectExt::property(self, "cell-area-context")
736 }
737
738 #[doc(alias = "draw-sensitive")]
739 pub fn connect_draw_sensitive_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
740 unsafe extern "C" fn notify_draw_sensitive_trampoline<F: Fn(&CellView) + 'static>(
741 this: *mut ffi::GtkCellView,
742 _param_spec: glib::ffi::gpointer,
743 f: glib::ffi::gpointer,
744 ) {
745 unsafe {
746 let f: &F = &*(f as *const F);
747 f(&from_glib_borrow(this))
748 }
749 }
750 unsafe {
751 let f: Box_<F> = Box_::new(f);
752 connect_raw(
753 self.as_ptr() as *mut _,
754 c"notify::draw-sensitive".as_ptr() as *const _,
755 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
756 notify_draw_sensitive_trampoline::<F> as *const (),
757 )),
758 Box_::into_raw(f),
759 )
760 }
761 }
762
763 #[doc(alias = "fit-model")]
764 pub fn connect_fit_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
765 unsafe extern "C" fn notify_fit_model_trampoline<F: Fn(&CellView) + 'static>(
766 this: *mut ffi::GtkCellView,
767 _param_spec: glib::ffi::gpointer,
768 f: glib::ffi::gpointer,
769 ) {
770 unsafe {
771 let f: &F = &*(f as *const F);
772 f(&from_glib_borrow(this))
773 }
774 }
775 unsafe {
776 let f: Box_<F> = Box_::new(f);
777 connect_raw(
778 self.as_ptr() as *mut _,
779 c"notify::fit-model".as_ptr() as *const _,
780 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
781 notify_fit_model_trampoline::<F> as *const (),
782 )),
783 Box_::into_raw(f),
784 )
785 }
786 }
787
788 #[doc(alias = "model")]
789 pub fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
790 unsafe extern "C" fn notify_model_trampoline<F: Fn(&CellView) + 'static>(
791 this: *mut ffi::GtkCellView,
792 _param_spec: glib::ffi::gpointer,
793 f: glib::ffi::gpointer,
794 ) {
795 unsafe {
796 let f: &F = &*(f as *const F);
797 f(&from_glib_borrow(this))
798 }
799 }
800 unsafe {
801 let f: Box_<F> = Box_::new(f);
802 connect_raw(
803 self.as_ptr() as *mut _,
804 c"notify::model".as_ptr() as *const _,
805 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
806 notify_model_trampoline::<F> as *const (),
807 )),
808 Box_::into_raw(f),
809 )
810 }
811 }
812}
813
814impl Default for CellView {
815 fn default() -> Self {
816 Self::new()
817 }
818}
819
820// rustdoc-stripper-ignore-next
821/// A [builder-pattern] type to construct [`CellView`] objects.
822///
823/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
824#[must_use = "The builder must be built to be used"]
825pub struct CellViewBuilder {
826 builder: glib::object::ObjectBuilder<'static, CellView>,
827}
828
829impl CellViewBuilder {
830 fn new() -> Self {
831 Self {
832 builder: glib::object::Object::builder(),
833 }
834 }
835
836 /// The [`CellArea`][crate::CellArea] rendering cells
837 ///
838 /// If no area is specified when creating the cell view with gtk_cell_view_new_with_context()
839 /// a horizontally oriented [`CellArea`][crate::CellArea]Box will be used.
840 ///
841 /// since 3.0
842 pub fn cell_area(self, cell_area: &impl IsA<CellArea>) -> Self {
843 Self {
844 builder: self
845 .builder
846 .property("cell-area", cell_area.clone().upcast()),
847 }
848 }
849
850 /// The [`CellAreaContext`][crate::CellAreaContext] used to compute the geometry of the cell view.
851 ///
852 /// A group of cell views can be assigned the same context in order to
853 /// ensure the sizes and cell alignments match across all the views with
854 /// the same context.
855 ///
856 /// [`ComboBox`][crate::ComboBox] menus uses this to assign the same context to all cell views
857 /// in the menu items for a single menu (each submenu creates its own
858 /// context since the size of each submenu does not depend on parent
859 /// or sibling menus).
860 ///
861 /// since 3.0
862 pub fn cell_area_context(self, cell_area_context: &impl IsA<CellAreaContext>) -> Self {
863 Self {
864 builder: self
865 .builder
866 .property("cell-area-context", cell_area_context.clone().upcast()),
867 }
868 }
869
870 /// Whether all cells should be draw as sensitive for this view regardless
871 /// of the actual cell properties (used to make menus with submenus appear
872 /// sensitive when the items in submenus might be insensitive).
873 ///
874 /// since 3.0
875 pub fn draw_sensitive(self, draw_sensitive: bool) -> Self {
876 Self {
877 builder: self.builder.property("draw-sensitive", draw_sensitive),
878 }
879 }
880
881 /// Whether the view should request enough space to always fit
882 /// the size of every row in the model (used by the combo box to
883 /// ensure the combo box size doesn't change when different items
884 /// are selected).
885 ///
886 /// since 3.0
887 pub fn fit_model(self, fit_model: bool) -> Self {
888 Self {
889 builder: self.builder.property("fit-model", fit_model),
890 }
891 }
892
893 /// The model for cell view
894 ///
895 /// since 2.10
896 pub fn model(self, model: &impl IsA<TreeModel>) -> Self {
897 Self {
898 builder: self.builder.property("model", model.clone().upcast()),
899 }
900 }
901
902 /// Whether the widget or any of its descendents can accept
903 /// the input focus.
904 ///
905 /// This property is meant to be set by widget implementations,
906 /// typically in their instance init function.
907 pub fn can_focus(self, can_focus: bool) -> Self {
908 Self {
909 builder: self.builder.property("can-focus", can_focus),
910 }
911 }
912
913 /// Whether the widget can receive pointer events.
914 pub fn can_target(self, can_target: bool) -> Self {
915 Self {
916 builder: self.builder.property("can-target", can_target),
917 }
918 }
919
920 /// A list of css classes applied to this widget.
921 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
922 Self {
923 builder: self.builder.property("css-classes", css_classes.into()),
924 }
925 }
926
927 /// The name of this widget in the CSS tree.
928 ///
929 /// This property is meant to be set by widget implementations,
930 /// typically in their instance init function.
931 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
932 Self {
933 builder: self.builder.property("css-name", css_name.into()),
934 }
935 }
936
937 /// The cursor used by @widget.
938 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
939 Self {
940 builder: self.builder.property("cursor", cursor.clone()),
941 }
942 }
943
944 /// Whether the widget should grab focus when it is clicked with the mouse.
945 ///
946 /// This property is only relevant for widgets that can take focus.
947 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
948 Self {
949 builder: self.builder.property("focus-on-click", focus_on_click),
950 }
951 }
952
953 /// Whether this widget itself will accept the input focus.
954 pub fn focusable(self, focusable: bool) -> Self {
955 Self {
956 builder: self.builder.property("focusable", focusable),
957 }
958 }
959
960 /// How to distribute horizontal space if widget gets extra space.
961 pub fn halign(self, halign: Align) -> Self {
962 Self {
963 builder: self.builder.property("halign", halign),
964 }
965 }
966
967 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
968 /// signal on @widget.
969 ///
970 /// A true value indicates that @widget can have a tooltip, in this case
971 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
972 /// determine whether it will provide a tooltip or not.
973 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
974 Self {
975 builder: self.builder.property("has-tooltip", has_tooltip),
976 }
977 }
978
979 /// Overrides for height request of the widget.
980 ///
981 /// If this is -1, the natural request will be used.
982 pub fn height_request(self, height_request: i32) -> Self {
983 Self {
984 builder: self.builder.property("height-request", height_request),
985 }
986 }
987
988 /// Whether to expand horizontally.
989 pub fn hexpand(self, hexpand: bool) -> Self {
990 Self {
991 builder: self.builder.property("hexpand", hexpand),
992 }
993 }
994
995 /// Whether to use the `hexpand` property.
996 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
997 Self {
998 builder: self.builder.property("hexpand-set", hexpand_set),
999 }
1000 }
1001
1002 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1003 /// the preferred size of the widget, and allocate its children.
1004 ///
1005 /// This property is meant to be set by widget implementations,
1006 /// typically in their instance init function.
1007 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1008 Self {
1009 builder: self
1010 .builder
1011 .property("layout-manager", layout_manager.clone().upcast()),
1012 }
1013 }
1014
1015 /// Makes this widget act like a modal dialog, with respect to
1016 /// event delivery.
1017 ///
1018 /// Global event controllers will not handle events with targets
1019 /// inside the widget, unless they are set up to ignore propagation
1020 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1021 #[cfg(feature = "v4_18")]
1022 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1023 pub fn limit_events(self, limit_events: bool) -> Self {
1024 Self {
1025 builder: self.builder.property("limit-events", limit_events),
1026 }
1027 }
1028
1029 /// Margin on bottom side of widget.
1030 ///
1031 /// This property adds margin outside of the widget's normal size
1032 /// request, the margin will be added in addition to the size from
1033 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1034 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1035 Self {
1036 builder: self.builder.property("margin-bottom", margin_bottom),
1037 }
1038 }
1039
1040 /// Margin on end of widget, horizontally.
1041 ///
1042 /// This property supports left-to-right and right-to-left text
1043 /// directions.
1044 ///
1045 /// This property adds margin outside of the widget's normal size
1046 /// request, the margin will be added in addition to the size from
1047 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1048 pub fn margin_end(self, margin_end: i32) -> Self {
1049 Self {
1050 builder: self.builder.property("margin-end", margin_end),
1051 }
1052 }
1053
1054 /// Margin on start of widget, horizontally.
1055 ///
1056 /// This property supports left-to-right and right-to-left text
1057 /// directions.
1058 ///
1059 /// This property adds margin outside of the widget's normal size
1060 /// request, the margin will be added in addition to the size from
1061 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1062 pub fn margin_start(self, margin_start: i32) -> Self {
1063 Self {
1064 builder: self.builder.property("margin-start", margin_start),
1065 }
1066 }
1067
1068 /// Margin on top side of widget.
1069 ///
1070 /// This property adds margin outside of the widget's normal size
1071 /// request, the margin will be added in addition to the size from
1072 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1073 pub fn margin_top(self, margin_top: i32) -> Self {
1074 Self {
1075 builder: self.builder.property("margin-top", margin_top),
1076 }
1077 }
1078
1079 /// The name of the widget.
1080 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1081 Self {
1082 builder: self.builder.property("name", name.into()),
1083 }
1084 }
1085
1086 /// The requested opacity of the widget.
1087 pub fn opacity(self, opacity: f64) -> Self {
1088 Self {
1089 builder: self.builder.property("opacity", opacity),
1090 }
1091 }
1092
1093 /// How content outside the widget's content area is treated.
1094 ///
1095 /// This property is meant to be set by widget implementations,
1096 /// typically in their instance init function.
1097 pub fn overflow(self, overflow: Overflow) -> Self {
1098 Self {
1099 builder: self.builder.property("overflow", overflow),
1100 }
1101 }
1102
1103 /// Whether the widget will receive the default action when it is focused.
1104 pub fn receives_default(self, receives_default: bool) -> Self {
1105 Self {
1106 builder: self.builder.property("receives-default", receives_default),
1107 }
1108 }
1109
1110 /// Whether the widget responds to input.
1111 pub fn sensitive(self, sensitive: bool) -> Self {
1112 Self {
1113 builder: self.builder.property("sensitive", sensitive),
1114 }
1115 }
1116
1117 /// Sets the text of tooltip to be the given string, which is marked up
1118 /// with Pango markup.
1119 ///
1120 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1121 ///
1122 /// This is a convenience property which will take care of getting the
1123 /// tooltip shown if the given string is not `NULL`:
1124 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1125 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1126 /// the default signal handler.
1127 ///
1128 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1129 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1130 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1131 Self {
1132 builder: self
1133 .builder
1134 .property("tooltip-markup", tooltip_markup.into()),
1135 }
1136 }
1137
1138 /// Sets the text of tooltip to be the given string.
1139 ///
1140 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1141 ///
1142 /// This is a convenience property which will take care of getting the
1143 /// tooltip shown if the given string is not `NULL`:
1144 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1145 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1146 /// the default signal handler.
1147 ///
1148 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1149 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1150 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1151 Self {
1152 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1153 }
1154 }
1155
1156 /// How to distribute vertical space if widget gets extra space.
1157 pub fn valign(self, valign: Align) -> Self {
1158 Self {
1159 builder: self.builder.property("valign", valign),
1160 }
1161 }
1162
1163 /// Whether to expand vertically.
1164 pub fn vexpand(self, vexpand: bool) -> Self {
1165 Self {
1166 builder: self.builder.property("vexpand", vexpand),
1167 }
1168 }
1169
1170 /// Whether to use the `vexpand` property.
1171 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1172 Self {
1173 builder: self.builder.property("vexpand-set", vexpand_set),
1174 }
1175 }
1176
1177 /// Whether the widget is visible.
1178 pub fn visible(self, visible: bool) -> Self {
1179 Self {
1180 builder: self.builder.property("visible", visible),
1181 }
1182 }
1183
1184 /// Overrides for width request of the widget.
1185 ///
1186 /// If this is -1, the natural request will be used.
1187 pub fn width_request(self, width_request: i32) -> Self {
1188 Self {
1189 builder: self.builder.property("width-request", width_request),
1190 }
1191 }
1192
1193 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1194 ///
1195 /// The accessible role cannot be changed once set.
1196 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1197 Self {
1198 builder: self.builder.property("accessible-role", accessible_role),
1199 }
1200 }
1201
1202 /// The orientation of the orientable.
1203 pub fn orientation(self, orientation: Orientation) -> Self {
1204 Self {
1205 builder: self.builder.property("orientation", orientation),
1206 }
1207 }
1208
1209 // rustdoc-stripper-ignore-next
1210 /// Build the [`CellView`].
1211 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1212 pub fn build(self) -> CellView {
1213 assert_initialized_main_thread!();
1214 self.builder.build()
1215 }
1216}