Skip to main content

gtk4/auto/
cell_renderer_spinner.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::{CellRenderer, CellRendererMode, IconSize, ffi};
7use glib::{
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// List views use widgets to display their contents.
16    ///   You should use [`Spinner`][crate::Spinner] instead
17    /// Renders a spinning animation in a cell
18    ///
19    /// [`CellRendererSpinner`][crate::CellRendererSpinner] renders a spinning animation in a cell, very
20    /// similar to [`Spinner`][crate::Spinner]. It can often be used as an alternative
21    /// to a [`CellRendererProgress`][crate::CellRendererProgress] for displaying indefinite activity,
22    /// instead of actual progress.
23    ///
24    /// To start the animation in a cell, set the `GtkCellRendererSpinner:active`
25    /// property to [`true`] and increment the `GtkCellRendererSpinner:pulse` property
26    /// at regular intervals. The usual way to set the cell renderer properties
27    /// for each cell is to bind them to columns in your tree model using e.g.
28    /// gtk_tree_view_column_add_attribute().
29    ///
30    /// ## Properties
31    ///
32    ///
33    /// #### `active`
34    ///  Whether the spinner is active (ie. shown) in the cell
35    ///
36    /// Readable | Writeable
37    ///
38    ///
39    /// #### `pulse`
40    ///  Pulse of the spinner. Increment this value to draw the next frame of the
41    /// spinner animation. Usually, you would update this value in a timeout.
42    ///
43    /// By default, the [`Spinner`][crate::Spinner] widget draws one full cycle of the animation,
44    /// consisting of 12 frames, in 750 milliseconds.
45    ///
46    /// Readable | Writeable
47    ///
48    ///
49    /// #### `size`
50    ///  The [`IconSize`][crate::IconSize] value that specifies the size of the rendered spinner.
51    ///
52    /// Readable | Writeable
53    /// <details><summary><h4>CellRenderer</h4></summary>
54    ///
55    ///
56    /// #### `cell-background`
57    ///  Writeable
58    ///
59    ///
60    /// #### `cell-background-rgba`
61    ///  Cell background as a [`gdk::RGBA`][crate::gdk::RGBA]
62    ///
63    /// Readable | Writeable
64    ///
65    ///
66    /// #### `cell-background-set`
67    ///  Readable | Writeable
68    ///
69    ///
70    /// #### `editing`
71    ///  Readable
72    ///
73    ///
74    /// #### `height`
75    ///  Readable | Writeable
76    ///
77    ///
78    /// #### `is-expanded`
79    ///  Readable | Writeable
80    ///
81    ///
82    /// #### `is-expander`
83    ///  Readable | Writeable
84    ///
85    ///
86    /// #### `mode`
87    ///  Readable | Writeable
88    ///
89    ///
90    /// #### `sensitive`
91    ///  Readable | Writeable
92    ///
93    ///
94    /// #### `visible`
95    ///  Readable | Writeable
96    ///
97    ///
98    /// #### `width`
99    ///  Readable | Writeable
100    ///
101    ///
102    /// #### `xalign`
103    ///  Readable | Writeable
104    ///
105    ///
106    /// #### `xpad`
107    ///  Readable | Writeable
108    ///
109    ///
110    /// #### `yalign`
111    ///  Readable | Writeable
112    ///
113    ///
114    /// #### `ypad`
115    ///  Readable | Writeable
116    /// </details>
117    ///
118    /// # Implements
119    ///
120    /// [`CellRendererExt`][trait@crate::prelude::CellRendererExt], [`trait@glib::ObjectExt`], [`CellRendererExtManual`][trait@crate::prelude::CellRendererExtManual]
121    #[doc(alias = "GtkCellRendererSpinner")]
122    pub struct CellRendererSpinner(Object<ffi::GtkCellRendererSpinner>) @extends CellRenderer;
123
124    match fn {
125        type_ => || ffi::gtk_cell_renderer_spinner_get_type(),
126    }
127}
128
129impl CellRendererSpinner {
130    /// Returns a new cell renderer which will show a spinner to indicate
131    /// activity.
132    ///
133    /// # Deprecated since 4.10
134    ///
135    ///
136    /// # Returns
137    ///
138    /// a new [`CellRenderer`][crate::CellRenderer]
139    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
140    #[allow(deprecated)]
141    #[doc(alias = "gtk_cell_renderer_spinner_new")]
142    pub fn new() -> CellRendererSpinner {
143        assert_initialized_main_thread!();
144        unsafe { CellRenderer::from_glib_none(ffi::gtk_cell_renderer_spinner_new()).unsafe_cast() }
145    }
146
147    // rustdoc-stripper-ignore-next
148    /// Creates a new builder-pattern struct instance to construct [`CellRendererSpinner`] objects.
149    ///
150    /// This method returns an instance of [`CellRendererSpinnerBuilder`](crate::builders::CellRendererSpinnerBuilder) which can be used to create [`CellRendererSpinner`] objects.
151    pub fn builder() -> CellRendererSpinnerBuilder {
152        CellRendererSpinnerBuilder::new()
153    }
154
155    /// Whether the spinner is active (ie. shown) in the cell
156    pub fn is_active(&self) -> bool {
157        ObjectExt::property(self, "active")
158    }
159
160    /// Whether the spinner is active (ie. shown) in the cell
161    pub fn set_active(&self, active: bool) {
162        ObjectExt::set_property(self, "active", active)
163    }
164
165    /// Pulse of the spinner. Increment this value to draw the next frame of the
166    /// spinner animation. Usually, you would update this value in a timeout.
167    ///
168    /// By default, the [`Spinner`][crate::Spinner] widget draws one full cycle of the animation,
169    /// consisting of 12 frames, in 750 milliseconds.
170    pub fn pulse(&self) -> u32 {
171        ObjectExt::property(self, "pulse")
172    }
173
174    /// Pulse of the spinner. Increment this value to draw the next frame of the
175    /// spinner animation. Usually, you would update this value in a timeout.
176    ///
177    /// By default, the [`Spinner`][crate::Spinner] widget draws one full cycle of the animation,
178    /// consisting of 12 frames, in 750 milliseconds.
179    pub fn set_pulse(&self, pulse: u32) {
180        ObjectExt::set_property(self, "pulse", pulse)
181    }
182
183    /// The [`IconSize`][crate::IconSize] value that specifies the size of the rendered spinner.
184    pub fn size(&self) -> IconSize {
185        ObjectExt::property(self, "size")
186    }
187
188    /// The [`IconSize`][crate::IconSize] value that specifies the size of the rendered spinner.
189    pub fn set_size(&self, size: IconSize) {
190        ObjectExt::set_property(self, "size", size)
191    }
192
193    #[doc(alias = "active")]
194    pub fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
195        unsafe extern "C" fn notify_active_trampoline<F: Fn(&CellRendererSpinner) + 'static>(
196            this: *mut ffi::GtkCellRendererSpinner,
197            _param_spec: glib::ffi::gpointer,
198            f: glib::ffi::gpointer,
199        ) {
200            unsafe {
201                let f: &F = &*(f as *const F);
202                f(&from_glib_borrow(this))
203            }
204        }
205        unsafe {
206            let f: Box_<F> = Box_::new(f);
207            connect_raw(
208                self.as_ptr() as *mut _,
209                c"notify::active".as_ptr() as *const _,
210                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
211                    notify_active_trampoline::<F> as *const (),
212                )),
213                Box_::into_raw(f),
214            )
215        }
216    }
217
218    #[doc(alias = "pulse")]
219    pub fn connect_pulse_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
220        unsafe extern "C" fn notify_pulse_trampoline<F: Fn(&CellRendererSpinner) + 'static>(
221            this: *mut ffi::GtkCellRendererSpinner,
222            _param_spec: glib::ffi::gpointer,
223            f: glib::ffi::gpointer,
224        ) {
225            unsafe {
226                let f: &F = &*(f as *const F);
227                f(&from_glib_borrow(this))
228            }
229        }
230        unsafe {
231            let f: Box_<F> = Box_::new(f);
232            connect_raw(
233                self.as_ptr() as *mut _,
234                c"notify::pulse".as_ptr() as *const _,
235                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
236                    notify_pulse_trampoline::<F> as *const (),
237                )),
238                Box_::into_raw(f),
239            )
240        }
241    }
242
243    #[doc(alias = "size")]
244    pub fn connect_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
245        unsafe extern "C" fn notify_size_trampoline<F: Fn(&CellRendererSpinner) + 'static>(
246            this: *mut ffi::GtkCellRendererSpinner,
247            _param_spec: glib::ffi::gpointer,
248            f: glib::ffi::gpointer,
249        ) {
250            unsafe {
251                let f: &F = &*(f as *const F);
252                f(&from_glib_borrow(this))
253            }
254        }
255        unsafe {
256            let f: Box_<F> = Box_::new(f);
257            connect_raw(
258                self.as_ptr() as *mut _,
259                c"notify::size".as_ptr() as *const _,
260                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
261                    notify_size_trampoline::<F> as *const (),
262                )),
263                Box_::into_raw(f),
264            )
265        }
266    }
267}
268
269impl Default for CellRendererSpinner {
270    fn default() -> Self {
271        Self::new()
272    }
273}
274
275// rustdoc-stripper-ignore-next
276/// A [builder-pattern] type to construct [`CellRendererSpinner`] objects.
277///
278/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
279#[must_use = "The builder must be built to be used"]
280pub struct CellRendererSpinnerBuilder {
281    builder: glib::object::ObjectBuilder<'static, CellRendererSpinner>,
282}
283
284impl CellRendererSpinnerBuilder {
285    fn new() -> Self {
286        Self {
287            builder: glib::object::Object::builder(),
288        }
289    }
290
291    /// Whether the spinner is active (ie. shown) in the cell
292    pub fn active(self, active: bool) -> Self {
293        Self {
294            builder: self.builder.property("active", active),
295        }
296    }
297
298    /// Pulse of the spinner. Increment this value to draw the next frame of the
299    /// spinner animation. Usually, you would update this value in a timeout.
300    ///
301    /// By default, the [`Spinner`][crate::Spinner] widget draws one full cycle of the animation,
302    /// consisting of 12 frames, in 750 milliseconds.
303    pub fn pulse(self, pulse: u32) -> Self {
304        Self {
305            builder: self.builder.property("pulse", pulse),
306        }
307    }
308
309    /// The [`IconSize`][crate::IconSize] value that specifies the size of the rendered spinner.
310    pub fn size(self, size: IconSize) -> Self {
311        Self {
312            builder: self.builder.property("size", size),
313        }
314    }
315
316    pub fn cell_background(self, cell_background: impl Into<glib::GString>) -> Self {
317        Self {
318            builder: self
319                .builder
320                .property("cell-background", cell_background.into()),
321        }
322    }
323
324    /// Cell background as a [`gdk::RGBA`][crate::gdk::RGBA]
325    pub fn cell_background_rgba(self, cell_background_rgba: &gdk::RGBA) -> Self {
326        Self {
327            builder: self
328                .builder
329                .property("cell-background-rgba", cell_background_rgba),
330        }
331    }
332
333    pub fn cell_background_set(self, cell_background_set: bool) -> Self {
334        Self {
335            builder: self
336                .builder
337                .property("cell-background-set", cell_background_set),
338        }
339    }
340
341    pub fn height(self, height: i32) -> Self {
342        Self {
343            builder: self.builder.property("height", height),
344        }
345    }
346
347    pub fn is_expanded(self, is_expanded: bool) -> Self {
348        Self {
349            builder: self.builder.property("is-expanded", is_expanded),
350        }
351    }
352
353    pub fn is_expander(self, is_expander: bool) -> Self {
354        Self {
355            builder: self.builder.property("is-expander", is_expander),
356        }
357    }
358
359    pub fn mode(self, mode: CellRendererMode) -> Self {
360        Self {
361            builder: self.builder.property("mode", mode),
362        }
363    }
364
365    pub fn sensitive(self, sensitive: bool) -> Self {
366        Self {
367            builder: self.builder.property("sensitive", sensitive),
368        }
369    }
370
371    pub fn visible(self, visible: bool) -> Self {
372        Self {
373            builder: self.builder.property("visible", visible),
374        }
375    }
376
377    pub fn width(self, width: i32) -> Self {
378        Self {
379            builder: self.builder.property("width", width),
380        }
381    }
382
383    pub fn xalign(self, xalign: f32) -> Self {
384        Self {
385            builder: self.builder.property("xalign", xalign),
386        }
387    }
388
389    pub fn xpad(self, xpad: u32) -> Self {
390        Self {
391            builder: self.builder.property("xpad", xpad),
392        }
393    }
394
395    pub fn yalign(self, yalign: f32) -> Self {
396        Self {
397            builder: self.builder.property("yalign", yalign),
398        }
399    }
400
401    pub fn ypad(self, ypad: u32) -> Self {
402        Self {
403            builder: self.builder.property("ypad", ypad),
404        }
405    }
406
407    // rustdoc-stripper-ignore-next
408    /// Build the [`CellRendererSpinner`].
409    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
410    pub fn build(self) -> CellRendererSpinner {
411        assert_initialized_main_thread!();
412        self.builder.build()
413    }
414}