gdk/
keys.rs

1// Copyright 2013-2015, The Gtk-rs Project Developers.
2// See the COPYRIGHT file at the top-level directory of this distribution.
3// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
4
5use gdk_sys;
6use glib::translate::*;
7use glib::GString;
8use libc::c_uint;
9use std::mem::transmute;
10
11pub fn keyval_name(keyval: u32) -> Option<GString> {
12    skip_assert_initialized!();
13    unsafe { from_glib_none(gdk_sys::gdk_keyval_name(keyval as c_uint)) }
14}
15
16pub fn keyval_to_unicode(keyval: u32) -> Option<char> {
17    skip_assert_initialized!();
18    unsafe {
19        let c: char = transmute(gdk_sys::gdk_keyval_to_unicode(keyval));
20        if c != '\0' {
21            Some(c)
22        } else {
23            None
24        }
25    }
26}