use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::{boxed::Box as Box_, fmt, mem::transmute};
glib::wrapper! {
#[doc(alias = "DzlSuggestion")]
pub struct Suggestion(Object<ffi::DzlSuggestion, ffi::DzlSuggestionClass>);
match fn {
type_ => || ffi::dzl_suggestion_get_type(),
}
}
impl Suggestion {
pub const NONE: Option<&'static Suggestion> = None;
#[doc(alias = "dzl_suggestion_new")]
pub fn new() -> Suggestion {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::dzl_suggestion_new()) }
}
}
impl Default for Suggestion {
fn default() -> Self {
Self::new()
}
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Suggestion>> Sealed for T {}
}
pub trait SuggestionExt: IsA<Suggestion> + sealed::Sealed + 'static {
#[cfg(feature = "v3_30")]
#[cfg_attr(docsrs, doc(cfg(feature = "v3_30")))]
#[doc(alias = "dzl_suggestion_get_icon")]
#[doc(alias = "get_icon")]
fn icon(&self) -> Option<gio::Icon> {
unsafe { from_glib_full(ffi::dzl_suggestion_get_icon(self.as_ref().to_glib_none().0)) }
}
#[doc(alias = "dzl_suggestion_get_icon_name")]
#[doc(alias = "get_icon_name")]
fn icon_name(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::dzl_suggestion_get_icon_name(
self.as_ref().to_glib_none().0,
))
}
}
#[cfg(feature = "v3_30")]
#[cfg_attr(docsrs, doc(cfg(feature = "v3_30")))]
#[doc(alias = "dzl_suggestion_get_icon_surface")]
#[doc(alias = "get_icon_surface")]
fn icon_surface(&self, widget: &impl IsA<gtk::Widget>) -> Option<cairo::Surface> {
unsafe {
from_glib_full(ffi::dzl_suggestion_get_icon_surface(
self.as_ref().to_glib_none().0,
widget.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "dzl_suggestion_get_id")]
#[doc(alias = "get_id")]
fn id(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::dzl_suggestion_get_id(self.as_ref().to_glib_none().0)) }
}
#[cfg(feature = "v3_36")]
#[cfg_attr(docsrs, doc(cfg(feature = "v3_36")))]
#[doc(alias = "dzl_suggestion_get_secondary_icon")]
#[doc(alias = "get_secondary_icon")]
fn secondary_icon(&self) -> Option<gio::Icon> {
unsafe {
from_glib_full(ffi::dzl_suggestion_get_secondary_icon(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "dzl_suggestion_get_secondary_icon_name")]
#[doc(alias = "get_secondary_icon_name")]
fn secondary_icon_name(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::dzl_suggestion_get_secondary_icon_name(
self.as_ref().to_glib_none().0,
))
}
}
#[cfg(feature = "v3_36")]
#[cfg_attr(docsrs, doc(cfg(feature = "v3_36")))]
#[doc(alias = "dzl_suggestion_get_secondary_icon_surface")]
#[doc(alias = "get_secondary_icon_surface")]
fn secondary_icon_surface(&self, widget: &impl IsA<gtk::Widget>) -> Option<cairo::Surface> {
unsafe {
from_glib_full(ffi::dzl_suggestion_get_secondary_icon_surface(
self.as_ref().to_glib_none().0,
widget.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "dzl_suggestion_get_subtitle")]
#[doc(alias = "get_subtitle")]
fn subtitle(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::dzl_suggestion_get_subtitle(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "dzl_suggestion_get_title")]
#[doc(alias = "get_title")]
fn title(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::dzl_suggestion_get_title(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "dzl_suggestion_replace_typed_text")]
fn replace_typed_text(&self, typed_text: &str) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::dzl_suggestion_replace_typed_text(
self.as_ref().to_glib_none().0,
typed_text.to_glib_none().0,
))
}
}
#[doc(alias = "dzl_suggestion_set_icon_name")]
fn set_icon_name(&self, icon_name: &str) {
unsafe {
ffi::dzl_suggestion_set_icon_name(
self.as_ref().to_glib_none().0,
icon_name.to_glib_none().0,
);
}
}
#[doc(alias = "dzl_suggestion_set_id")]
fn set_id(&self, id: &str) {
unsafe {
ffi::dzl_suggestion_set_id(self.as_ref().to_glib_none().0, id.to_glib_none().0);
}
}
#[doc(alias = "dzl_suggestion_set_secondary_icon_name")]
fn set_secondary_icon_name(&self, icon_name: &str) {
unsafe {
ffi::dzl_suggestion_set_secondary_icon_name(
self.as_ref().to_glib_none().0,
icon_name.to_glib_none().0,
);
}
}
#[doc(alias = "dzl_suggestion_set_subtitle")]
fn set_subtitle(&self, subtitle: &str) {
unsafe {
ffi::dzl_suggestion_set_subtitle(
self.as_ref().to_glib_none().0,
subtitle.to_glib_none().0,
);
}
}
#[doc(alias = "dzl_suggestion_set_title")]
fn set_title(&self, title: &str) {
unsafe {
ffi::dzl_suggestion_set_title(self.as_ref().to_glib_none().0, title.to_glib_none().0);
}
}
#[doc(alias = "dzl_suggestion_suggest_suffix")]
fn suggest_suffix(&self, typed_text: &str) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::dzl_suggestion_suggest_suffix(
self.as_ref().to_glib_none().0,
typed_text.to_glib_none().0,
))
}
}
fn get_property_icon(&self) -> Option<gio::Icon> {
ObjectExt::property(self.as_ref(), "icon")
}
#[doc(alias = "secondary-icon")]
fn get_property_secondary_icon(&self) -> Option<gio::Icon> {
ObjectExt::property(self.as_ref(), "secondary-icon")
}
#[doc(alias = "replace-typed-text")]
fn connect_replace_typed_text<F: Fn(&Self, &str) -> String + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn replace_typed_text_trampoline<
P: IsA<Suggestion>,
F: Fn(&P, &str) -> String + 'static,
>(
this: *mut ffi::DzlSuggestion,
object: *mut libc::c_char,
f: glib::ffi::gpointer,
) -> *mut libc::c_char {
let f: &F = &*(f as *const F);
f(
Suggestion::from_glib_borrow(this).unsafe_cast_ref(),
&glib::GString::from_glib_borrow(object),
)
.to_glib_full()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"replace-typed-text\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
replace_typed_text_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "suggest-suffix")]
fn connect_suggest_suffix<F: Fn(&Self, &str) -> String + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn suggest_suffix_trampoline<
P: IsA<Suggestion>,
F: Fn(&P, &str) -> String + 'static,
>(
this: *mut ffi::DzlSuggestion,
object: *mut libc::c_char,
f: glib::ffi::gpointer,
) -> *mut libc::c_char {
let f: &F = &*(f as *const F);
f(
Suggestion::from_glib_borrow(this).unsafe_cast_ref(),
&glib::GString::from_glib_borrow(object),
)
.to_glib_full()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"suggest-suffix\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
suggest_suffix_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "icon")]
fn connect_icon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_icon_trampoline<P: IsA<Suggestion>, F: Fn(&P) + 'static>(
this: *mut ffi::DzlSuggestion,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Suggestion::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::icon\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_icon_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "icon-name")]
fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_icon_name_trampoline<
P: IsA<Suggestion>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::DzlSuggestion,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Suggestion::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::icon-name\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_icon_name_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "id")]
fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_id_trampoline<P: IsA<Suggestion>, F: Fn(&P) + 'static>(
this: *mut ffi::DzlSuggestion,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Suggestion::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::id\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_id_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "secondary-icon")]
fn connect_secondary_icon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_secondary_icon_trampoline<
P: IsA<Suggestion>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::DzlSuggestion,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Suggestion::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::secondary-icon\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_secondary_icon_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "secondary-icon-name")]
fn connect_secondary_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_secondary_icon_name_trampoline<
P: IsA<Suggestion>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::DzlSuggestion,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Suggestion::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::secondary-icon-name\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_secondary_icon_name_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "subtitle")]
fn connect_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_subtitle_trampoline<P: IsA<Suggestion>, F: Fn(&P) + 'static>(
this: *mut ffi::DzlSuggestion,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Suggestion::from_glib_borrow(this).unsafe_cast_ref())
}
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::<_, unsafe extern "C" fn()>(
notify_subtitle_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "title")]
fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_title_trampoline<P: IsA<Suggestion>, F: Fn(&P) + 'static>(
this: *mut ffi::DzlSuggestion,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Suggestion::from_glib_borrow(this).unsafe_cast_ref())
}
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::<_, unsafe extern "C" fn()>(
notify_title_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<Suggestion>> SuggestionExt for O {}
impl fmt::Display for Suggestion {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Suggestion")
}
}