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