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::{CellRenderer, CellRendererMode, Orientable, Orientation, 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 [`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 unsafe {
291 let f: &F = &*(f as *const F);
292 f(&from_glib_borrow(this))
293 }
294 }
295 unsafe {
296 let f: Box_<F> = Box_::new(f);
297 connect_raw(
298 self.as_ptr() as *mut _,
299 c"notify::inverted".as_ptr() as *const _,
300 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
301 notify_inverted_trampoline::<F> as *const (),
302 )),
303 Box_::into_raw(f),
304 )
305 }
306 }
307
308 #[doc(alias = "pulse")]
309 pub fn connect_pulse_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
310 unsafe extern "C" fn notify_pulse_trampoline<F: Fn(&CellRendererProgress) + 'static>(
311 this: *mut ffi::GtkCellRendererProgress,
312 _param_spec: glib::ffi::gpointer,
313 f: glib::ffi::gpointer,
314 ) {
315 unsafe {
316 let f: &F = &*(f as *const F);
317 f(&from_glib_borrow(this))
318 }
319 }
320 unsafe {
321 let f: Box_<F> = Box_::new(f);
322 connect_raw(
323 self.as_ptr() as *mut _,
324 c"notify::pulse".as_ptr() as *const _,
325 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
326 notify_pulse_trampoline::<F> as *const (),
327 )),
328 Box_::into_raw(f),
329 )
330 }
331 }
332
333 #[doc(alias = "text")]
334 pub fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
335 unsafe extern "C" fn notify_text_trampoline<F: Fn(&CellRendererProgress) + 'static>(
336 this: *mut ffi::GtkCellRendererProgress,
337 _param_spec: glib::ffi::gpointer,
338 f: glib::ffi::gpointer,
339 ) {
340 unsafe {
341 let f: &F = &*(f as *const F);
342 f(&from_glib_borrow(this))
343 }
344 }
345 unsafe {
346 let f: Box_<F> = Box_::new(f);
347 connect_raw(
348 self.as_ptr() as *mut _,
349 c"notify::text".as_ptr() as *const _,
350 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
351 notify_text_trampoline::<F> as *const (),
352 )),
353 Box_::into_raw(f),
354 )
355 }
356 }
357
358 #[doc(alias = "text-xalign")]
359 pub fn connect_text_xalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
360 unsafe extern "C" fn notify_text_xalign_trampoline<
361 F: Fn(&CellRendererProgress) + 'static,
362 >(
363 this: *mut ffi::GtkCellRendererProgress,
364 _param_spec: glib::ffi::gpointer,
365 f: glib::ffi::gpointer,
366 ) {
367 unsafe {
368 let f: &F = &*(f as *const F);
369 f(&from_glib_borrow(this))
370 }
371 }
372 unsafe {
373 let f: Box_<F> = Box_::new(f);
374 connect_raw(
375 self.as_ptr() as *mut _,
376 c"notify::text-xalign".as_ptr() as *const _,
377 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
378 notify_text_xalign_trampoline::<F> as *const (),
379 )),
380 Box_::into_raw(f),
381 )
382 }
383 }
384
385 #[doc(alias = "text-yalign")]
386 pub fn connect_text_yalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
387 unsafe extern "C" fn notify_text_yalign_trampoline<
388 F: Fn(&CellRendererProgress) + 'static,
389 >(
390 this: *mut ffi::GtkCellRendererProgress,
391 _param_spec: glib::ffi::gpointer,
392 f: glib::ffi::gpointer,
393 ) {
394 unsafe {
395 let f: &F = &*(f as *const F);
396 f(&from_glib_borrow(this))
397 }
398 }
399 unsafe {
400 let f: Box_<F> = Box_::new(f);
401 connect_raw(
402 self.as_ptr() as *mut _,
403 c"notify::text-yalign".as_ptr() as *const _,
404 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
405 notify_text_yalign_trampoline::<F> as *const (),
406 )),
407 Box_::into_raw(f),
408 )
409 }
410 }
411
412 #[doc(alias = "value")]
413 pub fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
414 unsafe extern "C" fn notify_value_trampoline<F: Fn(&CellRendererProgress) + 'static>(
415 this: *mut ffi::GtkCellRendererProgress,
416 _param_spec: glib::ffi::gpointer,
417 f: glib::ffi::gpointer,
418 ) {
419 unsafe {
420 let f: &F = &*(f as *const F);
421 f(&from_glib_borrow(this))
422 }
423 }
424 unsafe {
425 let f: Box_<F> = Box_::new(f);
426 connect_raw(
427 self.as_ptr() as *mut _,
428 c"notify::value".as_ptr() as *const _,
429 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
430 notify_value_trampoline::<F> as *const (),
431 )),
432 Box_::into_raw(f),
433 )
434 }
435 }
436}
437
438impl Default for CellRendererProgress {
439 fn default() -> Self {
440 Self::new()
441 }
442}
443
444// rustdoc-stripper-ignore-next
445/// A [builder-pattern] type to construct [`CellRendererProgress`] objects.
446///
447/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
448#[must_use = "The builder must be built to be used"]
449pub struct CellRendererProgressBuilder {
450 builder: glib::object::ObjectBuilder<'static, CellRendererProgress>,
451}
452
453impl CellRendererProgressBuilder {
454 fn new() -> Self {
455 Self {
456 builder: glib::object::Object::builder(),
457 }
458 }
459
460 /// Whether progess is inverted.
461 pub fn inverted(self, inverted: bool) -> Self {
462 Self {
463 builder: self.builder.property("inverted", inverted),
464 }
465 }
466
467 /// Setting this to a non-negative value causes the cell renderer to
468 /// enter "activity mode", where a block bounces back and forth to
469 /// indicate that some progress is made, without specifying exactly how
470 /// much.
471 ///
472 /// Each increment of the property causes the block to move by a little
473 /// bit.
474 ///
475 /// To indicate that the activity has not started yet, set the property
476 /// to zero. To indicate completion, set the property to `G_MAXINT`.
477 pub fn pulse(self, pulse: i32) -> Self {
478 Self {
479 builder: self.builder.property("pulse", pulse),
480 }
481 }
482
483 /// The "text" property determines the label which will be drawn
484 /// over the progress bar. Setting this property to [`None`] causes the default
485 /// label to be displayed. Setting this property to an empty string causes
486 /// no label to be displayed.
487 pub fn text(self, text: impl Into<glib::GString>) -> Self {
488 Self {
489 builder: self.builder.property("text", text.into()),
490 }
491 }
492
493 /// The "text-xalign" property controls the horizontal alignment of the
494 /// text in the progress bar. Valid values range from 0 (left) to 1
495 /// (right). Reserved for RTL layouts.
496 pub fn text_xalign(self, text_xalign: f32) -> Self {
497 Self {
498 builder: self.builder.property("text-xalign", text_xalign),
499 }
500 }
501
502 /// The "text-yalign" property controls the vertical alignment of the
503 /// text in the progress bar. Valid values range from 0 (top) to 1
504 /// (bottom).
505 pub fn text_yalign(self, text_yalign: f32) -> Self {
506 Self {
507 builder: self.builder.property("text-yalign", text_yalign),
508 }
509 }
510
511 /// The "value" property determines the percentage to which the
512 /// progress bar will be "filled in".
513 pub fn value(self, value: i32) -> Self {
514 Self {
515 builder: self.builder.property("value", value),
516 }
517 }
518
519 pub fn cell_background(self, cell_background: impl Into<glib::GString>) -> Self {
520 Self {
521 builder: self
522 .builder
523 .property("cell-background", cell_background.into()),
524 }
525 }
526
527 /// Cell background as a [`gdk::RGBA`][crate::gdk::RGBA]
528 pub fn cell_background_rgba(self, cell_background_rgba: &gdk::RGBA) -> Self {
529 Self {
530 builder: self
531 .builder
532 .property("cell-background-rgba", cell_background_rgba),
533 }
534 }
535
536 pub fn cell_background_set(self, cell_background_set: bool) -> Self {
537 Self {
538 builder: self
539 .builder
540 .property("cell-background-set", cell_background_set),
541 }
542 }
543
544 pub fn height(self, height: i32) -> Self {
545 Self {
546 builder: self.builder.property("height", height),
547 }
548 }
549
550 pub fn is_expanded(self, is_expanded: bool) -> Self {
551 Self {
552 builder: self.builder.property("is-expanded", is_expanded),
553 }
554 }
555
556 pub fn is_expander(self, is_expander: bool) -> Self {
557 Self {
558 builder: self.builder.property("is-expander", is_expander),
559 }
560 }
561
562 pub fn mode(self, mode: CellRendererMode) -> Self {
563 Self {
564 builder: self.builder.property("mode", mode),
565 }
566 }
567
568 pub fn sensitive(self, sensitive: bool) -> Self {
569 Self {
570 builder: self.builder.property("sensitive", sensitive),
571 }
572 }
573
574 pub fn visible(self, visible: bool) -> Self {
575 Self {
576 builder: self.builder.property("visible", visible),
577 }
578 }
579
580 pub fn width(self, width: i32) -> Self {
581 Self {
582 builder: self.builder.property("width", width),
583 }
584 }
585
586 pub fn xalign(self, xalign: f32) -> Self {
587 Self {
588 builder: self.builder.property("xalign", xalign),
589 }
590 }
591
592 pub fn xpad(self, xpad: u32) -> Self {
593 Self {
594 builder: self.builder.property("xpad", xpad),
595 }
596 }
597
598 pub fn yalign(self, yalign: f32) -> Self {
599 Self {
600 builder: self.builder.property("yalign", yalign),
601 }
602 }
603
604 pub fn ypad(self, ypad: u32) -> Self {
605 Self {
606 builder: self.builder.property("ypad", ypad),
607 }
608 }
609
610 /// The orientation of the orientable.
611 pub fn orientation(self, orientation: Orientation) -> Self {
612 Self {
613 builder: self.builder.property("orientation", orientation),
614 }
615 }
616
617 // rustdoc-stripper-ignore-next
618 /// Build the [`CellRendererProgress`].
619 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
620 pub fn build(self) -> CellRendererProgress {
621 assert_initialized_main_thread!();
622 self.builder.build()
623 }
624}