forked from gtk-rs/gtk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
level_bar.rs
157 lines (137 loc) · 4.44 KB
/
level_bar.rs
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
// This file was generated by gir (b7f5189) from gir-files (71d73f0)
// DO NOT EDIT
#[cfg(feature = "v3_6")]
use LevelBarMode;
use Orientable;
use Widget;
use ffi;
use glib::object::Downcast;
#[cfg(feature = "v3_6")]
use glib::signal::connect;
use glib::translate::*;
#[cfg(feature = "v3_6")]
use glib_ffi;
#[cfg(feature = "v3_6")]
use libc;
#[cfg(feature = "v3_6")]
use std::boxed::Box as Box_;
#[cfg(feature = "v3_6")]
use std::mem;
#[cfg(feature = "v3_6")]
use std::mem::transmute;
glib_wrapper! {
pub struct LevelBar(Object<ffi::GtkLevelBar>): Widget, Orientable;
match fn {
get_type => || ffi::gtk_level_bar_get_type(),
}
}
impl LevelBar {
#[cfg(feature = "v3_6")]
pub fn new() -> LevelBar {
assert_initialized_main_thread!();
unsafe {
Widget::from_glib_none(ffi::gtk_level_bar_new()).downcast_unchecked()
}
}
#[cfg(feature = "v3_6")]
pub fn new_for_interval(min_value: f64, max_value: f64) -> LevelBar {
assert_initialized_main_thread!();
unsafe {
Widget::from_glib_none(ffi::gtk_level_bar_new_for_interval(min_value, max_value)).downcast_unchecked()
}
}
#[cfg(feature = "v3_6")]
pub fn add_offset_value(&self, name: &str, value: f64) {
unsafe {
ffi::gtk_level_bar_add_offset_value(self.to_glib_none().0, name.to_glib_none().0, value);
}
}
#[cfg(feature = "v3_8")]
pub fn get_inverted(&self) -> bool {
unsafe {
from_glib(ffi::gtk_level_bar_get_inverted(self.to_glib_none().0))
}
}
#[cfg(feature = "v3_6")]
pub fn get_max_value(&self) -> f64 {
unsafe {
ffi::gtk_level_bar_get_max_value(self.to_glib_none().0)
}
}
#[cfg(feature = "v3_6")]
pub fn get_min_value(&self) -> f64 {
unsafe {
ffi::gtk_level_bar_get_min_value(self.to_glib_none().0)
}
}
#[cfg(feature = "v3_6")]
pub fn get_mode(&self) -> LevelBarMode {
unsafe {
from_glib(ffi::gtk_level_bar_get_mode(self.to_glib_none().0))
}
}
#[cfg(feature = "v3_6")]
pub fn get_offset_value<'a, T: Into<Option<&'a str>>>(&self, name: T) -> Option<f64> {
unsafe {
let mut value = mem::uninitialized();
let ret = from_glib(ffi::gtk_level_bar_get_offset_value(self.to_glib_none().0, name.into().to_glib_none().0, &mut value));
if ret { Some(value) } else { None }
}
}
#[cfg(feature = "v3_6")]
pub fn get_value(&self) -> f64 {
unsafe {
ffi::gtk_level_bar_get_value(self.to_glib_none().0)
}
}
#[cfg(feature = "v3_6")]
pub fn remove_offset_value<'a, T: Into<Option<&'a str>>>(&self, name: T) {
unsafe {
ffi::gtk_level_bar_remove_offset_value(self.to_glib_none().0, name.into().to_glib_none().0);
}
}
#[cfg(feature = "v3_8")]
pub fn set_inverted(&self, inverted: bool) {
unsafe {
ffi::gtk_level_bar_set_inverted(self.to_glib_none().0, inverted.to_glib());
}
}
#[cfg(feature = "v3_6")]
pub fn set_max_value(&self, value: f64) {
unsafe {
ffi::gtk_level_bar_set_max_value(self.to_glib_none().0, value);
}
}
#[cfg(feature = "v3_6")]
pub fn set_min_value(&self, value: f64) {
unsafe {
ffi::gtk_level_bar_set_min_value(self.to_glib_none().0, value);
}
}
#[cfg(feature = "v3_6")]
pub fn set_mode(&self, mode: LevelBarMode) {
unsafe {
ffi::gtk_level_bar_set_mode(self.to_glib_none().0, mode.to_glib());
}
}
#[cfg(feature = "v3_6")]
pub fn set_value(&self, value: f64) {
unsafe {
ffi::gtk_level_bar_set_value(self.to_glib_none().0, value);
}
}
#[cfg(feature = "v3_6")]
pub fn connect_offset_changed<F: Fn(&LevelBar, &str) + 'static>(&self, f: F) -> u64 {
unsafe {
let f: Box_<Box_<Fn(&LevelBar, &str) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "offset-changed",
transmute(offset_changed_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
}
#[cfg(feature = "v3_6")]
unsafe extern "C" fn offset_changed_trampoline(this: *mut ffi::GtkLevelBar, name: *mut libc::c_char, f: glib_ffi::gpointer) {
callback_guard!();
let f: &Box_<Fn(&LevelBar, &str) + 'static> = transmute(f);
f(&from_glib_none(this), &String::from_glib_none(name))
}