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