|
1 |
| -// Copyright 2017, The Gtk-rs Project Developers. |
2 |
| -// See the COPYRIGHT file at the top-level directory of this distribution. |
3 |
| -// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> |
4 |
| - |
5 |
| -use glib::translate::*; |
6 |
| -use pango_sys; |
7 |
| -use AttrClass; |
8 | 1 | use Attribute;
|
| 2 | +use FontDescription; |
9 | 3 | use Gravity;
|
10 | 4 | use GravityHint;
|
| 5 | +use Language; |
| 6 | +use Rectangle; |
11 | 7 | use Stretch;
|
12 | 8 | use Style;
|
13 | 9 | use Underline;
|
14 |
| -use Variant; |
15 | 10 | use Weight;
|
16 | 11 |
|
| 12 | +use glib::translate::from_glib_full; |
| 13 | +use glib::translate::ToGlib; |
| 14 | +use glib::translate::ToGlibPtr; |
| 15 | + |
17 | 16 | impl Attribute {
|
18 | 17 | #[cfg(any(feature = "v1_38", feature = "dox"))]
|
19 |
| - pub fn new_background_alpha(alpha: u16) -> Option<Attribute> { |
| 18 | + pub fn background_alpha_new(alpha: u16) -> Option<Attribute> { |
20 | 19 | unsafe { from_glib_full(pango_sys::pango_attr_background_alpha_new(alpha)) }
|
21 | 20 | }
|
22 | 21 |
|
23 |
| - pub fn new_background(red: u16, green: u16, blue: u16) -> Option<Attribute> { |
| 22 | + pub fn background_new(red: u16, green: u16, blue: u16) -> Option<Attribute> { |
24 | 23 | unsafe { from_glib_full(pango_sys::pango_attr_background_new(red, green, blue)) }
|
25 | 24 | }
|
26 | 25 |
|
27 |
| - pub fn new_fallback(enable_fallback: bool) -> Option<Attribute> { |
| 26 | + pub fn fallback_new(enable_fallback: bool) -> Option<Attribute> { |
28 | 27 | unsafe {
|
29 | 28 | from_glib_full(pango_sys::pango_attr_fallback_new(
|
30 | 29 | enable_fallback.to_glib(),
|
31 | 30 | ))
|
32 | 31 | }
|
33 | 32 | }
|
34 | 33 |
|
35 |
| - pub fn new_family(family: &str) -> Option<Attribute> { |
| 34 | + // TODO: available at 1.44 |
| 35 | + // pub fn allow_breaks_new(allow_breaks: bool) -> Option<Attribute> { |
| 36 | + // unsafe { |
| 37 | + // from_glib_full(pango_sys::pango_attr_allow_breaks_new( |
| 38 | + // allow_breaks.to_glib(), |
| 39 | + // )) |
| 40 | + // } |
| 41 | + // } |
| 42 | + |
| 43 | + // TODO: available at 1.44 |
| 44 | + // pub fn insert_hyphens_new(insert_hyphens: bool) -> Option<Attribute> { |
| 45 | + // unsafe { |
| 46 | + // from_glib_full(pango_sys::pango_attr_insert_hyphens_new( |
| 47 | + // insert_hyphens.to_glib(), |
| 48 | + // )) |
| 49 | + // } |
| 50 | + // } |
| 51 | + |
| 52 | + // TODO: available at 1.44, needs PangoShowFlags |
| 53 | + // pub fn show_new(flags: PangoShowFlags) -> Option<Attribute> { |
| 54 | + // unsafe { |
| 55 | + // from_glib_full(pango_sys::pango_attr_show_new( |
| 56 | + // flags.to_glib(), |
| 57 | + // )) |
| 58 | + // } |
| 59 | + // } |
| 60 | + |
| 61 | + pub fn language_new(language: &Language) -> Option<Attribute> { |
| 62 | + unsafe { |
| 63 | + from_glib_full(pango_sys::pango_attr_language_new( |
| 64 | + language.to_glib_none().0, |
| 65 | + )) |
| 66 | + } |
| 67 | + } |
| 68 | + |
| 69 | + pub fn family_new(family: &str) -> Option<Attribute> { |
36 | 70 | unsafe { from_glib_full(pango_sys::pango_attr_family_new(family.to_glib_none().0)) }
|
37 | 71 | }
|
38 | 72 |
|
39 | 73 | #[cfg(any(feature = "v1_38", feature = "dox"))]
|
40 |
| - pub fn new_foreground_alpha(alpha: u16) -> Option<Attribute> { |
| 74 | + pub fn font_features_new(features: &str) -> Option<Attribute> { |
| 75 | + unsafe { |
| 76 | + from_glib_full(pango_sys::pango_attr_font_features_new( |
| 77 | + features.to_glib_none().0, |
| 78 | + )) |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + #[cfg(any(feature = "v1_38", feature = "dox"))] |
| 83 | + pub fn foreground_alpha_new(alpha: u16) -> Option<Attribute> { |
41 | 84 | unsafe { from_glib_full(pango_sys::pango_attr_foreground_alpha_new(alpha)) }
|
42 | 85 | }
|
43 | 86 |
|
44 |
| - pub fn new_foreground(red: u16, green: u16, blue: u16) -> Option<Attribute> { |
| 87 | + pub fn foreground_new(red: u16, green: u16, blue: u16) -> Option<Attribute> { |
45 | 88 | unsafe { from_glib_full(pango_sys::pango_attr_foreground_new(red, green, blue)) }
|
46 | 89 | }
|
47 | 90 |
|
48 |
| - pub fn new_gravity_hint(hint: GravityHint) -> Option<Attribute> { |
| 91 | + pub fn gravity_hint_new(hint: GravityHint) -> Option<Attribute> { |
49 | 92 | unsafe { from_glib_full(pango_sys::pango_attr_gravity_hint_new(hint.to_glib())) }
|
50 | 93 | }
|
51 | 94 |
|
52 |
| - pub fn new_gravity(gravity: Gravity) -> Option<Attribute> { |
| 95 | + pub fn gravity_new(gravity: Gravity) -> Option<Attribute> { |
53 | 96 | unsafe { from_glib_full(pango_sys::pango_attr_gravity_new(gravity.to_glib())) }
|
54 | 97 | }
|
55 | 98 |
|
56 |
| - pub fn new_letter_spacing(letter_spacing: i32) -> Option<Attribute> { |
| 99 | + pub fn letter_spacing_new(letter_spacing: i32) -> Option<Attribute> { |
57 | 100 | unsafe { from_glib_full(pango_sys::pango_attr_letter_spacing_new(letter_spacing)) }
|
58 | 101 | }
|
59 | 102 |
|
60 |
| - pub fn new_rise(rise: i32) -> Option<Attribute> { |
| 103 | + pub fn rise_new(rise: i32) -> Option<Attribute> { |
61 | 104 | unsafe { from_glib_full(pango_sys::pango_attr_rise_new(rise)) }
|
62 | 105 | }
|
63 | 106 |
|
64 |
| - pub fn new_scale(scale_factor: f64) -> Option<Attribute> { |
65 |
| - unsafe { from_glib_full(pango_sys::pango_attr_scale_new(scale_factor)) } |
66 |
| - } |
67 |
| - |
68 |
| - pub fn new_size(size: i32) -> Option<Attribute> { |
| 107 | + pub fn size_new(size: i32) -> Option<Attribute> { |
69 | 108 | unsafe { from_glib_full(pango_sys::pango_attr_size_new(size)) }
|
70 | 109 | }
|
71 | 110 |
|
72 |
| - pub fn new_size_absolute(size: i32) -> Option<Attribute> { |
| 111 | + pub fn size_new_absolute(size: i32) -> Option<Attribute> { |
73 | 112 | unsafe { from_glib_full(pango_sys::pango_attr_size_new_absolute(size)) }
|
74 | 113 | }
|
75 | 114 |
|
76 |
| - pub fn new_stretch(stretch: Stretch) -> Option<Attribute> { |
| 115 | + pub fn font_desc_new(desc: &FontDescription) -> Option<Attribute> { |
| 116 | + unsafe { from_glib_full(pango_sys::pango_attr_font_desc_new(desc.to_glib_none().0)) } |
| 117 | + } |
| 118 | + |
| 119 | + pub fn pango_attr_shape_new( |
| 120 | + ink_rect: &Rectangle, |
| 121 | + logical_rect: &Rectangle, |
| 122 | + ) -> Option<Attribute> { |
| 123 | + unsafe { |
| 124 | + from_glib_full(pango_sys::pango_attr_shape_new( |
| 125 | + ink_rect.to_glib_none().0, |
| 126 | + logical_rect.to_glib_none().0, |
| 127 | + )) |
| 128 | + } |
| 129 | + } |
| 130 | + |
| 131 | + pub fn scale_new(scale_factor: f64) -> Option<Attribute> { |
| 132 | + unsafe { from_glib_full(pango_sys::pango_attr_scale_new(scale_factor)) } |
| 133 | + } |
| 134 | + |
| 135 | + pub fn stretch_new(stretch: Stretch) -> Option<Attribute> { |
77 | 136 | unsafe { from_glib_full(pango_sys::pango_attr_stretch_new(stretch.to_glib())) }
|
78 | 137 | }
|
79 | 138 |
|
80 |
| - pub fn new_strikethrough_color(red: u16, green: u16, blue: u16) -> Option<Attribute> { |
| 139 | + pub fn strikethrough_color_new(red: u16, green: u16, blue: u16) -> Option<Attribute> { |
81 | 140 | unsafe {
|
82 | 141 | from_glib_full(pango_sys::pango_attr_strikethrough_color_new(
|
83 | 142 | red, green, blue,
|
84 | 143 | ))
|
85 | 144 | }
|
86 | 145 | }
|
87 | 146 |
|
88 |
| - pub fn new_strikethrough(strikethrough: bool) -> Option<Attribute> { |
| 147 | + pub fn strikethrough_new(strikethrough: bool) -> Option<Attribute> { |
89 | 148 | unsafe {
|
90 | 149 | from_glib_full(pango_sys::pango_attr_strikethrough_new(
|
91 | 150 | strikethrough.to_glib(),
|
92 | 151 | ))
|
93 | 152 | }
|
94 | 153 | }
|
95 | 154 |
|
96 |
| - pub fn new_style(style: Style) -> Option<Attribute> { |
| 155 | + pub fn style_new(style: Style) -> Option<Attribute> { |
97 | 156 | unsafe { from_glib_full(pango_sys::pango_attr_style_new(style.to_glib())) }
|
98 | 157 | }
|
99 | 158 |
|
100 |
| - pub fn new_underline_color(red: u16, green: u16, blue: u16) -> Option<Attribute> { |
| 159 | + pub fn underline_color_new(red: u16, green: u16, blue: u16) -> Option<Attribute> { |
101 | 160 | unsafe { from_glib_full(pango_sys::pango_attr_underline_color_new(red, green, blue)) }
|
102 | 161 | }
|
103 | 162 |
|
104 |
| - pub fn new_underline(underline: Underline) -> Option<Attribute> { |
| 163 | + pub fn underline_new(underline: Underline) -> Option<Attribute> { |
105 | 164 | unsafe { from_glib_full(pango_sys::pango_attr_underline_new(underline.to_glib())) }
|
106 | 165 | }
|
107 | 166 |
|
108 |
| - pub fn new_variant(variant: Variant) -> Option<Attribute> { |
| 167 | + /*pub fn attr_variant_new(variant: Variant) -> Option<Attribute> { |
109 | 168 | unsafe { from_glib_full(pango_sys::pango_attr_variant_new(variant.to_glib())) }
|
110 |
| - } |
| 169 | + }*/ |
111 | 170 |
|
112 |
| - pub fn new_weight(weight: Weight) -> Option<Attribute> { |
| 171 | + pub fn weight_new(weight: Weight) -> Option<Attribute> { |
113 | 172 | unsafe { from_glib_full(pango_sys::pango_attr_weight_new(weight.to_glib())) }
|
114 | 173 | }
|
115 |
| - |
116 |
| - pub fn get_attr_class(&self) -> AttrClass { |
117 |
| - unsafe { from_glib_full((*self.to_glib_none().0).klass) } |
118 |
| - } |
119 |
| - |
120 |
| - pub fn get_start_index(&self) -> u32 { |
121 |
| - unsafe { |
122 |
| - let stash = self.to_glib_none(); |
123 |
| - (*stash.0).start_index |
124 |
| - } |
125 |
| - } |
126 |
| - |
127 |
| - pub fn get_end_index(&self) -> u32 { |
128 |
| - unsafe { |
129 |
| - let stash = self.to_glib_none(); |
130 |
| - (*stash.0).end_index |
131 |
| - } |
132 |
| - } |
133 |
| - |
134 |
| - pub fn set_start_index(&mut self, index: u32) { |
135 |
| - unsafe { |
136 |
| - let stash = self.to_glib_none_mut(); |
137 |
| - (*stash.0).start_index = index; |
138 |
| - } |
139 |
| - } |
140 |
| - |
141 |
| - pub fn set_end_index(&mut self, index: u32) { |
142 |
| - unsafe { |
143 |
| - let stash = self.to_glib_none_mut(); |
144 |
| - (*stash.0).end_index = index; |
145 |
| - } |
146 |
| - } |
147 | 174 | }
|
0 commit comments