popover: Show overlays as selected

This commit is contained in:
Dorota Czaplejewicz
2019-12-08 18:15:09 +00:00
parent bafd1e6eb3
commit 01a8afad0d
4 changed files with 39 additions and 6 deletions

View File

@ -1,4 +1,5 @@
/*! Procedures relating to the management of the switching of layouts */
use ::util;
pub mod c {
use std::os::raw::{c_char, c_void};
@ -14,5 +15,20 @@ pub mod c {
manager: Manager,
name: *const c_char,
);
pub fn eekboard_context_service_get_overlay(
manager: Manager,
) -> *const c_char;
}
}
/// Returns the overlay name.
/// The result lifetime is "as long as the C copy lives"
pub fn get_overlay(manager: c::Manager) -> Option<String> {
let raw_str = unsafe {
c::eekboard_context_service_get_overlay(manager)
};
// this string is generated from Rust, should never be invalid
util::c::as_str(&raw_str).unwrap()
.map(String::from)
}