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
18
pub fn new_background_alpha ( alpha : u16 ) -> Option < Attribute > {
@@ -32,10 +31,54 @@ impl Attribute {
32
31
}
33
32
}
34
33
34
+ // TODO: available at 1.44
35
+ // pub fn new_allow_breaks(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 new_insert_hyphens(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 new_show(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 new_language ( 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
+
35
69
pub fn new_family ( 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
73
+ #[ cfg( any( feature = "v1_38" , feature = "dox" ) ) ]
74
+ pub fn new_font_features ( 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
+
39
82
#[ cfg( any( feature = "v1_38" , feature = "dox" ) ) ]
40
83
pub fn new_foreground_alpha ( alpha : u16 ) -> Option < Attribute > {
41
84
unsafe { from_glib_full ( pango_sys:: pango_attr_foreground_alpha_new ( alpha) ) }
@@ -61,18 +104,34 @@ impl 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
107
pub fn new_size ( 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 new_absolute_size ( size : i32 ) -> Option < Attribute > {
73
112
unsafe { from_glib_full ( pango_sys:: pango_attr_size_new_absolute ( size) ) }
74
113
}
75
114
115
+ pub fn new_font_desc ( 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 new_shape (
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 new_scale ( scale_factor : f64 ) -> Option < Attribute > {
132
+ unsafe { from_glib_full ( pango_sys:: pango_attr_scale_new ( scale_factor) ) }
133
+ }
134
+
76
135
pub fn new_stretch ( stretch : Stretch ) -> Option < Attribute > {
77
136
unsafe { from_glib_full ( pango_sys:: pango_attr_stretch_new ( stretch. to_glib ( ) ) ) }
78
137
}
@@ -105,43 +164,11 @@ impl 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
171
pub fn new_weight ( 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