gtk/
color_chooser.rs

1// Copyright 2013-2015, 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
5use gdk::RGBA;
6use gdk_sys;
7use glib::object::IsA;
8use glib::translate::*;
9use gtk_sys;
10use libc::c_int;
11use ColorChooser;
12use Orientation;
13
14pub trait ColorChooserExtManual: 'static {
15    fn add_palette(&self, orientation: Orientation, colors_per_line: i32, colors: &[RGBA]);
16}
17
18impl<O: IsA<ColorChooser>> ColorChooserExtManual for O {
19    fn add_palette(&self, orientation: Orientation, colors_per_line: i32, colors: &[RGBA]) {
20        unsafe {
21            gtk_sys::gtk_color_chooser_add_palette(
22                self.as_ref().to_glib_none().0,
23                orientation.to_glib(),
24                colors_per_line,
25                colors.len() as c_int,
26                colors.as_ptr() as *mut gdk_sys::GdkRGBA,
27            )
28        }
29    }
30}