use crate::ffi;
use glib::{prelude::*, translate::*};
glib::wrapper! {
#[doc(alias = "PanelApplication")]
pub struct Application(Object<ffi::PanelApplication, ffi::PanelApplicationClass>) @extends adw::Application, gtk::Application, gio::Application, @implements gio::ActionGroup, gio::ActionMap;
match fn {
type_ => || ffi::panel_application_get_type(),
}
}
impl Application {
pub const NONE: Option<&'static Application> = None;
#[doc(alias = "panel_application_new")]
pub fn new(application_id: &str, flags: gio::ApplicationFlags) -> Application {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::panel_application_new(
application_id.to_glib_none().0,
flags.into_glib(),
))
}
}
pub fn builder() -> ApplicationBuilder {
ApplicationBuilder::new()
}
}
impl Default for Application {
fn default() -> Self {
glib::object::Object::new::<Self>()
}
}
#[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 menubar(self, menubar: &impl IsA<gio::MenuModel>) -> Self {
Self {
builder: self.builder.property("menubar", menubar.clone().upcast()),
}
}
#[cfg_attr(feature = "gtk_v4_22", deprecated = "Since 4.22")]
pub fn register_session(self, register_session: bool) -> Self {
Self {
builder: self.builder.property("register-session", register_session),
}
}
#[deprecated = "Since 2.32"]
pub fn action_group(self, action_group: &impl IsA<gio::ActionGroup>) -> Self {
Self {
builder: self
.builder
.property("action-group", action_group.clone().upcast()),
}
}
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 {
assert_initialized_main_thread!();
self.builder.build()
}
}