Skip to content

Commit

Permalink
gdk: properly export all consts
Browse files Browse the repository at this point in the history
Fixes #49
  • Loading branch information
bilelmoussaoui committed Jan 11, 2021
1 parent eae10df commit db1ea73
Show file tree
Hide file tree
Showing 11 changed files with 4,882 additions and 97 deletions.
35 changes: 34 additions & 1 deletion gdk4/Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ generate = [
"Gdk.GrabBrokenEvent",
"Gdk.Gravity",
"Gdk.InputSource",
"Gdk.KeyEvent",
"Gdk.KeyMatch",
"Gdk.MemoryFormat",
"Gdk.MemoryTexture",
Expand Down Expand Up @@ -138,6 +137,30 @@ status = "generate"
name = "content_deserialize_async"
#manual: out
ignore = true
[[object.function]]
name = "keyval_convert_case"
manual = true # manually handled by keys::Key
[[object.function]]
name = "keyval_from_name"
manual = true # manually handled by keys::Key
[[object.function]]
name = "keyval_is_lower"
manual = true # manually handled by keys::Key
[[object.function]]
name = "keyval_is_upper"
manual = true # manually handled by keys::Key
[[object.function]]
name = "keyval_name"
manual = true # manually handled by keys::Key
[[object.function]]
name = "keyval_to_lower"
manual = true # manually handled by keys::Key
[[object.function]]
name = "keyval_to_unicode"
manual = true # manually handled by keys::Key
[[object.function]]
name = "keyval_to_upper"
manual = true # manually handled by keys::Key


[[object]]
Expand Down Expand Up @@ -267,6 +290,9 @@ status = "generate"
[object.function.return]
nullable = false
[[object.function]]
name = "translate_key"
manual = true # to return a Key instead of a u32
[[object.function]]
name = "map_keycode"
ignore = true # requires FromGlibPtrArrayContainerAsVec first
[[object.function]]
Expand Down Expand Up @@ -414,6 +440,13 @@ status = "generate"
# applications should not use setters
ignore = true

[[object]]
name = "Gdk.KeyEvent"
status = "generate"
[[object.function]]
name = "get_keyval"
manual = true # to return a Key instead of a u32

[[object]]
name = "Gdk.Monitor"
status = "generate"
Expand Down
36 changes: 0 additions & 36 deletions gdk4/src/auto/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::AppLaunchContext;
use crate::Clipboard;
use crate::Device;
use crate::Event;
use crate::ModifierType;
use crate::Monitor;
use crate::Seat;
use crate::Surface;
Expand All @@ -18,7 +17,6 @@ use glib::translate::*;
use glib::StaticType;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem;
use std::mem::transmute;

glib::wrapper! {
Expand Down Expand Up @@ -186,40 +184,6 @@ impl Display {
}
}

#[doc(alias = "gdk_display_translate_key")]
pub fn translate_key(
&self,
keycode: u32,
state: ModifierType,
group: i32,
) -> Option<(u32, i32, i32, ModifierType)> {
unsafe {
let mut keyval = mem::MaybeUninit::uninit();
let mut effective_group = mem::MaybeUninit::uninit();
let mut level = mem::MaybeUninit::uninit();
let mut consumed = mem::MaybeUninit::uninit();
let ret = from_glib(ffi::gdk_display_translate_key(
self.to_glib_none().0,
keycode,
state.to_glib(),
group,
keyval.as_mut_ptr(),
effective_group.as_mut_ptr(),
level.as_mut_ptr(),
consumed.as_mut_ptr(),
));
let keyval = keyval.assume_init();
let effective_group = effective_group.assume_init();
let level = level.assume_init();
let consumed = consumed.assume_init();
if ret {
Some((keyval, effective_group, level, from_glib(consumed)))
} else {
None
}
}
}

pub fn get_property_composited(&self) -> bool {
unsafe {
let mut value = glib::Value::from_type(<bool as StaticType>::static_type());
Expand Down
55 changes: 0 additions & 55 deletions gdk4/src/auto/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,61 +77,6 @@ pub fn intern_mime_type(string: &str) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::gdk_intern_mime_type(string.to_glib_none().0)) }
}

#[doc(alias = "gdk_keyval_convert_case")]
pub fn keyval_convert_case(symbol: u32) -> (u32, u32) {
assert_initialized_main_thread!();
unsafe {
let mut lower = mem::MaybeUninit::uninit();
let mut upper = mem::MaybeUninit::uninit();
ffi::gdk_keyval_convert_case(symbol, lower.as_mut_ptr(), upper.as_mut_ptr());
let lower = lower.assume_init();
let upper = upper.assume_init();
(lower, upper)
}
}

#[doc(alias = "gdk_keyval_from_name")]
pub fn keyval_from_name(keyval_name: &str) -> u32 {
assert_initialized_main_thread!();
unsafe { ffi::gdk_keyval_from_name(keyval_name.to_glib_none().0) }
}

#[doc(alias = "gdk_keyval_is_lower")]
pub fn keyval_is_lower(keyval: u32) -> bool {
assert_initialized_main_thread!();
unsafe { from_glib(ffi::gdk_keyval_is_lower(keyval)) }
}

#[doc(alias = "gdk_keyval_is_upper")]
pub fn keyval_is_upper(keyval: u32) -> bool {
assert_initialized_main_thread!();
unsafe { from_glib(ffi::gdk_keyval_is_upper(keyval)) }
}

#[doc(alias = "gdk_keyval_name")]
pub fn keyval_name(keyval: u32) -> Option<glib::GString> {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::gdk_keyval_name(keyval)) }
}

#[doc(alias = "gdk_keyval_to_lower")]
pub fn keyval_to_lower(keyval: u32) -> u32 {
assert_initialized_main_thread!();
unsafe { ffi::gdk_keyval_to_lower(keyval) }
}

#[doc(alias = "gdk_keyval_to_unicode")]
pub fn keyval_to_unicode(keyval: u32) -> u32 {
assert_initialized_main_thread!();
unsafe { ffi::gdk_keyval_to_unicode(keyval) }
}

#[doc(alias = "gdk_keyval_to_upper")]
pub fn keyval_to_upper(keyval: u32) -> u32 {
assert_initialized_main_thread!();
unsafe { ffi::gdk_keyval_to_upper(keyval) }
}

#[doc(alias = "gdk_pixbuf_get_from_surface")]
pub fn pixbuf_get_from_surface(
surface: &cairo::Surface,
Expand Down
5 changes: 0 additions & 5 deletions gdk4/src/auto/key_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ impl KeyEvent {
unsafe { ffi::gdk_key_event_get_keycode(self.to_glib_none().0) }
}

#[doc(alias = "gdk_key_event_get_keyval")]
pub fn get_keyval(&self) -> u32 {
unsafe { ffi::gdk_key_event_get_keyval(self.to_glib_none().0) }
}

#[doc(alias = "gdk_key_event_get_layout")]
pub fn get_layout(&self) -> u32 {
unsafe { ffi::gdk_key_event_get_layout(self.to_glib_none().0) }
Expand Down
41 changes: 41 additions & 0 deletions gdk4/src/display.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::{keys::Key, Display, ModifierType};
use glib::translate::*;
use std::mem;

impl Display {
#[doc(alias = "gdk_display_translate_key")]
pub fn translate_key(
&self,
keycode: u32,
state: ModifierType,
group: i32,
) -> Option<(Key, i32, i32, ModifierType)> {
unsafe {
let mut keyval = mem::MaybeUninit::uninit();
let mut effective_group = mem::MaybeUninit::uninit();
let mut level = mem::MaybeUninit::uninit();
let mut consumed = mem::MaybeUninit::uninit();
let ret = from_glib(ffi::gdk_display_translate_key(
self.to_glib_none().0,
keycode,
state.to_glib(),
group,
keyval.as_mut_ptr(),
effective_group.as_mut_ptr(),
level.as_mut_ptr(),
consumed.as_mut_ptr(),
));
let keyval: Key = keyval.assume_init().into();
let effective_group = effective_group.assume_init();
let level = level.assume_init();
let consumed = consumed.assume_init();
if ret {
Some((keyval, effective_group, level, from_glib(consumed)))
} else {
None
}
}
}
}
11 changes: 11 additions & 0 deletions gdk4/src/key_event.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::{keys::Key, KeyEvent};
use glib::translate::*;

impl KeyEvent {
#[doc(alias = "gdk_key_event_get_keyval")]
pub fn get_keyval(&self) -> Key {
unsafe { ffi::gdk_key_event_get_keyval(self.to_glib_none().0).into() }
}
}
Loading

0 comments on commit db1ea73

Please sign in to comment.