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

Commit

Permalink
Run everything through rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
sdroege committed Jun 13, 2019
1 parent ec0cbcf commit 0f88598
Show file tree
Hide file tree
Showing 37 changed files with 1,461 additions and 862 deletions.
9 changes: 3 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@ fn main() {
}

#[cfg(any(feature = "embed-lgpl-docs", feature = "purge-lgpl-docs"))]
fn manage_docs () {
fn manage_docs() {
extern crate lgpl_docs;
const PATH: &'static str = "src";
const IGNORES: &'static [&'static str] = &[
"lib.rs",
"prelude.rs",
];
const IGNORES: &'static [&'static str] = &["lib.rs", "prelude.rs"];
lgpl_docs::purge(PATH, IGNORES);
if cfg!(feature = "embed-lgpl-docs") {
lgpl_docs::embed(lgpl_docs::Library::Pango, PATH, IGNORES);
}
}

#[cfg(not(any(feature = "embed-lgpl-docs", feature = "purge-lgpl-docs")))]
fn manage_docs() { }
fn manage_docs() {}
1 change: 0 additions & 1 deletion src/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ impl Analysis {
}*/
}


#[doc(hidden)]
impl<'a> ToGlibPtr<'a, *const pango_sys::PangoAnalysis> for Analysis {
type Storage = &'a Self;
Expand Down
14 changes: 12 additions & 2 deletions src/attr_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,25 @@ use Language;
use std::ptr;

impl AttrIterator {
pub fn get_font(&mut self, desc: &mut FontDescription, language: Option<&Language>, extra_attrs: &[&Attribute]) {
pub fn get_font(
&mut self,
desc: &mut FontDescription,
language: Option<&Language>,
extra_attrs: &[&Attribute],
) {
unsafe {
let stash_vec: Vec<_> = extra_attrs.iter().rev().map(|v| v.to_glib_none()).collect();
let mut list: *mut glib_sys::GSList = ptr::null_mut();
for stash in &stash_vec {
list = glib_sys::g_slist_prepend(list, Ptr::to(stash.0));
}

pango_sys::pango_attr_iterator_get_font(self.to_glib_none_mut().0, desc.to_glib_none_mut().0, &mut language.to_glib_none().0, &mut list);
pango_sys::pango_attr_iterator_get_font(
self.to_glib_none_mut().0,
desc.to_glib_none_mut().0,
&mut language.to_glib_none().0,
&mut list,
);
}
}
}
15 changes: 12 additions & 3 deletions src/attr_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,30 @@ use Attribute;
impl AttrList {
pub fn change(&self, attr: Attribute) {
unsafe {
pango_sys::pango_attr_list_change(self.to_glib_none().0, attr.to_glib_none().0 as *mut _);
pango_sys::pango_attr_list_change(
self.to_glib_none().0,
attr.to_glib_none().0 as *mut _,
);
mem::forget(attr); //As attr transferred fully
}
}

pub fn insert(&self, attr: Attribute) {
unsafe {
pango_sys::pango_attr_list_insert(self.to_glib_none().0, attr.to_glib_none().0 as *mut _);
pango_sys::pango_attr_list_insert(
self.to_glib_none().0,
attr.to_glib_none().0 as *mut _,
);
mem::forget(attr); //As attr transferred fully
}
}

pub fn insert_before(&self, attr: Attribute) {
unsafe {
pango_sys::pango_attr_list_insert_before(self.to_glib_none().0, attr.to_glib_none().0 as *mut _);
pango_sys::pango_attr_list_insert_before(
self.to_glib_none().0,
attr.to_glib_none().0 as *mut _,
);
mem::forget(attr); //As attr transferred fully
}
}
Expand Down
80 changes: 26 additions & 54 deletions src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,124 +17,96 @@ use Weight;
impl Attribute {
#[cfg(any(feature = "v1_38", feature = "dox"))]
pub fn new_background_alpha(alpha: u16) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_background_alpha_new(alpha))
}
unsafe { from_glib_full(pango_sys::pango_attr_background_alpha_new(alpha)) }
}

pub fn new_background(red: u16, green: u16, blue: u16) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_background_new(red, green, blue))
}
unsafe { from_glib_full(pango_sys::pango_attr_background_new(red, green, blue)) }
}

pub fn new_fallback(enable_fallback: bool) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_fallback_new(enable_fallback.to_glib()))
from_glib_full(pango_sys::pango_attr_fallback_new(
enable_fallback.to_glib(),
))
}
}

pub fn new_family(family: &str) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_family_new(family.to_glib_none().0))
}
unsafe { from_glib_full(pango_sys::pango_attr_family_new(family.to_glib_none().0)) }
}

#[cfg(any(feature = "v1_38", feature = "dox"))]
pub fn new_foreground_alpha(alpha: u16) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_foreground_alpha_new(alpha))
}
unsafe { from_glib_full(pango_sys::pango_attr_foreground_alpha_new(alpha)) }
}

pub fn new_foreground(red: u16, green: u16, blue: u16) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_foreground_new(red, green, blue))
}
unsafe { from_glib_full(pango_sys::pango_attr_foreground_new(red, green, blue)) }
}

pub fn new_gravity_hint(hint: GravityHint) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_gravity_hint_new(hint.to_glib()))
}
unsafe { from_glib_full(pango_sys::pango_attr_gravity_hint_new(hint.to_glib())) }
}

pub fn new_gravity(gravity: Gravity) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_gravity_new(gravity.to_glib()))
}
unsafe { from_glib_full(pango_sys::pango_attr_gravity_new(gravity.to_glib())) }
}

pub fn new_letter_spacing(letter_spacing: i32) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_letter_spacing_new(letter_spacing))
}
unsafe { from_glib_full(pango_sys::pango_attr_letter_spacing_new(letter_spacing)) }
}

pub fn new_rise(rise: i32) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_rise_new(rise))
}
unsafe { from_glib_full(pango_sys::pango_attr_rise_new(rise)) }
}

pub fn new_scale(scale_factor: f64) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_scale_new(scale_factor))
}
unsafe { from_glib_full(pango_sys::pango_attr_scale_new(scale_factor)) }
}

pub fn new_stretch(stretch: Stretch) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_stretch_new(stretch.to_glib()))
}
unsafe { from_glib_full(pango_sys::pango_attr_stretch_new(stretch.to_glib())) }
}

pub fn new_strikethrough_color(red: u16, green: u16, blue: u16) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_strikethrough_color_new(red, green, blue))
from_glib_full(pango_sys::pango_attr_strikethrough_color_new(
red, green, blue,
))
}
}

pub fn new_strikethrough(strikethrough: bool) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_strikethrough_new(strikethrough.to_glib()))
from_glib_full(pango_sys::pango_attr_strikethrough_new(
strikethrough.to_glib(),
))
}
}

pub fn new_style(style: Style) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_style_new(style.to_glib()))
}
unsafe { from_glib_full(pango_sys::pango_attr_style_new(style.to_glib())) }
}

pub fn new_underline_color(red: u16, green: u16, blue: u16) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_underline_color_new(red, green, blue))
}
unsafe { from_glib_full(pango_sys::pango_attr_underline_color_new(red, green, blue)) }
}

pub fn new_underline(underline: Underline) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_underline_new(underline.to_glib()))
}
unsafe { from_glib_full(pango_sys::pango_attr_underline_new(underline.to_glib())) }
}

pub fn new_variant(variant: Variant) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_variant_new(variant.to_glib()))
}
unsafe { from_glib_full(pango_sys::pango_attr_variant_new(variant.to_glib())) }
}

pub fn new_weight(weight: Weight) -> Option<Attribute> {
unsafe {
from_glib_full(pango_sys::pango_attr_weight_new(weight.to_glib()))
}
unsafe { from_glib_full(pango_sys::pango_attr_weight_new(weight.to_glib())) }
}

pub fn get_attr_class(&self) -> AttrClass {
unsafe {
from_glib_full((*self.to_glib_none().0).klass)
}
unsafe { from_glib_full((*self.to_glib_none().0).klass) }
}

pub fn get_start_index(&self) -> u32 {
Expand Down
17 changes: 12 additions & 5 deletions src/auto/attr_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use AttrType;
use Attribute;
use glib::translate::*;
use pango_sys;
use std::mem;
use AttrType;
use Attribute;

glib_wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
Expand All @@ -21,19 +21,26 @@ glib_wrapper! {
impl AttrIterator {
pub fn get(&mut self, type_: AttrType) -> Option<Attribute> {
unsafe {
from_glib_none(pango_sys::pango_attr_iterator_get(self.to_glib_none_mut().0, type_.to_glib()))
from_glib_none(pango_sys::pango_attr_iterator_get(
self.to_glib_none_mut().0,
type_.to_glib(),
))
}
}

pub fn get_attrs(&mut self) -> Vec<Attribute> {
unsafe {
FromGlibPtrContainer::from_glib_full(pango_sys::pango_attr_iterator_get_attrs(self.to_glib_none_mut().0))
FromGlibPtrContainer::from_glib_full(pango_sys::pango_attr_iterator_get_attrs(
self.to_glib_none_mut().0,
))
}
}

pub fn next(&mut self) -> bool {
unsafe {
from_glib(pango_sys::pango_attr_iterator_next(self.to_glib_none_mut().0))
from_glib(pango_sys::pango_attr_iterator_next(
self.to_glib_none_mut().0,
))
}
}

Expand Down
34 changes: 22 additions & 12 deletions src/auto/attr_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use AttrIterator;
use Attribute;
use glib::translate::*;
use pango_sys;
use AttrIterator;
use Attribute;

glib_wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
Expand All @@ -20,20 +20,19 @@ glib_wrapper! {

impl AttrList {
pub fn new() -> AttrList {
unsafe {
from_glib_full(pango_sys::pango_attr_list_new())
}
unsafe { from_glib_full(pango_sys::pango_attr_list_new()) }
}

pub fn copy(&self) -> Option<AttrList> {
unsafe {
from_glib_full(pango_sys::pango_attr_list_copy(self.to_glib_none().0))
}
unsafe { from_glib_full(pango_sys::pango_attr_list_copy(self.to_glib_none().0)) }
}

pub fn filter<P: FnMut(&Attribute) -> bool>(&self, func: P) -> Option<AttrList> {
let func_data: P = func;
unsafe extern "C" fn func_func<P: FnMut(&Attribute) -> bool>(attribute: *mut pango_sys::PangoAttribute, user_data: glib_sys::gpointer) -> glib_sys::gboolean {
unsafe extern "C" fn func_func<P: FnMut(&Attribute) -> bool>(
attribute: *mut pango_sys::PangoAttribute,
user_data: glib_sys::gpointer,
) -> glib_sys::gboolean {
let attribute = from_glib_borrow(attribute);
let callback: *mut P = user_data as *const _ as usize as *mut P;
let res = (*callback)(&attribute);
Expand All @@ -42,19 +41,30 @@ impl AttrList {
let func = Some(func_func::<P> as _);
let super_callback0: &P = &func_data;
unsafe {
from_glib_full(pango_sys::pango_attr_list_filter(self.to_glib_none().0, func, super_callback0 as *const _ as usize as *mut _))
from_glib_full(pango_sys::pango_attr_list_filter(
self.to_glib_none().0,
func,
super_callback0 as *const _ as usize as *mut _,
))
}
}

pub fn get_iterator(&self) -> Option<AttrIterator> {
unsafe {
from_glib_full(pango_sys::pango_attr_list_get_iterator(self.to_glib_none().0))
from_glib_full(pango_sys::pango_attr_list_get_iterator(
self.to_glib_none().0,
))
}
}

pub fn splice(&self, other: &AttrList, pos: i32, len: i32) {
unsafe {
pango_sys::pango_attr_list_splice(self.to_glib_none().0, other.to_glib_none().0, pos, len);
pango_sys::pango_attr_list_splice(
self.to_glib_none().0,
other.to_glib_none().0,
pos,
len,
);
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/auto/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use AttrClass;
use glib::translate::*;
use pango_sys;
use AttrClass;

glib_wrapper! {
#[derive(Debug, PartialOrd, Ord, Hash)]
Expand All @@ -19,7 +19,10 @@ glib_wrapper! {
impl Attribute {
fn equal(&self, attr2: &Attribute) -> bool {
unsafe {
from_glib(pango_sys::pango_attribute_equal(self.to_glib_none().0, attr2.to_glib_none().0))
from_glib(pango_sys::pango_attribute_equal(
self.to_glib_none().0,
attr2.to_glib_none().0,
))
}
}

Expand Down

0 comments on commit 0f88598

Please sign in to comment.