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

Commit

Permalink
Moved attr_* functions to Attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
EPashkin committed Jul 8, 2017
1 parent b875d63 commit 567cdba
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 120 deletions.
4 changes: 4 additions & 0 deletions Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ status = "generate"
name = "log2vis_get_embedding_levels"
#out param
ignore = true
[[object.function]]
pattern = "attr_.+"
#moved to Attribute
ignore = true

[[object]]
name = "Pango.AttrList"
Expand Down
124 changes: 124 additions & 0 deletions src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,133 @@

use Attribute;
use AttrClass;
use Gravity;
use GravityHint;
use Stretch;
use Style;
use Underline;
use Variant;
use Weight;
use ffi;
use glib::translate::*;

impl Attribute {
#[cfg(feature = "v1_38")]
pub fn new_background_alpha(alpha: u16) -> Option<Attribute> {
unsafe {
from_glib_full(ffi::pango_attr_background_alpha_new(alpha))
}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pub fn get_attr_class(&self) -> AttrClass {
unsafe {
from_glib_full((*self.to_glib_none().0).klass)
Expand Down
120 changes: 0 additions & 120 deletions src/auto/functions.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
// This file was generated by gir (9e3f4cc) from gir-files (0bcaef9)
// DO NOT EDIT

use Attribute;
use Direction;
use Gravity;
use GravityHint;
use Rectangle;
use Stretch;
use Style;
use Underline;
use Variant;
use Weight;
use ffi;
Expand All @@ -18,122 +14,6 @@ use std::mem;
use std::ptr;


#[cfg(feature = "v1_38")]
pub fn attr_background_alpha_new(alpha: u16) -> Option<Attribute> {
unsafe {
from_glib_full(ffi::pango_attr_background_alpha_new(alpha))
}
}

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

pub fn attr_fallback_new(enable_fallback: bool) -> Option<Attribute> {
unsafe {
from_glib_full(ffi::pango_attr_fallback_new(enable_fallback.to_glib()))
}
}

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

#[cfg(feature = "v1_38")]
pub fn attr_foreground_alpha_new(alpha: u16) -> Option<Attribute> {
unsafe {
from_glib_full(ffi::pango_attr_foreground_alpha_new(alpha))
}
}

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

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

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

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

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

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

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

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

pub fn attr_strikethrough_new(strikethrough: bool) -> Option<Attribute> {
unsafe {
from_glib_full(ffi::pango_attr_strikethrough_new(strikethrough.to_glib()))
}
}

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

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

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

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

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

//pub fn break_(text: &str, length: i32, analysis: /*Ignored*/&mut Analysis, attrs: /*Ignored*/&[&LogAttr]) {
// unsafe { TODO: call ffi::pango_break() }
//}
Expand Down

0 comments on commit 567cdba

Please sign in to comment.