Generate Handy TitleBar
This commit is contained in:
parent
ca3a119f83
commit
84d0f1c8a7
|
@ -24,6 +24,7 @@ generate = ["Handy.Column",
|
|||
"Handy.DialerCycleButton",
|
||||
"Handy.ExpanderRow",
|
||||
"Handy.SearchBar",
|
||||
"Handy.TitleBar",
|
||||
"Handy.Fold",
|
||||
"Handy.Leaflet",
|
||||
"Handy.LeafletChildTransitionType",
|
||||
|
|
|
@ -38,6 +38,10 @@ mod search_bar;
|
|||
pub use self::search_bar::SearchBar;
|
||||
pub use self::search_bar::SearchBarExt;
|
||||
|
||||
mod title_bar;
|
||||
pub use self::title_bar::TitleBar;
|
||||
pub use self::title_bar::TitleBarExt;
|
||||
|
||||
mod enums;
|
||||
pub use self::enums::ArrowsDirection;
|
||||
pub use self::enums::Fold;
|
||||
|
@ -55,4 +59,5 @@ pub mod traits {
|
|||
pub use super::ExpanderRowExt;
|
||||
pub use super::LeafletExt;
|
||||
pub use super::SearchBarExt;
|
||||
pub use super::TitleBarExt;
|
||||
}
|
||||
|
|
80
handy/src/auto/title_bar.rs
Normal file
80
handy/src/auto/title_bar.rs
Normal file
|
@ -0,0 +1,80 @@
|
|||
// 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 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 TitleBar(Object<ffi::HdyTitleBar, ffi::HdyTitleBarClass>): [
|
||||
gtk::Widget => gtk_ffi::GtkWidget,
|
||||
];
|
||||
|
||||
match fn {
|
||||
get_type => || ffi::hdy_title_bar_get_type(),
|
||||
}
|
||||
}
|
||||
|
||||
impl TitleBar {
|
||||
pub fn new() -> TitleBar {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
from_glib_none(ffi::hdy_title_bar_new())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for TitleBar {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait TitleBarExt {
|
||||
fn get_selection_mode(&self) -> bool;
|
||||
|
||||
fn set_selection_mode(&self, selection_mode: bool);
|
||||
|
||||
fn connect_property_selection_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
|
||||
}
|
||||
|
||||
impl<O: IsA<TitleBar> + IsA<glib::object::Object>> TitleBarExt for O {
|
||||
fn get_selection_mode(&self) -> bool {
|
||||
unsafe {
|
||||
from_glib(ffi::hdy_title_bar_get_selection_mode(self.to_glib_none().0))
|
||||
}
|
||||
}
|
||||
|
||||
fn set_selection_mode(&self, selection_mode: bool) {
|
||||
unsafe {
|
||||
ffi::hdy_title_bar_set_selection_mode(self.to_glib_none().0, selection_mode.to_glib());
|
||||
}
|
||||
}
|
||||
|
||||
fn connect_property_selection_mode_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::selection-mode",
|
||||
transmute(notify_selection_mode_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe extern "C" fn notify_selection_mode_trampoline<P>(this: *mut ffi::HdyTitleBar, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
|
||||
where P: IsA<TitleBar> {
|
||||
let f: &&(Fn(&P) + 'static) = transmute(f);
|
||||
f(&TitleBar::from_glib_borrow(this).downcast_unchecked())
|
||||
}
|
Loading…
Reference in a new issue