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,
8};
9use glib::{
10 prelude::*,
11 signal::{connect_raw, SignalHandlerId},
12 translate::*,
13};
14use std::{boxed::Box as Box_, fmt, mem::transmute};
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 /// Writeable
40 ///
41 ///
42 /// #### `background-gdk`
43 /// The background color as a `GdkColor`
44 ///
45 /// Readable | Writeable
46 ///
47 ///
48 /// #### `background-rgba`
49 /// The background color as a [`gdk::RGBA`][crate::gdk::RGBA]
50 ///
51 /// Readable | Writeable
52 ///
53 ///
54 /// #### `background-set`
55 /// Readable | Writeable
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 | Writeable | 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 | Writeable | 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 | Writeable
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 | Writeable
105 ///
106 ///
107 /// #### `model`
108 /// The model for cell view
109 ///
110 /// since 2.10
111 ///
112 /// Readable | Writeable
113 /// <details><summary><h4>Widget</h4></summary>
114 ///
115 ///
116 /// #### `app-paintable`
117 /// Readable | Writeable
118 ///
119 ///
120 /// #### `can-default`
121 /// Readable | Writeable
122 ///
123 ///
124 /// #### `can-focus`
125 /// Readable | Writeable
126 ///
127 ///
128 /// #### `composite-child`
129 /// Readable
130 ///
131 ///
132 /// #### `double-buffered`
133 /// Whether the widget is double buffered.
134 ///
135 /// Readable | Writeable
136 ///
137 ///
138 /// #### `events`
139 /// Readable | Writeable
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 | Writeable
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 | Writeable
157 ///
158 ///
159 /// #### `halign`
160 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
161 ///
162 /// Readable | Writeable
163 ///
164 ///
165 /// #### `has-default`
166 /// Readable | Writeable
167 ///
168 ///
169 /// #### `has-focus`
170 /// Readable | Writeable
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 | Writeable
185 ///
186 ///
187 /// #### `height-request`
188 /// Readable | Writeable
189 ///
190 ///
191 /// #### `hexpand`
192 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
193 ///
194 /// Readable | Writeable
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 | Writeable
201 ///
202 ///
203 /// #### `is-focus`
204 /// Readable | Writeable
205 ///
206 ///
207 /// #### `margin`
208 /// Sets all four sides' margin at once. If read, returns max
209 /// margin on any side.
210 ///
211 /// Readable | Writeable
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 | Writeable
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 | Writeable
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 | Writeable
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 | Writeable
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 | Writeable
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 | Writeable
274 ///
275 ///
276 /// #### `name`
277 /// Readable | Writeable
278 ///
279 ///
280 /// #### `no-show-all`
281 /// Readable | Writeable
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 | Writeable
291 ///
292 ///
293 /// #### `parent`
294 /// Readable | Writeable
295 ///
296 ///
297 /// #### `receives-default`
298 /// Readable | Writeable
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 | Writeable
310 ///
311 ///
312 /// #### `style`
313 /// The style of the widget, which contains information about how it will look (colors, etc).
314 ///
315 /// Readable | Writeable
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 | Writeable
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 | Writeable
348 ///
349 ///
350 /// #### `valign`
351 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
352 ///
353 /// Readable | Writeable
354 ///
355 ///
356 /// #### `vexpand`
357 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
358 ///
359 /// Readable | Writeable
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 | Writeable
366 ///
367 ///
368 /// #### `visible`
369 /// Readable | Writeable
370 ///
371 ///
372 /// #### `width-request`
373 /// Readable | Writeable
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 | Writeable
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 self.builder.build()
895 }
896}
897
898mod sealed {
899 pub trait Sealed {}
900 impl<T: super::IsA<super::CellView>> Sealed for T {}
901}
902
903/// Trait containing all [`struct@CellView`] methods.
904///
905/// # Implementors
906///
907/// [`CellView`][struct@crate::CellView]
908pub trait CellViewExt: IsA<CellView> + sealed::Sealed + 'static {
909 /// Returns a [`TreePath`][crate::TreePath] referring to the currently
910 /// displayed row. If no row is currently displayed,
911 /// [`None`] is returned.
912 ///
913 /// # Returns
914 ///
915 /// the currently displayed row or [`None`]
916 #[doc(alias = "gtk_cell_view_get_displayed_row")]
917 #[doc(alias = "get_displayed_row")]
918 fn displayed_row(&self) -> Option<TreePath> {
919 unsafe {
920 from_glib_full(ffi::gtk_cell_view_get_displayed_row(
921 self.as_ref().to_glib_none().0,
922 ))
923 }
924 }
925
926 /// Gets whether `self` is configured to draw all of its
927 /// cells in a sensitive state.
928 ///
929 /// # Returns
930 ///
931 /// whether `self` draws all of its
932 /// cells in a sensitive state
933 #[doc(alias = "gtk_cell_view_get_draw_sensitive")]
934 #[doc(alias = "get_draw_sensitive")]
935 fn draws_sensitive(&self) -> bool {
936 unsafe {
937 from_glib(ffi::gtk_cell_view_get_draw_sensitive(
938 self.as_ref().to_glib_none().0,
939 ))
940 }
941 }
942
943 /// Gets whether `self` is configured to request space
944 /// to fit the entire [`TreeModel`][crate::TreeModel].
945 ///
946 /// # Returns
947 ///
948 /// whether `self` requests space to fit
949 /// the entire [`TreeModel`][crate::TreeModel].
950 #[doc(alias = "gtk_cell_view_get_fit_model")]
951 #[doc(alias = "get_fit_model")]
952 fn fits_model(&self) -> bool {
953 unsafe {
954 from_glib(ffi::gtk_cell_view_get_fit_model(
955 self.as_ref().to_glib_none().0,
956 ))
957 }
958 }
959
960 /// Returns the model for `self`. If no model is used [`None`] is
961 /// returned.
962 ///
963 /// # Returns
964 ///
965 /// a [`TreeModel`][crate::TreeModel] used or [`None`]
966 #[doc(alias = "gtk_cell_view_get_model")]
967 #[doc(alias = "get_model")]
968 fn model(&self) -> Option<TreeModel> {
969 unsafe { from_glib_none(ffi::gtk_cell_view_get_model(self.as_ref().to_glib_none().0)) }
970 }
971
972 /// Sets the background color of `self`.
973 /// ## `rgba`
974 /// the new background color
975 #[doc(alias = "gtk_cell_view_set_background_rgba")]
976 fn set_background_rgba(&self, rgba: &gdk::RGBA) {
977 unsafe {
978 ffi::gtk_cell_view_set_background_rgba(
979 self.as_ref().to_glib_none().0,
980 rgba.to_glib_none().0,
981 );
982 }
983 }
984
985 /// Sets the row of the model that is currently displayed
986 /// by the [`CellView`][crate::CellView]. If the path is unset, then the
987 /// contents of the cellview “stick” at their last value;
988 /// this is not normally a desired result, but may be
989 /// a needed intermediate state if say, the model for
990 /// the [`CellView`][crate::CellView] becomes temporarily empty.
991 /// ## `path`
992 /// a [`TreePath`][crate::TreePath] or [`None`] to unset.
993 #[doc(alias = "gtk_cell_view_set_displayed_row")]
994 fn set_displayed_row(&self, path: &mut TreePath) {
995 unsafe {
996 ffi::gtk_cell_view_set_displayed_row(
997 self.as_ref().to_glib_none().0,
998 path.to_glib_none_mut().0,
999 );
1000 }
1001 }
1002
1003 /// Sets whether `self` should draw all of its
1004 /// cells in a sensitive state, this is used by [`ComboBox`][crate::ComboBox] menus
1005 /// to ensure that rows with insensitive cells that contain
1006 /// children appear sensitive in the parent menu item.
1007 /// ## `draw_sensitive`
1008 /// whether to draw all cells in a sensitive state.
1009 #[doc(alias = "gtk_cell_view_set_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 fn set_fit_model(&self, fit_model: bool) {
1028 unsafe {
1029 ffi::gtk_cell_view_set_fit_model(self.as_ref().to_glib_none().0, fit_model.into_glib());
1030 }
1031 }
1032
1033 /// Sets the model for `self`. If `self` already has a model
1034 /// set, it will remove it before setting the new model. If `model` is
1035 /// [`None`], then it will unset the old model.
1036 /// ## `model`
1037 /// a [`TreeModel`][crate::TreeModel]
1038 #[doc(alias = "gtk_cell_view_set_model")]
1039 fn set_model(&self, model: Option<&impl IsA<TreeModel>>) {
1040 unsafe {
1041 ffi::gtk_cell_view_set_model(
1042 self.as_ref().to_glib_none().0,
1043 model.map(|p| p.as_ref()).to_glib_none().0,
1044 );
1045 }
1046 }
1047
1048 fn set_background(&self, background: Option<&str>) {
1049 ObjectExt::set_property(self.as_ref(), "background", background)
1050 }
1051
1052 /// The background color as a [`gdk::RGBA`][crate::gdk::RGBA]
1053 #[doc(alias = "background-rgba")]
1054 fn background_rgba(&self) -> Option<gdk::RGBA> {
1055 ObjectExt::property(self.as_ref(), "background-rgba")
1056 }
1057
1058 #[doc(alias = "background-set")]
1059 fn is_background_set(&self) -> bool {
1060 ObjectExt::property(self.as_ref(), "background-set")
1061 }
1062
1063 #[doc(alias = "background-set")]
1064 fn set_background_set(&self, background_set: bool) {
1065 ObjectExt::set_property(self.as_ref(), "background-set", background_set)
1066 }
1067
1068 /// The [`CellArea`][crate::CellArea] rendering cells
1069 ///
1070 /// If no area is specified when creating the cell view with [`CellView::with_context()`][crate::CellView::with_context()]
1071 /// a horizontally oriented [`CellAreaBox`][crate::CellAreaBox] will be used.
1072 ///
1073 /// since 3.0
1074 #[doc(alias = "cell-area")]
1075 fn cell_area(&self) -> Option<CellArea> {
1076 ObjectExt::property(self.as_ref(), "cell-area")
1077 }
1078
1079 /// The [`CellAreaContext`][crate::CellAreaContext] used to compute the geometry of the cell view.
1080 ///
1081 /// A group of cell views can be assigned the same context in order to
1082 /// ensure the sizes and cell alignments match across all the views with
1083 /// the same context.
1084 ///
1085 /// [`ComboBox`][crate::ComboBox] menus uses this to assign the same context to all cell views
1086 /// in the menu items for a single menu (each submenu creates its own
1087 /// context since the size of each submenu does not depend on parent
1088 /// or sibling menus).
1089 ///
1090 /// since 3.0
1091 #[doc(alias = "cell-area-context")]
1092 fn cell_area_context(&self) -> Option<CellAreaContext> {
1093 ObjectExt::property(self.as_ref(), "cell-area-context")
1094 }
1095
1096 #[doc(alias = "background")]
1097 fn connect_background_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1098 unsafe extern "C" fn notify_background_trampoline<P: IsA<CellView>, F: Fn(&P) + 'static>(
1099 this: *mut ffi::GtkCellView,
1100 _param_spec: glib::ffi::gpointer,
1101 f: glib::ffi::gpointer,
1102 ) {
1103 let f: &F = &*(f as *const F);
1104 f(CellView::from_glib_borrow(this).unsafe_cast_ref())
1105 }
1106 unsafe {
1107 let f: Box_<F> = Box_::new(f);
1108 connect_raw(
1109 self.as_ptr() as *mut _,
1110 b"notify::background\0".as_ptr() as *const _,
1111 Some(transmute::<_, unsafe extern "C" fn()>(
1112 notify_background_trampoline::<Self, F> as *const (),
1113 )),
1114 Box_::into_raw(f),
1115 )
1116 }
1117 }
1118
1119 #[doc(alias = "background-rgba")]
1120 fn connect_background_rgba_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1121 unsafe extern "C" fn notify_background_rgba_trampoline<
1122 P: IsA<CellView>,
1123 F: Fn(&P) + 'static,
1124 >(
1125 this: *mut ffi::GtkCellView,
1126 _param_spec: glib::ffi::gpointer,
1127 f: glib::ffi::gpointer,
1128 ) {
1129 let f: &F = &*(f as *const F);
1130 f(CellView::from_glib_borrow(this).unsafe_cast_ref())
1131 }
1132 unsafe {
1133 let f: Box_<F> = Box_::new(f);
1134 connect_raw(
1135 self.as_ptr() as *mut _,
1136 b"notify::background-rgba\0".as_ptr() as *const _,
1137 Some(transmute::<_, unsafe extern "C" fn()>(
1138 notify_background_rgba_trampoline::<Self, F> as *const (),
1139 )),
1140 Box_::into_raw(f),
1141 )
1142 }
1143 }
1144
1145 #[doc(alias = "background-set")]
1146 fn connect_background_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1147 unsafe extern "C" fn notify_background_set_trampoline<
1148 P: IsA<CellView>,
1149 F: Fn(&P) + 'static,
1150 >(
1151 this: *mut ffi::GtkCellView,
1152 _param_spec: glib::ffi::gpointer,
1153 f: glib::ffi::gpointer,
1154 ) {
1155 let f: &F = &*(f as *const F);
1156 f(CellView::from_glib_borrow(this).unsafe_cast_ref())
1157 }
1158 unsafe {
1159 let f: Box_<F> = Box_::new(f);
1160 connect_raw(
1161 self.as_ptr() as *mut _,
1162 b"notify::background-set\0".as_ptr() as *const _,
1163 Some(transmute::<_, unsafe extern "C" fn()>(
1164 notify_background_set_trampoline::<Self, F> as *const (),
1165 )),
1166 Box_::into_raw(f),
1167 )
1168 }
1169 }
1170
1171 #[doc(alias = "draw-sensitive")]
1172 fn connect_draw_sensitive_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1173 unsafe extern "C" fn notify_draw_sensitive_trampoline<
1174 P: IsA<CellView>,
1175 F: Fn(&P) + 'static,
1176 >(
1177 this: *mut ffi::GtkCellView,
1178 _param_spec: glib::ffi::gpointer,
1179 f: glib::ffi::gpointer,
1180 ) {
1181 let f: &F = &*(f as *const F);
1182 f(CellView::from_glib_borrow(this).unsafe_cast_ref())
1183 }
1184 unsafe {
1185 let f: Box_<F> = Box_::new(f);
1186 connect_raw(
1187 self.as_ptr() as *mut _,
1188 b"notify::draw-sensitive\0".as_ptr() as *const _,
1189 Some(transmute::<_, unsafe extern "C" fn()>(
1190 notify_draw_sensitive_trampoline::<Self, F> as *const (),
1191 )),
1192 Box_::into_raw(f),
1193 )
1194 }
1195 }
1196
1197 #[doc(alias = "fit-model")]
1198 fn connect_fit_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1199 unsafe extern "C" fn notify_fit_model_trampoline<P: IsA<CellView>, F: Fn(&P) + 'static>(
1200 this: *mut ffi::GtkCellView,
1201 _param_spec: glib::ffi::gpointer,
1202 f: glib::ffi::gpointer,
1203 ) {
1204 let f: &F = &*(f as *const F);
1205 f(CellView::from_glib_borrow(this).unsafe_cast_ref())
1206 }
1207 unsafe {
1208 let f: Box_<F> = Box_::new(f);
1209 connect_raw(
1210 self.as_ptr() as *mut _,
1211 b"notify::fit-model\0".as_ptr() as *const _,
1212 Some(transmute::<_, unsafe extern "C" fn()>(
1213 notify_fit_model_trampoline::<Self, F> as *const (),
1214 )),
1215 Box_::into_raw(f),
1216 )
1217 }
1218 }
1219
1220 #[doc(alias = "model")]
1221 fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1222 unsafe extern "C" fn notify_model_trampoline<P: IsA<CellView>, F: Fn(&P) + 'static>(
1223 this: *mut ffi::GtkCellView,
1224 _param_spec: glib::ffi::gpointer,
1225 f: glib::ffi::gpointer,
1226 ) {
1227 let f: &F = &*(f as *const F);
1228 f(CellView::from_glib_borrow(this).unsafe_cast_ref())
1229 }
1230 unsafe {
1231 let f: Box_<F> = Box_::new(f);
1232 connect_raw(
1233 self.as_ptr() as *mut _,
1234 b"notify::model\0".as_ptr() as *const _,
1235 Some(transmute::<_, unsafe extern "C" fn()>(
1236 notify_model_trampoline::<Self, F> as *const (),
1237 )),
1238 Box_::into_raw(f),
1239 )
1240 }
1241 }
1242}
1243
1244impl<O: IsA<CellView>> CellViewExt for O {}
1245
1246impl fmt::Display for CellView {
1247 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1248 f.write_str("CellView")
1249 }
1250}