Skip to main content

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};
6use glib::{prelude::*, translate::*};
7use std::fmt;
8
9glib::wrapper! {
10    ///
11    ///
12    /// ## Properties
13    ///
14    ///
15    /// #### `axes`
16    ///  Readable | Writeable | Construct Only
17    ///
18    ///
19    /// #### `hardware-id`
20    ///  Readable | Writeable | Construct Only
21    ///
22    ///
23    /// #### `serial`
24    ///  Readable | Writeable | Construct Only
25    ///
26    ///
27    /// #### `tool-type`
28    ///  Readable | Writeable | Construct Only
29    #[doc(alias = "GdkDeviceTool")]
30    pub struct DeviceTool(Object<ffi::GdkDeviceTool>);
31
32    match fn {
33        type_ => || ffi::gdk_device_tool_get_type(),
34    }
35}
36
37impl DeviceTool {
38    /// Gets the hardware ID of this tool, or 0 if it's not known. When
39    /// non-zero, the identificator is unique for the given tool model,
40    /// meaning that two identical tools will share the same `hardware_id`,
41    /// but will have different serial numbers (see [`serial()`][Self::serial()]).
42    ///
43    /// This is a more concrete (and device specific) method to identify
44    /// a [`DeviceTool`][crate::DeviceTool] than [`tool_type()`][Self::tool_type()], as a tablet
45    /// may support multiple devices with the same [`DeviceToolType`][crate::DeviceToolType],
46    /// but having different hardware identificators.
47    ///
48    /// # Returns
49    ///
50    /// The hardware identificator of this tool.
51    #[doc(alias = "gdk_device_tool_get_hardware_id")]
52    #[doc(alias = "get_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    pub fn tool_type(&self) -> DeviceToolType {
78        unsafe { from_glib(ffi::gdk_device_tool_get_tool_type(self.to_glib_none().0)) }
79    }
80
81    pub fn axes(&self) -> AxisFlags {
82        ObjectExt::property(self, "axes")
83    }
84}
85
86impl fmt::Display for DeviceTool {
87    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
88        f.write_str("DeviceTool")
89    }
90}