forked from gtk-rs/gtk-rs-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pango: Implement GlyphItemIter constructors
Fixes gtk-rs#36
- Loading branch information
Showing
4 changed files
with
53 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Take a look at the license at the top of the repository in the LICENSE file. | ||
|
||
use crate::GlyphItem; | ||
use crate::GlyphItemIter; | ||
use glib::translate::*; | ||
use std::mem; | ||
|
||
impl GlyphItemIter { | ||
#[doc(alias = "pango_glyph_item_iter_init_end")] | ||
pub fn new_end(glyph_item: &GlyphItem, text: &str) -> Result<Self, glib::BoolError> { | ||
unsafe { | ||
let mut iter = mem::MaybeUninit::zeroed(); | ||
let res: bool = from_glib(ffi::pango_glyph_item_iter_init_end( | ||
iter.as_mut_ptr(), | ||
mut_override(glyph_item.to_glib_none().0), | ||
text.to_glib_none().0, | ||
)); | ||
|
||
if res { | ||
Ok(from_glib_none(&iter.assume_init() as *const _)) | ||
} else { | ||
Err(glib::bool_error!("Failed to create glyph item iter")) | ||
} | ||
} | ||
} | ||
|
||
#[doc(alias = "pango_glyph_item_iter_init_start")] | ||
pub fn new_start(glyph_item: &GlyphItem, text: &str) -> Result<Self, glib::BoolError> { | ||
unsafe { | ||
let mut iter = mem::MaybeUninit::zeroed(); | ||
let res: bool = from_glib(ffi::pango_glyph_item_iter_init_start( | ||
iter.as_mut_ptr(), | ||
mut_override(glyph_item.to_glib_none().0), | ||
text.to_glib_none().0, | ||
)); | ||
|
||
if res { | ||
Ok(from_glib_none(&iter.assume_init() as *const _)) | ||
} else { | ||
Err(glib::bool_error!("Failed to create glyph item iter")) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters