gtk4/auto/
accessible_hyperlink.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::{
6    Accessible, AccessibleHypertext, AccessiblePlatformState, AccessibleRole, AccessibleTextRange,
7    ffi,
8};
9use glib::{prelude::*, translate::*};
10
11glib::wrapper! {
12    /// Represents a link (i.e. a uri).
13    ///
14    /// A widget that contains one or more links should implement
15    /// the [`AccessibleHypertext`][crate::AccessibleHypertext] interface and return
16    /// `GtkAccessibleHyperlink] objects for each of the links.
17    ///
18    /// # Implements
19    ///
20    /// [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
21    #[doc(alias = "GtkAccessibleHyperlink")]
22    pub struct AccessibleHyperlink(Object<ffi::GtkAccessibleHyperlink, ffi::GtkAccessibleHyperlinkClass>) @implements Accessible;
23
24    match fn {
25        type_ => || ffi::gtk_accessible_hyperlink_get_type(),
26    }
27}
28
29impl AccessibleHyperlink {
30    /// Creates an accessible object that represents a hyperlink.
31    ///
32    /// This is meant to be used with an implementation of the
33    /// [`AccessibleHypertext`][crate::AccessibleHypertext] interface.
34    /// ## `parent`
35    /// the parent
36    /// ## `index`
37    /// the index of this link in the parent
38    /// ## `uri`
39    /// the uri
40    /// ## `bounds`
41    /// the text range that the link occupies (or 0, 0)
42    #[doc(alias = "gtk_accessible_hyperlink_new")]
43    pub fn new(
44        parent: &impl IsA<AccessibleHypertext>,
45        index: u32,
46        uri: &str,
47        bounds: &mut AccessibleTextRange,
48    ) -> AccessibleHyperlink {
49        skip_assert_initialized!();
50        unsafe {
51            from_glib_full(ffi::gtk_accessible_hyperlink_new(
52                parent.as_ref().to_glib_none().0,
53                index,
54                uri.to_glib_none().0,
55                bounds.to_glib_none_mut().0,
56            ))
57        }
58    }
59
60    // rustdoc-stripper-ignore-next
61    /// Creates a new builder-pattern struct instance to construct [`AccessibleHyperlink`] objects.
62    ///
63    /// This method returns an instance of [`AccessibleHyperlinkBuilder`](crate::builders::AccessibleHyperlinkBuilder) which can be used to create [`AccessibleHyperlink`] objects.
64    pub fn builder() -> AccessibleHyperlinkBuilder {
65        AccessibleHyperlinkBuilder::new()
66    }
67
68    /// Sets a platform state on the accessible.
69    /// ## `state`
70    /// the platform state to change
71    /// ## `enabled`
72    /// the new value for the platform state
73    #[doc(alias = "gtk_accessible_hyperlink_set_platform_state")]
74    pub fn set_platform_state(&self, state: AccessiblePlatformState, enabled: bool) {
75        unsafe {
76            ffi::gtk_accessible_hyperlink_set_platform_state(
77                self.to_glib_none().0,
78                state.into_glib(),
79                enabled.into_glib(),
80            );
81        }
82    }
83}
84
85#[cfg(feature = "v4_22")]
86#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
87impl Default for AccessibleHyperlink {
88    fn default() -> Self {
89        glib::object::Object::new::<Self>()
90    }
91}
92
93// rustdoc-stripper-ignore-next
94/// A [builder-pattern] type to construct [`AccessibleHyperlink`] objects.
95///
96/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
97#[must_use = "The builder must be built to be used"]
98pub struct AccessibleHyperlinkBuilder {
99    builder: glib::object::ObjectBuilder<'static, AccessibleHyperlink>,
100}
101
102impl AccessibleHyperlinkBuilder {
103    fn new() -> Self {
104        Self {
105            builder: glib::object::Object::builder(),
106        }
107    }
108
109    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
110    ///
111    /// The accessible role cannot be changed once set.
112    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
113        Self {
114            builder: self.builder.property("accessible-role", accessible_role),
115        }
116    }
117
118    // rustdoc-stripper-ignore-next
119    /// Build the [`AccessibleHyperlink`].
120    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
121    pub fn build(self) -> AccessibleHyperlink {
122        assert_initialized_main_thread!();
123        self.builder.build()
124    }
125}