use Buildable;
use Container;
use PackType;
use Widget;
use ffi;
use glib::GString;
use glib::StaticType;
use glib::Value;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect_raw;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;
glib_wrapper! {
pub struct HeaderBar(Object<ffi::GtkHeaderBar, ffi::GtkHeaderBarClass, HeaderBarClass>) @extends Container, Widget, @implements Buildable;
match fn {
get_type => || ffi::gtk_header_bar_get_type(),
}
}
impl HeaderBar {
pub fn new() -> HeaderBar {
assert_initialized_main_thread!();
unsafe {
Widget::from_glib_none(ffi::gtk_header_bar_new()).unsafe_cast()
}
}
}
impl Default for HeaderBar {
fn default() -> Self {
Self::new()
}
}
pub const NONE_HEADER_BAR: Option<&HeaderBar> = None;
pub trait HeaderBarExt: 'static {
fn get_custom_title(&self) -> Option<Widget>;
fn get_decoration_layout(&self) -> Option<GString>;
fn get_has_subtitle(&self) -> bool;
fn get_show_close_button(&self) -> bool;
fn get_subtitle(&self) -> Option<GString>;
fn get_title(&self) -> Option<GString>;
fn pack_end<P: IsA<Widget>>(&self, child: &P);
fn pack_start<P: IsA<Widget>>(&self, child: &P);
fn set_custom_title<'a, P: IsA<Widget> + 'a, Q: Into<Option<&'a P>>>(&self, title_widget: Q);
fn set_decoration_layout<'a, P: Into<Option<&'a str>>>(&self, layout: P);
fn set_has_subtitle(&self, setting: bool);
fn set_show_close_button(&self, setting: bool);
fn set_subtitle<'a, P: Into<Option<&'a str>>>(&self, subtitle: P);
fn set_title<'a, P: Into<Option<&'a str>>>(&self, title: P);
fn get_property_decoration_layout_set(&self) -> bool;
fn set_property_decoration_layout_set(&self, decoration_layout_set: bool);
fn get_property_spacing(&self) -> i32;
fn set_property_spacing(&self, spacing: i32);
fn get_child_pack_type<T: IsA<Widget>>(&self, item: &T) -> PackType;
fn set_child_pack_type<T: IsA<Widget>>(&self, item: &T, pack_type: PackType);
fn get_child_position<T: IsA<Widget>>(&self, item: &T) -> i32;
fn set_child_position<T: IsA<Widget>>(&self, item: &T, position: i32);
fn connect_property_custom_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_decoration_layout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_decoration_layout_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_has_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_show_close_button_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<HeaderBar>> HeaderBarExt for O {
fn get_custom_title(&self) -> Option<Widget> {
unsafe {
from_glib_none(ffi::gtk_header_bar_get_custom_title(self.as_ref().to_glib_none().0))
}
}
fn get_decoration_layout(&self) -> Option<GString> {
unsafe {
from_glib_none(ffi::gtk_header_bar_get_decoration_layout(self.as_ref().to_glib_none().0))
}
}
fn get_has_subtitle(&self) -> bool {
unsafe {
from_glib(ffi::gtk_header_bar_get_has_subtitle(self.as_ref().to_glib_none().0))
}
}
fn get_show_close_button(&self) -> bool {
unsafe {
from_glib(ffi::gtk_header_bar_get_show_close_button(self.as_ref().to_glib_none().0))
}
}
fn get_subtitle(&self) -> Option<GString> {
unsafe {
from_glib_none(ffi::gtk_header_bar_get_subtitle(self.as_ref().to_glib_none().0))
}
}
fn get_title(&self) -> Option<GString> {
unsafe {
from_glib_none(ffi::gtk_header_bar_get_title(self.as_ref().to_glib_none().0))
}
}
fn pack_end<P: IsA<Widget>>(&self, child: &P) {
unsafe {
ffi::gtk_header_bar_pack_end(self.as_ref().to_glib_none().0, child.as_ref().to_glib_none().0);
}
}
fn pack_start<P: IsA<Widget>>(&self, child: &P) {
unsafe {
ffi::gtk_header_bar_pack_start(self.as_ref().to_glib_none().0, child.as_ref().to_glib_none().0);
}
}
fn set_custom_title<'a, P: IsA<Widget> + 'a, Q: Into<Option<&'a P>>>(&self, title_widget: Q) {
let title_widget = title_widget.into();
unsafe {
ffi::gtk_header_bar_set_custom_title(self.as_ref().to_glib_none().0, title_widget.map(|p| p.as_ref()).to_glib_none().0);
}
}
fn set_decoration_layout<'a, P: Into<Option<&'a str>>>(&self, layout: P) {
let layout = layout.into();
unsafe {
ffi::gtk_header_bar_set_decoration_layout(self.as_ref().to_glib_none().0, layout.to_glib_none().0);
}
}
fn set_has_subtitle(&self, setting: bool) {
unsafe {
ffi::gtk_header_bar_set_has_subtitle(self.as_ref().to_glib_none().0, setting.to_glib());
}
}
fn set_show_close_button(&self, setting: bool) {
unsafe {
ffi::gtk_header_bar_set_show_close_button(self.as_ref().to_glib_none().0, setting.to_glib());
}
}
fn set_subtitle<'a, P: Into<Option<&'a str>>>(&self, subtitle: P) {
let subtitle = subtitle.into();
unsafe {
ffi::gtk_header_bar_set_subtitle(self.as_ref().to_glib_none().0, subtitle.to_glib_none().0);
}
}
fn set_title<'a, P: Into<Option<&'a str>>>(&self, title: P) {
let title = title.into();
unsafe {
ffi::gtk_header_bar_set_title(self.as_ref().to_glib_none().0, title.to_glib_none().0);
}
}
fn get_property_decoration_layout_set(&self) -> bool {
unsafe {
let mut value = Value::from_type(<bool as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"decoration-layout-set\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().unwrap()
}
}
fn set_property_decoration_layout_set(&self, decoration_layout_set: bool) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"decoration-layout-set\0".as_ptr() as *const _, Value::from(&decoration_layout_set).to_glib_none().0);
}
}
fn get_property_spacing(&self) -> i32 {
unsafe {
let mut value = Value::from_type(<i32 as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"spacing\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().unwrap()
}
}
fn set_property_spacing(&self, spacing: i32) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"spacing\0".as_ptr() as *const _, Value::from(&spacing).to_glib_none().0);
}
}
fn get_child_pack_type<T: IsA<Widget>>(&self, item: &T) -> PackType {
unsafe {
let mut value = Value::from_type(<PackType as StaticType>::static_type());
ffi::gtk_container_child_get_property(self.to_glib_none().0 as *mut ffi::GtkContainer, item.to_glib_none().0 as *mut _, b"pack-type\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().unwrap()
}
}
fn set_child_pack_type<T: IsA<Widget>>(&self, item: &T, pack_type: PackType) {
unsafe {
ffi::gtk_container_child_set_property(self.to_glib_none().0 as *mut ffi::GtkContainer, item.to_glib_none().0 as *mut _, b"pack-type\0".as_ptr() as *const _, Value::from(&pack_type).to_glib_none().0);
}
}
fn get_child_position<T: IsA<Widget>>(&self, item: &T) -> i32 {
unsafe {
let mut value = Value::from_type(<i32 as StaticType>::static_type());
ffi::gtk_container_child_get_property(self.to_glib_none().0 as *mut ffi::GtkContainer, item.to_glib_none().0 as *mut _, b"position\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().unwrap()
}
}
fn set_child_position<T: IsA<Widget>>(&self, item: &T, position: i32) {
unsafe {
ffi::gtk_container_child_set_property(self.to_glib_none().0 as *mut ffi::GtkContainer, item.to_glib_none().0 as *mut _, b"position\0".as_ptr() as *const _, Value::from(&position).to_glib_none().0);
}
}
fn connect_property_custom_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::custom-title\0".as_ptr() as *const _,
Some(transmute(notify_custom_title_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_decoration_layout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::decoration-layout\0".as_ptr() as *const _,
Some(transmute(notify_decoration_layout_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_decoration_layout_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::decoration-layout-set\0".as_ptr() as *const _,
Some(transmute(notify_decoration_layout_set_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_has_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::has-subtitle\0".as_ptr() as *const _,
Some(transmute(notify_has_subtitle_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_show_close_button_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::show-close-button\0".as_ptr() as *const _,
Some(transmute(notify_show_close_button_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::spacing\0".as_ptr() as *const _,
Some(transmute(notify_spacing_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::subtitle\0".as_ptr() as *const _,
Some(transmute(notify_subtitle_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::title\0".as_ptr() as *const _,
Some(transmute(notify_title_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
}
unsafe extern "C" fn notify_custom_title_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkHeaderBar, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<HeaderBar> {
let f: &F = transmute(f);
f(&HeaderBar::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_decoration_layout_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkHeaderBar, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<HeaderBar> {
let f: &F = transmute(f);
f(&HeaderBar::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_decoration_layout_set_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkHeaderBar, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<HeaderBar> {
let f: &F = transmute(f);
f(&HeaderBar::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_has_subtitle_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkHeaderBar, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<HeaderBar> {
let f: &F = transmute(f);
f(&HeaderBar::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_show_close_button_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkHeaderBar, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<HeaderBar> {
let f: &F = transmute(f);
f(&HeaderBar::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_spacing_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkHeaderBar, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<HeaderBar> {
let f: &F = transmute(f);
f(&HeaderBar::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_subtitle_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkHeaderBar, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<HeaderBar> {
let f: &F = transmute(f);
f(&HeaderBar::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_title_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkHeaderBar, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<HeaderBar> {
let f: &F = transmute(f);
f(&HeaderBar::from_glib_borrow(this).unsafe_cast())
}
impl fmt::Display for HeaderBar {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "HeaderBar")
}
}