Skip to main content

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