gtk4/auto/
cell_renderer_progress.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, Orientable, Orientation};
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 [`ProgressBar`][crate::ProgressBar] instead
17    /// Renders numbers as progress bars
18    ///
19    /// [`CellRendererProgress`][crate::CellRendererProgress] renders a numeric value as a progress par in a cell.
20    /// Additionally, it can display a text on top of the progress bar.
21    ///
22    /// ## Properties
23    ///
24    ///
25    /// #### `inverted`
26    ///  Whether progess is inverted.
27    ///
28    /// Readable | Writeable
29    ///
30    ///
31    /// #### `pulse`
32    ///  Setting this to a non-negative value causes the cell renderer to
33    /// enter "activity mode", where a block bounces back and forth to
34    /// indicate that some progress is made, without specifying exactly how
35    /// much.
36    ///
37    /// Each increment of the property causes the block to move by a little
38    /// bit.
39    ///
40    /// To indicate that the activity has not started yet, set the property
41    /// to zero. To indicate completion, set the property to `G_MAXINT`.
42    ///
43    /// Readable | Writeable
44    ///
45    ///
46    /// #### `text`
47    ///  The "text" property determines the label which will be drawn
48    /// over the progress bar. Setting this property to [`None`] causes the default
49    /// label to be displayed. Setting this property to an empty string causes
50    /// no label to be displayed.
51    ///
52    /// Readable | Writeable
53    ///
54    ///
55    /// #### `text-xalign`
56    ///  The "text-xalign" property controls the horizontal alignment of the
57    /// text in the progress bar.  Valid values range from 0 (left) to 1
58    /// (right).  Reserved for RTL layouts.
59    ///
60    /// Readable | Writeable
61    ///
62    ///
63    /// #### `text-yalign`
64    ///  The "text-yalign" property controls the vertical alignment of the
65    /// text in the progress bar.  Valid values range from 0 (top) to 1
66    /// (bottom).
67    ///
68    /// Readable | Writeable
69    ///
70    ///
71    /// #### `value`
72    ///  The "value" property determines the percentage to which the
73    /// progress bar will be "filled in".
74    ///
75    /// Readable | Writeable
76    /// <details><summary><h4>CellRenderer</h4></summary>
77    ///
78    ///
79    /// #### `cell-background`
80    ///  Writeable
81    ///
82    ///
83    /// #### `cell-background-rgba`
84    ///  Cell background as a [`gdk::RGBA`][crate::gdk::RGBA]
85    ///
86    /// Readable | Writeable
87    ///
88    ///
89    /// #### `cell-background-set`
90    ///  Readable | Writeable
91    ///
92    ///
93    /// #### `editing`
94    ///  Readable
95    ///
96    ///
97    /// #### `height`
98    ///  Readable | Writeable
99    ///
100    ///
101    /// #### `is-expanded`
102    ///  Readable | Writeable
103    ///
104    ///
105    /// #### `is-expander`
106    ///  Readable | Writeable
107    ///
108    ///
109    /// #### `mode`
110    ///  Readable | Writeable
111    ///
112    ///
113    /// #### `sensitive`
114    ///  Readable | Writeable
115    ///
116    ///
117    /// #### `visible`
118    ///  Readable | Writeable
119    ///
120    ///
121    /// #### `width`
122    ///  Readable | Writeable
123    ///
124    ///
125    /// #### `xalign`
126    ///  Readable | Writeable
127    ///
128    ///
129    /// #### `xpad`
130    ///  Readable | Writeable
131    ///
132    ///
133    /// #### `yalign`
134    ///  Readable | Writeable
135    ///
136    ///
137    /// #### `ypad`
138    ///  Readable | Writeable
139    /// </details>
140    /// <details><summary><h4>Orientable</h4></summary>
141    ///
142    ///
143    /// #### `orientation`
144    ///  The orientation of the orientable.
145    ///
146    /// Readable | Writeable
147    /// </details>
148    ///
149    /// # Implements
150    ///
151    /// [`CellRendererExt`][trait@crate::prelude::CellRendererExt], [`trait@glib::ObjectExt`], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`CellRendererExtManual`][trait@crate::prelude::CellRendererExtManual]
152    #[doc(alias = "GtkCellRendererProgress")]
153    pub struct CellRendererProgress(Object<ffi::GtkCellRendererProgress>) @extends CellRenderer, @implements Orientable;
154
155    match fn {
156        type_ => || ffi::gtk_cell_renderer_progress_get_type(),
157    }
158}
159
160impl CellRendererProgress {
161    /// Creates a new [`CellRendererProgress`][crate::CellRendererProgress].
162    ///
163    /// # Deprecated since 4.10
164    ///
165    ///
166    /// # Returns
167    ///
168    /// the new cell renderer
169    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
170    #[allow(deprecated)]
171    #[doc(alias = "gtk_cell_renderer_progress_new")]
172    pub fn new() -> CellRendererProgress {
173        assert_initialized_main_thread!();
174        unsafe { CellRenderer::from_glib_none(ffi::gtk_cell_renderer_progress_new()).unsafe_cast() }
175    }
176
177    // rustdoc-stripper-ignore-next
178    /// Creates a new builder-pattern struct instance to construct [`CellRendererProgress`] objects.
179    ///
180    /// This method returns an instance of [`CellRendererProgressBuilder`](crate::builders::CellRendererProgressBuilder) which can be used to create [`CellRendererProgress`] objects.
181    pub fn builder() -> CellRendererProgressBuilder {
182        CellRendererProgressBuilder::new()
183    }
184
185    /// Whether progess is inverted.
186    pub fn is_inverted(&self) -> bool {
187        ObjectExt::property(self, "inverted")
188    }
189
190    /// Whether progess is inverted.
191    pub fn set_inverted(&self, inverted: bool) {
192        ObjectExt::set_property(self, "inverted", inverted)
193    }
194
195    /// Setting this to a non-negative value causes the cell renderer to
196    /// enter "activity mode", where a block bounces back and forth to
197    /// indicate that some progress is made, without specifying exactly how
198    /// much.
199    ///
200    /// Each increment of the property causes the block to move by a little
201    /// bit.
202    ///
203    /// To indicate that the activity has not started yet, set the property
204    /// to zero. To indicate completion, set the property to `G_MAXINT`.
205    pub fn pulse(&self) -> i32 {
206        ObjectExt::property(self, "pulse")
207    }
208
209    /// Setting this to a non-negative value causes the cell renderer to
210    /// enter "activity mode", where a block bounces back and forth to
211    /// indicate that some progress is made, without specifying exactly how
212    /// much.
213    ///
214    /// Each increment of the property causes the block to move by a little
215    /// bit.
216    ///
217    /// To indicate that the activity has not started yet, set the property
218    /// to zero. To indicate completion, set the property to `G_MAXINT`.
219    pub fn set_pulse(&self, pulse: i32) {
220        ObjectExt::set_property(self, "pulse", pulse)
221    }
222
223    /// The "text" property determines the label which will be drawn
224    /// over the progress bar. Setting this property to [`None`] causes the default
225    /// label to be displayed. Setting this property to an empty string causes
226    /// no label to be displayed.
227    pub fn text(&self) -> Option<glib::GString> {
228        ObjectExt::property(self, "text")
229    }
230
231    /// The "text" property determines the label which will be drawn
232    /// over the progress bar. Setting this property to [`None`] causes the default
233    /// label to be displayed. Setting this property to an empty string causes
234    /// no label to be displayed.
235    pub fn set_text(&self, text: Option<&str>) {
236        ObjectExt::set_property(self, "text", text)
237    }
238
239    /// The "text-xalign" property controls the horizontal alignment of the
240    /// text in the progress bar.  Valid values range from 0 (left) to 1
241    /// (right).  Reserved for RTL layouts.
242    #[doc(alias = "text-xalign")]
243    pub fn text_xalign(&self) -> f32 {
244        ObjectExt::property(self, "text-xalign")
245    }
246
247    /// The "text-xalign" property controls the horizontal alignment of the
248    /// text in the progress bar.  Valid values range from 0 (left) to 1
249    /// (right).  Reserved for RTL layouts.
250    #[doc(alias = "text-xalign")]
251    pub fn set_text_xalign(&self, text_xalign: f32) {
252        ObjectExt::set_property(self, "text-xalign", text_xalign)
253    }
254
255    /// The "text-yalign" property controls the vertical alignment of the
256    /// text in the progress bar.  Valid values range from 0 (top) to 1
257    /// (bottom).
258    #[doc(alias = "text-yalign")]
259    pub fn text_yalign(&self) -> f32 {
260        ObjectExt::property(self, "text-yalign")
261    }
262
263    /// The "text-yalign" property controls the vertical alignment of the
264    /// text in the progress bar.  Valid values range from 0 (top) to 1
265    /// (bottom).
266    #[doc(alias = "text-yalign")]
267    pub fn set_text_yalign(&self, text_yalign: f32) {
268        ObjectExt::set_property(self, "text-yalign", text_yalign)
269    }
270
271    /// The "value" property determines the percentage to which the
272    /// progress bar will be "filled in".
273    pub fn value(&self) -> i32 {
274        ObjectExt::property(self, "value")
275    }
276
277    /// The "value" property determines the percentage to which the
278    /// progress bar will be "filled in".
279    pub fn set_value(&self, value: i32) {
280        ObjectExt::set_property(self, "value", value)
281    }
282
283    #[doc(alias = "inverted")]
284    pub fn connect_inverted_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
285        unsafe extern "C" fn notify_inverted_trampoline<F: Fn(&CellRendererProgress) + 'static>(
286            this: *mut ffi::GtkCellRendererProgress,
287            _param_spec: glib::ffi::gpointer,
288            f: glib::ffi::gpointer,
289        ) {
290            let f: &F = &*(f as *const F);
291            f(&from_glib_borrow(this))
292        }
293        unsafe {
294            let f: Box_<F> = Box_::new(f);
295            connect_raw(
296                self.as_ptr() as *mut _,
297                b"notify::inverted\0".as_ptr() as *const _,
298                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
299                    notify_inverted_trampoline::<F> as *const (),
300                )),
301                Box_::into_raw(f),
302            )
303        }
304    }
305
306    #[doc(alias = "pulse")]
307    pub fn connect_pulse_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
308        unsafe extern "C" fn notify_pulse_trampoline<F: Fn(&CellRendererProgress) + 'static>(
309            this: *mut ffi::GtkCellRendererProgress,
310            _param_spec: glib::ffi::gpointer,
311            f: glib::ffi::gpointer,
312        ) {
313            let f: &F = &*(f as *const F);
314            f(&from_glib_borrow(this))
315        }
316        unsafe {
317            let f: Box_<F> = Box_::new(f);
318            connect_raw(
319                self.as_ptr() as *mut _,
320                b"notify::pulse\0".as_ptr() as *const _,
321                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
322                    notify_pulse_trampoline::<F> as *const (),
323                )),
324                Box_::into_raw(f),
325            )
326        }
327    }
328
329    #[doc(alias = "text")]
330    pub fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
331        unsafe extern "C" fn notify_text_trampoline<F: Fn(&CellRendererProgress) + 'static>(
332            this: *mut ffi::GtkCellRendererProgress,
333            _param_spec: glib::ffi::gpointer,
334            f: glib::ffi::gpointer,
335        ) {
336            let f: &F = &*(f as *const F);
337            f(&from_glib_borrow(this))
338        }
339        unsafe {
340            let f: Box_<F> = Box_::new(f);
341            connect_raw(
342                self.as_ptr() as *mut _,
343                b"notify::text\0".as_ptr() as *const _,
344                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
345                    notify_text_trampoline::<F> as *const (),
346                )),
347                Box_::into_raw(f),
348            )
349        }
350    }
351
352    #[doc(alias = "text-xalign")]
353    pub fn connect_text_xalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
354        unsafe extern "C" fn notify_text_xalign_trampoline<
355            F: Fn(&CellRendererProgress) + 'static,
356        >(
357            this: *mut ffi::GtkCellRendererProgress,
358            _param_spec: glib::ffi::gpointer,
359            f: glib::ffi::gpointer,
360        ) {
361            let f: &F = &*(f as *const F);
362            f(&from_glib_borrow(this))
363        }
364        unsafe {
365            let f: Box_<F> = Box_::new(f);
366            connect_raw(
367                self.as_ptr() as *mut _,
368                b"notify::text-xalign\0".as_ptr() as *const _,
369                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
370                    notify_text_xalign_trampoline::<F> as *const (),
371                )),
372                Box_::into_raw(f),
373            )
374        }
375    }
376
377    #[doc(alias = "text-yalign")]
378    pub fn connect_text_yalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
379        unsafe extern "C" fn notify_text_yalign_trampoline<
380            F: Fn(&CellRendererProgress) + 'static,
381        >(
382            this: *mut ffi::GtkCellRendererProgress,
383            _param_spec: glib::ffi::gpointer,
384            f: glib::ffi::gpointer,
385        ) {
386            let f: &F = &*(f as *const F);
387            f(&from_glib_borrow(this))
388        }
389        unsafe {
390            let f: Box_<F> = Box_::new(f);
391            connect_raw(
392                self.as_ptr() as *mut _,
393                b"notify::text-yalign\0".as_ptr() as *const _,
394                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
395                    notify_text_yalign_trampoline::<F> as *const (),
396                )),
397                Box_::into_raw(f),
398            )
399        }
400    }
401
402    #[doc(alias = "value")]
403    pub fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
404        unsafe extern "C" fn notify_value_trampoline<F: Fn(&CellRendererProgress) + 'static>(
405            this: *mut ffi::GtkCellRendererProgress,
406            _param_spec: glib::ffi::gpointer,
407            f: glib::ffi::gpointer,
408        ) {
409            let f: &F = &*(f as *const F);
410            f(&from_glib_borrow(this))
411        }
412        unsafe {
413            let f: Box_<F> = Box_::new(f);
414            connect_raw(
415                self.as_ptr() as *mut _,
416                b"notify::value\0".as_ptr() as *const _,
417                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
418                    notify_value_trampoline::<F> as *const (),
419                )),
420                Box_::into_raw(f),
421            )
422        }
423    }
424}
425
426impl Default for CellRendererProgress {
427    fn default() -> Self {
428        Self::new()
429    }
430}
431
432// rustdoc-stripper-ignore-next
433/// A [builder-pattern] type to construct [`CellRendererProgress`] objects.
434///
435/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
436#[must_use = "The builder must be built to be used"]
437pub struct CellRendererProgressBuilder {
438    builder: glib::object::ObjectBuilder<'static, CellRendererProgress>,
439}
440
441impl CellRendererProgressBuilder {
442    fn new() -> Self {
443        Self {
444            builder: glib::object::Object::builder(),
445        }
446    }
447
448    /// Whether progess is inverted.
449    pub fn inverted(self, inverted: bool) -> Self {
450        Self {
451            builder: self.builder.property("inverted", inverted),
452        }
453    }
454
455    /// Setting this to a non-negative value causes the cell renderer to
456    /// enter "activity mode", where a block bounces back and forth to
457    /// indicate that some progress is made, without specifying exactly how
458    /// much.
459    ///
460    /// Each increment of the property causes the block to move by a little
461    /// bit.
462    ///
463    /// To indicate that the activity has not started yet, set the property
464    /// to zero. To indicate completion, set the property to `G_MAXINT`.
465    pub fn pulse(self, pulse: i32) -> Self {
466        Self {
467            builder: self.builder.property("pulse", pulse),
468        }
469    }
470
471    /// The "text" property determines the label which will be drawn
472    /// over the progress bar. Setting this property to [`None`] causes the default
473    /// label to be displayed. Setting this property to an empty string causes
474    /// no label to be displayed.
475    pub fn text(self, text: impl Into<glib::GString>) -> Self {
476        Self {
477            builder: self.builder.property("text", text.into()),
478        }
479    }
480
481    /// The "text-xalign" property controls the horizontal alignment of the
482    /// text in the progress bar.  Valid values range from 0 (left) to 1
483    /// (right).  Reserved for RTL layouts.
484    pub fn text_xalign(self, text_xalign: f32) -> Self {
485        Self {
486            builder: self.builder.property("text-xalign", text_xalign),
487        }
488    }
489
490    /// The "text-yalign" property controls the vertical alignment of the
491    /// text in the progress bar.  Valid values range from 0 (top) to 1
492    /// (bottom).
493    pub fn text_yalign(self, text_yalign: f32) -> Self {
494        Self {
495            builder: self.builder.property("text-yalign", text_yalign),
496        }
497    }
498
499    /// The "value" property determines the percentage to which the
500    /// progress bar will be "filled in".
501    pub fn value(self, value: i32) -> Self {
502        Self {
503            builder: self.builder.property("value", value),
504        }
505    }
506
507    pub fn cell_background(self, cell_background: impl Into<glib::GString>) -> Self {
508        Self {
509            builder: self
510                .builder
511                .property("cell-background", cell_background.into()),
512        }
513    }
514
515    /// Cell background as a [`gdk::RGBA`][crate::gdk::RGBA]
516    pub fn cell_background_rgba(self, cell_background_rgba: &gdk::RGBA) -> Self {
517        Self {
518            builder: self
519                .builder
520                .property("cell-background-rgba", cell_background_rgba),
521        }
522    }
523
524    pub fn cell_background_set(self, cell_background_set: bool) -> Self {
525        Self {
526            builder: self
527                .builder
528                .property("cell-background-set", cell_background_set),
529        }
530    }
531
532    pub fn height(self, height: i32) -> Self {
533        Self {
534            builder: self.builder.property("height", height),
535        }
536    }
537
538    pub fn is_expanded(self, is_expanded: bool) -> Self {
539        Self {
540            builder: self.builder.property("is-expanded", is_expanded),
541        }
542    }
543
544    pub fn is_expander(self, is_expander: bool) -> Self {
545        Self {
546            builder: self.builder.property("is-expander", is_expander),
547        }
548    }
549
550    pub fn mode(self, mode: CellRendererMode) -> Self {
551        Self {
552            builder: self.builder.property("mode", mode),
553        }
554    }
555
556    pub fn sensitive(self, sensitive: bool) -> Self {
557        Self {
558            builder: self.builder.property("sensitive", sensitive),
559        }
560    }
561
562    pub fn visible(self, visible: bool) -> Self {
563        Self {
564            builder: self.builder.property("visible", visible),
565        }
566    }
567
568    pub fn width(self, width: i32) -> Self {
569        Self {
570            builder: self.builder.property("width", width),
571        }
572    }
573
574    pub fn xalign(self, xalign: f32) -> Self {
575        Self {
576            builder: self.builder.property("xalign", xalign),
577        }
578    }
579
580    pub fn xpad(self, xpad: u32) -> Self {
581        Self {
582            builder: self.builder.property("xpad", xpad),
583        }
584    }
585
586    pub fn yalign(self, yalign: f32) -> Self {
587        Self {
588            builder: self.builder.property("yalign", yalign),
589        }
590    }
591
592    pub fn ypad(self, ypad: u32) -> Self {
593        Self {
594            builder: self.builder.property("ypad", ypad),
595        }
596    }
597
598    /// The orientation of the orientable.
599    pub fn orientation(self, orientation: Orientation) -> Self {
600        Self {
601            builder: self.builder.property("orientation", orientation),
602        }
603    }
604
605    // rustdoc-stripper-ignore-next
606    /// Build the [`CellRendererProgress`].
607    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
608    pub fn build(self) -> CellRendererProgress {
609        assert_initialized_main_thread!();
610        self.builder.build()
611    }
612}