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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// This file was generated by gir (4b09025) from gir-files (71d73f0)
// DO NOT EDIT

use IconSource;
use StyleContext;
#[cfg(feature = "v3_10")]
use cairo;
use ffi;
#[cfg(feature = "v3_10")]
use gdk;
use gdk_pixbuf;
use glib::translate::*;

glib_wrapper! {
    pub struct IconSet(Shared<ffi::GtkIconSet>);

    match fn {
        ref => |ptr| ffi::gtk_icon_set_ref(ptr),
        unref => |ptr| ffi::gtk_icon_set_unref(ptr),
    }
}

impl IconSet {
    pub fn new() -> IconSet {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gtk_icon_set_new())
        }
    }

    pub fn new_from_pixbuf(pixbuf: &gdk_pixbuf::Pixbuf) -> IconSet {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gtk_icon_set_new_from_pixbuf(pixbuf.to_glib_none().0))
        }
    }

    pub fn add_source(&self, source: &IconSource) {
        unsafe {
            ffi::gtk_icon_set_add_source(self.to_glib_none().0, source.to_glib_none().0);
        }
    }

    pub fn copy(&self) -> Option<IconSet> {
        unsafe {
            from_glib_full(ffi::gtk_icon_set_copy(self.to_glib_none().0))
        }
    }

    //pub fn get_sizes(&self, sizes: /*Unimplemented*/CArray TypeId { ns_id: 0, id: 14 }) -> i32 {
    //    unsafe { TODO: call ffi::gtk_icon_set_get_sizes() }
    //}

    pub fn render_icon_pixbuf(&self, context: &StyleContext, size: i32) -> Option<gdk_pixbuf::Pixbuf> {
        unsafe {
            from_glib_full(ffi::gtk_icon_set_render_icon_pixbuf(self.to_glib_none().0, context.to_glib_none().0, size))
        }
    }

    #[cfg(feature = "v3_10")]
    pub fn render_icon_surface<'a, P: Into<Option<&'a gdk::Window>>>(&self, context: &StyleContext, size: i32, scale: i32, for_window: P) -> Option<cairo::Surface> {
        let for_window = for_window.into();
        let for_window = for_window.to_glib_none();
        unsafe {
            from_glib_full(ffi::gtk_icon_set_render_icon_surface(self.to_glib_none().0, context.to_glib_none().0, size, scale, for_window.0))
        }
    }
}