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
use ffi;
use glib::object::Downcast;
use glib::translate::*;
use std::ptr;
use Dialog;
use DialogFlags;
use IsA;
use Widget;
use Window;
use auto::DialogExt;
impl Dialog {
pub fn new_with_buttons<T: IsA<Window>>(title: Option<&str>, parent: Option<&T>,
flags: DialogFlags, buttons: &[(&str, i32)]) -> Dialog {
assert_initialized_main_thread!();
let ret: Dialog = unsafe {
Widget::from_glib_none(
ffi::gtk_dialog_new_with_buttons(title.to_glib_none().0, parent.to_glib_none().0,
flags.to_glib(), ptr::null_mut()))
.downcast_unchecked()
};
ret.add_buttons(buttons);
ret
}
}
pub trait DialogExtManual {
fn add_buttons(&self, buttons: &[(&str, i32)]);
}
impl<O: DialogExt> DialogExtManual for O {
fn add_buttons(&self, buttons: &[(&str, i32)]) {
for &(text, id) in buttons {
O::add_button(self, text, id);
}
}
}