Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Commit

Permalink
Merge pull request #346 from danigm/keyval-functions
Browse files Browse the repository at this point in the history
Nicer bindings for Key(val) related functions
  • Loading branch information
GuillaumeGomez authored Jun 6, 2020
2 parents af324b3 + a59fd4e commit 51927f0
Show file tree
Hide file tree
Showing 7 changed files with 2,362 additions and 2,291 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ addons:
packages:
- libgtk-3-dev
- libmount-dev
- xvfb

before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
Expand All @@ -34,7 +35,8 @@ script:
make regen_check;
fi
- cargo doc --features "dox,embed-lgpl-docs"
- cargo test --features "$FEATURES,embed-lgpl-docs"
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then xvfb-run cargo test --features "$FEATURES,embed-lgpl-docs"; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cargo test --features "$FEATURES,embed-lgpl-docs"; fi
# catch any sneaked in lgpl docs
- cargo build --features "$FEATURES,purge-lgpl-docs" --jobs 1
- git diff -R --exit-code
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ install:

build_script:
- cargo doc --features "dox"
- cargo test
- cargo test --features v3_24
- IF "%BITS%" == "64" cargo test
- IF "%BITS%" == "64" cargo test --features v3_24
- cargo doc --features "dox"
- mkdir .cargo
- echo paths = ["."] > .cargo\config
Expand Down
2,283 changes: 0 additions & 2,283 deletions src/enums.rs

This file was deleted.

4 changes: 2 additions & 2 deletions src/event_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ impl EventKey {
from_glib(self.as_ref().state)
}

pub fn get_keyval(&self) -> ::enums::key::Key {
self.as_ref().keyval as ::enums::key::Key
pub fn get_keyval(&self) -> ::keys::Key {
from_glib(self.as_ref().keyval)
}

pub fn get_length(&self) -> u32 {
Expand Down
2,332 changes: 2,332 additions & 0 deletions src/keys.rs

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ pub mod prelude;
pub use self::auto::functions::*;
pub use auto::*;

pub mod enums;

mod atom;
mod cairo_interaction;
mod change_data;
Expand Down Expand Up @@ -77,7 +75,7 @@ mod functions;
mod geometry;
mod keymap;
mod keymap_key;
mod keys;
pub mod keys;
mod rectangle;
mod rgba;
mod screen;
Expand Down
22 changes: 22 additions & 0 deletions tests/check_event.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
extern crate gdk;
extern crate gdk_sys;

#[test]
fn check_event() {
gdk::init();
let base_ev = gdk::Event::new(gdk::EventType::KeyPress);
let mut ev: gdk::EventKey = base_ev.downcast().unwrap();
ev.as_mut().keyval = *gdk::keys::constants::A;

let keyval = gdk::keyval_to_unicode(*ev.get_keyval());
let keyval2 = ev.get_keyval().to_unicode();

assert_eq!(keyval, Some('A'));
assert_eq!(keyval, keyval2);

let name = gdk::keyval_name(*ev.get_keyval());
let name2 = ev.get_keyval().name();

assert_eq!(name, Some("A".into()));
assert_eq!(name, name2);
}

0 comments on commit 51927f0

Please sign in to comment.