libappstream/auto/screenshot.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT
use crate::{ffi, Context, Image, ScreenshotKind, ScreenshotMediaKind, Video};
use glib::{prelude::*, translate::*};
glib::wrapper! {
///
///
/// # Implements
///
/// [`ScreenshotExt`][trait@crate::prelude::ScreenshotExt]
#[doc(alias = "AsScreenshot")]
pub struct Screenshot(Object<ffi::AsScreenshot, ffi::AsScreenshotClass>);
match fn {
type_ => || ffi::as_screenshot_get_type(),
}
}
impl Screenshot {
pub const NONE: Option<&'static Screenshot> = None;
/// Creates a new [`Screenshot`][crate::Screenshot].
///
/// # Returns
///
/// a [`Screenshot`][crate::Screenshot]
#[doc(alias = "as_screenshot_new")]
pub fn new() -> Screenshot {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::as_screenshot_new()) }
}
}
impl Default for Screenshot {
fn default() -> Self {
Self::new()
}
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Screenshot>> Sealed for T {}
}
/// Trait containing all [`struct@Screenshot`] methods.
///
/// # Implementors
///
/// [`Screenshot`][struct@crate::Screenshot]
pub trait ScreenshotExt: IsA<Screenshot> + sealed::Sealed + 'static {
/// Adds an image to the screenshot.
/// ## `image`
/// a [`Image`][crate::Image] instance.
#[doc(alias = "as_screenshot_add_image")]
fn add_image(&self, image: &impl IsA<Image>) {
unsafe {
ffi::as_screenshot_add_image(
self.as_ref().to_glib_none().0,
image.as_ref().to_glib_none().0,
);
}
}
/// Adds a video to the screenshot.
/// ## `video`
/// a [`Video`][crate::Video] instance.
#[doc(alias = "as_screenshot_add_video")]
fn add_video(&self, video: &impl IsA<Video>) {
unsafe {
ffi::as_screenshot_add_video(
self.as_ref().to_glib_none().0,
video.as_ref().to_glib_none().0,
);
}
}
/// Remove all images associated with this screenshot.
#[doc(alias = "as_screenshot_clear_images")]
fn clear_images(&self) {
unsafe {
ffi::as_screenshot_clear_images(self.as_ref().to_glib_none().0);
}
}
/// Gets the image caption
///
/// # Returns
///
/// the caption
#[doc(alias = "as_screenshot_get_caption")]
#[doc(alias = "get_caption")]
fn caption(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::as_screenshot_get_caption(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns the [`Context`][crate::Context] associated with this screenshot.
/// This function may return [`None`] if no context is set.
///
/// # Returns
///
/// the [`Context`][crate::Context] used by this screenshot.
#[doc(alias = "as_screenshot_get_context")]
#[doc(alias = "get_context")]
fn context(&self) -> Option<Context> {
unsafe {
from_glib_none(ffi::as_screenshot_get_context(
self.as_ref().to_glib_none().0,
))
}
}
/// Get the GUI environment ID of this screenshot, if any
/// is associated with it. E.g. "plasma-mobile" or "gnome:dark".
///
/// # Returns
///
/// The GUI environment ID the screenshot was recorded in, or [`None`] if none set.
#[doc(alias = "as_screenshot_get_environment")]
#[doc(alias = "get_environment")]
fn environment(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::as_screenshot_get_environment(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the AsImage closest to the target size. The [`Image`][crate::Image] may not actually
/// be the requested size, and the application may have to pad / rescale the
/// image to make it fit.
/// Only images for the current active locale (or fallback, if images are not localized)
/// are considered.
/// ## `width`
/// target width
/// ## `height`
/// target height
/// ## `scale`
/// the target scaling factor.
///
/// # Returns
///
/// an [`Image`][crate::Image], or [`None`]
#[doc(alias = "as_screenshot_get_image")]
#[doc(alias = "get_image")]
fn image(&self, width: u32, height: u32, scale: u32) -> Option<Image> {
unsafe {
from_glib_none(ffi::as_screenshot_get_image(
self.as_ref().to_glib_none().0,
width,
height,
scale,
))
}
}
/// Gets the images for this screenshots. Only images valid for the current
/// language are returned. We return all sizes.
///
/// # Returns
///
/// an array
#[doc(alias = "as_screenshot_get_images")]
#[doc(alias = "get_images")]
fn images(&self) -> Vec<Image> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::as_screenshot_get_images(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns an array of all images we have, regardless of their
/// size and language.
///
/// # Returns
///
/// an array
#[doc(alias = "as_screenshot_get_images_all")]
#[doc(alias = "get_images_all")]
fn images_all(&self) -> Vec<Image> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::as_screenshot_get_images_all(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the screenshot kind.
///
/// # Returns
///
/// a [`ScreenshotKind`][crate::ScreenshotKind]
#[doc(alias = "as_screenshot_get_kind")]
#[doc(alias = "get_kind")]
fn kind(&self) -> ScreenshotKind {
unsafe { from_glib(ffi::as_screenshot_get_kind(self.as_ref().to_glib_none().0)) }
}
/// Gets the screenshot media kind.
///
/// # Returns
///
/// a [`ScreenshotMediaKind`][crate::ScreenshotMediaKind]
#[doc(alias = "as_screenshot_get_media_kind")]
#[doc(alias = "get_media_kind")]
fn media_kind(&self) -> ScreenshotMediaKind {
unsafe {
from_glib(ffi::as_screenshot_get_media_kind(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the videos for this screenshots. Only videos valid for the current
/// language selection are returned. We return all sizes.
///
/// # Returns
///
/// an array
#[doc(alias = "as_screenshot_get_videos")]
#[doc(alias = "get_videos")]
fn videos(&self) -> Vec<Video> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::as_screenshot_get_videos(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns an array of all screencast videos we have, regardless of their
/// size and locale.
///
/// # Returns
///
/// an array
#[doc(alias = "as_screenshot_get_videos_all")]
#[doc(alias = "get_videos_all")]
fn videos_all(&self) -> Vec<Video> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::as_screenshot_get_videos_all(
self.as_ref().to_glib_none().0,
))
}
}
/// Performs a quick validation on this screenshot
///
/// # Returns
///
/// TRUE if the screenshot is a complete [`Screenshot`][crate::Screenshot]
#[doc(alias = "as_screenshot_is_valid")]
fn is_valid(&self) -> bool {
unsafe { from_glib(ffi::as_screenshot_is_valid(self.as_ref().to_glib_none().0)) }
}
/// Sets a caption on the screenshot
/// ## `caption`
/// the caption text.
#[doc(alias = "as_screenshot_set_caption")]
fn set_caption(&self, caption: &str, locale: &str) {
unsafe {
ffi::as_screenshot_set_caption(
self.as_ref().to_glib_none().0,
caption.to_glib_none().0,
locale.to_glib_none().0,
);
}
}
/// Sets the document context this screenshot is associated
/// with.
/// ## `context`
/// the [`Context`][crate::Context].
#[doc(alias = "as_screenshot_set_context")]
fn set_context(&self, context: &impl IsA<Context>) {
unsafe {
ffi::as_screenshot_set_context(
self.as_ref().to_glib_none().0,
context.as_ref().to_glib_none().0,
);
}
}
/// Sets the GUI environment ID of this screenshot.
/// ## `env_id`
/// the GUI environment ID, e.g. "plasma-mobile" or "gnome:dark"
#[doc(alias = "as_screenshot_set_environment")]
fn set_environment(&self, env_id: Option<&str>) {
unsafe {
ffi::as_screenshot_set_environment(
self.as_ref().to_glib_none().0,
env_id.to_glib_none().0,
);
}
}
/// Sets the screenshot kind.
/// ## `kind`
/// the [`ScreenshotKind`][crate::ScreenshotKind].
#[doc(alias = "as_screenshot_set_kind")]
fn set_kind(&self, kind: ScreenshotKind) {
unsafe {
ffi::as_screenshot_set_kind(self.as_ref().to_glib_none().0, kind.into_glib());
}
}
}
impl<O: IsA<Screenshot>> ScreenshotExt for O {}