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
// Take a look at the license at the top of the repository in the LICENSE file.
use crate::ShortcutTrigger;
use glib::translate::*;
use glib::IsA;
pub trait ShortcutTriggerExtManual {
/// The types of `self` and `trigger2` are `gconstpointer` only to allow
/// use of this function as a `GCompareFunc`.
///
/// They must each be a [`ShortcutTrigger`][crate::ShortcutTrigger].
/// ## `trigger2`
/// a [`ShortcutTrigger`][crate::ShortcutTrigger]
///
/// # Returns
///
/// An integer less than, equal to, or greater than zero if
/// `self` is found, respectively, to be less than, to match,
/// or be greater than `trigger2`.
#[doc(alias = "gtk_shortcut_trigger_compare")]
fn compare<P: IsA<ShortcutTrigger>>(&self, trigger2: &P) -> std::cmp::Ordering;
/// Checks if `self` and `trigger2` trigger under the same conditions.
///
/// The types of `one` and `two` are `gconstpointer` only to allow use of this
/// function with `GHashTable`. They must each be a [`ShortcutTrigger`][crate::ShortcutTrigger].
/// ## `trigger2`
/// a [`ShortcutTrigger`][crate::ShortcutTrigger]
///
/// # Returns
///
/// [`true`] if `self` and `trigger2` are equal
#[doc(alias = "gtk_shortcut_trigger_equal")]
fn equal<P: IsA<ShortcutTrigger>>(&self, trigger2: &P) -> bool;
/// Generates a hash value for a [`ShortcutTrigger`][crate::ShortcutTrigger].
///
/// The output of this function is guaranteed to be the same for a given
/// value only per-process. It may change between different processor
/// architectures or even different versions of GTK. Do not use this
/// function as a basis for building protocols or file formats.
///
/// The types of `self` is `gconstpointer` only to allow use of this
/// function with `GHashTable`. They must each be a [`ShortcutTrigger`][crate::ShortcutTrigger].
///
/// # Returns
///
/// a hash value corresponding to `self`
#[doc(alias = "gtk_shortcut_trigger_hash")]
fn hash(&self) -> u32;
/// Checks if the given `event` triggers `self`.
/// ## `event`
/// the event to check
/// ## `enable_mnemonics`
/// [`true`] if mnemonics should trigger. Usually the
/// value of this property is determined by checking that the passed
/// in `event` is a Key event and has the right modifiers set.
///
/// # Returns
///
/// Whether the event triggered the shortcut
#[doc(alias = "gtk_shortcut_trigger_trigger")]
fn trigger(&self, event: &gdk::Event, enable_mnemonics: bool) -> gdk::KeyMatch;
}
impl<O: IsA<ShortcutTrigger>> ShortcutTriggerExtManual for O {
fn compare<P: IsA<ShortcutTrigger>>(&self, trigger2: &P) -> std::cmp::Ordering {
unsafe {
from_glib(ffi::gtk_shortcut_trigger_compare(
ToGlibPtr::<*mut ffi::GtkShortcutTrigger>::to_glib_none(self.as_ref()).0
as glib::ffi::gconstpointer,
ToGlibPtr::<*mut ffi::GtkShortcutTrigger>::to_glib_none(trigger2.as_ref()).0
as glib::ffi::gconstpointer,
))
}
}
fn equal<P: IsA<ShortcutTrigger>>(&self, trigger2: &P) -> bool {
unsafe {
from_glib(ffi::gtk_shortcut_trigger_equal(
ToGlibPtr::<*mut ffi::GtkShortcutTrigger>::to_glib_none(self.as_ref()).0
as glib::ffi::gconstpointer,
ToGlibPtr::<*mut ffi::GtkShortcutTrigger>::to_glib_none(trigger2.as_ref()).0
as glib::ffi::gconstpointer,
))
}
}
fn hash(&self) -> u32 {
unsafe {
ffi::gtk_shortcut_trigger_hash(
ToGlibPtr::<*mut ffi::GtkShortcutTrigger>::to_glib_none(self.as_ref()).0
as glib::ffi::gconstpointer,
)
}
}
fn trigger(&self, event: &gdk::Event, enable_mnemonics: bool) -> gdk::KeyMatch {
unsafe {
from_glib(ffi::gtk_shortcut_trigger_trigger(
self.as_ref().to_glib_none().0,
event.to_glib_none().0,
enable_mnemonics.into_glib(),
))
}
}
}