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

Commit 3b6bc0f

Browse files
committed
impl Color
1 parent e8de622 commit 3b6bc0f

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

src/analysis.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use Font;
1111
use Gravity;
1212
use Language;
1313
use Script;
14-
use pango_sys::{PangoAttribute, PangoAttrColor, PangoColor};
1514

1615
#[repr(C)]
1716
pub struct Analysis(pango_sys::PangoAnalysis);

src/attr_class.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub struct AttrClass(*mut pango_sys::PangoAttrClass);
5353

5454
impl AttrClass {
5555
pub fn get_type(&self) -> AttrType {
56-
unsafe{ from_glib((*self.0).type_) }
56+
unsafe { from_glib((*self.0).type_) }
5757
}
5858
}
5959

src/color.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2018, 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 Color;
7+
8+
impl Color {
9+
pub fn red(&self) -> u16 {
10+
unsafe {
11+
let stash = self.to_glib_none();
12+
(*stash.0).red
13+
}
14+
}
15+
16+
pub fn green(&self) -> u16 {
17+
unsafe {
18+
let stash = self.to_glib_none();
19+
(*stash.0).green
20+
}
21+
}
22+
23+
pub fn blue(&self) -> u16 {
24+
unsafe {
25+
let stash = self.to_glib_none();
26+
(*stash.0).blue
27+
}
28+
}
29+
}

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub use attr_color::AttrColor;
3838
pub mod attr_iterator;
3939
pub mod attr_list;
4040
pub mod attribute;
41+
pub mod color;
4142
pub mod font_description;
4243
mod functions;
4344
pub mod gravity;

0 commit comments

Comments
 (0)