gdk4/auto/device.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{ffi, DeviceTool, Display, InputSource, ModifierType, Seat, Surface};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
/// The [`Device`][crate::Device] object represents an input device, such
/// as a keyboard, a mouse, or a touchpad.
///
/// See the [`Seat`][crate::Seat] documentation for more information
/// about the various kinds of devices, and their relationships.
///
/// This is an Abstract Base Class, you cannot instantiate it.
///
/// ## Properties
///
///
/// #### `caps-lock-state`
/// Whether Caps Lock is on.
///
/// This is only relevant for keyboard devices.
///
/// Readable
///
///
/// #### `direction`
/// The direction of the current layout.
///
/// This is only relevant for keyboard devices.
///
/// Readable
///
///
/// #### `display`
/// The [`Display`][crate::Display] the [`Device`][crate::Device] pertains to.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `has-bidi-layouts`
/// Whether the device has both right-to-left and left-to-right layouts.
///
/// This is only relevant for keyboard devices.
///
/// Readable
///
///
/// #### `has-cursor`
/// Whether the device is represented by a cursor on the screen.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `modifier-state`
/// The current modifier state of the device.
///
/// This is only relevant for keyboard devices.
///
/// Readable
///
///
/// #### `n-axes`
/// Number of axes in the device.
///
/// Readable
///
///
/// #### `name`
/// The device name.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `num-lock-state`
/// Whether Num Lock is on.
///
/// This is only relevant for keyboard devices.
///
/// Readable
///
///
/// #### `num-touches`
/// The maximal number of concurrent touches on a touch device.
///
/// Will be 0 if the device is not a touch device or if the number
/// of touches is unknown.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `product-id`
/// Product ID of this device.
///
/// See [`DeviceExt::product_id()`][crate::prelude::DeviceExt::product_id()].
///
/// Readable | Writeable | Construct Only
///
///
/// #### `scroll-lock-state`
/// Whether Scroll Lock is on.
///
/// This is only relevant for keyboard devices.
///
/// Readable
///
///
/// #### `seat`
/// [`Seat`][crate::Seat] of this device.
///
/// Readable | Writeable
///
///
/// #### `source`
/// Source type for the device.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `tool`
/// The [`DeviceTool`][crate::DeviceTool] that is currently used with this device.
///
/// Readable
///
///
/// #### `vendor-id`
/// Vendor ID of this device.
///
/// See [`DeviceExt::vendor_id()`][crate::prelude::DeviceExt::vendor_id()].
///
/// Readable | Writeable | Construct Only
///
/// ## Signals
///
///
/// #### `changed`
/// Emitted either when the number of either axes or keys changes.
///
/// On X11 this will normally happen when the physical device
/// routing events through the logical device changes (for
/// example, user switches from the USB mouse to a tablet); in
/// that case the logical device will change to reflect the axes
/// and keys on the new physical device.
///
///
///
///
/// #### `tool-changed`
/// Emitted on pen/eraser devices whenever tools enter or leave proximity.
///
///
///
/// # Implements
///
/// [`DeviceExt`][trait@crate::prelude::DeviceExt]
#[doc(alias = "GdkDevice")]
pub struct Device(Object<ffi::GdkDevice>);
match fn {
type_ => || ffi::gdk_device_get_type(),
}
}
impl Device {
pub const NONE: Option<&'static Device> = None;
}
impl std::fmt::Display for Device {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(&DeviceExt::name(self))
}
}
/// Trait containing all [`struct@Device`] methods.
///
/// # Implementors
///
/// [`DevicePad`][struct@crate::DevicePad], [`Device`][struct@crate::Device]
pub trait DeviceExt: IsA<Device> + 'static {
/// Retrieves whether the Caps Lock modifier of the keyboard is locked.
///
/// This is only relevant for keyboard devices.
///
/// # Returns
///
/// [`true`] if Caps Lock is on for @self
#[doc(alias = "gdk_device_get_caps_lock_state")]
#[doc(alias = "get_caps_lock_state")]
#[doc(alias = "caps-lock-state")]
fn is_caps_locked(&self) -> bool {
unsafe {
from_glib(ffi::gdk_device_get_caps_lock_state(
self.as_ref().to_glib_none().0,
))
}
}
/// Retrieves the current tool for @self.
///
/// # Returns
///
/// the [`DeviceTool`][crate::DeviceTool]
#[doc(alias = "gdk_device_get_device_tool")]
#[doc(alias = "get_device_tool")]
#[doc(alias = "tool")]
fn device_tool(&self) -> Option<DeviceTool> {
unsafe {
from_glib_none(ffi::gdk_device_get_device_tool(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns the direction of effective layout of the keyboard.
///
/// This is only relevant for keyboard devices.
///
/// The direction of a layout is the direction of the majority
/// of its symbols. See `unichar_direction()`.
///
/// # Returns
///
/// [`pango::Direction::Ltr`][crate::pango::Direction::Ltr] or [`pango::Direction::Rtl`][crate::pango::Direction::Rtl]
/// if it can determine the direction. [`pango::Direction::Neutral`][crate::pango::Direction::Neutral]
/// otherwise
#[doc(alias = "gdk_device_get_direction")]
#[doc(alias = "get_direction")]
fn direction(&self) -> pango::Direction {
unsafe {
from_glib(ffi::gdk_device_get_direction(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns the [`Display`][crate::Display] to which @self pertains.
///
/// # Returns
///
/// a [`Display`][crate::Display]
#[doc(alias = "gdk_device_get_display")]
#[doc(alias = "get_display")]
fn display(&self) -> Display {
unsafe { from_glib_none(ffi::gdk_device_get_display(self.as_ref().to_glib_none().0)) }
}
/// Determines whether the pointer follows device motion.
///
/// This is not meaningful for keyboard devices, which
/// don't have a pointer.
///
/// # Returns
///
/// [`true`] if the pointer follows device motion
#[doc(alias = "gdk_device_get_has_cursor")]
#[doc(alias = "get_has_cursor")]
#[doc(alias = "has-cursor")]
fn has_cursor(&self) -> bool {
unsafe {
from_glib(ffi::gdk_device_get_has_cursor(
self.as_ref().to_glib_none().0,
))
}
}
/// Retrieves the current modifier state of the keyboard.
///
/// This is only relevant for keyboard devices.
///
/// # Returns
///
/// the current modifier state
#[doc(alias = "gdk_device_get_modifier_state")]
#[doc(alias = "get_modifier_state")]
#[doc(alias = "modifier-state")]
fn modifier_state(&self) -> ModifierType {
unsafe {
from_glib(ffi::gdk_device_get_modifier_state(
self.as_ref().to_glib_none().0,
))
}
}
/// The name of the device, suitable for showing in a user interface.
///
/// # Returns
///
/// a name
#[doc(alias = "gdk_device_get_name")]
#[doc(alias = "get_name")]
fn name(&self) -> glib::GString {
unsafe { from_glib_none(ffi::gdk_device_get_name(self.as_ref().to_glib_none().0)) }
}
/// Retrieves whether the Num Lock modifier of the keyboard is locked.
///
/// This is only relevant for keyboard devices.
///
/// # Returns
///
/// [`true`] if Num Lock is on for @self
#[doc(alias = "gdk_device_get_num_lock_state")]
#[doc(alias = "get_num_lock_state")]
#[doc(alias = "num-lock-state")]
fn is_num_locked(&self) -> bool {
unsafe {
from_glib(ffi::gdk_device_get_num_lock_state(
self.as_ref().to_glib_none().0,
))
}
}
/// Retrieves the number of touch points associated to @self.
///
/// # Returns
///
/// the number of touch points
#[doc(alias = "gdk_device_get_num_touches")]
#[doc(alias = "get_num_touches")]
#[doc(alias = "num-touches")]
fn num_touches(&self) -> u32 {
unsafe { ffi::gdk_device_get_num_touches(self.as_ref().to_glib_none().0) }
}
/// Returns the product ID of this device.
///
/// This ID is retrieved from the device, and does not change.
/// See [`vendor_id()`][Self::vendor_id()] for more information.
///
/// # Returns
///
/// the product ID
#[doc(alias = "gdk_device_get_product_id")]
#[doc(alias = "get_product_id")]
#[doc(alias = "product-id")]
fn product_id(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::gdk_device_get_product_id(
self.as_ref().to_glib_none().0,
))
}
}
/// Retrieves whether the Scroll Lock modifier of the keyboard is locked.
///
/// This is only relevant for keyboard devices.
///
/// # Returns
///
/// [`true`] if Scroll Lock is on for @self
#[doc(alias = "gdk_device_get_scroll_lock_state")]
#[doc(alias = "get_scroll_lock_state")]
#[doc(alias = "scroll-lock-state")]
fn is_scroll_locked(&self) -> bool {
unsafe {
from_glib(ffi::gdk_device_get_scroll_lock_state(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns the [`Seat`][crate::Seat] the device belongs to.
///
/// # Returns
///
/// a [`Seat`][crate::Seat]
#[doc(alias = "gdk_device_get_seat")]
#[doc(alias = "get_seat")]
fn seat(&self) -> Seat {
unsafe { from_glib_none(ffi::gdk_device_get_seat(self.as_ref().to_glib_none().0)) }
}
/// Determines the type of the device.
///
/// # Returns
///
/// a [`InputSource`][crate::InputSource]
#[doc(alias = "gdk_device_get_source")]
#[doc(alias = "get_source")]
fn source(&self) -> InputSource {
unsafe { from_glib(ffi::gdk_device_get_source(self.as_ref().to_glib_none().0)) }
}
/// Obtains the surface underneath @self, returning the location of the
/// device in @win_x and @win_y.
///
/// Returns [`None`] if the surface tree under @self is not known to GDK
/// (for example, belongs to another application).
///
/// # Returns
///
/// the [`Surface`][crate::Surface] under the
/// device position
///
/// ## `win_x`
/// return location for the X coordinate
/// of the device location relative to the surface origin
///
/// ## `win_y`
/// return location for the Y coordinate
/// of the device location relative to the surface origin
#[doc(alias = "gdk_device_get_surface_at_position")]
#[doc(alias = "get_surface_at_position")]
fn surface_at_position(&self) -> (Option<Surface>, f64, f64) {
unsafe {
let mut win_x = std::mem::MaybeUninit::uninit();
let mut win_y = std::mem::MaybeUninit::uninit();
let ret = from_glib_none(ffi::gdk_device_get_surface_at_position(
self.as_ref().to_glib_none().0,
win_x.as_mut_ptr(),
win_y.as_mut_ptr(),
));
(ret, win_x.assume_init(), win_y.assume_init())
}
}
/// Returns the timestamp of the last activity for this device.
///
/// In practice, this means the timestamp of the last event that was
/// received from the OS for this device. (GTK may occasionally produce
/// events for a device that are not received from the OS, and will not
/// update the timestamp).
///
/// # Returns
///
/// the timestamp of the last activity for this device
#[cfg(feature = "v4_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
#[doc(alias = "gdk_device_get_timestamp")]
#[doc(alias = "get_timestamp")]
fn timestamp(&self) -> u32 {
unsafe { ffi::gdk_device_get_timestamp(self.as_ref().to_glib_none().0) }
}
/// Returns the vendor ID of this device.
///
/// This ID is retrieved from the device, and does not change.
///
/// This function, together with [`product_id()`][Self::product_id()],
/// can be used to eg. compose `GSettings` paths to store settings
/// for this device.
///
/// **⚠️ The following code is in c ⚠️**
///
/// ```c
/// static GSettings *
/// get_device_settings (GdkDevice *device)
/// {
/// const char *vendor, *product;
/// GSettings *settings;
/// GdkDevice *device;
/// char *path;
///
/// vendor = gdk_device_get_vendor_id (device);
/// product = gdk_device_get_product_id (device);
///
/// path = g_strdup_printf ("/org/example/app/devices/%s:%s/", vendor, product);
/// settings = g_settings_new_with_path (DEVICE_SCHEMA, path);
/// g_free (path);
///
/// return settings;
/// }
/// ```
///
/// # Returns
///
/// the vendor ID
#[doc(alias = "gdk_device_get_vendor_id")]
#[doc(alias = "get_vendor_id")]
#[doc(alias = "vendor-id")]
fn vendor_id(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::gdk_device_get_vendor_id(
self.as_ref().to_glib_none().0,
))
}
}
/// Determines if layouts for both right-to-left and
/// left-to-right languages are in use on the keyboard.
///
/// This is only relevant for keyboard devices.
///
/// # Returns
///
/// [`true`] if there are layouts with both directions, [`false`] otherwise
#[doc(alias = "gdk_device_has_bidi_layouts")]
#[doc(alias = "has-bidi-layouts")]
fn has_bidi_layouts(&self) -> bool {
unsafe {
from_glib(ffi::gdk_device_has_bidi_layouts(
self.as_ref().to_glib_none().0,
))
}
}
/// Number of axes in the device.
#[doc(alias = "n-axes")]
fn n_axes(&self) -> u32 {
ObjectExt::property(self.as_ref(), "n-axes")
}
/// [`Seat`][crate::Seat] of this device.
fn set_seat<P: IsA<Seat>>(&self, seat: Option<&P>) {
ObjectExt::set_property(self.as_ref(), "seat", seat)
}
/// Emitted either when the number of either axes or keys changes.
///
/// On X11 this will normally happen when the physical device
/// routing events through the logical device changes (for
/// example, user switches from the USB mouse to a tablet); in
/// that case the logical device will change to reflect the axes
/// and keys on the new physical device.
#[doc(alias = "changed")]
fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn changed_trampoline<P: IsA<Device>, F: Fn(&P) + 'static>(
this: *mut ffi::GdkDevice,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Device::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"changed".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
changed_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted on pen/eraser devices whenever tools enter or leave proximity.
/// ## `tool`
/// The new current tool
#[doc(alias = "tool-changed")]
fn connect_tool_changed<F: Fn(&Self, &DeviceTool) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn tool_changed_trampoline<
P: IsA<Device>,
F: Fn(&P, &DeviceTool) + 'static,
>(
this: *mut ffi::GdkDevice,
tool: *mut ffi::GdkDeviceTool,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
Device::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(tool),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"tool-changed".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
tool_changed_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "caps-lock-state")]
fn connect_caps_lock_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_caps_lock_state_trampoline<
P: IsA<Device>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GdkDevice,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Device::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::caps-lock-state".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_caps_lock_state_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "direction")]
fn connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_direction_trampoline<P: IsA<Device>, F: Fn(&P) + 'static>(
this: *mut ffi::GdkDevice,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Device::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::direction".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_direction_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "has-bidi-layouts")]
fn connect_has_bidi_layouts_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_has_bidi_layouts_trampoline<
P: IsA<Device>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GdkDevice,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Device::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::has-bidi-layouts".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_has_bidi_layouts_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "modifier-state")]
fn connect_modifier_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_modifier_state_trampoline<
P: IsA<Device>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GdkDevice,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Device::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::modifier-state".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_modifier_state_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "n-axes")]
fn connect_n_axes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_n_axes_trampoline<P: IsA<Device>, F: Fn(&P) + 'static>(
this: *mut ffi::GdkDevice,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Device::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::n-axes".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_n_axes_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "num-lock-state")]
fn connect_num_lock_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_num_lock_state_trampoline<
P: IsA<Device>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GdkDevice,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Device::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::num-lock-state".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_num_lock_state_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "scroll-lock-state")]
fn connect_scroll_lock_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_scroll_lock_state_trampoline<
P: IsA<Device>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GdkDevice,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Device::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::scroll-lock-state".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_scroll_lock_state_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "seat")]
fn connect_seat_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_seat_trampoline<P: IsA<Device>, F: Fn(&P) + 'static>(
this: *mut ffi::GdkDevice,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Device::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::seat".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_seat_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "tool")]
fn connect_tool_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_tool_trampoline<P: IsA<Device>, F: Fn(&P) + 'static>(
this: *mut ffi::GdkDevice,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Device::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::tool".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_tool_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<Device>> DeviceExt for O {}