Skip to main content

libadwaita/auto/
toggle.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::{
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// A toggle within [`ToggleGroup`][crate::ToggleGroup].
16    ///
17    /// [`Toggle`][crate::Toggle] can optionally have a name, set with [`name`][struct@crate::Toggle#name].
18    /// If the name is set, [`active-name`][struct@crate::ToggleGroup#active-name] can be used to access
19    /// toggles instead of index.
20    ///
21    /// ## Properties
22    ///
23    ///
24    /// #### `child`
25    ///  The toggle child.
26    ///
27    /// When the child is set, icon and label are not displayed.
28    ///
29    /// It's recommended to still set the label, as it can still be used by the
30    /// screen reader.
31    ///
32    /// Readable | Writeable
33    ///
34    ///
35    /// #### `description`
36    ///  The description of the toggle.
37    ///
38    /// The description will be read out when using screen reader. If not set,
39    /// [`tooltip`][struct@crate::Toggle#tooltip] will be used instead.
40    ///
41    /// See [enum@Gtk.AccessibleProperty.description].
42    ///
43    /// Readable | Writeable
44    ///
45    ///
46    /// #### `enabled`
47    ///  Whether this toggle is enabled.
48    ///
49    /// Readable | Writeable
50    ///
51    ///
52    /// #### `icon-name`
53    ///  The toggle icon name.
54    ///
55    /// The icon will be displayed alone or next to the label, unless
56    /// [`child`][struct@crate::Toggle#child] is set.
57    ///
58    /// Readable | Writeable
59    ///
60    ///
61    /// #### `label`
62    ///  The toggle label.
63    ///
64    /// The label will be displayed alone or next to the icon, unless
65    /// [`child`][struct@crate::Toggle#child] is set, but will still be read out by the screen
66    /// reader.
67    ///
68    /// Readable | Writeable
69    ///
70    ///
71    /// #### `name`
72    ///  The toggle name.
73    ///
74    /// Allows accessing the toggle by its name instead of index.
75    ///
76    /// See [`active-name`][struct@crate::ToggleGroup#active-name].
77    ///
78    /// Readable | Writeable
79    ///
80    ///
81    /// #### `tooltip`
82    ///  The tooltip of the toggle.
83    ///
84    /// The tooltip can be marked up with the Pango text markup language.
85    ///
86    /// Tooltip text will also be used as accessible description. Use
87    /// [`description`][struct@crate::Toggle#description] to set it separately.
88    ///
89    /// Readable | Writeable
90    ///
91    ///
92    /// #### `use-underline`
93    ///  Whether an embedded underline in the label indicates a mnemonic.
94    ///
95    /// See [`label`][struct@crate::Toggle#label].
96    ///
97    /// Readable | Writeable
98    ///
99    /// # Implements
100    ///
101    /// [`trait@glib::ObjectExt`]
102    #[doc(alias = "AdwToggle")]
103    pub struct Toggle(Object<ffi::AdwToggle, ffi::AdwToggleClass>);
104
105    match fn {
106        type_ => || ffi::adw_toggle_get_type(),
107    }
108}
109
110impl Toggle {
111    /// Creates a new [`Toggle`][crate::Toggle].
112    ///
113    /// # Returns
114    ///
115    /// the newly created [`Toggle`][crate::Toggle]
116    #[doc(alias = "adw_toggle_new")]
117    pub fn new() -> Toggle {
118        assert_initialized_main_thread!();
119        unsafe { from_glib_full(ffi::adw_toggle_new()) }
120    }
121
122    // rustdoc-stripper-ignore-next
123    /// Creates a new builder-pattern struct instance to construct [`Toggle`] objects.
124    ///
125    /// This method returns an instance of [`ToggleBuilder`](crate::builders::ToggleBuilder) which can be used to create [`Toggle`] objects.
126    pub fn builder() -> ToggleBuilder {
127        ToggleBuilder::new()
128    }
129
130    /// Gets the child widget of @self.
131    ///
132    /// # Returns
133    ///
134    /// the toggle child
135    #[doc(alias = "adw_toggle_get_child")]
136    #[doc(alias = "get_child")]
137    pub fn child(&self) -> Option<gtk::Widget> {
138        unsafe { from_glib_none(ffi::adw_toggle_get_child(self.to_glib_none().0)) }
139    }
140
141    /// Gets the description of @self.
142    ///
143    /// # Returns
144    ///
145    /// the toggle description
146    #[cfg(feature = "v1_9")]
147    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
148    #[doc(alias = "adw_toggle_get_description")]
149    #[doc(alias = "get_description")]
150    pub fn description(&self) -> glib::GString {
151        unsafe { from_glib_none(ffi::adw_toggle_get_description(self.to_glib_none().0)) }
152    }
153
154    /// Gets whether @self is enabled.
155    ///
156    /// # Returns
157    ///
158    /// whether the toggle is enabled
159    #[doc(alias = "adw_toggle_get_enabled")]
160    #[doc(alias = "get_enabled")]
161    #[doc(alias = "enabled")]
162    pub fn is_enabled(&self) -> bool {
163        unsafe { from_glib(ffi::adw_toggle_get_enabled(self.to_glib_none().0)) }
164    }
165
166    /// Gets the icon name of @self.
167    ///
168    /// # Returns
169    ///
170    /// the toggle icon name
171    #[doc(alias = "adw_toggle_get_icon_name")]
172    #[doc(alias = "get_icon_name")]
173    #[doc(alias = "icon-name")]
174    pub fn icon_name(&self) -> Option<glib::GString> {
175        unsafe { from_glib_none(ffi::adw_toggle_get_icon_name(self.to_glib_none().0)) }
176    }
177
178    /// Gets the index of @self within its toggle group.
179    ///
180    /// # Returns
181    ///
182    /// the index, or `Gtk::INVALID_LIST_POSITION` if it's not in a group
183    #[doc(alias = "adw_toggle_get_index")]
184    #[doc(alias = "get_index")]
185    pub fn index(&self) -> u32 {
186        unsafe { ffi::adw_toggle_get_index(self.to_glib_none().0) }
187    }
188
189    /// Gets the label of @self.
190    ///
191    /// # Returns
192    ///
193    /// the toggle label
194    #[doc(alias = "adw_toggle_get_label")]
195    #[doc(alias = "get_label")]
196    pub fn label(&self) -> Option<glib::GString> {
197        unsafe { from_glib_none(ffi::adw_toggle_get_label(self.to_glib_none().0)) }
198    }
199
200    /// Gets the name of @self.
201    ///
202    /// # Returns
203    ///
204    /// the toggle name
205    #[doc(alias = "adw_toggle_get_name")]
206    #[doc(alias = "get_name")]
207    pub fn name(&self) -> glib::GString {
208        unsafe { from_glib_none(ffi::adw_toggle_get_name(self.to_glib_none().0)) }
209    }
210
211    /// Gets the tooltip of @self.
212    ///
213    /// # Returns
214    ///
215    /// the toggle tooltip
216    #[doc(alias = "adw_toggle_get_tooltip")]
217    #[doc(alias = "get_tooltip")]
218    pub fn tooltip(&self) -> glib::GString {
219        unsafe { from_glib_none(ffi::adw_toggle_get_tooltip(self.to_glib_none().0)) }
220    }
221
222    /// Gets whether @self uses underlines.
223    ///
224    /// # Returns
225    ///
226    /// whether the toggle uses underlines
227    #[doc(alias = "adw_toggle_get_use_underline")]
228    #[doc(alias = "get_use_underline")]
229    #[doc(alias = "use-underline")]
230    pub fn uses_underline(&self) -> bool {
231        unsafe { from_glib(ffi::adw_toggle_get_use_underline(self.to_glib_none().0)) }
232    }
233
234    /// Sets the child of @self to @child.
235    ///
236    /// When the child is set, icon and label are not displayed.
237    ///
238    /// It's recommended to still set the label, as it can still be used by the
239    /// screen reader.
240    /// ## `child`
241    /// a child widget
242    #[doc(alias = "adw_toggle_set_child")]
243    #[doc(alias = "child")]
244    pub fn set_child(&self, child: Option<&impl IsA<gtk::Widget>>) {
245        unsafe {
246            ffi::adw_toggle_set_child(
247                self.to_glib_none().0,
248                child.map(|p| p.as_ref()).to_glib_none().0,
249            );
250        }
251    }
252
253    /// Sets the description of @self to @description.
254    ///
255    /// The description will be read out when using screen reader. If not set,
256    /// [`tooltip`][struct@crate::Toggle#tooltip] will be used instead.
257    ///
258    /// See [enum@Gtk.AccessibleProperty.description].
259    /// ## `description`
260    /// the description
261    #[cfg(feature = "v1_9")]
262    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
263    #[doc(alias = "adw_toggle_set_description")]
264    #[doc(alias = "description")]
265    pub fn set_description(&self, description: &str) {
266        unsafe {
267            ffi::adw_toggle_set_description(self.to_glib_none().0, description.to_glib_none().0);
268        }
269    }
270
271    /// Sets whether @self is enabled.
272    /// ## `enabled`
273    /// whether the toggle should be enbled
274    #[doc(alias = "adw_toggle_set_enabled")]
275    #[doc(alias = "enabled")]
276    pub fn set_enabled(&self, enabled: bool) {
277        unsafe {
278            ffi::adw_toggle_set_enabled(self.to_glib_none().0, enabled.into_glib());
279        }
280    }
281
282    /// Sets the icon name of @self to @icon_name.
283    ///
284    /// The icon will be displayed alone or next to the label, unless
285    /// [`child`][struct@crate::Toggle#child] is set.
286    /// ## `icon_name`
287    /// the icon name
288    #[doc(alias = "adw_toggle_set_icon_name")]
289    #[doc(alias = "icon-name")]
290    pub fn set_icon_name(&self, icon_name: Option<&str>) {
291        unsafe {
292            ffi::adw_toggle_set_icon_name(self.to_glib_none().0, icon_name.to_glib_none().0);
293        }
294    }
295
296    /// Sets the label of @self to @label.
297    ///
298    /// The label will be displayed alone or next to the icon, unless
299    /// [`child`][struct@crate::Toggle#child] is set, but will still be read out by the screen
300    /// reader.
301    /// ## `label`
302    /// a label
303    #[doc(alias = "adw_toggle_set_label")]
304    #[doc(alias = "label")]
305    pub fn set_label(&self, label: Option<&str>) {
306        unsafe {
307            ffi::adw_toggle_set_label(self.to_glib_none().0, label.to_glib_none().0);
308        }
309    }
310
311    /// Sets the name of @self to @name.
312    ///
313    /// Allows accessing @self by its name instead of index.
314    ///
315    /// See [`active-name`][struct@crate::ToggleGroup#active-name].
316    /// ## `name`
317    /// a name
318    #[doc(alias = "adw_toggle_set_name")]
319    #[doc(alias = "name")]
320    pub fn set_name(&self, name: Option<&str>) {
321        unsafe {
322            ffi::adw_toggle_set_name(self.to_glib_none().0, name.to_glib_none().0);
323        }
324    }
325
326    /// Sets the tooltip of @self to @tooltip.
327    ///
328    /// @tooltip can be marked up with the Pango text markup language.
329    ///
330    /// Tooltip text will also be used as accessible description. Use
331    /// [`description`][struct@crate::Toggle#description] to set it separately.
332    /// ## `tooltip`
333    /// the tooltip
334    #[doc(alias = "adw_toggle_set_tooltip")]
335    #[doc(alias = "tooltip")]
336    pub fn set_tooltip(&self, tooltip: &str) {
337        unsafe {
338            ffi::adw_toggle_set_tooltip(self.to_glib_none().0, tooltip.to_glib_none().0);
339        }
340    }
341
342    /// Sets whether an embedded underline in the label indicates a mnemonic.
343    ///
344    /// See [`label`][struct@crate::Toggle#label].
345    /// ## `use_underline`
346    /// whether an underline in the label indicates a mnemonic
347    #[doc(alias = "adw_toggle_set_use_underline")]
348    #[doc(alias = "use-underline")]
349    pub fn set_use_underline(&self, use_underline: bool) {
350        unsafe {
351            ffi::adw_toggle_set_use_underline(self.to_glib_none().0, use_underline.into_glib());
352        }
353    }
354
355    #[cfg(feature = "v1_7")]
356    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
357    #[doc(alias = "child")]
358    pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
359        unsafe extern "C" fn notify_child_trampoline<F: Fn(&Toggle) + 'static>(
360            this: *mut ffi::AdwToggle,
361            _param_spec: glib::ffi::gpointer,
362            f: glib::ffi::gpointer,
363        ) {
364            unsafe {
365                let f: &F = &*(f as *const F);
366                f(&from_glib_borrow(this))
367            }
368        }
369        unsafe {
370            let f: Box_<F> = Box_::new(f);
371            connect_raw(
372                self.as_ptr() as *mut _,
373                c"notify::child".as_ptr(),
374                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
375                    notify_child_trampoline::<F> as *const (),
376                )),
377                Box_::into_raw(f),
378            )
379        }
380    }
381
382    #[cfg(feature = "v1_9")]
383    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
384    #[doc(alias = "description")]
385    pub fn connect_description_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
386        unsafe extern "C" fn notify_description_trampoline<F: Fn(&Toggle) + 'static>(
387            this: *mut ffi::AdwToggle,
388            _param_spec: glib::ffi::gpointer,
389            f: glib::ffi::gpointer,
390        ) {
391            unsafe {
392                let f: &F = &*(f as *const F);
393                f(&from_glib_borrow(this))
394            }
395        }
396        unsafe {
397            let f: Box_<F> = Box_::new(f);
398            connect_raw(
399                self.as_ptr() as *mut _,
400                c"notify::description".as_ptr(),
401                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
402                    notify_description_trampoline::<F> as *const (),
403                )),
404                Box_::into_raw(f),
405            )
406        }
407    }
408
409    #[cfg(feature = "v1_7")]
410    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
411    #[doc(alias = "enabled")]
412    pub fn connect_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
413        unsafe extern "C" fn notify_enabled_trampoline<F: Fn(&Toggle) + 'static>(
414            this: *mut ffi::AdwToggle,
415            _param_spec: glib::ffi::gpointer,
416            f: glib::ffi::gpointer,
417        ) {
418            unsafe {
419                let f: &F = &*(f as *const F);
420                f(&from_glib_borrow(this))
421            }
422        }
423        unsafe {
424            let f: Box_<F> = Box_::new(f);
425            connect_raw(
426                self.as_ptr() as *mut _,
427                c"notify::enabled".as_ptr(),
428                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
429                    notify_enabled_trampoline::<F> as *const (),
430                )),
431                Box_::into_raw(f),
432            )
433        }
434    }
435
436    #[cfg(feature = "v1_7")]
437    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
438    #[doc(alias = "icon-name")]
439    pub fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
440        unsafe extern "C" fn notify_icon_name_trampoline<F: Fn(&Toggle) + 'static>(
441            this: *mut ffi::AdwToggle,
442            _param_spec: glib::ffi::gpointer,
443            f: glib::ffi::gpointer,
444        ) {
445            unsafe {
446                let f: &F = &*(f as *const F);
447                f(&from_glib_borrow(this))
448            }
449        }
450        unsafe {
451            let f: Box_<F> = Box_::new(f);
452            connect_raw(
453                self.as_ptr() as *mut _,
454                c"notify::icon-name".as_ptr(),
455                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
456                    notify_icon_name_trampoline::<F> as *const (),
457                )),
458                Box_::into_raw(f),
459            )
460        }
461    }
462
463    #[cfg(feature = "v1_7")]
464    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
465    #[doc(alias = "label")]
466    pub fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
467        unsafe extern "C" fn notify_label_trampoline<F: Fn(&Toggle) + 'static>(
468            this: *mut ffi::AdwToggle,
469            _param_spec: glib::ffi::gpointer,
470            f: glib::ffi::gpointer,
471        ) {
472            unsafe {
473                let f: &F = &*(f as *const F);
474                f(&from_glib_borrow(this))
475            }
476        }
477        unsafe {
478            let f: Box_<F> = Box_::new(f);
479            connect_raw(
480                self.as_ptr() as *mut _,
481                c"notify::label".as_ptr(),
482                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
483                    notify_label_trampoline::<F> as *const (),
484                )),
485                Box_::into_raw(f),
486            )
487        }
488    }
489
490    #[cfg(feature = "v1_7")]
491    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
492    #[doc(alias = "name")]
493    pub fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
494        unsafe extern "C" fn notify_name_trampoline<F: Fn(&Toggle) + 'static>(
495            this: *mut ffi::AdwToggle,
496            _param_spec: glib::ffi::gpointer,
497            f: glib::ffi::gpointer,
498        ) {
499            unsafe {
500                let f: &F = &*(f as *const F);
501                f(&from_glib_borrow(this))
502            }
503        }
504        unsafe {
505            let f: Box_<F> = Box_::new(f);
506            connect_raw(
507                self.as_ptr() as *mut _,
508                c"notify::name".as_ptr(),
509                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
510                    notify_name_trampoline::<F> as *const (),
511                )),
512                Box_::into_raw(f),
513            )
514        }
515    }
516
517    #[cfg(feature = "v1_7")]
518    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
519    #[doc(alias = "tooltip")]
520    pub fn connect_tooltip_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
521        unsafe extern "C" fn notify_tooltip_trampoline<F: Fn(&Toggle) + 'static>(
522            this: *mut ffi::AdwToggle,
523            _param_spec: glib::ffi::gpointer,
524            f: glib::ffi::gpointer,
525        ) {
526            unsafe {
527                let f: &F = &*(f as *const F);
528                f(&from_glib_borrow(this))
529            }
530        }
531        unsafe {
532            let f: Box_<F> = Box_::new(f);
533            connect_raw(
534                self.as_ptr() as *mut _,
535                c"notify::tooltip".as_ptr(),
536                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
537                    notify_tooltip_trampoline::<F> as *const (),
538                )),
539                Box_::into_raw(f),
540            )
541        }
542    }
543
544    #[cfg(feature = "v1_7")]
545    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
546    #[doc(alias = "use-underline")]
547    pub fn connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
548        unsafe extern "C" fn notify_use_underline_trampoline<F: Fn(&Toggle) + 'static>(
549            this: *mut ffi::AdwToggle,
550            _param_spec: glib::ffi::gpointer,
551            f: glib::ffi::gpointer,
552        ) {
553            unsafe {
554                let f: &F = &*(f as *const F);
555                f(&from_glib_borrow(this))
556            }
557        }
558        unsafe {
559            let f: Box_<F> = Box_::new(f);
560            connect_raw(
561                self.as_ptr() as *mut _,
562                c"notify::use-underline".as_ptr(),
563                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
564                    notify_use_underline_trampoline::<F> as *const (),
565                )),
566                Box_::into_raw(f),
567            )
568        }
569    }
570}
571
572#[cfg(feature = "v1_7")]
573#[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
574impl Default for Toggle {
575    fn default() -> Self {
576        Self::new()
577    }
578}
579
580impl std::fmt::Display for Toggle {
581    #[inline]
582    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
583        f.write_str(&self.name())
584    }
585}
586
587// rustdoc-stripper-ignore-next
588/// A [builder-pattern] type to construct [`Toggle`] objects.
589///
590/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
591#[must_use = "The builder must be built to be used"]
592pub struct ToggleBuilder {
593    builder: glib::object::ObjectBuilder<'static, Toggle>,
594}
595
596impl ToggleBuilder {
597    fn new() -> Self {
598        Self {
599            builder: glib::object::Object::builder(),
600        }
601    }
602
603    /// The toggle child.
604    ///
605    /// When the child is set, icon and label are not displayed.
606    ///
607    /// It's recommended to still set the label, as it can still be used by the
608    /// screen reader.
609    #[cfg(feature = "v1_7")]
610    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
611    pub fn child(self, child: &impl IsA<gtk::Widget>) -> Self {
612        Self {
613            builder: self.builder.property("child", child.clone().upcast()),
614        }
615    }
616
617    /// The description of the toggle.
618    ///
619    /// The description will be read out when using screen reader. If not set,
620    /// [`tooltip`][struct@crate::Toggle#tooltip] will be used instead.
621    ///
622    /// See [enum@Gtk.AccessibleProperty.description].
623    #[cfg(feature = "v1_9")]
624    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
625    pub fn description(self, description: impl Into<glib::GString>) -> Self {
626        Self {
627            builder: self.builder.property("description", description.into()),
628        }
629    }
630
631    /// Whether this toggle is enabled.
632    #[cfg(feature = "v1_7")]
633    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
634    pub fn enabled(self, enabled: bool) -> Self {
635        Self {
636            builder: self.builder.property("enabled", enabled),
637        }
638    }
639
640    /// The toggle icon name.
641    ///
642    /// The icon will be displayed alone or next to the label, unless
643    /// [`child`][struct@crate::Toggle#child] is set.
644    #[cfg(feature = "v1_7")]
645    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
646    pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
647        Self {
648            builder: self.builder.property("icon-name", icon_name.into()),
649        }
650    }
651
652    /// The toggle label.
653    ///
654    /// The label will be displayed alone or next to the icon, unless
655    /// [`child`][struct@crate::Toggle#child] is set, but will still be read out by the screen
656    /// reader.
657    #[cfg(feature = "v1_7")]
658    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
659    pub fn label(self, label: impl Into<glib::GString>) -> Self {
660        Self {
661            builder: self.builder.property("label", label.into()),
662        }
663    }
664
665    /// The toggle name.
666    ///
667    /// Allows accessing the toggle by its name instead of index.
668    ///
669    /// See [`active-name`][struct@crate::ToggleGroup#active-name].
670    #[cfg(feature = "v1_7")]
671    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
672    pub fn name(self, name: impl Into<glib::GString>) -> Self {
673        Self {
674            builder: self.builder.property("name", name.into()),
675        }
676    }
677
678    /// The tooltip of the toggle.
679    ///
680    /// The tooltip can be marked up with the Pango text markup language.
681    ///
682    /// Tooltip text will also be used as accessible description. Use
683    /// [`description`][struct@crate::Toggle#description] to set it separately.
684    #[cfg(feature = "v1_7")]
685    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
686    pub fn tooltip(self, tooltip: impl Into<glib::GString>) -> Self {
687        Self {
688            builder: self.builder.property("tooltip", tooltip.into()),
689        }
690    }
691
692    /// Whether an embedded underline in the label indicates a mnemonic.
693    ///
694    /// See [`label`][struct@crate::Toggle#label].
695    #[cfg(feature = "v1_7")]
696    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
697    pub fn use_underline(self, use_underline: bool) -> Self {
698        Self {
699            builder: self.builder.property("use-underline", use_underline),
700        }
701    }
702
703    // rustdoc-stripper-ignore-next
704    /// Build the [`Toggle`].
705    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
706    pub fn build(self) -> Toggle {
707        assert_initialized_main_thread!();
708        self.builder.build()
709    }
710}