1#![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 #[doc(alias = "GtkCellRendererProgress")]
16 pub struct CellRendererProgress(Object<ffi::GtkCellRendererProgress>) @extends CellRenderer, @implements Orientable;
17
18 match fn {
19 type_ => || ffi::gtk_cell_renderer_progress_get_type(),
20 }
21}
22
23impl CellRendererProgress {
24 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
25 #[allow(deprecated)]
26 #[doc(alias = "gtk_cell_renderer_progress_new")]
27 pub fn new() -> CellRendererProgress {
28 assert_initialized_main_thread!();
29 unsafe { CellRenderer::from_glib_none(ffi::gtk_cell_renderer_progress_new()).unsafe_cast() }
30 }
31
32 pub fn builder() -> CellRendererProgressBuilder {
37 CellRendererProgressBuilder::new()
38 }
39
40 pub fn is_inverted(&self) -> bool {
41 ObjectExt::property(self, "inverted")
42 }
43
44 pub fn set_inverted(&self, inverted: bool) {
45 ObjectExt::set_property(self, "inverted", inverted)
46 }
47
48 pub fn pulse(&self) -> i32 {
49 ObjectExt::property(self, "pulse")
50 }
51
52 pub fn set_pulse(&self, pulse: i32) {
53 ObjectExt::set_property(self, "pulse", pulse)
54 }
55
56 pub fn text(&self) -> Option<glib::GString> {
57 ObjectExt::property(self, "text")
58 }
59
60 pub fn set_text(&self, text: Option<&str>) {
61 ObjectExt::set_property(self, "text", text)
62 }
63
64 #[doc(alias = "text-xalign")]
65 pub fn text_xalign(&self) -> f32 {
66 ObjectExt::property(self, "text-xalign")
67 }
68
69 #[doc(alias = "text-xalign")]
70 pub fn set_text_xalign(&self, text_xalign: f32) {
71 ObjectExt::set_property(self, "text-xalign", text_xalign)
72 }
73
74 #[doc(alias = "text-yalign")]
75 pub fn text_yalign(&self) -> f32 {
76 ObjectExt::property(self, "text-yalign")
77 }
78
79 #[doc(alias = "text-yalign")]
80 pub fn set_text_yalign(&self, text_yalign: f32) {
81 ObjectExt::set_property(self, "text-yalign", text_yalign)
82 }
83
84 pub fn value(&self) -> i32 {
85 ObjectExt::property(self, "value")
86 }
87
88 pub fn set_value(&self, value: i32) {
89 ObjectExt::set_property(self, "value", value)
90 }
91
92 #[doc(alias = "inverted")]
93 pub fn connect_inverted_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
94 unsafe extern "C" fn notify_inverted_trampoline<F: Fn(&CellRendererProgress) + 'static>(
95 this: *mut ffi::GtkCellRendererProgress,
96 _param_spec: glib::ffi::gpointer,
97 f: glib::ffi::gpointer,
98 ) {
99 let f: &F = &*(f as *const F);
100 f(&from_glib_borrow(this))
101 }
102 unsafe {
103 let f: Box_<F> = Box_::new(f);
104 connect_raw(
105 self.as_ptr() as *mut _,
106 c"notify::inverted".as_ptr() as *const _,
107 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
108 notify_inverted_trampoline::<F> as *const (),
109 )),
110 Box_::into_raw(f),
111 )
112 }
113 }
114
115 #[doc(alias = "pulse")]
116 pub fn connect_pulse_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
117 unsafe extern "C" fn notify_pulse_trampoline<F: Fn(&CellRendererProgress) + 'static>(
118 this: *mut ffi::GtkCellRendererProgress,
119 _param_spec: glib::ffi::gpointer,
120 f: glib::ffi::gpointer,
121 ) {
122 let f: &F = &*(f as *const F);
123 f(&from_glib_borrow(this))
124 }
125 unsafe {
126 let f: Box_<F> = Box_::new(f);
127 connect_raw(
128 self.as_ptr() as *mut _,
129 c"notify::pulse".as_ptr() as *const _,
130 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
131 notify_pulse_trampoline::<F> as *const (),
132 )),
133 Box_::into_raw(f),
134 )
135 }
136 }
137
138 #[doc(alias = "text")]
139 pub fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
140 unsafe extern "C" fn notify_text_trampoline<F: Fn(&CellRendererProgress) + 'static>(
141 this: *mut ffi::GtkCellRendererProgress,
142 _param_spec: glib::ffi::gpointer,
143 f: glib::ffi::gpointer,
144 ) {
145 let f: &F = &*(f as *const F);
146 f(&from_glib_borrow(this))
147 }
148 unsafe {
149 let f: Box_<F> = Box_::new(f);
150 connect_raw(
151 self.as_ptr() as *mut _,
152 c"notify::text".as_ptr() as *const _,
153 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
154 notify_text_trampoline::<F> as *const (),
155 )),
156 Box_::into_raw(f),
157 )
158 }
159 }
160
161 #[doc(alias = "text-xalign")]
162 pub fn connect_text_xalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
163 unsafe extern "C" fn notify_text_xalign_trampoline<
164 F: Fn(&CellRendererProgress) + 'static,
165 >(
166 this: *mut ffi::GtkCellRendererProgress,
167 _param_spec: glib::ffi::gpointer,
168 f: glib::ffi::gpointer,
169 ) {
170 let f: &F = &*(f as *const F);
171 f(&from_glib_borrow(this))
172 }
173 unsafe {
174 let f: Box_<F> = Box_::new(f);
175 connect_raw(
176 self.as_ptr() as *mut _,
177 c"notify::text-xalign".as_ptr() as *const _,
178 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
179 notify_text_xalign_trampoline::<F> as *const (),
180 )),
181 Box_::into_raw(f),
182 )
183 }
184 }
185
186 #[doc(alias = "text-yalign")]
187 pub fn connect_text_yalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
188 unsafe extern "C" fn notify_text_yalign_trampoline<
189 F: Fn(&CellRendererProgress) + 'static,
190 >(
191 this: *mut ffi::GtkCellRendererProgress,
192 _param_spec: glib::ffi::gpointer,
193 f: glib::ffi::gpointer,
194 ) {
195 let f: &F = &*(f as *const F);
196 f(&from_glib_borrow(this))
197 }
198 unsafe {
199 let f: Box_<F> = Box_::new(f);
200 connect_raw(
201 self.as_ptr() as *mut _,
202 c"notify::text-yalign".as_ptr() as *const _,
203 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
204 notify_text_yalign_trampoline::<F> as *const (),
205 )),
206 Box_::into_raw(f),
207 )
208 }
209 }
210
211 #[doc(alias = "value")]
212 pub fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
213 unsafe extern "C" fn notify_value_trampoline<F: Fn(&CellRendererProgress) + 'static>(
214 this: *mut ffi::GtkCellRendererProgress,
215 _param_spec: glib::ffi::gpointer,
216 f: glib::ffi::gpointer,
217 ) {
218 let f: &F = &*(f as *const F);
219 f(&from_glib_borrow(this))
220 }
221 unsafe {
222 let f: Box_<F> = Box_::new(f);
223 connect_raw(
224 self.as_ptr() as *mut _,
225 c"notify::value".as_ptr() as *const _,
226 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
227 notify_value_trampoline::<F> as *const (),
228 )),
229 Box_::into_raw(f),
230 )
231 }
232 }
233}
234
235impl Default for CellRendererProgress {
236 fn default() -> Self {
237 Self::new()
238 }
239}
240
241#[must_use = "The builder must be built to be used"]
246pub struct CellRendererProgressBuilder {
247 builder: glib::object::ObjectBuilder<'static, CellRendererProgress>,
248}
249
250impl CellRendererProgressBuilder {
251 fn new() -> Self {
252 Self {
253 builder: glib::object::Object::builder(),
254 }
255 }
256
257 pub fn inverted(self, inverted: bool) -> Self {
258 Self {
259 builder: self.builder.property("inverted", inverted),
260 }
261 }
262
263 pub fn pulse(self, pulse: i32) -> Self {
264 Self {
265 builder: self.builder.property("pulse", pulse),
266 }
267 }
268
269 pub fn text(self, text: impl Into<glib::GString>) -> Self {
270 Self {
271 builder: self.builder.property("text", text.into()),
272 }
273 }
274
275 pub fn text_xalign(self, text_xalign: f32) -> Self {
276 Self {
277 builder: self.builder.property("text-xalign", text_xalign),
278 }
279 }
280
281 pub fn text_yalign(self, text_yalign: f32) -> Self {
282 Self {
283 builder: self.builder.property("text-yalign", text_yalign),
284 }
285 }
286
287 pub fn value(self, value: i32) -> Self {
288 Self {
289 builder: self.builder.property("value", value),
290 }
291 }
292
293 pub fn cell_background(self, cell_background: impl Into<glib::GString>) -> Self {
294 Self {
295 builder: self
296 .builder
297 .property("cell-background", cell_background.into()),
298 }
299 }
300
301 pub fn cell_background_rgba(self, cell_background_rgba: &gdk::RGBA) -> Self {
302 Self {
303 builder: self
304 .builder
305 .property("cell-background-rgba", cell_background_rgba),
306 }
307 }
308
309 pub fn cell_background_set(self, cell_background_set: bool) -> Self {
310 Self {
311 builder: self
312 .builder
313 .property("cell-background-set", cell_background_set),
314 }
315 }
316
317 pub fn height(self, height: i32) -> Self {
318 Self {
319 builder: self.builder.property("height", height),
320 }
321 }
322
323 pub fn is_expanded(self, is_expanded: bool) -> Self {
324 Self {
325 builder: self.builder.property("is-expanded", is_expanded),
326 }
327 }
328
329 pub fn is_expander(self, is_expander: bool) -> Self {
330 Self {
331 builder: self.builder.property("is-expander", is_expander),
332 }
333 }
334
335 pub fn mode(self, mode: CellRendererMode) -> Self {
336 Self {
337 builder: self.builder.property("mode", mode),
338 }
339 }
340
341 pub fn sensitive(self, sensitive: bool) -> Self {
342 Self {
343 builder: self.builder.property("sensitive", sensitive),
344 }
345 }
346
347 pub fn visible(self, visible: bool) -> Self {
348 Self {
349 builder: self.builder.property("visible", visible),
350 }
351 }
352
353 pub fn width(self, width: i32) -> Self {
354 Self {
355 builder: self.builder.property("width", width),
356 }
357 }
358
359 pub fn xalign(self, xalign: f32) -> Self {
360 Self {
361 builder: self.builder.property("xalign", xalign),
362 }
363 }
364
365 pub fn xpad(self, xpad: u32) -> Self {
366 Self {
367 builder: self.builder.property("xpad", xpad),
368 }
369 }
370
371 pub fn yalign(self, yalign: f32) -> Self {
372 Self {
373 builder: self.builder.property("yalign", yalign),
374 }
375 }
376
377 pub fn ypad(self, ypad: u32) -> Self {
378 Self {
379 builder: self.builder.property("ypad", ypad),
380 }
381 }
382
383 pub fn orientation(self, orientation: Orientation) -> Self {
384 Self {
385 builder: self.builder.property("orientation", orientation),
386 }
387 }
388
389 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
392 pub fn build(self) -> CellRendererProgress {
393 assert_initialized_main_thread!();
394 self.builder.build()
395 }
396}