gio/auto/
file_icon.rs

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
5use crate::{ffi, File, Icon, LoadableIcon};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// `GFileIcon` specifies an icon by pointing to an image file
10    /// to be used as icon.
11    ///
12    /// It implements [`LoadableIcon`][crate::LoadableIcon].
13    ///
14    /// ## Properties
15    ///
16    ///
17    /// #### `file`
18    ///  The file containing the icon.
19    ///
20    /// Readable | Writeable | Construct Only
21    ///
22    /// # Implements
23    ///
24    /// [`trait@glib::ObjectExt`], [`IconExt`][trait@crate::prelude::IconExt], [`LoadableIconExt`][trait@crate::prelude::LoadableIconExt]
25    #[doc(alias = "GFileIcon")]
26    pub struct FileIcon(Object<ffi::GFileIcon, ffi::GFileIconClass>) @implements Icon, LoadableIcon;
27
28    match fn {
29        type_ => || ffi::g_file_icon_get_type(),
30    }
31}
32
33impl FileIcon {
34    /// Creates a new icon for a file.
35    /// ## `file`
36    /// a #GFile.
37    ///
38    /// # Returns
39    ///
40    /// a #GIcon for the given
41    ///   @file, or [`None`] on error.
42    #[doc(alias = "g_file_icon_new")]
43    pub fn new(file: &impl IsA<File>) -> FileIcon {
44        unsafe { from_glib_full(ffi::g_file_icon_new(file.as_ref().to_glib_none().0)) }
45    }
46
47    /// Gets the #GFile associated with the given @self.
48    ///
49    /// # Returns
50    ///
51    /// a #GFile.
52    #[doc(alias = "g_file_icon_get_file")]
53    #[doc(alias = "get_file")]
54    pub fn file(&self) -> File {
55        unsafe { from_glib_none(ffi::g_file_icon_get_file(self.to_glib_none().0)) }
56    }
57}