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 
5 #[cfg(any(feature = "v0_0_10", feature = "dox"))]
6 use glib::object::Cast;
7 use glib::object::IsA;
8 #[cfg(any(feature = "v0_0_10", feature = "dox"))]
9 use glib::signal::connect_raw;
10 #[cfg(any(feature = "v0_0_10", feature = "dox"))]
11 use glib::signal::SignalHandlerId;
12 use glib::translate::*;
13 #[cfg(any(feature = "v0_0_10", feature = "dox"))]
14 use glib_sys;
15 use gtk;
16 use handy_sys;
17 #[cfg(any(feature = "v0_0_10", feature = "dox"))]
18 use pango;
19 #[cfg(any(feature = "v0_0_10", feature = "dox"))]
20 use std::boxed::Box as Box_;
21 use std::fmt;
22 #[cfg(any(feature = "v0_0_10", feature = "dox"))]
23 use std::mem::transmute;
24 #[cfg(any(feature = "v0_0_10", feature = "dox"))]
25 use ViewSwitcherPolicy;
26 
27 glib_wrapper! {
28     pub struct ViewSwitcher(Object<handy_sys::HdyViewSwitcher, handy_sys::HdyViewSwitcherClass, ViewSwitcherClass>) @extends gtk::Box, gtk::Container, gtk::Widget, @implements gtk::Orientable;
29 
30     match fn {
31         get_type => || handy_sys::hdy_view_switcher_get_type(),
32     }
33 }
34 
35 impl ViewSwitcher {
36     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
new() -> ViewSwitcher37     pub fn new() -> ViewSwitcher {
38         assert_initialized_main_thread!();
39         unsafe {
40             from_glib_none(handy_sys::hdy_view_switcher_new())
41         }
42     }
43 }
44 
45 #[cfg(any(feature = "v0_0_10", feature = "dox"))]
46 impl Default for ViewSwitcher {
default() -> Self47     fn default() -> Self {
48         Self::new()
49     }
50 }
51 
52 pub const NONE_VIEW_SWITCHER: Option<&ViewSwitcher> = None;
53 
54 pub trait ViewSwitcherExt: 'static {
55     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
get_icon_size(&self) -> gtk::IconSize56     fn get_icon_size(&self) -> gtk::IconSize;
57 
58     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
get_narrow_ellipsize(&self) -> pango::EllipsizeMode59     fn get_narrow_ellipsize(&self) -> pango::EllipsizeMode;
60 
61     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
get_policy(&self) -> ViewSwitcherPolicy62     fn get_policy(&self) -> ViewSwitcherPolicy;
63 
64     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
get_stack(&self) -> Option<gtk::Stack>65     fn get_stack(&self) -> Option<gtk::Stack>;
66 
67     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
set_icon_size(&self, icon_size: gtk::IconSize)68     fn set_icon_size(&self, icon_size: gtk::IconSize);
69 
70     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
set_narrow_ellipsize(&self, mode: pango::EllipsizeMode)71     fn set_narrow_ellipsize(&self, mode: pango::EllipsizeMode);
72 
73     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
set_policy(&self, policy: ViewSwitcherPolicy)74     fn set_policy(&self, policy: ViewSwitcherPolicy);
75 
76     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
set_stack<P: IsA<gtk::Stack>>(&self, stack: Option<&P>)77     fn set_stack<P: IsA<gtk::Stack>>(&self, stack: Option<&P>);
78 
79     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
connect_property_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId80     fn connect_property_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
81 
82     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
connect_property_narrow_ellipsize_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId83     fn connect_property_narrow_ellipsize_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
84 
85     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
connect_property_policy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId86     fn connect_property_policy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
87 
88     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
connect_property_stack_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId89     fn connect_property_stack_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
90 }
91 
92 impl<O: IsA<ViewSwitcher>> ViewSwitcherExt for O {
93     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
get_icon_size(&self) -> gtk::IconSize94     fn get_icon_size(&self) -> gtk::IconSize {
95         unsafe {
96             from_glib(handy_sys::hdy_view_switcher_get_icon_size(self.as_ref().to_glib_none().0))
97         }
98     }
99 
100     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
get_narrow_ellipsize(&self) -> pango::EllipsizeMode101     fn get_narrow_ellipsize(&self) -> pango::EllipsizeMode {
102         unsafe {
103             from_glib(handy_sys::hdy_view_switcher_get_narrow_ellipsize(self.as_ref().to_glib_none().0))
104         }
105     }
106 
107     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
get_policy(&self) -> ViewSwitcherPolicy108     fn get_policy(&self) -> ViewSwitcherPolicy {
109         unsafe {
110             from_glib(handy_sys::hdy_view_switcher_get_policy(self.as_ref().to_glib_none().0))
111         }
112     }
113 
114     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
get_stack(&self) -> Option<gtk::Stack>115     fn get_stack(&self) -> Option<gtk::Stack> {
116         unsafe {
117             from_glib_none(handy_sys::hdy_view_switcher_get_stack(self.as_ref().to_glib_none().0))
118         }
119     }
120 
121     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
set_icon_size(&self, icon_size: gtk::IconSize)122     fn set_icon_size(&self, icon_size: gtk::IconSize) {
123         unsafe {
124             handy_sys::hdy_view_switcher_set_icon_size(self.as_ref().to_glib_none().0, icon_size.to_glib());
125         }
126     }
127 
128     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
set_narrow_ellipsize(&self, mode: pango::EllipsizeMode)129     fn set_narrow_ellipsize(&self, mode: pango::EllipsizeMode) {
130         unsafe {
131             handy_sys::hdy_view_switcher_set_narrow_ellipsize(self.as_ref().to_glib_none().0, mode.to_glib());
132         }
133     }
134 
135     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
set_policy(&self, policy: ViewSwitcherPolicy)136     fn set_policy(&self, policy: ViewSwitcherPolicy) {
137         unsafe {
138             handy_sys::hdy_view_switcher_set_policy(self.as_ref().to_glib_none().0, policy.to_glib());
139         }
140     }
141 
142     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
set_stack<P: IsA<gtk::Stack>>(&self, stack: Option<&P>)143     fn set_stack<P: IsA<gtk::Stack>>(&self, stack: Option<&P>) {
144         unsafe {
145             handy_sys::hdy_view_switcher_set_stack(self.as_ref().to_glib_none().0, stack.map(|p| p.as_ref()).to_glib_none().0);
146         }
147     }
148 
149     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
connect_property_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId150     fn connect_property_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
151         unsafe extern "C" fn notify_icon_size_trampoline<P, F: Fn(&P) + 'static>(this: *mut handy_sys::HdyViewSwitcher, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
152             where P: IsA<ViewSwitcher>
153         {
154             let f: &F = &*(f as *const F);
155             f(&ViewSwitcher::from_glib_borrow(this).unsafe_cast())
156         }
157         unsafe {
158             let f: Box_<F> = Box_::new(f);
159             connect_raw(self.as_ptr() as *mut _, b"notify::icon-size\0".as_ptr() as *const _,
160                 Some(transmute(notify_icon_size_trampoline::<Self, F> as usize)), Box_::into_raw(f))
161         }
162     }
163 
164     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
connect_property_narrow_ellipsize_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId165     fn connect_property_narrow_ellipsize_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
166         unsafe extern "C" fn notify_narrow_ellipsize_trampoline<P, F: Fn(&P) + 'static>(this: *mut handy_sys::HdyViewSwitcher, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
167             where P: IsA<ViewSwitcher>
168         {
169             let f: &F = &*(f as *const F);
170             f(&ViewSwitcher::from_glib_borrow(this).unsafe_cast())
171         }
172         unsafe {
173             let f: Box_<F> = Box_::new(f);
174             connect_raw(self.as_ptr() as *mut _, b"notify::narrow-ellipsize\0".as_ptr() as *const _,
175                 Some(transmute(notify_narrow_ellipsize_trampoline::<Self, F> as usize)), Box_::into_raw(f))
176         }
177     }
178 
179     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
connect_property_policy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId180     fn connect_property_policy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
181         unsafe extern "C" fn notify_policy_trampoline<P, F: Fn(&P) + 'static>(this: *mut handy_sys::HdyViewSwitcher, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
182             where P: IsA<ViewSwitcher>
183         {
184             let f: &F = &*(f as *const F);
185             f(&ViewSwitcher::from_glib_borrow(this).unsafe_cast())
186         }
187         unsafe {
188             let f: Box_<F> = Box_::new(f);
189             connect_raw(self.as_ptr() as *mut _, b"notify::policy\0".as_ptr() as *const _,
190                 Some(transmute(notify_policy_trampoline::<Self, F> as usize)), Box_::into_raw(f))
191         }
192     }
193 
194     #[cfg(any(feature = "v0_0_10", feature = "dox"))]
connect_property_stack_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId195     fn connect_property_stack_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
196         unsafe extern "C" fn notify_stack_trampoline<P, F: Fn(&P) + 'static>(this: *mut handy_sys::HdyViewSwitcher, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
197             where P: IsA<ViewSwitcher>
198         {
199             let f: &F = &*(f as *const F);
200             f(&ViewSwitcher::from_glib_borrow(this).unsafe_cast())
201         }
202         unsafe {
203             let f: Box_<F> = Box_::new(f);
204             connect_raw(self.as_ptr() as *mut _, b"notify::stack\0".as_ptr() as *const _,
205                 Some(transmute(notify_stack_trampoline::<Self, F> as usize)), Box_::into_raw(f))
206         }
207     }
208 }
209 
210 impl fmt::Display for ViewSwitcher {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result211     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
212         write!(f, "ViewSwitcher")
213     }
214 }
215