use crate::{ffi, RGBColor};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
#[doc(alias = "HeApplication")]
pub struct Application(Object<ffi::HeApplication, ffi::HeApplicationClass>) @extends gtk::Application, gio::Application, @implements gio::ActionGroup, gio::ActionMap;
match fn {
type_ => || ffi::he_application_get_type(),
}
}
impl Application {
pub const NONE: Option<&'static Application> = None;
pub fn builder() -> ApplicationBuilder {
ApplicationBuilder::new()
}
}
#[must_use = "The builder must be built to be used"]
pub struct ApplicationBuilder {
builder: glib::object::ObjectBuilder<'static, Application>,
}
impl ApplicationBuilder {
fn new() -> Self {
Self {
builder: glib::object::Object::builder(),
}
}
pub fn default_accent_color(self, default_accent_color: &RGBColor) -> Self {
Self {
builder: self
.builder
.property("default-accent-color", default_accent_color),
}
}
pub fn override_accent_color(self, override_accent_color: bool) -> Self {
Self {
builder: self
.builder
.property("override-accent-color", override_accent_color),
}
}
pub fn override_dark_style(self, override_dark_style: bool) -> Self {
Self {
builder: self
.builder
.property("override-dark-style", override_dark_style),
}
}
pub fn override_contrast(self, override_contrast: bool) -> Self {
Self {
builder: self
.builder
.property("override-contrast", override_contrast),
}
}
pub fn default_contrast(self, default_contrast: f64) -> Self {
Self {
builder: self.builder.property("default-contrast", default_contrast),
}
}
pub fn is_content(self, is_content: bool) -> Self {
Self {
builder: self.builder.property("is-content", is_content),
}
}
pub fn is_mono(self, is_mono: bool) -> Self {
Self {
builder: self.builder.property("is-mono", is_mono),
}
}
pub fn menubar(self, menubar: &impl IsA<gio::MenuModel>) -> Self {
Self {
builder: self.builder.property("menubar", menubar.clone().upcast()),
}
}
pub fn register_session(self, register_session: bool) -> Self {
Self {
builder: self.builder.property("register-session", register_session),
}
}
pub fn application_id(self, application_id: impl Into<glib::GString>) -> Self {
Self {
builder: self
.builder
.property("application-id", application_id.into()),
}
}
pub fn flags(self, flags: gio::ApplicationFlags) -> Self {
Self {
builder: self.builder.property("flags", flags),
}
}
pub fn inactivity_timeout(self, inactivity_timeout: u32) -> Self {
Self {
builder: self
.builder
.property("inactivity-timeout", inactivity_timeout),
}
}
pub fn resource_base_path(self, resource_base_path: impl Into<glib::GString>) -> Self {
Self {
builder: self
.builder
.property("resource-base-path", resource_base_path.into()),
}
}
#[cfg(feature = "gio_v2_80")]
#[cfg_attr(docsrs, doc(cfg(feature = "gio_v2_80")))]
pub fn version(self, version: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("version", version.into()),
}
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> Application {
let ret = self.builder.build();
{
Application::register_startup_hook(&ret);
}
ret
}
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Application>> Sealed for T {}
}
pub trait HeApplicationExt: IsA<Application> + sealed::Sealed + 'static {
#[doc(alias = "he_application_get_default_accent_color")]
#[doc(alias = "get_default_accent_color")]
fn default_accent_color(&self) -> Option<RGBColor> {
unsafe {
from_glib_none(ffi::he_application_get_default_accent_color(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "he_application_get_override_accent_color")]
#[doc(alias = "get_override_accent_color")]
fn is_override_accent_color(&self) -> bool {
unsafe {
from_glib(ffi::he_application_get_override_accent_color(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "he_application_set_override_accent_color")]
fn set_override_accent_color(&self, value: bool) {
unsafe {
ffi::he_application_set_override_accent_color(
self.as_ref().to_glib_none().0,
value.into_glib(),
);
}
}
#[doc(alias = "he_application_get_override_dark_style")]
#[doc(alias = "get_override_dark_style")]
fn is_override_dark_style(&self) -> bool {
unsafe {
from_glib(ffi::he_application_get_override_dark_style(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "he_application_set_override_dark_style")]
fn set_override_dark_style(&self, value: bool) {
unsafe {
ffi::he_application_set_override_dark_style(
self.as_ref().to_glib_none().0,
value.into_glib(),
);
}
}
#[doc(alias = "he_application_get_override_contrast")]
#[doc(alias = "get_override_contrast")]
fn is_override_contrast(&self) -> bool {
unsafe {
from_glib(ffi::he_application_get_override_contrast(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "he_application_set_override_contrast")]
fn set_override_contrast(&self, value: bool) {
unsafe {
ffi::he_application_set_override_contrast(
self.as_ref().to_glib_none().0,
value.into_glib(),
);
}
}
#[doc(alias = "he_application_get_default_contrast")]
#[doc(alias = "get_default_contrast")]
fn default_contrast(&self) -> f64 {
unsafe { ffi::he_application_get_default_contrast(self.as_ref().to_glib_none().0) }
}
#[doc(alias = "he_application_set_default_contrast")]
fn set_default_contrast(&self, value: f64) {
unsafe {
ffi::he_application_set_default_contrast(self.as_ref().to_glib_none().0, value);
}
}
#[doc(alias = "he_application_get_is_content")]
#[doc(alias = "get_is_content")]
fn is_content(&self) -> bool {
unsafe {
from_glib(ffi::he_application_get_is_content(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "he_application_set_is_content")]
fn set_is_content(&self, value: bool) {
unsafe {
ffi::he_application_set_is_content(self.as_ref().to_glib_none().0, value.into_glib());
}
}
#[doc(alias = "he_application_get_is_mono")]
#[doc(alias = "get_is_mono")]
fn is_mono(&self) -> bool {
unsafe {
from_glib(ffi::he_application_get_is_mono(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "he_application_set_is_mono")]
fn set_is_mono(&self, value: bool) {
unsafe {
ffi::he_application_set_is_mono(self.as_ref().to_glib_none().0, value.into_glib());
}
}
#[doc(alias = "default-accent-color")]
fn connect_default_accent_color_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_default_accent_color_trampoline<
P: IsA<Application>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::HeApplication,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Application::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::default-accent-color\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_default_accent_color_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "override-accent-color")]
fn connect_override_accent_color_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_override_accent_color_trampoline<
P: IsA<Application>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::HeApplication,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Application::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::override-accent-color\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_override_accent_color_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "override-dark-style")]
fn connect_override_dark_style_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_override_dark_style_trampoline<
P: IsA<Application>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::HeApplication,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Application::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::override-dark-style\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_override_dark_style_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "override-contrast")]
fn connect_override_contrast_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_override_contrast_trampoline<
P: IsA<Application>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::HeApplication,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Application::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::override-contrast\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_override_contrast_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "default-contrast")]
fn connect_default_contrast_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_default_contrast_trampoline<
P: IsA<Application>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::HeApplication,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Application::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::default-contrast\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_default_contrast_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "is-content")]
fn connect_is_content_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_is_content_trampoline<
P: IsA<Application>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::HeApplication,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Application::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::is-content\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_is_content_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "is-mono")]
fn connect_is_mono_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_is_mono_trampoline<P: IsA<Application>, F: Fn(&P) + 'static>(
this: *mut ffi::HeApplication,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Application::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::is-mono\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_is_mono_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<Application>> HeApplicationExt for O {}