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