gdk4/auto/device_tool.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, AxisFlags, DeviceToolType};
6use glib::translate::*;
7
8glib::wrapper! {
9 /// A physical tool associated to a [`Device`][crate::Device].
10 ///
11 /// ## Properties
12 ///
13 ///
14 /// #### `axes`
15 /// The axes of the tool.
16 ///
17 /// Readable | Writeable | Construct Only
18 ///
19 ///
20 /// #### `hardware-id`
21 /// The hardware ID of the tool.
22 ///
23 /// Readable | Writeable | Construct Only
24 ///
25 ///
26 /// #### `serial`
27 /// The serial number of the tool.
28 ///
29 /// Readable | Writeable | Construct Only
30 ///
31 ///
32 /// #### `tool-type`
33 /// The type of the tool.
34 ///
35 /// Readable | Writeable | Construct Only
36 #[doc(alias = "GdkDeviceTool")]
37 pub struct DeviceTool(Object<ffi::GdkDeviceTool>);
38
39 match fn {
40 type_ => || ffi::gdk_device_tool_get_type(),
41 }
42}
43
44impl DeviceTool {
45 /// Gets the axes of the tool.
46 ///
47 /// # Returns
48 ///
49 /// the axes of @self
50 #[doc(alias = "gdk_device_tool_get_axes")]
51 #[doc(alias = "get_axes")]
52 pub fn axes(&self) -> AxisFlags {
53 unsafe { from_glib(ffi::gdk_device_tool_get_axes(self.to_glib_none().0)) }
54 }
55
56 /// Gets the hardware ID of this tool, or 0 if it's not known.
57 ///
58 /// When non-zero, the identifier is unique for the given tool model,
59 /// meaning that two identical tools will share the same @hardware_id,
60 /// but will have different serial numbers (see
61 /// [`serial()`][Self::serial()]).
62 ///
63 /// This is a more concrete (and device specific) method to identify
64 /// a [`DeviceTool`][crate::DeviceTool] than [`tool_type()`][Self::tool_type()],
65 /// as a tablet may support multiple devices with the same
66 /// [`DeviceToolType`][crate::DeviceToolType], but different hardware identifiers.
67 ///
68 /// # Returns
69 ///
70 /// The hardware identifier of this tool.
71 #[doc(alias = "gdk_device_tool_get_hardware_id")]
72 #[doc(alias = "get_hardware_id")]
73 #[doc(alias = "hardware-id")]
74 pub fn hardware_id(&self) -> u64 {
75 unsafe { ffi::gdk_device_tool_get_hardware_id(self.to_glib_none().0) }
76 }
77
78 /// Gets the serial number of this tool.
79 ///
80 /// This value can be used to identify a physical tool
81 /// (eg. a tablet pen) across program executions.
82 ///
83 /// # Returns
84 ///
85 /// The serial ID for this tool
86 #[doc(alias = "gdk_device_tool_get_serial")]
87 #[doc(alias = "get_serial")]
88 pub fn serial(&self) -> u64 {
89 unsafe { ffi::gdk_device_tool_get_serial(self.to_glib_none().0) }
90 }
91
92 /// Gets the [`DeviceToolType`][crate::DeviceToolType] of the tool.
93 ///
94 /// # Returns
95 ///
96 /// The physical type for this tool. This can be used to
97 /// figure out what sort of pen is being used, such as an airbrush
98 /// or a pencil.
99 #[doc(alias = "gdk_device_tool_get_tool_type")]
100 #[doc(alias = "get_tool_type")]
101 #[doc(alias = "tool-type")]
102 pub fn tool_type(&self) -> DeviceToolType {
103 unsafe { from_glib(ffi::gdk_device_tool_get_tool_type(self.to_glib_none().0)) }
104 }
105}