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};
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::{boxed::Box as Box_, fmt, mem::transmute};
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 | Writeable
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 | Writeable
40 ///
41 ///
42 /// #### `size`
43 /// The [`IconSize`][crate::IconSize] value that specifies the size of the rendered spinner.
44 ///
45 /// Readable | Writeable
46 /// <details><summary><h4>CellRenderer</h4></summary>
47 ///
48 ///
49 /// #### `cell-background`
50 /// Writeable
51 ///
52 ///
53 /// #### `cell-background-gdk`
54 /// Cell background as a `GdkColor`
55 ///
56 /// Readable | Writeable
57 ///
58 ///
59 /// #### `cell-background-rgba`
60 /// Cell background as a [`gdk::RGBA`][crate::gdk::RGBA]
61 ///
62 /// Readable | Writeable
63 ///
64 ///
65 /// #### `cell-background-set`
66 /// Readable | Writeable
67 ///
68 ///
69 /// #### `editing`
70 /// Readable
71 ///
72 ///
73 /// #### `height`
74 /// Readable | Writeable
75 ///
76 ///
77 /// #### `is-expanded`
78 /// Readable | Writeable
79 ///
80 ///
81 /// #### `is-expander`
82 /// Readable | Writeable
83 ///
84 ///
85 /// #### `mode`
86 /// Readable | Writeable
87 ///
88 ///
89 /// #### `sensitive`
90 /// Readable | Writeable
91 ///
92 ///
93 /// #### `visible`
94 /// Readable | Writeable
95 ///
96 ///
97 /// #### `width`
98 /// Readable | Writeable
99 ///
100 ///
101 /// #### `xalign`
102 /// Readable | Writeable
103 ///
104 ///
105 /// #### `xpad`
106 /// Readable | Writeable
107 ///
108 ///
109 /// #### `yalign`
110 /// Readable | Writeable
111 ///
112 ///
113 /// #### `ypad`
114 /// Readable | Writeable
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 self.builder.build()
294 }
295}
296
297mod sealed {
298 pub trait Sealed {}
299 impl<T: super::IsA<super::CellRendererSpinner>> Sealed for T {}
300}
301
302/// Trait containing all [`struct@CellRendererSpinner`] methods.
303///
304/// # Implementors
305///
306/// [`CellRendererSpinner`][struct@crate::CellRendererSpinner]
307pub trait CellRendererSpinnerExt: IsA<CellRendererSpinner> + sealed::Sealed + 'static {
308 fn is_active(&self) -> bool {
309 ObjectExt::property(self.as_ref(), "active")
310 }
311
312 fn set_active(&self, active: bool) {
313 ObjectExt::set_property(self.as_ref(), "active", active)
314 }
315
316 /// Pulse of the spinner. Increment this value to draw the next frame of the
317 /// spinner animation. Usually, you would update this value in a timeout.
318 ///
319 /// By default, the [`Spinner`][crate::Spinner] widget draws one full cycle of the animation,
320 /// consisting of 12 frames, in 750 milliseconds.
321 fn pulse(&self) -> u32 {
322 ObjectExt::property(self.as_ref(), "pulse")
323 }
324
325 /// Pulse of the spinner. Increment this value to draw the next frame of the
326 /// spinner animation. Usually, you would update this value in a timeout.
327 ///
328 /// By default, the [`Spinner`][crate::Spinner] widget draws one full cycle of the animation,
329 /// consisting of 12 frames, in 750 milliseconds.
330 fn set_pulse(&self, pulse: u32) {
331 ObjectExt::set_property(self.as_ref(), "pulse", pulse)
332 }
333
334 /// The [`IconSize`][crate::IconSize] value that specifies the size of the rendered spinner.
335 fn size(&self) -> IconSize {
336 ObjectExt::property(self.as_ref(), "size")
337 }
338
339 /// The [`IconSize`][crate::IconSize] value that specifies the size of the rendered spinner.
340 fn set_size(&self, size: IconSize) {
341 ObjectExt::set_property(self.as_ref(), "size", size)
342 }
343
344 #[doc(alias = "active")]
345 fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
346 unsafe extern "C" fn notify_active_trampoline<
347 P: IsA<CellRendererSpinner>,
348 F: Fn(&P) + 'static,
349 >(
350 this: *mut ffi::GtkCellRendererSpinner,
351 _param_spec: glib::ffi::gpointer,
352 f: glib::ffi::gpointer,
353 ) {
354 let f: &F = &*(f as *const F);
355 f(CellRendererSpinner::from_glib_borrow(this).unsafe_cast_ref())
356 }
357 unsafe {
358 let f: Box_<F> = Box_::new(f);
359 connect_raw(
360 self.as_ptr() as *mut _,
361 b"notify::active\0".as_ptr() as *const _,
362 Some(transmute::<_, unsafe extern "C" fn()>(
363 notify_active_trampoline::<Self, F> as *const (),
364 )),
365 Box_::into_raw(f),
366 )
367 }
368 }
369
370 #[doc(alias = "pulse")]
371 fn connect_pulse_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
372 unsafe extern "C" fn notify_pulse_trampoline<
373 P: IsA<CellRendererSpinner>,
374 F: Fn(&P) + 'static,
375 >(
376 this: *mut ffi::GtkCellRendererSpinner,
377 _param_spec: glib::ffi::gpointer,
378 f: glib::ffi::gpointer,
379 ) {
380 let f: &F = &*(f as *const F);
381 f(CellRendererSpinner::from_glib_borrow(this).unsafe_cast_ref())
382 }
383 unsafe {
384 let f: Box_<F> = Box_::new(f);
385 connect_raw(
386 self.as_ptr() as *mut _,
387 b"notify::pulse\0".as_ptr() as *const _,
388 Some(transmute::<_, 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 let f: &F = &*(f as *const F);
407 f(CellRendererSpinner::from_glib_borrow(this).unsafe_cast_ref())
408 }
409 unsafe {
410 let f: Box_<F> = Box_::new(f);
411 connect_raw(
412 self.as_ptr() as *mut _,
413 b"notify::size\0".as_ptr() as *const _,
414 Some(transmute::<_, unsafe extern "C" fn()>(
415 notify_size_trampoline::<Self, F> as *const (),
416 )),
417 Box_::into_raw(f),
418 )
419 }
420 }
421}
422
423impl<O: IsA<CellRendererSpinner>> CellRendererSpinnerExt for O {}
424
425impl fmt::Display for CellRendererSpinner {
426 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
427 f.write_str("CellRendererSpinner")
428 }
429}