Generate Handy ExpanderRow

This commit is contained in:
Jordan Petridis 2018-12-27 12:22:34 +02:00 committed by Julian Sparber
parent c0c3e62e97
commit 20e58739ae
3 changed files with 120 additions and 0 deletions

View file

@ -20,6 +20,7 @@ generate = ["Handy.Column",
"Handy.DialerButton",
"Handy.Dialer",
"Handy.DialerCycleButton",
"Handy.ExpanderRow",
"Handy.Fold",
"Handy.Leaflet",
"Handy.LeafletChildTransitionType",

View file

@ -0,0 +1,114 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use ActionRow;
use ffi;
use glib;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gtk;
use gtk_ffi;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;
glib_wrapper! {
pub struct ExpanderRow(Object<ffi::HdyExpanderRow, ffi::HdyExpanderRowClass>): [
ActionRow,
gtk::Widget => gtk_ffi::GtkWidget,
];
match fn {
get_type => || ffi::hdy_expander_row_get_type(),
}
}
impl ExpanderRow {
pub fn new() -> ExpanderRow {
assert_initialized_main_thread!();
unsafe {
from_glib_none(ffi::hdy_expander_row_new())
}
}
}
impl Default for ExpanderRow {
fn default() -> Self {
Self::new()
}
}
pub trait ExpanderRowExt {
fn get_enable_expansion(&self) -> bool;
fn get_show_enable_switch(&self) -> bool;
fn set_enable_expansion(&self, enable_expansion: bool);
fn set_show_enable_switch(&self, show_enable_switch: bool);
fn connect_property_enable_expansion_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_show_enable_switch_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<ExpanderRow> + IsA<glib::object::Object>> ExpanderRowExt for O {
fn get_enable_expansion(&self) -> bool {
unsafe {
from_glib(ffi::hdy_expander_row_get_enable_expansion(self.to_glib_none().0))
}
}
fn get_show_enable_switch(&self) -> bool {
unsafe {
from_glib(ffi::hdy_expander_row_get_show_enable_switch(self.to_glib_none().0))
}
}
fn set_enable_expansion(&self, enable_expansion: bool) {
unsafe {
ffi::hdy_expander_row_set_enable_expansion(self.to_glib_none().0, enable_expansion.to_glib());
}
}
fn set_show_enable_switch(&self, show_enable_switch: bool) {
unsafe {
ffi::hdy_expander_row_set_show_enable_switch(self.to_glib_none().0, show_enable_switch.to_glib());
}
}
fn connect_property_enable_expansion_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::enable-expansion",
transmute(notify_enable_expansion_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_property_show_enable_switch_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::show-enable-switch",
transmute(notify_show_enable_switch_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe extern "C" fn notify_enable_expansion_trampoline<P>(this: *mut ffi::HdyExpanderRow, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<ExpanderRow> {
let f: &&(Fn(&P) + 'static) = transmute(f);
f(&ExpanderRow::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_show_enable_switch_trampoline<P>(this: *mut ffi::HdyExpanderRow, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<ExpanderRow> {
let f: &&(Fn(&P) + 'static) = transmute(f);
f(&ExpanderRow::from_glib_borrow(this).downcast_unchecked())
}

View file

@ -26,6 +26,10 @@ mod dialer_cycle_button;
pub use self::dialer_cycle_button::DialerCycleButton;
pub use self::dialer_cycle_button::DialerCycleButtonExt;
mod expander_row;
pub use self::expander_row::ExpanderRow;
pub use self::expander_row::ExpanderRowExt;
mod leaflet;
pub use self::leaflet::Leaflet;
pub use self::leaflet::LeafletExt;
@ -44,5 +48,6 @@ pub mod traits {
pub use super::DialerExt;
pub use super::DialerButtonExt;
pub use super::DialerCycleButtonExt;
pub use super::ExpanderRowExt;
pub use super::LeafletExt;
}