use crate::{ffi,StatusIcon,StatusPage};
use glib::{object::ObjectType as _,prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
use std::{boxed::Box as Box_};
glib::wrapper! {
#[doc(alias = "PhoshQuickSetting")]
pub struct QuickSetting(Object<ffi::PhoshQuickSetting, ffi::PhoshQuickSettingClass>) @extends gtk::Container, gtk::Widget;
match fn {
type_ => || ffi::phosh_quick_setting_get_type(),
}
}
impl QuickSetting {
pub const NONE: Option<&'static QuickSetting> = None;
#[doc(alias = "phosh_quick_setting_new")]
pub fn new(status_page: &impl IsA<StatusPage>) -> QuickSetting {
skip_assert_initialized!();
unsafe {
gtk::Widget::from_glib_none(ffi::phosh_quick_setting_new(status_page.as_ref().to_glib_none().0)).unsafe_cast()
}
}
pub fn builder() -> QuickSettingBuilder {
QuickSettingBuilder::new()
}
}
impl Default for QuickSetting {
fn default() -> Self {
glib::object::Object::new::<Self>()
}
}
#[must_use = "The builder must be built to be used"]
pub struct QuickSettingBuilder {
builder: glib::object::ObjectBuilder<'static, QuickSetting>,
}
impl QuickSettingBuilder {
fn new() -> Self {
Self { builder: glib::object::Object::builder() }
}
pub fn active(self, active: bool) -> Self {
Self { builder: self.builder.property("active", active), }
}
pub fn can_show_status(self, can_show_status: bool) -> Self {
Self { builder: self.builder.property("can-show-status", can_show_status), }
}
pub fn long_press_action_name(self, long_press_action_name: impl Into<glib::GString>) -> Self {
Self { builder: self.builder.property("long-press-action-name", long_press_action_name.into()), }
}
pub fn long_press_action_target(self, long_press_action_target: impl Into<glib::GString>) -> Self {
Self { builder: self.builder.property("long-press-action-target", long_press_action_target.into()), }
}
pub fn showing_status(self, showing_status: bool) -> Self {
Self { builder: self.builder.property("showing-status", showing_status), }
}
pub fn status_icon(self, status_icon: &impl IsA<StatusIcon>) -> Self {
Self { builder: self.builder.property("status-icon", status_icon.clone().upcast()), }
}
pub fn status_page(self, status_page: &impl IsA<StatusPage>) -> Self {
Self { builder: self.builder.property("status-page", status_page.clone().upcast()), }
}
pub fn border_width(self, border_width: u32) -> Self {
Self { builder: self.builder.property("border-width", border_width), }
}
pub fn child(self, child: &impl IsA<gtk::Widget>) -> Self {
Self { builder: self.builder.property("child", child.clone().upcast()), }
}
pub fn app_paintable(self, app_paintable: bool) -> Self {
Self { builder: self.builder.property("app-paintable", app_paintable), }
}
pub fn can_default(self, can_default: bool) -> Self {
Self { builder: self.builder.property("can-default", can_default), }
}
pub fn can_focus(self, can_focus: bool) -> Self {
Self { builder: self.builder.property("can-focus", can_focus), }
}
#[cfg(feature = "gtk_v2_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v2_18")))]
#[cfg_attr(feature = "v3_14", deprecated = "Since 3.14")]
pub fn double_buffered(self, double_buffered: bool) -> Self {
Self { builder: self.builder.property("double-buffered", double_buffered), }
}
#[cfg(feature = "gtk_v3")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
pub fn expand(self, expand: bool) -> Self {
Self { builder: self.builder.property("expand", expand), }
}
#[cfg(feature = "gtk_v3_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3_20")))]
pub fn focus_on_click(self, focus_on_click: bool) -> Self {
Self { builder: self.builder.property("focus-on-click", focus_on_click), }
}
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
pub fn has_default(self, has_default: bool) -> Self {
Self { builder: self.builder.property("has-default", has_default), }
}
pub fn has_focus(self, has_focus: bool) -> Self {
Self { builder: self.builder.property("has-focus", has_focus), }
}
#[cfg(feature = "gtk_v2_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v2_12")))]
pub fn has_tooltip(self, has_tooltip: bool) -> Self {
Self { builder: self.builder.property("has-tooltip", has_tooltip), }
}
pub fn height_request(self, height_request: i32) -> Self {
Self { builder: self.builder.property("height-request", height_request), }
}
#[cfg(feature = "gtk_v3")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
pub fn hexpand(self, hexpand: bool) -> Self {
Self { builder: self.builder.property("hexpand", hexpand), }
}
#[cfg(feature = "gtk_v3")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
pub fn hexpand_set(self, hexpand_set: bool) -> Self {
Self { builder: self.builder.property("hexpand-set", hexpand_set), }
}
pub fn is_focus(self, is_focus: bool) -> Self {
Self { builder: self.builder.property("is-focus", is_focus), }
}
#[cfg(feature = "gtk_v3")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
pub fn margin(self, margin: i32) -> Self {
Self { builder: self.builder.property("margin", margin), }
}
#[cfg(feature = "gtk_v3")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
pub fn margin_bottom(self, margin_bottom: i32) -> Self {
Self { builder: self.builder.property("margin-bottom", margin_bottom), }
}
#[cfg(feature = "gtk_v3_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3_12")))]
pub fn margin_end(self, margin_end: i32) -> Self {
Self { builder: self.builder.property("margin-end", margin_end), }
}
#[cfg(feature = "gtk_v3")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
#[cfg_attr(feature = "v3_12", deprecated = "Since 3.12")]
pub fn margin_left(self, margin_left: i32) -> Self {
Self { builder: self.builder.property("margin-left", margin_left), }
}
#[cfg(feature = "gtk_v3")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
#[cfg_attr(feature = "v3_12", deprecated = "Since 3.12")]
pub fn margin_right(self, margin_right: i32) -> Self {
Self { builder: self.builder.property("margin-right", margin_right), }
}
#[cfg(feature = "gtk_v3_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3_12")))]
pub fn margin_start(self, margin_start: i32) -> Self {
Self { builder: self.builder.property("margin-start", margin_start), }
}
#[cfg(feature = "gtk_v3")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
pub fn margin_top(self, margin_top: i32) -> Self {
Self { builder: self.builder.property("margin-top", margin_top), }
}
pub fn name(self, name: impl Into<glib::GString>) -> Self {
Self { builder: self.builder.property("name", name.into()), }
}
pub fn no_show_all(self, no_show_all: bool) -> Self {
Self { builder: self.builder.property("no-show-all", no_show_all), }
}
#[cfg(feature = "gtk_v3_8")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3_8")))]
pub fn opacity(self, opacity: f64) -> Self {
Self { builder: self.builder.property("opacity", opacity), }
}
pub fn parent(self, parent: &impl IsA<gtk::Container>) -> Self {
Self { builder: self.builder.property("parent", parent.clone().upcast()), }
}
pub fn receives_default(self, receives_default: bool) -> Self {
Self { builder: self.builder.property("receives-default", receives_default), }
}
pub fn sensitive(self, sensitive: bool) -> Self {
Self { builder: self.builder.property("sensitive", sensitive), }
}
#[cfg(feature = "gtk_v2_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v2_12")))]
pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
Self { builder: self.builder.property("tooltip-markup", tooltip_markup.into()), }
}
#[cfg(feature = "gtk_v2_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v2_12")))]
pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), }
}
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
#[cfg(feature = "gtk_v3")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
pub fn vexpand(self, vexpand: bool) -> Self {
Self { builder: self.builder.property("vexpand", vexpand), }
}
#[cfg(feature = "gtk_v3")]
#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v3")))]
pub fn vexpand_set(self, vexpand_set: bool) -> Self {
Self { builder: self.builder.property("vexpand-set", vexpand_set), }
}
pub fn visible(self, visible: bool) -> Self {
Self { builder: self.builder.property("visible", visible), }
}
pub fn width_request(self, width_request: i32) -> Self {
Self { builder: self.builder.property("width-request", width_request), }
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> QuickSetting {
assert_initialized_main_thread!();
self.builder.build() }
}
pub trait QuickSettingExt: IsA<QuickSetting> + 'static {
#[doc(alias = "phosh_quick_setting_get_active")]
#[doc(alias = "get_active")]
#[doc(alias = "active")]
fn is_active(&self) -> bool {
unsafe {
from_glib(ffi::phosh_quick_setting_get_active(self.as_ref().to_glib_none().0))
}
}
#[doc(alias = "phosh_quick_setting_get_can_show_status")]
#[doc(alias = "get_can_show_status")]
#[doc(alias = "can-show-status")]
fn can_show_status(&self) -> bool {
unsafe {
from_glib(ffi::phosh_quick_setting_get_can_show_status(self.as_ref().to_glib_none().0))
}
}
#[doc(alias = "phosh_quick_setting_get_long_press_action_name")]
#[doc(alias = "get_long_press_action_name")]
#[doc(alias = "long-press-action-name")]
fn long_press_action_name(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::phosh_quick_setting_get_long_press_action_name(self.as_ref().to_glib_none().0))
}
}
#[doc(alias = "phosh_quick_setting_get_long_press_action_target")]
#[doc(alias = "get_long_press_action_target")]
#[doc(alias = "long-press-action-target")]
fn long_press_action_target(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::phosh_quick_setting_get_long_press_action_target(self.as_ref().to_glib_none().0))
}
}
#[doc(alias = "phosh_quick_setting_get_showing_status")]
#[doc(alias = "get_showing_status")]
#[doc(alias = "showing-status")]
fn is_showing_status(&self) -> bool {
unsafe {
from_glib(ffi::phosh_quick_setting_get_showing_status(self.as_ref().to_glib_none().0))
}
}
#[doc(alias = "phosh_quick_setting_get_status_icon")]
#[doc(alias = "get_status_icon")]
#[doc(alias = "status-icon")]
fn status_icon(&self) -> StatusIcon {
unsafe {
from_glib_none(ffi::phosh_quick_setting_get_status_icon(self.as_ref().to_glib_none().0))
}
}
#[doc(alias = "phosh_quick_setting_get_status_page")]
#[doc(alias = "get_status_page")]
#[doc(alias = "status-page")]
fn status_page(&self) -> StatusPage {
unsafe {
from_glib_none(ffi::phosh_quick_setting_get_status_page(self.as_ref().to_glib_none().0))
}
}
#[doc(alias = "phosh_quick_setting_set_active")]
#[doc(alias = "active")]
fn set_active(&self, active: bool) {
unsafe {
ffi::phosh_quick_setting_set_active(self.as_ref().to_glib_none().0, active.into_glib());
}
}
#[doc(alias = "phosh_quick_setting_set_can_show_status")]
#[doc(alias = "can-show-status")]
fn set_can_show_status(&self, can_show_status: bool) {
unsafe {
ffi::phosh_quick_setting_set_can_show_status(self.as_ref().to_glib_none().0, can_show_status.into_glib());
}
}
#[doc(alias = "phosh_quick_setting_set_long_press_action_name")]
#[doc(alias = "long-press-action-name")]
fn set_long_press_action_name(&self, action_name: &str) {
unsafe {
ffi::phosh_quick_setting_set_long_press_action_name(self.as_ref().to_glib_none().0, action_name.to_glib_none().0);
}
}
#[doc(alias = "phosh_quick_setting_set_long_press_action_target")]
#[doc(alias = "long-press-action-target")]
fn set_long_press_action_target(&self, action_target: &str) {
unsafe {
ffi::phosh_quick_setting_set_long_press_action_target(self.as_ref().to_glib_none().0, action_target.to_glib_none().0);
}
}
#[doc(alias = "phosh_quick_setting_set_showing_status")]
#[doc(alias = "showing-status")]
fn set_showing_status(&self, showing_status: bool) {
unsafe {
ffi::phosh_quick_setting_set_showing_status(self.as_ref().to_glib_none().0, showing_status.into_glib());
}
}
#[doc(alias = "phosh_quick_setting_set_status_icon")]
#[doc(alias = "status-icon")]
fn set_status_icon(&self, status_icon: &impl IsA<StatusIcon>) {
unsafe {
ffi::phosh_quick_setting_set_status_icon(self.as_ref().to_glib_none().0, status_icon.as_ref().to_glib_none().0);
}
}
#[doc(alias = "phosh_quick_setting_set_status_page")]
#[doc(alias = "status-page")]
fn set_status_page(&self, status_page: &impl IsA<StatusPage>) {
unsafe {
ffi::phosh_quick_setting_set_status_page(self.as_ref().to_glib_none().0, status_page.as_ref().to_glib_none().0);
}
}
#[doc(alias = "clicked")]
fn connect_clicked<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn clicked_trampoline<P: IsA<QuickSetting>, F: Fn(&P) + 'static>(this: *mut ffi::PhoshQuickSetting, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(QuickSetting::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, c"clicked".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(clicked_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
#[doc(alias = "hide-status")]
fn connect_hide_status<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn hide_status_trampoline<P: IsA<QuickSetting>, F: Fn(&P) + 'static>(this: *mut ffi::PhoshQuickSetting, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(QuickSetting::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, c"hide-status".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(hide_status_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
#[doc(alias = "long-pressed")]
fn connect_long_pressed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn long_pressed_trampoline<P: IsA<QuickSetting>, F: Fn(&P) + 'static>(this: *mut ffi::PhoshQuickSetting, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(QuickSetting::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, c"long-pressed".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(long_pressed_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
#[doc(alias = "show-status")]
fn connect_show_status<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn show_status_trampoline<P: IsA<QuickSetting>, F: Fn(&P) + 'static>(this: *mut ffi::PhoshQuickSetting, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(QuickSetting::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, c"show-status".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(show_status_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
#[doc(alias = "active")]
fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_active_trampoline<P: IsA<QuickSetting>, F: Fn(&P) + 'static>(this: *mut ffi::PhoshQuickSetting, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(QuickSetting::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, c"notify::active".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_active_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
#[doc(alias = "can-show-status")]
fn connect_can_show_status_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_can_show_status_trampoline<P: IsA<QuickSetting>, F: Fn(&P) + 'static>(this: *mut ffi::PhoshQuickSetting, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(QuickSetting::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, c"notify::can-show-status".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_can_show_status_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
#[doc(alias = "long-press-action-name")]
fn connect_long_press_action_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_long_press_action_name_trampoline<P: IsA<QuickSetting>, F: Fn(&P) + 'static>(this: *mut ffi::PhoshQuickSetting, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(QuickSetting::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, c"notify::long-press-action-name".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_long_press_action_name_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
#[doc(alias = "long-press-action-target")]
fn connect_long_press_action_target_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_long_press_action_target_trampoline<P: IsA<QuickSetting>, F: Fn(&P) + 'static>(this: *mut ffi::PhoshQuickSetting, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(QuickSetting::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, c"notify::long-press-action-target".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_long_press_action_target_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
#[doc(alias = "showing-status")]
fn connect_showing_status_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_showing_status_trampoline<P: IsA<QuickSetting>, F: Fn(&P) + 'static>(this: *mut ffi::PhoshQuickSetting, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(QuickSetting::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, c"notify::showing-status".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_showing_status_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
#[doc(alias = "status-icon")]
fn connect_status_icon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_status_icon_trampoline<P: IsA<QuickSetting>, F: Fn(&P) + 'static>(this: *mut ffi::PhoshQuickSetting, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(QuickSetting::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, c"notify::status-icon".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_status_icon_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
#[doc(alias = "status-page")]
fn connect_status_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_status_page_trampoline<P: IsA<QuickSetting>, F: Fn(&P) + 'static>(this: *mut ffi::PhoshQuickSetting, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(QuickSetting::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, c"notify::status-page".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_status_page_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
}
impl<O: IsA<QuickSetting>> QuickSettingExt for O {}