1use crate::ffi;
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "AdwPreferencesRow")]
16 pub struct PreferencesRow(Object<ffi::AdwPreferencesRow, ffi::AdwPreferencesRowClass>) @extends gtk::ListBoxRow, gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Actionable;
17
18 match fn {
19 type_ => || ffi::adw_preferences_row_get_type(),
20 }
21}
22
23impl PreferencesRow {
24 pub const NONE: Option<&'static PreferencesRow> = None;
25
26 #[doc(alias = "adw_preferences_row_new")]
27 pub fn new() -> PreferencesRow {
28 assert_initialized_main_thread!();
29 unsafe { gtk::Widget::from_glib_none(ffi::adw_preferences_row_new()).unsafe_cast() }
30 }
31
32 pub fn builder() -> PreferencesRowBuilder {
37 PreferencesRowBuilder::new()
38 }
39}
40
41impl Default for PreferencesRow {
42 fn default() -> Self {
43 Self::new()
44 }
45}
46
47#[must_use = "The builder must be built to be used"]
52pub struct PreferencesRowBuilder {
53 builder: glib::object::ObjectBuilder<'static, PreferencesRow>,
54}
55
56impl PreferencesRowBuilder {
57 fn new() -> Self {
58 Self {
59 builder: glib::object::Object::builder(),
60 }
61 }
62
63 pub fn title(self, title: impl Into<glib::GString>) -> Self {
64 Self {
65 builder: self.builder.property("title", title.into()),
66 }
67 }
68
69 #[cfg(feature = "v1_1")]
70 #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
71 pub fn title_selectable(self, title_selectable: bool) -> Self {
72 Self {
73 builder: self.builder.property("title-selectable", title_selectable),
74 }
75 }
76
77 #[cfg(feature = "v1_2")]
78 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
79 pub fn use_markup(self, use_markup: bool) -> Self {
80 Self {
81 builder: self.builder.property("use-markup", use_markup),
82 }
83 }
84
85 pub fn use_underline(self, use_underline: bool) -> Self {
86 Self {
87 builder: self.builder.property("use-underline", use_underline),
88 }
89 }
90
91 pub fn activatable(self, activatable: bool) -> Self {
92 Self {
93 builder: self.builder.property("activatable", activatable),
94 }
95 }
96
97 pub fn child(self, child: &impl IsA<gtk::Widget>) -> Self {
98 Self {
99 builder: self.builder.property("child", child.clone().upcast()),
100 }
101 }
102
103 pub fn selectable(self, selectable: bool) -> Self {
104 Self {
105 builder: self.builder.property("selectable", selectable),
106 }
107 }
108
109 pub fn can_focus(self, can_focus: bool) -> Self {
110 Self {
111 builder: self.builder.property("can-focus", can_focus),
112 }
113 }
114
115 pub fn can_target(self, can_target: bool) -> Self {
116 Self {
117 builder: self.builder.property("can-target", can_target),
118 }
119 }
120
121 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
122 Self {
123 builder: self.builder.property("css-classes", css_classes.into()),
124 }
125 }
126
127 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
128 Self {
129 builder: self.builder.property("css-name", css_name.into()),
130 }
131 }
132
133 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
134 Self {
135 builder: self.builder.property("cursor", cursor.clone()),
136 }
137 }
138
139 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
140 Self {
141 builder: self.builder.property("focus-on-click", focus_on_click),
142 }
143 }
144
145 pub fn focusable(self, focusable: bool) -> Self {
146 Self {
147 builder: self.builder.property("focusable", focusable),
148 }
149 }
150
151 pub fn halign(self, halign: gtk::Align) -> Self {
152 Self {
153 builder: self.builder.property("halign", halign),
154 }
155 }
156
157 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
158 Self {
159 builder: self.builder.property("has-tooltip", has_tooltip),
160 }
161 }
162
163 pub fn height_request(self, height_request: i32) -> Self {
164 Self {
165 builder: self.builder.property("height-request", height_request),
166 }
167 }
168
169 pub fn hexpand(self, hexpand: bool) -> Self {
170 Self {
171 builder: self.builder.property("hexpand", hexpand),
172 }
173 }
174
175 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
176 Self {
177 builder: self.builder.property("hexpand-set", hexpand_set),
178 }
179 }
180
181 pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
182 Self {
183 builder: self
184 .builder
185 .property("layout-manager", layout_manager.clone().upcast()),
186 }
187 }
188
189 #[cfg(feature = "gtk_v4_18")]
190 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
191 pub fn limit_events(self, limit_events: bool) -> Self {
192 Self {
193 builder: self.builder.property("limit-events", limit_events),
194 }
195 }
196
197 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
198 Self {
199 builder: self.builder.property("margin-bottom", margin_bottom),
200 }
201 }
202
203 pub fn margin_end(self, margin_end: i32) -> Self {
204 Self {
205 builder: self.builder.property("margin-end", margin_end),
206 }
207 }
208
209 pub fn margin_start(self, margin_start: i32) -> Self {
210 Self {
211 builder: self.builder.property("margin-start", margin_start),
212 }
213 }
214
215 pub fn margin_top(self, margin_top: i32) -> Self {
216 Self {
217 builder: self.builder.property("margin-top", margin_top),
218 }
219 }
220
221 pub fn name(self, name: impl Into<glib::GString>) -> Self {
222 Self {
223 builder: self.builder.property("name", name.into()),
224 }
225 }
226
227 pub fn opacity(self, opacity: f64) -> Self {
228 Self {
229 builder: self.builder.property("opacity", opacity),
230 }
231 }
232
233 pub fn overflow(self, overflow: gtk::Overflow) -> Self {
234 Self {
235 builder: self.builder.property("overflow", overflow),
236 }
237 }
238
239 pub fn receives_default(self, receives_default: bool) -> Self {
240 Self {
241 builder: self.builder.property("receives-default", receives_default),
242 }
243 }
244
245 pub fn sensitive(self, sensitive: bool) -> Self {
246 Self {
247 builder: self.builder.property("sensitive", sensitive),
248 }
249 }
250
251 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
252 Self {
253 builder: self
254 .builder
255 .property("tooltip-markup", tooltip_markup.into()),
256 }
257 }
258
259 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
260 Self {
261 builder: self.builder.property("tooltip-text", tooltip_text.into()),
262 }
263 }
264
265 pub fn valign(self, valign: gtk::Align) -> Self {
266 Self {
267 builder: self.builder.property("valign", valign),
268 }
269 }
270
271 pub fn vexpand(self, vexpand: bool) -> Self {
272 Self {
273 builder: self.builder.property("vexpand", vexpand),
274 }
275 }
276
277 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
278 Self {
279 builder: self.builder.property("vexpand-set", vexpand_set),
280 }
281 }
282
283 pub fn visible(self, visible: bool) -> Self {
284 Self {
285 builder: self.builder.property("visible", visible),
286 }
287 }
288
289 pub fn width_request(self, width_request: i32) -> Self {
290 Self {
291 builder: self.builder.property("width-request", width_request),
292 }
293 }
294
295 pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
296 Self {
297 builder: self.builder.property("accessible-role", accessible_role),
298 }
299 }
300
301 pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
302 Self {
303 builder: self.builder.property("action-name", action_name.into()),
304 }
305 }
306
307 pub fn action_target(self, action_target: &glib::Variant) -> Self {
308 Self {
309 builder: self
310 .builder
311 .property("action-target", action_target.clone()),
312 }
313 }
314
315 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
318 pub fn build(self) -> PreferencesRow {
319 assert_initialized_main_thread!();
320 self.builder.build()
321 }
322}
323
324pub trait PreferencesRowExt: IsA<PreferencesRow> + 'static {
325 #[doc(alias = "adw_preferences_row_get_title")]
326 #[doc(alias = "get_title")]
327 fn title(&self) -> glib::GString {
328 unsafe {
329 from_glib_none(ffi::adw_preferences_row_get_title(
330 self.as_ref().to_glib_none().0,
331 ))
332 }
333 }
334
335 #[cfg(feature = "v1_1")]
336 #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
337 #[doc(alias = "adw_preferences_row_get_title_selectable")]
338 #[doc(alias = "get_title_selectable")]
339 #[doc(alias = "title-selectable")]
340 fn is_title_selectable(&self) -> bool {
341 unsafe {
342 from_glib(ffi::adw_preferences_row_get_title_selectable(
343 self.as_ref().to_glib_none().0,
344 ))
345 }
346 }
347
348 #[cfg(feature = "v1_2")]
349 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
350 #[doc(alias = "adw_preferences_row_get_use_markup")]
351 #[doc(alias = "get_use_markup")]
352 #[doc(alias = "use-markup")]
353 fn uses_markup(&self) -> bool {
354 unsafe {
355 from_glib(ffi::adw_preferences_row_get_use_markup(
356 self.as_ref().to_glib_none().0,
357 ))
358 }
359 }
360
361 #[doc(alias = "adw_preferences_row_get_use_underline")]
362 #[doc(alias = "get_use_underline")]
363 #[doc(alias = "use-underline")]
364 fn uses_underline(&self) -> bool {
365 unsafe {
366 from_glib(ffi::adw_preferences_row_get_use_underline(
367 self.as_ref().to_glib_none().0,
368 ))
369 }
370 }
371
372 #[doc(alias = "adw_preferences_row_set_title")]
373 #[doc(alias = "title")]
374 fn set_title(&self, title: &str) {
375 unsafe {
376 ffi::adw_preferences_row_set_title(
377 self.as_ref().to_glib_none().0,
378 title.to_glib_none().0,
379 );
380 }
381 }
382
383 #[cfg(feature = "v1_1")]
384 #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
385 #[doc(alias = "adw_preferences_row_set_title_selectable")]
386 #[doc(alias = "title-selectable")]
387 fn set_title_selectable(&self, title_selectable: bool) {
388 unsafe {
389 ffi::adw_preferences_row_set_title_selectable(
390 self.as_ref().to_glib_none().0,
391 title_selectable.into_glib(),
392 );
393 }
394 }
395
396 #[cfg(feature = "v1_2")]
397 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
398 #[doc(alias = "adw_preferences_row_set_use_markup")]
399 #[doc(alias = "use-markup")]
400 fn set_use_markup(&self, use_markup: bool) {
401 unsafe {
402 ffi::adw_preferences_row_set_use_markup(
403 self.as_ref().to_glib_none().0,
404 use_markup.into_glib(),
405 );
406 }
407 }
408
409 #[doc(alias = "adw_preferences_row_set_use_underline")]
410 #[doc(alias = "use-underline")]
411 fn set_use_underline(&self, use_underline: bool) {
412 unsafe {
413 ffi::adw_preferences_row_set_use_underline(
414 self.as_ref().to_glib_none().0,
415 use_underline.into_glib(),
416 );
417 }
418 }
419
420 #[doc(alias = "title")]
421 fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
422 unsafe extern "C" fn notify_title_trampoline<
423 P: IsA<PreferencesRow>,
424 F: Fn(&P) + 'static,
425 >(
426 this: *mut ffi::AdwPreferencesRow,
427 _param_spec: glib::ffi::gpointer,
428 f: glib::ffi::gpointer,
429 ) {
430 let f: &F = &*(f as *const F);
431 f(PreferencesRow::from_glib_borrow(this).unsafe_cast_ref())
432 }
433 unsafe {
434 let f: Box_<F> = Box_::new(f);
435 connect_raw(
436 self.as_ptr() as *mut _,
437 c"notify::title".as_ptr() as *const _,
438 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
439 notify_title_trampoline::<Self, F> as *const (),
440 )),
441 Box_::into_raw(f),
442 )
443 }
444 }
445
446 #[cfg(feature = "v1_1")]
447 #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
448 #[doc(alias = "title-selectable")]
449 fn connect_title_selectable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
450 unsafe extern "C" fn notify_title_selectable_trampoline<
451 P: IsA<PreferencesRow>,
452 F: Fn(&P) + 'static,
453 >(
454 this: *mut ffi::AdwPreferencesRow,
455 _param_spec: glib::ffi::gpointer,
456 f: glib::ffi::gpointer,
457 ) {
458 let f: &F = &*(f as *const F);
459 f(PreferencesRow::from_glib_borrow(this).unsafe_cast_ref())
460 }
461 unsafe {
462 let f: Box_<F> = Box_::new(f);
463 connect_raw(
464 self.as_ptr() as *mut _,
465 c"notify::title-selectable".as_ptr() as *const _,
466 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
467 notify_title_selectable_trampoline::<Self, F> as *const (),
468 )),
469 Box_::into_raw(f),
470 )
471 }
472 }
473
474 #[cfg(feature = "v1_2")]
475 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
476 #[doc(alias = "use-markup")]
477 fn connect_use_markup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
478 unsafe extern "C" fn notify_use_markup_trampoline<
479 P: IsA<PreferencesRow>,
480 F: Fn(&P) + 'static,
481 >(
482 this: *mut ffi::AdwPreferencesRow,
483 _param_spec: glib::ffi::gpointer,
484 f: glib::ffi::gpointer,
485 ) {
486 let f: &F = &*(f as *const F);
487 f(PreferencesRow::from_glib_borrow(this).unsafe_cast_ref())
488 }
489 unsafe {
490 let f: Box_<F> = Box_::new(f);
491 connect_raw(
492 self.as_ptr() as *mut _,
493 c"notify::use-markup".as_ptr() as *const _,
494 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
495 notify_use_markup_trampoline::<Self, F> as *const (),
496 )),
497 Box_::into_raw(f),
498 )
499 }
500 }
501
502 #[doc(alias = "use-underline")]
503 fn connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
504 unsafe extern "C" fn notify_use_underline_trampoline<
505 P: IsA<PreferencesRow>,
506 F: Fn(&P) + 'static,
507 >(
508 this: *mut ffi::AdwPreferencesRow,
509 _param_spec: glib::ffi::gpointer,
510 f: glib::ffi::gpointer,
511 ) {
512 let f: &F = &*(f as *const F);
513 f(PreferencesRow::from_glib_borrow(this).unsafe_cast_ref())
514 }
515 unsafe {
516 let f: Box_<F> = Box_::new(f);
517 connect_raw(
518 self.as_ptr() as *mut _,
519 c"notify::use-underline".as_ptr() as *const _,
520 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
521 notify_use_underline_trampoline::<Self, F> as *const (),
522 )),
523 Box_::into_raw(f),
524 )
525 }
526 }
527}
528
529impl<O: IsA<PreferencesRow>> PreferencesRowExt for O {}