| 1 |
// This file was generated by gir (https://github.com/gtk-rs/gir) |
| 2 |
// from gir-files (https://github.com/gtk-rs/gir-files) |
| 3 |
// DO NOT EDIT |
| 4 |
|
| 5 |
use crate::{Initable, ffi}; |
| 6 |
use glib::{ |
| 7 |
prelude::*, |
| 8 |
signal::{SignalHandlerId, connect_raw}, |
| 9 |
translate::*, |
| 10 |
}; |
| 11 |
use std::boxed::Box as Box_; |
| 12 |
|
| 13 |
glib::wrapper! { |
| 14 |
#[doc(alias = "GPowerProfileMonitor")] |
| 15 |
pub struct PowerProfileMonitor(Interface<ffi::GPowerProfileMonitor, ffi::GPowerProfileMonitorInterface>) @requires Initable; |
| 16 |
|
| 17 |
match fn { |
| 18 |
type_ => || ffi::g_power_profile_monitor_get_type(), |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
impl PowerProfileMonitor { |
| 23 |
pub const NONE: Option<&'static PowerProfileMonitor> = None; |
| 24 |
|
| 25 |
#[doc(alias = "g_power_profile_monitor_dup_default")] |
| 26 |
#[doc(alias = "dup_default")] |
| 27 |
pub fn get_default() -> PowerProfileMonitor { |
| 28 |
unsafe { from_glib_full(ffi::g_power_profile_monitor_dup_default()) } |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
pub trait PowerProfileMonitorExt: IsA<PowerProfileMonitor> + 'static { |
| 33 |
#[doc(alias = "g_power_profile_monitor_get_power_saver_enabled")] |
| 34 |
#[doc(alias = "get_power_saver_enabled")] |
| 35 |
#[doc(alias = "power-saver-enabled")] |
| 36 |
fn is_power_saver_enabled(&self) -> bool { |
| 37 |
unsafe { |
| 38 |
from_glib(ffi::g_power_profile_monitor_get_power_saver_enabled( |
| 39 |
self.as_ref().to_glib_none().0, |
| 40 |
)) |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
#[cfg(feature = "v2_70")] |
| 45 |
#[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] |
| 46 |
#[doc(alias = "power-saver-enabled")] |
| 47 |
fn connect_power_saver_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { |
| 48 |
unsafe extern "C" fn notify_power_saver_enabled_trampoline< |
| 49 |
P: IsA<PowerProfileMonitor>, |
| 50 |
F: Fn(&P) + 'static, |
| 51 |
>( |
| 52 |
this: *mut ffi::GPowerProfileMonitor, |
| 53 |
_param_spec: glib::ffi::gpointer, |
| 54 |
f: glib::ffi::gpointer, |
| 55 |
) { |
| 56 |
unsafe { |
| 57 |
let f: &F = &*(f as *const F); |
| 58 |
f(PowerProfileMonitor::from_glib_borrow(this).unsafe_cast_ref()) |
| 59 |
} |
| 60 |
} |
| 61 |
unsafe { |
| 62 |
let f: Box_<F> = Box_::new(f); |
| 63 |
connect_raw( |
| 64 |
self.as_ptr() as *mut _, |
| 65 |
c"notify::power-saver-enabled".as_ptr(), |
| 66 |
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( |
| 67 |
notify_power_saver_enabled_trampoline::<Self, F> as *const (), |
| 68 |
)), |
| 69 |
Box_::into_raw(f), |
| 70 |
) |
| 71 |
} |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
impl<O: IsA<PowerProfileMonitor>> PowerProfileMonitorExt for O {} |