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