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
use AccelGroup;
use Actionable;
use Bin;
use Container;
use MenuItem;
use Widget;
use ffi;
use glib::object::Downcast;
use glib::object::IsA;
use glib::translate::*;
use gobject_ffi;
glib_wrapper! {
pub struct ImageMenuItem(Object<ffi::GtkImageMenuItem>): MenuItem, Bin, Container, Widget, Actionable;
match fn {
get_type => || ffi::gtk_image_menu_item_get_type(),
}
}
impl ImageMenuItem {
pub fn new() -> ImageMenuItem {
assert_initialized_main_thread!();
unsafe {
Widget::from_glib_none(ffi::gtk_image_menu_item_new()).downcast_unchecked()
}
}
pub fn new_from_stock<'a, P: Into<Option<&'a AccelGroup>>>(stock_id: &str, accel_group: P) -> ImageMenuItem {
assert_initialized_main_thread!();
let accel_group = accel_group.into();
let accel_group = accel_group.to_glib_none();
unsafe {
Widget::from_glib_none(ffi::gtk_image_menu_item_new_from_stock(stock_id.to_glib_none().0, accel_group.0)).downcast_unchecked()
}
}
pub fn new_with_label(label: &str) -> ImageMenuItem {
assert_initialized_main_thread!();
unsafe {
Widget::from_glib_none(ffi::gtk_image_menu_item_new_with_label(label.to_glib_none().0)).downcast_unchecked()
}
}
pub fn new_with_mnemonic(label: &str) -> ImageMenuItem {
assert_initialized_main_thread!();
unsafe {
Widget::from_glib_none(ffi::gtk_image_menu_item_new_with_mnemonic(label.to_glib_none().0)).downcast_unchecked()
}
}
}
pub trait ImageMenuItemExt {
fn get_always_show_image(&self) -> bool;
fn get_image(&self) -> Option<Widget>;
fn get_use_stock(&self) -> bool;
fn set_accel_group(&self, accel_group: &AccelGroup);
fn set_always_show_image(&self, always_show: bool);
fn set_image<'a, P: IsA<Widget> + 'a, Q: Into<Option<&'a P>>>(&self, image: Q);
fn set_use_stock(&self, use_stock: bool);
}
impl<O: IsA<ImageMenuItem>> ImageMenuItemExt for O {
fn get_always_show_image(&self) -> bool {
unsafe {
from_glib(ffi::gtk_image_menu_item_get_always_show_image(self.to_glib_none().0))
}
}
fn get_image(&self) -> Option<Widget> {
unsafe {
from_glib_none(ffi::gtk_image_menu_item_get_image(self.to_glib_none().0))
}
}
fn get_use_stock(&self) -> bool {
unsafe {
from_glib(ffi::gtk_image_menu_item_get_use_stock(self.to_glib_none().0))
}
}
fn set_accel_group(&self, accel_group: &AccelGroup) {
unsafe {
ffi::gtk_image_menu_item_set_accel_group(self.to_glib_none().0, accel_group.to_glib_none().0);
}
}
fn set_always_show_image(&self, always_show: bool) {
unsafe {
ffi::gtk_image_menu_item_set_always_show_image(self.to_glib_none().0, always_show.to_glib());
}
}
fn set_image<'a, P: IsA<Widget> + 'a, Q: Into<Option<&'a P>>>(&self, image: Q) {
let image = image.into();
let image = image.to_glib_none();
unsafe {
ffi::gtk_image_menu_item_set_image(self.to_glib_none().0, image.0);
}
}
fn set_use_stock(&self, use_stock: bool) {
unsafe {
ffi::gtk_image_menu_item_set_use_stock(self.to_glib_none().0, use_stock.to_glib());
}
}
}