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::{ffi, CellRenderer, CellRendererMode, IconSize};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
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            let f: &F = &*(f as *const F);
201            f(&from_glib_borrow(this))
202        }
203        unsafe {
204            let f: Box_<F> = Box_::new(f);
205            connect_raw(
206                self.as_ptr() as *mut _,
207                b"notify::active\0".as_ptr() as *const _,
208                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
209                    notify_active_trampoline::<F> as *const (),
210                )),
211                Box_::into_raw(f),
212            )
213        }
214    }
215
216    #[doc(alias = "pulse")]
217    pub fn connect_pulse_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
218        unsafe extern "C" fn notify_pulse_trampoline<F: Fn(&CellRendererSpinner) + 'static>(
219            this: *mut ffi::GtkCellRendererSpinner,
220            _param_spec: glib::ffi::gpointer,
221            f: glib::ffi::gpointer,
222        ) {
223            let f: &F = &*(f as *const F);
224            f(&from_glib_borrow(this))
225        }
226        unsafe {
227            let f: Box_<F> = Box_::new(f);
228            connect_raw(
229                self.as_ptr() as *mut _,
230                b"notify::pulse\0".as_ptr() as *const _,
231                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
232                    notify_pulse_trampoline::<F> as *const (),
233                )),
234                Box_::into_raw(f),
235            )
236        }
237    }
238
239    #[doc(alias = "size")]
240    pub fn connect_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
241        unsafe extern "C" fn notify_size_trampoline<F: Fn(&CellRendererSpinner) + 'static>(
242            this: *mut ffi::GtkCellRendererSpinner,
243            _param_spec: glib::ffi::gpointer,
244            f: glib::ffi::gpointer,
245        ) {
246            let f: &F = &*(f as *const F);
247            f(&from_glib_borrow(this))
248        }
249        unsafe {
250            let f: Box_<F> = Box_::new(f);
251            connect_raw(
252                self.as_ptr() as *mut _,
253                b"notify::size\0".as_ptr() as *const _,
254                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
255                    notify_size_trampoline::<F> as *const (),
256                )),
257                Box_::into_raw(f),
258            )
259        }
260    }
261}
262
263impl Default for CellRendererSpinner {
264    fn default() -> Self {
265        Self::new()
266    }
267}
268
269// rustdoc-stripper-ignore-next
270/// A [builder-pattern] type to construct [`CellRendererSpinner`] objects.
271///
272/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
273#[must_use = "The builder must be built to be used"]
274pub struct CellRendererSpinnerBuilder {
275    builder: glib::object::ObjectBuilder<'static, CellRendererSpinner>,
276}
277
278impl CellRendererSpinnerBuilder {
279    fn new() -> Self {
280        Self {
281            builder: glib::object::Object::builder(),
282        }
283    }
284
285    /// Whether the spinner is active (ie. shown) in the cell
286    pub fn active(self, active: bool) -> Self {
287        Self {
288            builder: self.builder.property("active", active),
289        }
290    }
291
292    /// Pulse of the spinner. Increment this value to draw the next frame of the
293    /// spinner animation. Usually, you would update this value in a timeout.
294    ///
295    /// By default, the [`Spinner`][crate::Spinner] widget draws one full cycle of the animation,
296    /// consisting of 12 frames, in 750 milliseconds.
297    pub fn pulse(self, pulse: u32) -> Self {
298        Self {
299            builder: self.builder.property("pulse", pulse),
300        }
301    }
302
303    /// The [`IconSize`][crate::IconSize] value that specifies the size of the rendered spinner.
304    pub fn size(self, size: IconSize) -> Self {
305        Self {
306            builder: self.builder.property("size", size),
307        }
308    }
309
310    pub fn cell_background(self, cell_background: impl Into<glib::GString>) -> Self {
311        Self {
312            builder: self
313                .builder
314                .property("cell-background", cell_background.into()),
315        }
316    }
317
318    /// Cell background as a [`gdk::RGBA`][crate::gdk::RGBA]
319    pub fn cell_background_rgba(self, cell_background_rgba: &gdk::RGBA) -> Self {
320        Self {
321            builder: self
322                .builder
323                .property("cell-background-rgba", cell_background_rgba),
324        }
325    }
326
327    pub fn cell_background_set(self, cell_background_set: bool) -> Self {
328        Self {
329            builder: self
330                .builder
331                .property("cell-background-set", cell_background_set),
332        }
333    }
334
335    pub fn height(self, height: i32) -> Self {
336        Self {
337            builder: self.builder.property("height", height),
338        }
339    }
340
341    pub fn is_expanded(self, is_expanded: bool) -> Self {
342        Self {
343            builder: self.builder.property("is-expanded", is_expanded),
344        }
345    }
346
347    pub fn is_expander(self, is_expander: bool) -> Self {
348        Self {
349            builder: self.builder.property("is-expander", is_expander),
350        }
351    }
352
353    pub fn mode(self, mode: CellRendererMode) -> Self {
354        Self {
355            builder: self.builder.property("mode", mode),
356        }
357    }
358
359    pub fn sensitive(self, sensitive: bool) -> Self {
360        Self {
361            builder: self.builder.property("sensitive", sensitive),
362        }
363    }
364
365    pub fn visible(self, visible: bool) -> Self {
366        Self {
367            builder: self.builder.property("visible", visible),
368        }
369    }
370
371    pub fn width(self, width: i32) -> Self {
372        Self {
373            builder: self.builder.property("width", width),
374        }
375    }
376
377    pub fn xalign(self, xalign: f32) -> Self {
378        Self {
379            builder: self.builder.property("xalign", xalign),
380        }
381    }
382
383    pub fn xpad(self, xpad: u32) -> Self {
384        Self {
385            builder: self.builder.property("xpad", xpad),
386        }
387    }
388
389    pub fn yalign(self, yalign: f32) -> Self {
390        Self {
391            builder: self.builder.property("yalign", yalign),
392        }
393    }
394
395    pub fn ypad(self, ypad: u32) -> Self {
396        Self {
397            builder: self.builder.property("ypad", ypad),
398        }
399    }
400
401    // rustdoc-stripper-ignore-next
402    /// Build the [`CellRendererSpinner`].
403    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
404    pub fn build(self) -> CellRendererSpinner {
405        assert_initialized_main_thread!();
406        self.builder.build()
407    }
408}