Skip to main content

gdk4_x11/auto/
x11_device_xi2.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::ffi;
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    ///
10    ///
11    /// ## Properties
12    ///
13    ///
14    /// #### `device-id`
15    ///  Readable | Writeable | Construct Only
16    /// <details><summary><h4>Device</h4></summary>
17    ///
18    ///
19    /// #### `active-layout-index`
20    ///  The index of the keyboard active layout of a [`gdk::Device`][crate::gdk::Device].
21    ///
22    /// Will be -1 if there is no valid active layout.
23    ///
24    /// This is only relevant for keyboard devices.
25    ///
26    /// Value changes from compositor events, connect to notify if needed.
27    ///
28    /// Readable
29    ///
30    ///
31    /// #### `caps-lock-state`
32    ///  Whether Caps Lock is on.
33    ///
34    /// This is only relevant for keyboard devices.
35    ///
36    /// Readable
37    ///
38    ///
39    /// #### `direction`
40    ///  The direction of the current layout.
41    ///
42    /// This is only relevant for keyboard devices.
43    ///
44    /// Readable
45    ///
46    ///
47    /// #### `display`
48    ///  The [`gdk::Display`][crate::gdk::Display] the [`gdk::Device`][crate::gdk::Device] pertains to.
49    ///
50    /// Readable | Writeable | Construct Only
51    ///
52    ///
53    /// #### `has-bidi-layouts`
54    ///  Whether the device has both right-to-left and left-to-right layouts.
55    ///
56    /// This is only relevant for keyboard devices.
57    ///
58    /// Readable
59    ///
60    ///
61    /// #### `has-cursor`
62    ///  Whether the device is represented by a cursor on the screen.
63    ///
64    /// Readable | Writeable | Construct Only
65    ///
66    ///
67    /// #### `layout-names`
68    ///  The names of the keyboard layouts of a [`gdk::Device`][crate::gdk::Device].
69    ///
70    /// This is only relevant for keyboard devices.
71    ///
72    /// Value changes from compositor events, connect to notify if needed.
73    ///
74    /// Readable
75    ///
76    ///
77    /// #### `modifier-state`
78    ///  The current modifier state of the device.
79    ///
80    /// This is only relevant for keyboard devices.
81    ///
82    /// Readable
83    ///
84    ///
85    /// #### `n-axes`
86    ///  Number of axes in the device.
87    ///
88    /// Readable
89    ///
90    ///
91    /// #### `name`
92    ///  The device name.
93    ///
94    /// Readable | Writeable | Construct Only
95    ///
96    ///
97    /// #### `num-lock-state`
98    ///  Whether Num Lock is on.
99    ///
100    /// This is only relevant for keyboard devices.
101    ///
102    /// Readable
103    ///
104    ///
105    /// #### `num-touches`
106    ///  The maximal number of concurrent touches on a touch device.
107    ///
108    /// Will be 0 if the device is not a touch device or if the number
109    /// of touches is unknown.
110    ///
111    /// Readable | Writeable | Construct Only
112    ///
113    ///
114    /// #### `product-id`
115    ///  Product ID of this device.
116    ///
117    /// See `Gdk::Device::get_product_id()`.
118    ///
119    /// Readable | Writeable | Construct Only
120    ///
121    ///
122    /// #### `scroll-lock-state`
123    ///  Whether Scroll Lock is on.
124    ///
125    /// This is only relevant for keyboard devices.
126    ///
127    /// Readable
128    ///
129    ///
130    /// #### `seat`
131    ///  [`gdk::Seat`][crate::gdk::Seat] of this device.
132    ///
133    /// Readable | Writeable
134    ///
135    ///
136    /// #### `source`
137    ///  Source type for the device.
138    ///
139    /// Readable | Writeable | Construct Only
140    ///
141    ///
142    /// #### `tool`
143    ///  The [`gdk::DeviceTool`][crate::gdk::DeviceTool] that is currently used with this device.
144    ///
145    /// Readable
146    ///
147    ///
148    /// #### `vendor-id`
149    ///  Vendor ID of this device.
150    ///
151    /// See `Gdk::Device::get_vendor_id()`.
152    ///
153    /// Readable | Writeable | Construct Only
154    /// </details>
155    ///
156    /// # Implements
157    ///
158    /// [`trait@gdk::prelude::DeviceExt`]
159    #[doc(alias = "GdkX11DeviceXI2")]
160    pub struct X11DeviceXI2(Object<ffi::GdkX11DeviceXI2, ffi::GdkX11DeviceXI2Class>) @extends gdk::Device;
161
162    match fn {
163        type_ => || ffi::gdk_x11_device_xi2_get_type(),
164    }
165}
166
167impl X11DeviceXI2 {
168    // rustdoc-stripper-ignore-next
169    /// Creates a new builder-pattern struct instance to construct [`X11DeviceXI2`] objects.
170    ///
171    /// This method returns an instance of [`X11DeviceXI2Builder`](crate::builders::X11DeviceXI2Builder) which can be used to create [`X11DeviceXI2`] objects.
172    pub fn builder() -> X11DeviceXI2Builder {
173        X11DeviceXI2Builder::new()
174    }
175
176    #[doc(alias = "device-id")]
177    pub fn device_id(&self) -> i32 {
178        ObjectExt::property(self, "device-id")
179    }
180}
181
182// rustdoc-stripper-ignore-next
183/// A [builder-pattern] type to construct [`X11DeviceXI2`] objects.
184///
185/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
186#[must_use = "The builder must be built to be used"]
187pub struct X11DeviceXI2Builder {
188    builder: glib::object::ObjectBuilder<'static, X11DeviceXI2>,
189}
190
191impl X11DeviceXI2Builder {
192    fn new() -> Self {
193        Self {
194            builder: glib::object::Object::builder(),
195        }
196    }
197
198    pub fn device_id(self, device_id: i32) -> Self {
199        Self {
200            builder: self.builder.property("device-id", device_id),
201        }
202    }
203
204    /// The [`gdk::Display`][crate::gdk::Display] the [`gdk::Device`][crate::gdk::Device] pertains to.
205    pub fn display(self, display: &impl IsA<gdk::Display>) -> Self {
206        Self {
207            builder: self.builder.property("display", display.clone().upcast()),
208        }
209    }
210
211    /// Whether the device is represented by a cursor on the screen.
212    pub fn has_cursor(self, has_cursor: bool) -> Self {
213        Self {
214            builder: self.builder.property("has-cursor", has_cursor),
215        }
216    }
217
218    /// The device name.
219    pub fn name(self, name: impl Into<glib::GString>) -> Self {
220        Self {
221            builder: self.builder.property("name", name.into()),
222        }
223    }
224
225    /// The maximal number of concurrent touches on a touch device.
226    ///
227    /// Will be 0 if the device is not a touch device or if the number
228    /// of touches is unknown.
229    pub fn num_touches(self, num_touches: u32) -> Self {
230        Self {
231            builder: self.builder.property("num-touches", num_touches),
232        }
233    }
234
235    /// Product ID of this device.
236    ///
237    /// See `Gdk::Device::get_product_id()`.
238    pub fn product_id(self, product_id: impl Into<glib::GString>) -> Self {
239        Self {
240            builder: self.builder.property("product-id", product_id.into()),
241        }
242    }
243
244    /// [`gdk::Seat`][crate::gdk::Seat] of this device.
245    pub fn seat(self, seat: &gdk::Seat) -> Self {
246        Self {
247            builder: self.builder.property("seat", seat.clone()),
248        }
249    }
250
251    /// Source type for the device.
252    pub fn source(self, source: gdk::InputSource) -> Self {
253        Self {
254            builder: self.builder.property("source", source),
255        }
256    }
257
258    /// Vendor ID of this device.
259    ///
260    /// See `Gdk::Device::get_vendor_id()`.
261    pub fn vendor_id(self, vendor_id: impl Into<glib::GString>) -> Self {
262        Self {
263            builder: self.builder.property("vendor-id", vendor_id.into()),
264        }
265    }
266
267    // rustdoc-stripper-ignore-next
268    /// Build the [`X11DeviceXI2`].
269    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
270    pub fn build(self) -> X11DeviceXI2 {
271        assert_initialized_main_thread!();
272        self.builder.build()
273    }
274}