use crate::{ffi, Ref, RefKind};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
#[doc(alias = "FlatpakInstalledRef")]
pub struct InstalledRef(Object<ffi::FlatpakInstalledRef, ffi::FlatpakInstalledRefClass>) @extends Ref;
match fn {
type_ => || ffi::flatpak_installed_ref_get_type(),
}
}
impl InstalledRef {
pub const NONE: Option<&'static InstalledRef> = None;
pub fn builder() -> InstalledRefBuilder {
InstalledRefBuilder::new()
}
}
#[must_use = "The builder must be built to be used"]
pub struct InstalledRefBuilder {
builder: glib::object::ObjectBuilder<'static, InstalledRef>,
}
impl InstalledRefBuilder {
fn new() -> Self {
Self {
builder: glib::object::Object::builder(),
}
}
pub fn appdata_content_rating_type(
self,
appdata_content_rating_type: impl Into<glib::GString>,
) -> Self {
Self {
builder: self.builder.property(
"appdata-content-rating-type",
appdata_content_rating_type.into(),
),
}
}
pub fn appdata_license(self, appdata_license: impl Into<glib::GString>) -> Self {
Self {
builder: self
.builder
.property("appdata-license", appdata_license.into()),
}
}
pub fn appdata_name(self, appdata_name: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("appdata-name", appdata_name.into()),
}
}
pub fn appdata_summary(self, appdata_summary: impl Into<glib::GString>) -> Self {
Self {
builder: self
.builder
.property("appdata-summary", appdata_summary.into()),
}
}
pub fn appdata_version(self, appdata_version: impl Into<glib::GString>) -> Self {
Self {
builder: self
.builder
.property("appdata-version", appdata_version.into()),
}
}
pub fn deploy_dir(self, deploy_dir: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("deploy-dir", deploy_dir.into()),
}
}
pub fn end_of_life(self, end_of_life: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("end-of-life", end_of_life.into()),
}
}
pub fn end_of_life_rebase(self, end_of_life_rebase: impl Into<glib::GString>) -> Self {
Self {
builder: self
.builder
.property("end-of-life-rebase", end_of_life_rebase.into()),
}
}
pub fn installed_size(self, installed_size: u64) -> Self {
Self {
builder: self.builder.property("installed-size", installed_size),
}
}
pub fn is_current(self, is_current: bool) -> Self {
Self {
builder: self.builder.property("is-current", is_current),
}
}
pub fn latest_commit(self, latest_commit: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("latest-commit", latest_commit.into()),
}
}
pub fn origin(self, origin: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("origin", origin.into()),
}
}
pub fn subpaths(self, subpaths: impl Into<glib::StrV>) -> Self {
Self {
builder: self.builder.property("subpaths", subpaths.into()),
}
}
pub fn arch(self, arch: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("arch", arch.into()),
}
}
pub fn branch(self, branch: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("branch", branch.into()),
}
}
pub fn collection_id(self, collection_id: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("collection-id", collection_id.into()),
}
}
pub fn commit(self, commit: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("commit", commit.into()),
}
}
pub fn kind(self, kind: RefKind) -> Self {
Self {
builder: self.builder.property("kind", kind),
}
}
pub fn name(self, name: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("name", name.into()),
}
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> InstalledRef {
self.builder.build()
}
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::InstalledRef>> Sealed for T {}
}
pub trait InstalledRefExt: IsA<InstalledRef> + sealed::Sealed + 'static {
#[cfg(feature = "v1_4_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_4_2")))]
#[doc(alias = "flatpak_installed_ref_get_appdata_content_rating_type")]
#[doc(alias = "get_appdata_content_rating_type")]
#[doc(alias = "appdata-content-rating-type")]
fn appdata_content_rating_type(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::flatpak_installed_ref_get_appdata_content_rating_type(
self.as_ref().to_glib_none().0,
))
}
}
#[cfg(feature = "v1_1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_1_2")))]
#[doc(alias = "flatpak_installed_ref_get_appdata_license")]
#[doc(alias = "get_appdata_license")]
#[doc(alias = "appdata-license")]
fn appdata_license(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::flatpak_installed_ref_get_appdata_license(
self.as_ref().to_glib_none().0,
))
}
}
#[cfg(feature = "v1_1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_1_2")))]
#[doc(alias = "flatpak_installed_ref_get_appdata_name")]
#[doc(alias = "get_appdata_name")]
#[doc(alias = "appdata-name")]
fn appdata_name(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::flatpak_installed_ref_get_appdata_name(
self.as_ref().to_glib_none().0,
))
}
}
#[cfg(feature = "v1_1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_1_2")))]
#[doc(alias = "flatpak_installed_ref_get_appdata_summary")]
#[doc(alias = "get_appdata_summary")]
#[doc(alias = "appdata-summary")]
fn appdata_summary(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::flatpak_installed_ref_get_appdata_summary(
self.as_ref().to_glib_none().0,
))
}
}
#[cfg(feature = "v1_1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_1_2")))]
#[doc(alias = "flatpak_installed_ref_get_appdata_version")]
#[doc(alias = "get_appdata_version")]
#[doc(alias = "appdata-version")]
fn appdata_version(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::flatpak_installed_ref_get_appdata_version(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "flatpak_installed_ref_get_deploy_dir")]
#[doc(alias = "get_deploy_dir")]
#[doc(alias = "deploy-dir")]
fn deploy_dir(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::flatpak_installed_ref_get_deploy_dir(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "flatpak_installed_ref_get_eol")]
#[doc(alias = "get_eol")]
fn eol(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::flatpak_installed_ref_get_eol(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "flatpak_installed_ref_get_eol_rebase")]
#[doc(alias = "get_eol_rebase")]
fn eol_rebase(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::flatpak_installed_ref_get_eol_rebase(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "flatpak_installed_ref_get_installed_size")]
#[doc(alias = "get_installed_size")]
#[doc(alias = "installed-size")]
fn installed_size(&self) -> u64 {
unsafe { ffi::flatpak_installed_ref_get_installed_size(self.as_ref().to_glib_none().0) }
}
#[doc(alias = "flatpak_installed_ref_get_is_current")]
#[doc(alias = "get_is_current")]
#[doc(alias = "is-current")]
fn is_current(&self) -> bool {
unsafe {
from_glib(ffi::flatpak_installed_ref_get_is_current(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "flatpak_installed_ref_get_latest_commit")]
#[doc(alias = "get_latest_commit")]
#[doc(alias = "latest-commit")]
fn latest_commit(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::flatpak_installed_ref_get_latest_commit(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "flatpak_installed_ref_get_origin")]
#[doc(alias = "get_origin")]
fn origin(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::flatpak_installed_ref_get_origin(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "flatpak_installed_ref_get_subpaths")]
#[doc(alias = "get_subpaths")]
fn subpaths(&self) -> Vec<glib::GString> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::flatpak_installed_ref_get_subpaths(
self.as_ref().to_glib_none().0,
))
}
}
#[cfg(feature = "v1_1_2")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_1_2")))]
#[doc(alias = "flatpak_installed_ref_load_appdata")]
fn load_appdata(
&self,
cancellable: Option<&impl IsA<gio::Cancellable>>,
) -> Result<glib::Bytes, glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let ret = ffi::flatpak_installed_ref_load_appdata(
self.as_ref().to_glib_none().0,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "flatpak_installed_ref_load_metadata")]
fn load_metadata(
&self,
cancellable: Option<&impl IsA<gio::Cancellable>>,
) -> Result<glib::Bytes, glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let ret = ffi::flatpak_installed_ref_load_metadata(
self.as_ref().to_glib_none().0,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
}
}
}
#[cfg(not(feature = "v1_4_2"))]
#[cfg_attr(docsrs, doc(cfg(not(feature = "v1_4_2"))))]
#[doc(alias = "appdata-content-rating-type")]
fn appdata_content_rating_type(&self) -> Option<glib::GString> {
ObjectExt::property(self.as_ref(), "appdata-content-rating-type")
}
#[cfg(not(feature = "v1_1_2"))]
#[cfg_attr(docsrs, doc(cfg(not(feature = "v1_1_2"))))]
#[doc(alias = "appdata-license")]
fn appdata_license(&self) -> Option<glib::GString> {
ObjectExt::property(self.as_ref(), "appdata-license")
}
#[cfg(not(feature = "v1_1_2"))]
#[cfg_attr(docsrs, doc(cfg(not(feature = "v1_1_2"))))]
#[doc(alias = "appdata-name")]
fn appdata_name(&self) -> Option<glib::GString> {
ObjectExt::property(self.as_ref(), "appdata-name")
}
#[cfg(not(feature = "v1_1_2"))]
#[cfg_attr(docsrs, doc(cfg(not(feature = "v1_1_2"))))]
#[doc(alias = "appdata-summary")]
fn appdata_summary(&self) -> Option<glib::GString> {
ObjectExt::property(self.as_ref(), "appdata-summary")
}
#[cfg(not(feature = "v1_1_2"))]
#[cfg_attr(docsrs, doc(cfg(not(feature = "v1_1_2"))))]
#[doc(alias = "appdata-version")]
fn appdata_version(&self) -> Option<glib::GString> {
ObjectExt::property(self.as_ref(), "appdata-version")
}
#[doc(alias = "deploy-dir")]
fn set_deploy_dir(&self, deploy_dir: Option<&str>) {
ObjectExt::set_property(self.as_ref(), "deploy-dir", deploy_dir)
}
#[doc(alias = "end-of-life")]
fn end_of_life(&self) -> Option<glib::GString> {
ObjectExt::property(self.as_ref(), "end-of-life")
}
#[doc(alias = "end-of-life-rebase")]
fn end_of_life_rebase(&self) -> Option<glib::GString> {
ObjectExt::property(self.as_ref(), "end-of-life-rebase")
}
#[doc(alias = "installed-size")]
fn set_installed_size(&self, installed_size: u64) {
ObjectExt::set_property(self.as_ref(), "installed-size", installed_size)
}
#[doc(alias = "is-current")]
fn set_is_current(&self, is_current: bool) {
ObjectExt::set_property(self.as_ref(), "is-current", is_current)
}
#[doc(alias = "latest-commit")]
fn set_latest_commit(&self, latest_commit: Option<&str>) {
ObjectExt::set_property(self.as_ref(), "latest-commit", latest_commit)
}
fn set_origin(&self, origin: Option<&str>) {
ObjectExt::set_property(self.as_ref(), "origin", origin)
}
fn set_subpaths(&self, subpaths: &[&str]) {
ObjectExt::set_property(self.as_ref(), "subpaths", subpaths)
}
#[doc(alias = "deploy-dir")]
fn connect_deploy_dir_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_deploy_dir_trampoline<
P: IsA<InstalledRef>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::FlatpakInstalledRef,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(InstalledRef::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::deploy-dir\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_deploy_dir_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "installed-size")]
fn connect_installed_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_installed_size_trampoline<
P: IsA<InstalledRef>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::FlatpakInstalledRef,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(InstalledRef::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::installed-size\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_installed_size_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "is-current")]
fn connect_is_current_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_is_current_trampoline<
P: IsA<InstalledRef>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::FlatpakInstalledRef,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(InstalledRef::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-current\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_is_current_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "latest-commit")]
fn connect_latest_commit_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_latest_commit_trampoline<
P: IsA<InstalledRef>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::FlatpakInstalledRef,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(InstalledRef::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::latest-commit\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_latest_commit_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "origin")]
fn connect_origin_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_origin_trampoline<P: IsA<InstalledRef>, F: Fn(&P) + 'static>(
this: *mut ffi::FlatpakInstalledRef,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(InstalledRef::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::origin\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_origin_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "subpaths")]
fn connect_subpaths_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_subpaths_trampoline<
P: IsA<InstalledRef>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::FlatpakInstalledRef,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(InstalledRef::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::subpaths\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_subpaths_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<InstalledRef>> InstalledRefExt for O {}