1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2013-2017, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>

use gdk_pixbuf;
use glib::object::IsA;
use glib::translate::*;
use gtk;
use gtk_source_sys;
use MarkAttributes;

impl MarkAttributes {
    pub fn get_pixbuf(&self) -> Option<gdk_pixbuf::Pixbuf> {
        unsafe {
            let ptr = gtk_source_sys::gtk_source_mark_attributes_get_pixbuf(self.to_glib_none().0);
            if ptr.is_null() {
                None
            } else {
                Some(from_glib_full(mut_override(ptr)))
            }
        }
    }

    pub fn render_icon<P: IsA<gtk::Widget>>(
        &self,
        widget: &P,
        size: i32,
    ) -> Option<gdk_pixbuf::Pixbuf> {
        unsafe {
            let ptr = gtk_source_sys::gtk_source_mark_attributes_render_icon(
                self.to_glib_none().0,
                widget.as_ref().to_glib_none().0,
                size,
            );
            if ptr.is_null() {
                None
            } else {
                Some(from_glib_full(mut_override(ptr)))
            }
        }
    }
}