use Image;
use ScreenshotKind;
use app_stream_glib_sys;
use glib::GString;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
glib_wrapper! {
pub struct Screenshot(Object<app_stream_glib_sys::AsScreenshot, app_stream_glib_sys::AsScreenshotClass, ScreenshotClass>);
match fn {
get_type => || app_stream_glib_sys::as_screenshot_get_type(),
}
}
impl Screenshot {
pub fn new() -> Screenshot {
unsafe {
from_glib_full(app_stream_glib_sys::as_screenshot_new())
}
}
pub fn kind_from_string(kind: &str) -> ScreenshotKind {
unsafe {
from_glib(app_stream_glib_sys::as_screenshot_kind_from_string(kind.to_glib_none().0))
}
}
pub fn kind_to_string(kind: ScreenshotKind) -> Option<GString> {
unsafe {
from_glib_none(app_stream_glib_sys::as_screenshot_kind_to_string(kind.to_glib()))
}
}
}
impl Default for Screenshot {
fn default() -> Self {
Self::new()
}
}
pub const NONE_SCREENSHOT: Option<&Screenshot> = None;
pub trait ScreenshotExt: 'static {
fn add_image<P: IsA<Image>>(&self, image: &P);
#[cfg(any(feature = "v0_5_7", feature = "dox"))]
fn equal<P: IsA<Screenshot>>(&self, screenshot2: &P) -> bool;
fn get_caption(&self, locale: Option<&str>) -> Option<GString>;
#[cfg(any(feature = "v0_2_2", feature = "dox"))]
fn get_image(&self, width: u32, height: u32) -> Option<Image>;
#[cfg(any(feature = "v0_5_14", feature = "dox"))]
fn get_image_for_locale(&self, locale: Option<&str>, width: u32, height: u32) -> Option<Image>;
fn get_kind(&self) -> ScreenshotKind;
#[cfg(any(feature = "v0_3_1", feature = "dox"))]
fn get_priority(&self) -> i32;
#[cfg(any(feature = "v0_1_6", feature = "dox"))]
fn get_source(&self) -> Option<Image>;
fn set_caption(&self, locale: Option<&str>, caption: &str);
fn set_kind(&self, kind: ScreenshotKind);
#[cfg(any(feature = "v0_3_1", feature = "dox"))]
fn set_priority(&self, priority: i32);
}
impl<O: IsA<Screenshot>> ScreenshotExt for O {
fn add_image<P: IsA<Image>>(&self, image: &P) {
unsafe {
app_stream_glib_sys::as_screenshot_add_image(self.as_ref().to_glib_none().0, image.as_ref().to_glib_none().0);
}
}
#[cfg(any(feature = "v0_5_7", feature = "dox"))]
fn equal<P: IsA<Screenshot>>(&self, screenshot2: &P) -> bool {
unsafe {
from_glib(app_stream_glib_sys::as_screenshot_equal(self.as_ref().to_glib_none().0, screenshot2.as_ref().to_glib_none().0))
}
}
fn get_caption(&self, locale: Option<&str>) -> Option<GString> {
unsafe {
from_glib_none(app_stream_glib_sys::as_screenshot_get_caption(self.as_ref().to_glib_none().0, locale.to_glib_none().0))
}
}
#[cfg(any(feature = "v0_2_2", feature = "dox"))]
fn get_image(&self, width: u32, height: u32) -> Option<Image> {
unsafe {
from_glib_none(app_stream_glib_sys::as_screenshot_get_image(self.as_ref().to_glib_none().0, width, height))
}
}
#[cfg(any(feature = "v0_5_14", feature = "dox"))]
fn get_image_for_locale(&self, locale: Option<&str>, width: u32, height: u32) -> Option<Image> {
unsafe {
from_glib_none(app_stream_glib_sys::as_screenshot_get_image_for_locale(self.as_ref().to_glib_none().0, locale.to_glib_none().0, width, height))
}
}
fn get_kind(&self) -> ScreenshotKind {
unsafe {
from_glib(app_stream_glib_sys::as_screenshot_get_kind(self.as_ref().to_glib_none().0))
}
}
#[cfg(any(feature = "v0_3_1", feature = "dox"))]
fn get_priority(&self) -> i32 {
unsafe {
app_stream_glib_sys::as_screenshot_get_priority(self.as_ref().to_glib_none().0)
}
}
#[cfg(any(feature = "v0_1_6", feature = "dox"))]
fn get_source(&self) -> Option<Image> {
unsafe {
from_glib_none(app_stream_glib_sys::as_screenshot_get_source(self.as_ref().to_glib_none().0))
}
}
fn set_caption(&self, locale: Option<&str>, caption: &str) {
unsafe {
app_stream_glib_sys::as_screenshot_set_caption(self.as_ref().to_glib_none().0, locale.to_glib_none().0, caption.to_glib_none().0);
}
}
fn set_kind(&self, kind: ScreenshotKind) {
unsafe {
app_stream_glib_sys::as_screenshot_set_kind(self.as_ref().to_glib_none().0, kind.to_glib());
}
}
#[cfg(any(feature = "v0_3_1", feature = "dox"))]
fn set_priority(&self, priority: i32) {
unsafe {
app_stream_glib_sys::as_screenshot_set_priority(self.as_ref().to_glib_none().0, priority);
}
}
}
impl fmt::Display for Screenshot {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Screenshot")
}
}