1#![allow(deprecated)]
6
7use crate::{ffi, PreferencesRow};
8use glib::{
9 object::ObjectType as _,
10 prelude::*,
11 signal::{connect_raw, SignalHandlerId},
12 translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17 #[doc(alias = "AdwActionRow")]
18 pub struct ActionRow(Object<ffi::AdwActionRow, ffi::AdwActionRowClass>) @extends PreferencesRow, gtk::ListBoxRow, gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Actionable;
19
20 match fn {
21 type_ => || ffi::adw_action_row_get_type(),
22 }
23}
24
25impl ActionRow {
26 pub const NONE: Option<&'static ActionRow> = None;
27
28 #[doc(alias = "adw_action_row_new")]
29 pub fn new() -> ActionRow {
30 assert_initialized_main_thread!();
31 unsafe { gtk::Widget::from_glib_none(ffi::adw_action_row_new()).unsafe_cast() }
32 }
33
34 pub fn builder() -> ActionRowBuilder {
39 ActionRowBuilder::new()
40 }
41}
42
43impl Default for ActionRow {
44 fn default() -> Self {
45 Self::new()
46 }
47}
48
49#[must_use = "The builder must be built to be used"]
54pub struct ActionRowBuilder {
55 builder: glib::object::ObjectBuilder<'static, ActionRow>,
56}
57
58impl ActionRowBuilder {
59 fn new() -> Self {
60 Self {
61 builder: glib::object::Object::builder(),
62 }
63 }
64
65 pub fn activatable_widget(self, activatable_widget: &impl IsA<gtk::Widget>) -> Self {
66 Self {
67 builder: self
68 .builder
69 .property("activatable-widget", activatable_widget.clone().upcast()),
70 }
71 }
72
73 #[cfg_attr(feature = "v1_3", deprecated = "Since 1.3")]
74 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
75 Self {
76 builder: self.builder.property("icon-name", icon_name.into()),
77 }
78 }
79
80 pub fn subtitle(self, subtitle: impl Into<glib::GString>) -> Self {
81 Self {
82 builder: self.builder.property("subtitle", subtitle.into()),
83 }
84 }
85
86 pub fn subtitle_lines(self, subtitle_lines: i32) -> Self {
87 Self {
88 builder: self.builder.property("subtitle-lines", subtitle_lines),
89 }
90 }
91
92 #[cfg(feature = "v1_3")]
93 #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
94 pub fn subtitle_selectable(self, subtitle_selectable: bool) -> Self {
95 Self {
96 builder: self
97 .builder
98 .property("subtitle-selectable", subtitle_selectable),
99 }
100 }
101
102 pub fn title_lines(self, title_lines: i32) -> Self {
103 Self {
104 builder: self.builder.property("title-lines", title_lines),
105 }
106 }
107
108 pub fn title(self, title: impl Into<glib::GString>) -> Self {
109 Self {
110 builder: self.builder.property("title", title.into()),
111 }
112 }
113
114 #[cfg(feature = "v1_1")]
115 #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
116 pub fn title_selectable(self, title_selectable: bool) -> Self {
117 Self {
118 builder: self.builder.property("title-selectable", title_selectable),
119 }
120 }
121
122 #[cfg(feature = "v1_2")]
123 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
124 pub fn use_markup(self, use_markup: bool) -> Self {
125 Self {
126 builder: self.builder.property("use-markup", use_markup),
127 }
128 }
129
130 pub fn use_underline(self, use_underline: bool) -> Self {
131 Self {
132 builder: self.builder.property("use-underline", use_underline),
133 }
134 }
135
136 pub fn activatable(self, activatable: bool) -> Self {
137 Self {
138 builder: self.builder.property("activatable", activatable),
139 }
140 }
141
142 pub fn child(self, child: &impl IsA<gtk::Widget>) -> Self {
143 Self {
144 builder: self.builder.property("child", child.clone().upcast()),
145 }
146 }
147
148 pub fn selectable(self, selectable: bool) -> Self {
149 Self {
150 builder: self.builder.property("selectable", selectable),
151 }
152 }
153
154 pub fn can_focus(self, can_focus: bool) -> Self {
155 Self {
156 builder: self.builder.property("can-focus", can_focus),
157 }
158 }
159
160 pub fn can_target(self, can_target: bool) -> Self {
161 Self {
162 builder: self.builder.property("can-target", can_target),
163 }
164 }
165
166 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
167 Self {
168 builder: self.builder.property("css-classes", css_classes.into()),
169 }
170 }
171
172 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
173 Self {
174 builder: self.builder.property("css-name", css_name.into()),
175 }
176 }
177
178 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
179 Self {
180 builder: self.builder.property("cursor", cursor.clone()),
181 }
182 }
183
184 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
185 Self {
186 builder: self.builder.property("focus-on-click", focus_on_click),
187 }
188 }
189
190 pub fn focusable(self, focusable: bool) -> Self {
191 Self {
192 builder: self.builder.property("focusable", focusable),
193 }
194 }
195
196 pub fn halign(self, halign: gtk::Align) -> Self {
197 Self {
198 builder: self.builder.property("halign", halign),
199 }
200 }
201
202 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
203 Self {
204 builder: self.builder.property("has-tooltip", has_tooltip),
205 }
206 }
207
208 pub fn height_request(self, height_request: i32) -> Self {
209 Self {
210 builder: self.builder.property("height-request", height_request),
211 }
212 }
213
214 pub fn hexpand(self, hexpand: bool) -> Self {
215 Self {
216 builder: self.builder.property("hexpand", hexpand),
217 }
218 }
219
220 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
221 Self {
222 builder: self.builder.property("hexpand-set", hexpand_set),
223 }
224 }
225
226 pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
227 Self {
228 builder: self
229 .builder
230 .property("layout-manager", layout_manager.clone().upcast()),
231 }
232 }
233
234 #[cfg(feature = "gtk_v4_18")]
235 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
236 pub fn limit_events(self, limit_events: bool) -> Self {
237 Self {
238 builder: self.builder.property("limit-events", limit_events),
239 }
240 }
241
242 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
243 Self {
244 builder: self.builder.property("margin-bottom", margin_bottom),
245 }
246 }
247
248 pub fn margin_end(self, margin_end: i32) -> Self {
249 Self {
250 builder: self.builder.property("margin-end", margin_end),
251 }
252 }
253
254 pub fn margin_start(self, margin_start: i32) -> Self {
255 Self {
256 builder: self.builder.property("margin-start", margin_start),
257 }
258 }
259
260 pub fn margin_top(self, margin_top: i32) -> Self {
261 Self {
262 builder: self.builder.property("margin-top", margin_top),
263 }
264 }
265
266 pub fn name(self, name: impl Into<glib::GString>) -> Self {
267 Self {
268 builder: self.builder.property("name", name.into()),
269 }
270 }
271
272 pub fn opacity(self, opacity: f64) -> Self {
273 Self {
274 builder: self.builder.property("opacity", opacity),
275 }
276 }
277
278 pub fn overflow(self, overflow: gtk::Overflow) -> Self {
279 Self {
280 builder: self.builder.property("overflow", overflow),
281 }
282 }
283
284 pub fn receives_default(self, receives_default: bool) -> Self {
285 Self {
286 builder: self.builder.property("receives-default", receives_default),
287 }
288 }
289
290 pub fn sensitive(self, sensitive: bool) -> Self {
291 Self {
292 builder: self.builder.property("sensitive", sensitive),
293 }
294 }
295
296 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
297 Self {
298 builder: self
299 .builder
300 .property("tooltip-markup", tooltip_markup.into()),
301 }
302 }
303
304 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
305 Self {
306 builder: self.builder.property("tooltip-text", tooltip_text.into()),
307 }
308 }
309
310 pub fn valign(self, valign: gtk::Align) -> Self {
311 Self {
312 builder: self.builder.property("valign", valign),
313 }
314 }
315
316 pub fn vexpand(self, vexpand: bool) -> Self {
317 Self {
318 builder: self.builder.property("vexpand", vexpand),
319 }
320 }
321
322 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
323 Self {
324 builder: self.builder.property("vexpand-set", vexpand_set),
325 }
326 }
327
328 pub fn visible(self, visible: bool) -> Self {
329 Self {
330 builder: self.builder.property("visible", visible),
331 }
332 }
333
334 pub fn width_request(self, width_request: i32) -> Self {
335 Self {
336 builder: self.builder.property("width-request", width_request),
337 }
338 }
339
340 pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
341 Self {
342 builder: self.builder.property("accessible-role", accessible_role),
343 }
344 }
345
346 pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
347 Self {
348 builder: self.builder.property("action-name", action_name.into()),
349 }
350 }
351
352 pub fn action_target(self, action_target: &glib::Variant) -> Self {
353 Self {
354 builder: self
355 .builder
356 .property("action-target", action_target.clone()),
357 }
358 }
359
360 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
363 pub fn build(self) -> ActionRow {
364 assert_initialized_main_thread!();
365 self.builder.build()
366 }
367}
368
369pub trait ActionRowExt: IsA<ActionRow> + 'static {
370 #[doc(alias = "adw_action_row_activate")]
371 fn activate(&self) {
372 unsafe {
373 ffi::adw_action_row_activate(self.as_ref().to_glib_none().0);
374 }
375 }
376
377 #[doc(alias = "adw_action_row_add_prefix")]
378 fn add_prefix(&self, widget: &impl IsA<gtk::Widget>) {
379 unsafe {
380 ffi::adw_action_row_add_prefix(
381 self.as_ref().to_glib_none().0,
382 widget.as_ref().to_glib_none().0,
383 );
384 }
385 }
386
387 #[doc(alias = "adw_action_row_add_suffix")]
388 fn add_suffix(&self, widget: &impl IsA<gtk::Widget>) {
389 unsafe {
390 ffi::adw_action_row_add_suffix(
391 self.as_ref().to_glib_none().0,
392 widget.as_ref().to_glib_none().0,
393 );
394 }
395 }
396
397 #[doc(alias = "adw_action_row_get_activatable_widget")]
398 #[doc(alias = "get_activatable_widget")]
399 #[doc(alias = "activatable-widget")]
400 fn activatable_widget(&self) -> Option<gtk::Widget> {
401 unsafe {
402 from_glib_none(ffi::adw_action_row_get_activatable_widget(
403 self.as_ref().to_glib_none().0,
404 ))
405 }
406 }
407
408 #[cfg_attr(feature = "v1_3", deprecated = "Since 1.3")]
409 #[allow(deprecated)]
410 #[doc(alias = "adw_action_row_get_icon_name")]
411 #[doc(alias = "get_icon_name")]
412 #[doc(alias = "icon-name")]
413 fn icon_name(&self) -> Option<glib::GString> {
414 unsafe {
415 from_glib_none(ffi::adw_action_row_get_icon_name(
416 self.as_ref().to_glib_none().0,
417 ))
418 }
419 }
420
421 #[doc(alias = "adw_action_row_get_subtitle")]
422 #[doc(alias = "get_subtitle")]
423 fn subtitle(&self) -> Option<glib::GString> {
424 unsafe {
425 from_glib_none(ffi::adw_action_row_get_subtitle(
426 self.as_ref().to_glib_none().0,
427 ))
428 }
429 }
430
431 #[doc(alias = "adw_action_row_get_subtitle_lines")]
432 #[doc(alias = "get_subtitle_lines")]
433 #[doc(alias = "subtitle-lines")]
434 fn subtitle_lines(&self) -> i32 {
435 unsafe { ffi::adw_action_row_get_subtitle_lines(self.as_ref().to_glib_none().0) }
436 }
437
438 #[cfg(feature = "v1_3")]
439 #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
440 #[doc(alias = "adw_action_row_get_subtitle_selectable")]
441 #[doc(alias = "get_subtitle_selectable")]
442 #[doc(alias = "subtitle-selectable")]
443 fn is_subtitle_selectable(&self) -> bool {
444 unsafe {
445 from_glib(ffi::adw_action_row_get_subtitle_selectable(
446 self.as_ref().to_glib_none().0,
447 ))
448 }
449 }
450
451 #[doc(alias = "adw_action_row_get_title_lines")]
452 #[doc(alias = "get_title_lines")]
453 #[doc(alias = "title-lines")]
454 fn title_lines(&self) -> i32 {
455 unsafe { ffi::adw_action_row_get_title_lines(self.as_ref().to_glib_none().0) }
456 }
457
458 #[doc(alias = "adw_action_row_remove")]
459 fn remove(&self, widget: &impl IsA<gtk::Widget>) {
460 unsafe {
461 ffi::adw_action_row_remove(
462 self.as_ref().to_glib_none().0,
463 widget.as_ref().to_glib_none().0,
464 );
465 }
466 }
467
468 #[doc(alias = "adw_action_row_set_activatable_widget")]
469 #[doc(alias = "activatable-widget")]
470 fn set_activatable_widget(&self, widget: Option<&impl IsA<gtk::Widget>>) {
471 unsafe {
472 ffi::adw_action_row_set_activatable_widget(
473 self.as_ref().to_glib_none().0,
474 widget.map(|p| p.as_ref()).to_glib_none().0,
475 );
476 }
477 }
478
479 #[cfg_attr(feature = "v1_3", deprecated = "Since 1.3")]
480 #[allow(deprecated)]
481 #[doc(alias = "adw_action_row_set_icon_name")]
482 #[doc(alias = "icon-name")]
483 fn set_icon_name(&self, icon_name: Option<&str>) {
484 unsafe {
485 ffi::adw_action_row_set_icon_name(
486 self.as_ref().to_glib_none().0,
487 icon_name.to_glib_none().0,
488 );
489 }
490 }
491
492 #[doc(alias = "adw_action_row_set_subtitle")]
493 #[doc(alias = "subtitle")]
494 fn set_subtitle(&self, subtitle: &str) {
495 unsafe {
496 ffi::adw_action_row_set_subtitle(
497 self.as_ref().to_glib_none().0,
498 subtitle.to_glib_none().0,
499 );
500 }
501 }
502
503 #[doc(alias = "adw_action_row_set_subtitle_lines")]
504 #[doc(alias = "subtitle-lines")]
505 fn set_subtitle_lines(&self, subtitle_lines: i32) {
506 unsafe {
507 ffi::adw_action_row_set_subtitle_lines(self.as_ref().to_glib_none().0, subtitle_lines);
508 }
509 }
510
511 #[cfg(feature = "v1_3")]
512 #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
513 #[doc(alias = "adw_action_row_set_subtitle_selectable")]
514 #[doc(alias = "subtitle-selectable")]
515 fn set_subtitle_selectable(&self, subtitle_selectable: bool) {
516 unsafe {
517 ffi::adw_action_row_set_subtitle_selectable(
518 self.as_ref().to_glib_none().0,
519 subtitle_selectable.into_glib(),
520 );
521 }
522 }
523
524 #[doc(alias = "adw_action_row_set_title_lines")]
525 #[doc(alias = "title-lines")]
526 fn set_title_lines(&self, title_lines: i32) {
527 unsafe {
528 ffi::adw_action_row_set_title_lines(self.as_ref().to_glib_none().0, title_lines);
529 }
530 }
531
532 #[doc(alias = "activated")]
533 fn connect_activated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
534 unsafe extern "C" fn activated_trampoline<P: IsA<ActionRow>, F: Fn(&P) + 'static>(
535 this: *mut ffi::AdwActionRow,
536 f: glib::ffi::gpointer,
537 ) {
538 let f: &F = &*(f as *const F);
539 f(ActionRow::from_glib_borrow(this).unsafe_cast_ref())
540 }
541 unsafe {
542 let f: Box_<F> = Box_::new(f);
543 connect_raw(
544 self.as_ptr() as *mut _,
545 c"activated".as_ptr() as *const _,
546 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
547 activated_trampoline::<Self, F> as *const (),
548 )),
549 Box_::into_raw(f),
550 )
551 }
552 }
553
554 #[doc(alias = "activatable-widget")]
555 fn connect_activatable_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
556 unsafe extern "C" fn notify_activatable_widget_trampoline<
557 P: IsA<ActionRow>,
558 F: Fn(&P) + 'static,
559 >(
560 this: *mut ffi::AdwActionRow,
561 _param_spec: glib::ffi::gpointer,
562 f: glib::ffi::gpointer,
563 ) {
564 let f: &F = &*(f as *const F);
565 f(ActionRow::from_glib_borrow(this).unsafe_cast_ref())
566 }
567 unsafe {
568 let f: Box_<F> = Box_::new(f);
569 connect_raw(
570 self.as_ptr() as *mut _,
571 c"notify::activatable-widget".as_ptr() as *const _,
572 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
573 notify_activatable_widget_trampoline::<Self, F> as *const (),
574 )),
575 Box_::into_raw(f),
576 )
577 }
578 }
579
580 #[cfg_attr(feature = "v1_3", deprecated = "Since 1.3")]
581 #[doc(alias = "icon-name")]
582 fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
583 unsafe extern "C" fn notify_icon_name_trampoline<P: IsA<ActionRow>, F: Fn(&P) + 'static>(
584 this: *mut ffi::AdwActionRow,
585 _param_spec: glib::ffi::gpointer,
586 f: glib::ffi::gpointer,
587 ) {
588 let f: &F = &*(f as *const F);
589 f(ActionRow::from_glib_borrow(this).unsafe_cast_ref())
590 }
591 unsafe {
592 let f: Box_<F> = Box_::new(f);
593 connect_raw(
594 self.as_ptr() as *mut _,
595 c"notify::icon-name".as_ptr() as *const _,
596 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
597 notify_icon_name_trampoline::<Self, F> as *const (),
598 )),
599 Box_::into_raw(f),
600 )
601 }
602 }
603
604 #[doc(alias = "subtitle")]
605 fn connect_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
606 unsafe extern "C" fn notify_subtitle_trampoline<P: IsA<ActionRow>, F: Fn(&P) + 'static>(
607 this: *mut ffi::AdwActionRow,
608 _param_spec: glib::ffi::gpointer,
609 f: glib::ffi::gpointer,
610 ) {
611 let f: &F = &*(f as *const F);
612 f(ActionRow::from_glib_borrow(this).unsafe_cast_ref())
613 }
614 unsafe {
615 let f: Box_<F> = Box_::new(f);
616 connect_raw(
617 self.as_ptr() as *mut _,
618 c"notify::subtitle".as_ptr() as *const _,
619 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
620 notify_subtitle_trampoline::<Self, F> as *const (),
621 )),
622 Box_::into_raw(f),
623 )
624 }
625 }
626
627 #[doc(alias = "subtitle-lines")]
628 fn connect_subtitle_lines_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
629 unsafe extern "C" fn notify_subtitle_lines_trampoline<
630 P: IsA<ActionRow>,
631 F: Fn(&P) + 'static,
632 >(
633 this: *mut ffi::AdwActionRow,
634 _param_spec: glib::ffi::gpointer,
635 f: glib::ffi::gpointer,
636 ) {
637 let f: &F = &*(f as *const F);
638 f(ActionRow::from_glib_borrow(this).unsafe_cast_ref())
639 }
640 unsafe {
641 let f: Box_<F> = Box_::new(f);
642 connect_raw(
643 self.as_ptr() as *mut _,
644 c"notify::subtitle-lines".as_ptr() as *const _,
645 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
646 notify_subtitle_lines_trampoline::<Self, F> as *const (),
647 )),
648 Box_::into_raw(f),
649 )
650 }
651 }
652
653 #[cfg(feature = "v1_3")]
654 #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
655 #[doc(alias = "subtitle-selectable")]
656 fn connect_subtitle_selectable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
657 unsafe extern "C" fn notify_subtitle_selectable_trampoline<
658 P: IsA<ActionRow>,
659 F: Fn(&P) + 'static,
660 >(
661 this: *mut ffi::AdwActionRow,
662 _param_spec: glib::ffi::gpointer,
663 f: glib::ffi::gpointer,
664 ) {
665 let f: &F = &*(f as *const F);
666 f(ActionRow::from_glib_borrow(this).unsafe_cast_ref())
667 }
668 unsafe {
669 let f: Box_<F> = Box_::new(f);
670 connect_raw(
671 self.as_ptr() as *mut _,
672 c"notify::subtitle-selectable".as_ptr() as *const _,
673 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
674 notify_subtitle_selectable_trampoline::<Self, F> as *const (),
675 )),
676 Box_::into_raw(f),
677 )
678 }
679 }
680
681 #[doc(alias = "title-lines")]
682 fn connect_title_lines_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
683 unsafe extern "C" fn notify_title_lines_trampoline<
684 P: IsA<ActionRow>,
685 F: Fn(&P) + 'static,
686 >(
687 this: *mut ffi::AdwActionRow,
688 _param_spec: glib::ffi::gpointer,
689 f: glib::ffi::gpointer,
690 ) {
691 let f: &F = &*(f as *const F);
692 f(ActionRow::from_glib_borrow(this).unsafe_cast_ref())
693 }
694 unsafe {
695 let f: Box_<F> = Box_::new(f);
696 connect_raw(
697 self.as_ptr() as *mut _,
698 c"notify::title-lines".as_ptr() as *const _,
699 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
700 notify_title_lines_trampoline::<Self, F> as *const (),
701 )),
702 Box_::into_raw(f),
703 )
704 }
705 }
706}
707
708impl<O: IsA<ActionRow>> ActionRowExt for O {}