gtk/auto/
shortcuts_window.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use glib;
6use glib::object::Cast;
7use glib::object::IsA;
8use glib::object::ObjectExt;
9use glib::signal::connect_raw;
10use glib::signal::SignalHandlerId;
11use glib::translate::*;
12use glib::GString;
13use glib::StaticType;
14use glib::Value;
15use glib_sys;
16use gobject_sys;
17use gtk_sys;
18use std::boxed::Box as Box_;
19use std::fmt;
20use std::mem::transmute;
21use Bin;
22use Buildable;
23use Container;
24use Widget;
25use Window;
26
27glib_wrapper! {
28    pub struct ShortcutsWindow(Object<gtk_sys::GtkShortcutsWindow, gtk_sys::GtkShortcutsWindowClass, ShortcutsWindowClass>) @extends Window, Bin, Container, Widget, @implements Buildable;
29
30    match fn {
31        get_type => || gtk_sys::gtk_shortcuts_window_get_type(),
32    }
33}
34
35pub const NONE_SHORTCUTS_WINDOW: Option<&ShortcutsWindow> = None;
36
37pub trait ShortcutsWindowExt: 'static {
38    fn get_property_section_name(&self) -> Option<GString>;
39
40    fn set_property_section_name(&self, section_name: Option<&str>);
41
42    fn get_property_view_name(&self) -> Option<GString>;
43
44    fn set_property_view_name(&self, view_name: Option<&str>);
45
46    fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
47
48    fn emit_close(&self);
49
50    fn connect_search<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
51
52    fn emit_search(&self);
53
54    fn connect_property_section_name_notify<F: Fn(&Self) + 'static>(&self, f: F)
55        -> SignalHandlerId;
56
57    fn connect_property_view_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
58}
59
60impl<O: IsA<ShortcutsWindow>> ShortcutsWindowExt for O {
61    fn get_property_section_name(&self) -> Option<GString> {
62        unsafe {
63            let mut value = Value::from_type(<GString as StaticType>::static_type());
64            gobject_sys::g_object_get_property(
65                self.to_glib_none().0 as *mut gobject_sys::GObject,
66                b"section-name\0".as_ptr() as *const _,
67                value.to_glib_none_mut().0,
68            );
69            value.get()
70        }
71    }
72
73    fn set_property_section_name(&self, section_name: Option<&str>) {
74        unsafe {
75            gobject_sys::g_object_set_property(
76                self.to_glib_none().0 as *mut gobject_sys::GObject,
77                b"section-name\0".as_ptr() as *const _,
78                Value::from(section_name).to_glib_none().0,
79            );
80        }
81    }
82
83    fn get_property_view_name(&self) -> Option<GString> {
84        unsafe {
85            let mut value = Value::from_type(<GString as StaticType>::static_type());
86            gobject_sys::g_object_get_property(
87                self.to_glib_none().0 as *mut gobject_sys::GObject,
88                b"view-name\0".as_ptr() as *const _,
89                value.to_glib_none_mut().0,
90            );
91            value.get()
92        }
93    }
94
95    fn set_property_view_name(&self, view_name: Option<&str>) {
96        unsafe {
97            gobject_sys::g_object_set_property(
98                self.to_glib_none().0 as *mut gobject_sys::GObject,
99                b"view-name\0".as_ptr() as *const _,
100                Value::from(view_name).to_glib_none().0,
101            );
102        }
103    }
104
105    fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
106        unsafe extern "C" fn close_trampoline<P, F: Fn(&P) + 'static>(
107            this: *mut gtk_sys::GtkShortcutsWindow,
108            f: glib_sys::gpointer,
109        ) where
110            P: IsA<ShortcutsWindow>,
111        {
112            let f: &F = &*(f as *const F);
113            f(&ShortcutsWindow::from_glib_borrow(this).unsafe_cast())
114        }
115        unsafe {
116            let f: Box_<F> = Box_::new(f);
117            connect_raw(
118                self.as_ptr() as *mut _,
119                b"close\0".as_ptr() as *const _,
120                Some(transmute(close_trampoline::<Self, F> as usize)),
121                Box_::into_raw(f),
122            )
123        }
124    }
125
126    fn emit_close(&self) {
127        let _ = unsafe {
128            glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_sys::GObject)
129                .emit("close", &[])
130                .unwrap()
131        };
132    }
133
134    fn connect_search<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
135        unsafe extern "C" fn search_trampoline<P, F: Fn(&P) + 'static>(
136            this: *mut gtk_sys::GtkShortcutsWindow,
137            f: glib_sys::gpointer,
138        ) where
139            P: IsA<ShortcutsWindow>,
140        {
141            let f: &F = &*(f as *const F);
142            f(&ShortcutsWindow::from_glib_borrow(this).unsafe_cast())
143        }
144        unsafe {
145            let f: Box_<F> = Box_::new(f);
146            connect_raw(
147                self.as_ptr() as *mut _,
148                b"search\0".as_ptr() as *const _,
149                Some(transmute(search_trampoline::<Self, F> as usize)),
150                Box_::into_raw(f),
151            )
152        }
153    }
154
155    fn emit_search(&self) {
156        let _ = unsafe {
157            glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_sys::GObject)
158                .emit("search", &[])
159                .unwrap()
160        };
161    }
162
163    fn connect_property_section_name_notify<F: Fn(&Self) + 'static>(
164        &self,
165        f: F,
166    ) -> SignalHandlerId {
167        unsafe extern "C" fn notify_section_name_trampoline<P, F: Fn(&P) + 'static>(
168            this: *mut gtk_sys::GtkShortcutsWindow,
169            _param_spec: glib_sys::gpointer,
170            f: glib_sys::gpointer,
171        ) where
172            P: IsA<ShortcutsWindow>,
173        {
174            let f: &F = &*(f as *const F);
175            f(&ShortcutsWindow::from_glib_borrow(this).unsafe_cast())
176        }
177        unsafe {
178            let f: Box_<F> = Box_::new(f);
179            connect_raw(
180                self.as_ptr() as *mut _,
181                b"notify::section-name\0".as_ptr() as *const _,
182                Some(transmute(
183                    notify_section_name_trampoline::<Self, F> as usize,
184                )),
185                Box_::into_raw(f),
186            )
187        }
188    }
189
190    fn connect_property_view_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
191        unsafe extern "C" fn notify_view_name_trampoline<P, F: Fn(&P) + 'static>(
192            this: *mut gtk_sys::GtkShortcutsWindow,
193            _param_spec: glib_sys::gpointer,
194            f: glib_sys::gpointer,
195        ) where
196            P: IsA<ShortcutsWindow>,
197        {
198            let f: &F = &*(f as *const F);
199            f(&ShortcutsWindow::from_glib_borrow(this).unsafe_cast())
200        }
201        unsafe {
202            let f: Box_<F> = Box_::new(f);
203            connect_raw(
204                self.as_ptr() as *mut _,
205                b"notify::view-name\0".as_ptr() as *const _,
206                Some(transmute(notify_view_name_trampoline::<Self, F> as usize)),
207                Box_::into_raw(f),
208            )
209        }
210    }
211}
212
213impl fmt::Display for ShortcutsWindow {
214    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
215        write!(f, "ShortcutsWindow")
216    }
217}