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
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
// This file was generated by gir (9e3f4cc) from gir-files (71d73f0)
// DO NOT EDIT

use Container;
use DestDefaults;
use Orientable;
use Scrollable;
use SelectionData;
use TargetEntry;
use ToolItem;
use ToolItemGroup;
use ToolPaletteDragTargets;
use ToolbarStyle;
use Widget;
use ffi;
use gdk;
use glib;
use glib::Value;
use glib::object::Downcast;
use glib::object::IsA;
use glib::translate::*;
use gobject_ffi;
use std::mem::transmute;

glib_wrapper! {
    pub struct ToolPalette(Object<ffi::GtkToolPalette>): Container, Widget, Orientable, Scrollable;

    match fn {
        get_type => || ffi::gtk_tool_palette_get_type(),
    }
}

impl ToolPalette {
    pub fn new() -> ToolPalette {
        assert_initialized_main_thread!();
        unsafe {
            Widget::from_glib_none(ffi::gtk_tool_palette_new()).downcast_unchecked()
        }
    }

    pub fn get_drag_target_group() -> Option<TargetEntry> {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_none(ffi::gtk_tool_palette_get_drag_target_group())
        }
    }

    pub fn get_drag_target_item() -> Option<TargetEntry> {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_none(ffi::gtk_tool_palette_get_drag_target_item())
        }
    }
}

pub trait ToolPaletteExt {
    fn add_drag_dest<P: IsA<Widget>>(&self, widget: &P, flags: DestDefaults, targets: ToolPaletteDragTargets, actions: gdk::DragAction);

    fn get_drag_item(&self, selection: &SelectionData) -> Option<Widget>;

    fn get_drop_group(&self, x: i32, y: i32) -> Option<ToolItemGroup>;

    fn get_drop_item(&self, x: i32, y: i32) -> Option<ToolItem>;

    fn get_exclusive(&self, group: &ToolItemGroup) -> bool;

    fn get_expand(&self, group: &ToolItemGroup) -> bool;

    fn get_group_position(&self, group: &ToolItemGroup) -> i32;

    fn get_icon_size(&self) -> i32;

    fn get_style(&self) -> ToolbarStyle;

    fn set_drag_source(&self, targets: ToolPaletteDragTargets);

    fn set_exclusive(&self, group: &ToolItemGroup, exclusive: bool);

    fn set_expand(&self, group: &ToolItemGroup, expand: bool);

    fn set_group_position(&self, group: &ToolItemGroup, position: i32);

    fn set_icon_size(&self, icon_size: i32);

    fn set_style(&self, style: ToolbarStyle);

    fn unset_icon_size(&self);

    fn unset_style(&self);

    fn get_property_icon_size_set(&self) -> bool;

    fn set_property_icon_size_set(&self, icon_size_set: bool);

    fn get_property_toolbar_style(&self) -> ToolbarStyle;

    fn set_property_toolbar_style(&self, toolbar_style: ToolbarStyle);
}

impl<O: IsA<ToolPalette> + IsA<glib::object::Object>> ToolPaletteExt for O {
    fn add_drag_dest<P: IsA<Widget>>(&self, widget: &P, flags: DestDefaults, targets: ToolPaletteDragTargets, actions: gdk::DragAction) {
        unsafe {
            ffi::gtk_tool_palette_add_drag_dest(self.to_glib_none().0, widget.to_glib_none().0, flags.to_glib(), targets.to_glib(), actions.to_glib());
        }
    }

    fn get_drag_item(&self, selection: &SelectionData) -> Option<Widget> {
        unsafe {
            from_glib_none(ffi::gtk_tool_palette_get_drag_item(self.to_glib_none().0, selection.to_glib_none().0))
        }
    }

    fn get_drop_group(&self, x: i32, y: i32) -> Option<ToolItemGroup> {
        unsafe {
            from_glib_none(ffi::gtk_tool_palette_get_drop_group(self.to_glib_none().0, x, y))
        }
    }

    fn get_drop_item(&self, x: i32, y: i32) -> Option<ToolItem> {
        unsafe {
            from_glib_none(ffi::gtk_tool_palette_get_drop_item(self.to_glib_none().0, x, y))
        }
    }

    fn get_exclusive(&self, group: &ToolItemGroup) -> bool {
        unsafe {
            from_glib(ffi::gtk_tool_palette_get_exclusive(self.to_glib_none().0, group.to_glib_none().0))
        }
    }

    fn get_expand(&self, group: &ToolItemGroup) -> bool {
        unsafe {
            from_glib(ffi::gtk_tool_palette_get_expand(self.to_glib_none().0, group.to_glib_none().0))
        }
    }

    fn get_group_position(&self, group: &ToolItemGroup) -> i32 {
        unsafe {
            ffi::gtk_tool_palette_get_group_position(self.to_glib_none().0, group.to_glib_none().0)
        }
    }

    fn get_icon_size(&self) -> i32 {
        unsafe {
            ffi::gtk_tool_palette_get_icon_size(self.to_glib_none().0)
        }
    }

    fn get_style(&self) -> ToolbarStyle {
        unsafe {
            from_glib(ffi::gtk_tool_palette_get_style(self.to_glib_none().0))
        }
    }

    fn set_drag_source(&self, targets: ToolPaletteDragTargets) {
        unsafe {
            ffi::gtk_tool_palette_set_drag_source(self.to_glib_none().0, targets.to_glib());
        }
    }

    fn set_exclusive(&self, group: &ToolItemGroup, exclusive: bool) {
        unsafe {
            ffi::gtk_tool_palette_set_exclusive(self.to_glib_none().0, group.to_glib_none().0, exclusive.to_glib());
        }
    }

    fn set_expand(&self, group: &ToolItemGroup, expand: bool) {
        unsafe {
            ffi::gtk_tool_palette_set_expand(self.to_glib_none().0, group.to_glib_none().0, expand.to_glib());
        }
    }

    fn set_group_position(&self, group: &ToolItemGroup, position: i32) {
        unsafe {
            ffi::gtk_tool_palette_set_group_position(self.to_glib_none().0, group.to_glib_none().0, position);
        }
    }

    fn set_icon_size(&self, icon_size: i32) {
        unsafe {
            ffi::gtk_tool_palette_set_icon_size(self.to_glib_none().0, icon_size);
        }
    }

    fn set_style(&self, style: ToolbarStyle) {
        unsafe {
            ffi::gtk_tool_palette_set_style(self.to_glib_none().0, style.to_glib());
        }
    }

    fn unset_icon_size(&self) {
        unsafe {
            ffi::gtk_tool_palette_unset_icon_size(self.to_glib_none().0);
        }
    }

    fn unset_style(&self) {
        unsafe {
            ffi::gtk_tool_palette_unset_style(self.to_glib_none().0);
        }
    }

    fn get_property_icon_size_set(&self) -> bool {
        let mut value = Value::from(&false);
        unsafe {
            gobject_ffi::g_object_get_property(self.to_glib_none().0, "icon-size-set".to_glib_none().0, value.to_glib_none_mut().0);
        }
        value.get().unwrap()
    }

    fn set_property_icon_size_set(&self, icon_size_set: bool) {
        unsafe {
            gobject_ffi::g_object_set_property(self.to_glib_none().0, "icon-size-set".to_glib_none().0, Value::from(&icon_size_set).to_glib_none().0);
        }
    }

    fn get_property_toolbar_style(&self) -> ToolbarStyle {
        let mut value = Value::from(&0);
        unsafe {
            gobject_ffi::g_object_get_property(self.to_glib_none().0, "toolbar-style".to_glib_none().0, value.to_glib_none_mut().0);
            from_glib(transmute(value.get::<i32>().unwrap()))
        }
    }

    fn set_property_toolbar_style(&self, toolbar_style: ToolbarStyle) {
        let toolbar_style = toolbar_style.to_glib() as i32;
        unsafe {
            gobject_ffi::g_object_set_property(self.to_glib_none().0, "toolbar-style".to_glib_none().0, Value::from(&toolbar_style).to_glib_none().0);
        }
    }
}