Skip to content

Commit

Permalink
pango: manual impl for some functions
Browse files Browse the repository at this point in the history
Functions `itemize()` & `itemize_with_base_dir` now use Into<Option<&_>> for the
`cached_dir` argument. Because of this new signature, the lifetime for the inner
type `AttrIterator<'_>>` must be specified.
  • Loading branch information
fengalin committed Dec 2, 2024
1 parent b8c11a3 commit b20f195
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion pango/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,51 @@ use glib::translate::*;
pub use crate::auto::functions::*;
#[cfg(feature = "v1_44")]
use crate::ShapeFlags;
use crate::{ffi, Analysis, GlyphString, Item};
use crate::{ffi, Analysis, AttrIterator, AttrList, Context, Direction, GlyphString, Item};

#[doc(alias = "pango_itemize")]
pub fn itemize<'a>(
context: &Context,
text: &str,
start_index: i32,
length: i32,
attrs: &AttrList,
cached_iter: impl Into<Option<&'a AttrIterator<'a>>>,
) -> Vec<Item> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::pango_itemize(
context.to_glib_none().0,
text.to_glib_none().0,
start_index,
length,
attrs.to_glib_none().0,
mut_override(cached_iter.into().to_glib_none().0),
))
}
}

#[doc(alias = "pango_itemize_with_base_dir")]
pub fn itemize_with_base_dir<'a>(
context: &Context,
base_dir: Direction,
text: &str,
start_index: i32,
length: i32,
attrs: &AttrList,
cached_iter: impl Into<Option<&'a AttrIterator<'a>>>,
) -> Vec<Item> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::pango_itemize_with_base_dir(
context.to_glib_none().0,
base_dir.into_glib(),
text.to_glib_none().0,
start_index,
length,
attrs.to_glib_none().0,
mut_override(cached_iter.into().to_glib_none().0),
))
}
}

#[doc(alias = "pango_reorder_items")]
pub fn reorder_items(logical_items: &glib::List<Item>) -> glib::List<Item> {
Expand Down

0 comments on commit b20f195

Please sign in to comment.