[go: up one dir, main page]

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    ffi, Accessible, AccessibleRole, Align, Buildable, CellArea, CellAreaContext, CellLayout,
8    ConstraintTarget, LayoutManager, Orientable, Orientation, Overflow, TreeModel, TreePath,
9    Widget,
10};
11use glib::{
12    prelude::*,
13    signal::{connect_raw, SignalHandlerId},
14    translate::*,
15};
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19    #[doc(alias = "GtkCellView")]
20    pub struct CellView(Object<ffi::GtkCellView>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, CellLayout, Orientable;
21
22    match fn {
23        type_ => || ffi::gtk_cell_view_get_type(),
24    }
25}
26
27impl CellView {
28    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
29    #[allow(deprecated)]
30    #[doc(alias = "gtk_cell_view_new")]
31    pub fn new() -> CellView {
32        assert_initialized_main_thread!();
33        unsafe { Widget::from_glib_none(ffi::gtk_cell_view_new()).unsafe_cast() }
34    }
35
36    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
37    #[allow(deprecated)]
38    #[doc(alias = "gtk_cell_view_new_with_context")]
39    #[doc(alias = "new_with_context")]
40    pub fn with_context(
41        area: &impl IsA<CellArea>,
42        context: &impl IsA<CellAreaContext>,
43    ) -> CellView {
44        skip_assert_initialized!();
45        unsafe {
46            Widget::from_glib_none(ffi::gtk_cell_view_new_with_context(
47                area.as_ref().to_glib_none().0,
48                context.as_ref().to_glib_none().0,
49            ))
50            .unsafe_cast()
51        }
52    }
53
54    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
55    #[allow(deprecated)]
56    #[doc(alias = "gtk_cell_view_new_with_markup")]
57    #[doc(alias = "new_with_markup")]
58    pub fn with_markup(markup: &str) -> CellView {
59        assert_initialized_main_thread!();
60        unsafe {
61            Widget::from_glib_none(ffi::gtk_cell_view_new_with_markup(markup.to_glib_none().0))
62                .unsafe_cast()
63        }
64    }
65
66    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
67    #[allow(deprecated)]
68    #[doc(alias = "gtk_cell_view_new_with_text")]
69    #[doc(alias = "new_with_text")]
70    pub fn with_text(text: &str) -> CellView {
71        assert_initialized_main_thread!();
72        unsafe {
73            Widget::from_glib_none(ffi::gtk_cell_view_new_with_text(text.to_glib_none().0))
74                .unsafe_cast()
75        }
76    }
77
78    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
79    #[allow(deprecated)]
80    #[doc(alias = "gtk_cell_view_new_with_texture")]
81    #[doc(alias = "new_with_texture")]
82    pub fn with_texture(texture: &impl IsA<gdk::Texture>) -> CellView {
83        assert_initialized_main_thread!();
84        unsafe {
85            Widget::from_glib_none(ffi::gtk_cell_view_new_with_texture(
86                texture.as_ref().to_glib_none().0,
87            ))
88            .unsafe_cast()
89        }
90    }
91
92    // rustdoc-stripper-ignore-next
93    /// Creates a new builder-pattern struct instance to construct [`CellView`] objects.
94    ///
95    /// This method returns an instance of [`CellViewBuilder`](crate::builders::CellViewBuilder) which can be used to create [`CellView`] objects.
96    pub fn builder() -> CellViewBuilder {
97        CellViewBuilder::new()
98    }
99
100    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
101    #[allow(deprecated)]
102    #[doc(alias = "gtk_cell_view_get_displayed_row")]
103    #[doc(alias = "get_displayed_row")]
104    pub fn displayed_row(&self) -> Option<TreePath> {
105        unsafe { from_glib_full(ffi::gtk_cell_view_get_displayed_row(self.to_glib_none().0)) }
106    }
107
108    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
109    #[allow(deprecated)]
110    #[doc(alias = "gtk_cell_view_get_draw_sensitive")]
111    #[doc(alias = "get_draw_sensitive")]
112    #[doc(alias = "draw-sensitive")]
113    pub fn draws_sensitive(&self) -> bool {
114        unsafe { from_glib(ffi::gtk_cell_view_get_draw_sensitive(self.to_glib_none().0)) }
115    }
116
117    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
118    #[allow(deprecated)]
119    #[doc(alias = "gtk_cell_view_get_fit_model")]
120    #[doc(alias = "get_fit_model")]
121    #[doc(alias = "fit-model")]
122    pub fn fits_model(&self) -> bool {
123        unsafe { from_glib(ffi::gtk_cell_view_get_fit_model(self.to_glib_none().0)) }
124    }
125
126    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
127    #[allow(deprecated)]
128    #[doc(alias = "gtk_cell_view_get_model")]
129    #[doc(alias = "get_model")]
130    pub fn model(&self) -> Option<TreeModel> {
131        unsafe { from_glib_none(ffi::gtk_cell_view_get_model(self.to_glib_none().0)) }
132    }
133
134    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
135    #[allow(deprecated)]
136    #[doc(alias = "gtk_cell_view_set_displayed_row")]
137    pub fn set_displayed_row(&self, path: Option<&TreePath>) {
138        unsafe {
139            ffi::gtk_cell_view_set_displayed_row(
140                self.to_glib_none().0,
141                mut_override(path.to_glib_none().0),
142            );
143        }
144    }
145
146    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
147    #[allow(deprecated)]
148    #[doc(alias = "gtk_cell_view_set_draw_sensitive")]
149    #[doc(alias = "draw-sensitive")]
150    pub fn set_draw_sensitive(&self, draw_sensitive: bool) {
151        unsafe {
152            ffi::gtk_cell_view_set_draw_sensitive(
153                self.to_glib_none().0,
154                draw_sensitive.into_glib(),
155            );
156        }
157    }
158
159    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
160    #[allow(deprecated)]
161    #[doc(alias = "gtk_cell_view_set_fit_model")]
162    #[doc(alias = "fit-model")]
163    pub fn set_fit_model(&self, fit_model: bool) {
164        unsafe {
165            ffi::gtk_cell_view_set_fit_model(self.to_glib_none().0, fit_model.into_glib());
166        }
167    }
168
169    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
170    #[allow(deprecated)]
171    #[doc(alias = "gtk_cell_view_set_model")]
172    #[doc(alias = "model")]
173    pub fn set_model(&self, model: Option<&impl IsA<TreeModel>>) {
174        unsafe {
175            ffi::gtk_cell_view_set_model(
176                self.to_glib_none().0,
177                model.map(|p| p.as_ref()).to_glib_none().0,
178            );
179        }
180    }
181
182    #[doc(alias = "cell-area")]
183    pub fn cell_area(&self) -> Option<CellArea> {
184        ObjectExt::property(self, "cell-area")
185    }
186
187    #[doc(alias = "cell-area-context")]
188    pub fn cell_area_context(&self) -> Option<CellAreaContext> {
189        ObjectExt::property(self, "cell-area-context")
190    }
191
192    #[doc(alias = "draw-sensitive")]
193    pub fn connect_draw_sensitive_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
194        unsafe extern "C" fn notify_draw_sensitive_trampoline<F: Fn(&CellView) + 'static>(
195            this: *mut ffi::GtkCellView,
196            _param_spec: glib::ffi::gpointer,
197            f: glib::ffi::gpointer,
198        ) {
199            let f: &F = &*(f as *const F);
200            f(&from_glib_borrow(this))
201        }
202        unsafe {
203            let f: Box_<F> = Box_::new(f);
204            connect_raw(
205                self.as_ptr() as *mut _,
206                c"notify::draw-sensitive".as_ptr() as *const _,
207                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
208                    notify_draw_sensitive_trampoline::<F> as *const (),
209                )),
210                Box_::into_raw(f),
211            )
212        }
213    }
214
215    #[doc(alias = "fit-model")]
216    pub fn connect_fit_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
217        unsafe extern "C" fn notify_fit_model_trampoline<F: Fn(&CellView) + 'static>(
218            this: *mut ffi::GtkCellView,
219            _param_spec: glib::ffi::gpointer,
220            f: glib::ffi::gpointer,
221        ) {
222            let f: &F = &*(f as *const F);
223            f(&from_glib_borrow(this))
224        }
225        unsafe {
226            let f: Box_<F> = Box_::new(f);
227            connect_raw(
228                self.as_ptr() as *mut _,
229                c"notify::fit-model".as_ptr() as *const _,
230                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
231                    notify_fit_model_trampoline::<F> as *const (),
232                )),
233                Box_::into_raw(f),
234            )
235        }
236    }
237
238    #[doc(alias = "model")]
239    pub fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
240        unsafe extern "C" fn notify_model_trampoline<F: Fn(&CellView) + 'static>(
241            this: *mut ffi::GtkCellView,
242            _param_spec: glib::ffi::gpointer,
243            f: glib::ffi::gpointer,
244        ) {
245            let f: &F = &*(f as *const F);
246            f(&from_glib_borrow(this))
247        }
248        unsafe {
249            let f: Box_<F> = Box_::new(f);
250            connect_raw(
251                self.as_ptr() as *mut _,
252                c"notify::model".as_ptr() as *const _,
253                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
254                    notify_model_trampoline::<F> as *const (),
255                )),
256                Box_::into_raw(f),
257            )
258        }
259    }
260}
261
262impl Default for CellView {
263    fn default() -> Self {
264        Self::new()
265    }
266}
267
268// rustdoc-stripper-ignore-next
269/// A [builder-pattern] type to construct [`CellView`] objects.
270///
271/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
272#[must_use = "The builder must be built to be used"]
273pub struct CellViewBuilder {
274    builder: glib::object::ObjectBuilder<'static, CellView>,
275}
276
277impl CellViewBuilder {
278    fn new() -> Self {
279        Self {
280            builder: glib::object::Object::builder(),
281        }
282    }
283
284    pub fn cell_area(self, cell_area: &impl IsA<CellArea>) -> Self {
285        Self {
286            builder: self
287                .builder
288                .property("cell-area", cell_area.clone().upcast()),
289        }
290    }
291
292    pub fn cell_area_context(self, cell_area_context: &impl IsA<CellAreaContext>) -> Self {
293        Self {
294            builder: self
295                .builder
296                .property("cell-area-context", cell_area_context.clone().upcast()),
297        }
298    }
299
300    pub fn draw_sensitive(self, draw_sensitive: bool) -> Self {
301        Self {
302            builder: self.builder.property("draw-sensitive", draw_sensitive),
303        }
304    }
305
306    pub fn fit_model(self, fit_model: bool) -> Self {
307        Self {
308            builder: self.builder.property("fit-model", fit_model),
309        }
310    }
311
312    pub fn model(self, model: &impl IsA<TreeModel>) -> Self {
313        Self {
314            builder: self.builder.property("model", model.clone().upcast()),
315        }
316    }
317
318    pub fn can_focus(self, can_focus: bool) -> Self {
319        Self {
320            builder: self.builder.property("can-focus", can_focus),
321        }
322    }
323
324    pub fn can_target(self, can_target: bool) -> Self {
325        Self {
326            builder: self.builder.property("can-target", can_target),
327        }
328    }
329
330    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
331        Self {
332            builder: self.builder.property("css-classes", css_classes.into()),
333        }
334    }
335
336    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
337        Self {
338            builder: self.builder.property("css-name", css_name.into()),
339        }
340    }
341
342    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
343        Self {
344            builder: self.builder.property("cursor", cursor.clone()),
345        }
346    }
347
348    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
349        Self {
350            builder: self.builder.property("focus-on-click", focus_on_click),
351        }
352    }
353
354    pub fn focusable(self, focusable: bool) -> Self {
355        Self {
356            builder: self.builder.property("focusable", focusable),
357        }
358    }
359
360    pub fn halign(self, halign: Align) -> Self {
361        Self {
362            builder: self.builder.property("halign", halign),
363        }
364    }
365
366    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
367        Self {
368            builder: self.builder.property("has-tooltip", has_tooltip),
369        }
370    }
371
372    pub fn height_request(self, height_request: i32) -> Self {
373        Self {
374            builder: self.builder.property("height-request", height_request),
375        }
376    }
377
378    pub fn hexpand(self, hexpand: bool) -> Self {
379        Self {
380            builder: self.builder.property("hexpand", hexpand),
381        }
382    }
383
384    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
385        Self {
386            builder: self.builder.property("hexpand-set", hexpand_set),
387        }
388    }
389
390    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
391        Self {
392            builder: self
393                .builder
394                .property("layout-manager", layout_manager.clone().upcast()),
395        }
396    }
397
398    #[cfg(feature = "v4_18")]
399    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
400    pub fn limit_events(self, limit_events: bool) -> Self {
401        Self {
402            builder: self.builder.property("limit-events", limit_events),
403        }
404    }
405
406    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
407        Self {
408            builder: self.builder.property("margin-bottom", margin_bottom),
409        }
410    }
411
412    pub fn margin_end(self, margin_end: i32) -> Self {
413        Self {
414            builder: self.builder.property("margin-end", margin_end),
415        }
416    }
417
418    pub fn margin_start(self, margin_start: i32) -> Self {
419        Self {
420            builder: self.builder.property("margin-start", margin_start),
421        }
422    }
423
424    pub fn margin_top(self, margin_top: i32) -> Self {
425        Self {
426            builder: self.builder.property("margin-top", margin_top),
427        }
428    }
429
430    pub fn name(self, name: impl Into<glib::GString>) -> Self {
431        Self {
432            builder: self.builder.property("name", name.into()),
433        }
434    }
435
436    pub fn opacity(self, opacity: f64) -> Self {
437        Self {
438            builder: self.builder.property("opacity", opacity),
439        }
440    }
441
442    pub fn overflow(self, overflow: Overflow) -> Self {
443        Self {
444            builder: self.builder.property("overflow", overflow),
445        }
446    }
447
448    pub fn receives_default(self, receives_default: bool) -> Self {
449        Self {
450            builder: self.builder.property("receives-default", receives_default),
451        }
452    }
453
454    pub fn sensitive(self, sensitive: bool) -> Self {
455        Self {
456            builder: self.builder.property("sensitive", sensitive),
457        }
458    }
459
460    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
461        Self {
462            builder: self
463                .builder
464                .property("tooltip-markup", tooltip_markup.into()),
465        }
466    }
467
468    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
469        Self {
470            builder: self.builder.property("tooltip-text", tooltip_text.into()),
471        }
472    }
473
474    pub fn valign(self, valign: Align) -> Self {
475        Self {
476            builder: self.builder.property("valign", valign),
477        }
478    }
479
480    pub fn vexpand(self, vexpand: bool) -> Self {
481        Self {
482            builder: self.builder.property("vexpand", vexpand),
483        }
484    }
485
486    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
487        Self {
488            builder: self.builder.property("vexpand-set", vexpand_set),
489        }
490    }
491
492    pub fn visible(self, visible: bool) -> Self {
493        Self {
494            builder: self.builder.property("visible", visible),
495        }
496    }
497
498    pub fn width_request(self, width_request: i32) -> Self {
499        Self {
500            builder: self.builder.property("width-request", width_request),
501        }
502    }
503
504    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
505        Self {
506            builder: self.builder.property("accessible-role", accessible_role),
507        }
508    }
509
510    pub fn orientation(self, orientation: Orientation) -> Self {
511        Self {
512            builder: self.builder.property("orientation", orientation),
513        }
514    }
515
516    // rustdoc-stripper-ignore-next
517    /// Build the [`CellView`].
518    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
519    pub fn build(self) -> CellView {
520        assert_initialized_main_thread!();
521        self.builder.build()
522    }
523}