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
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// from webkit2gtk-gir-files
// DO NOT EDIT

use crate::MimeInfo;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;

glib::wrapper! {
    /// Represents a plugin, enabling fine-grained control.
    ///
    /// This object represents a single plugin, found while scanning the
    /// various platform plugin directories. This object can be used to get
    /// more information about a plugin, and enable/disable it, allowing
    /// fine-grained control of plugins. The list of available plugins can
    /// be obtained from the [`WebContext`][crate::WebContext], with
    /// [`WebContextExt::plugins()`][crate::prelude::WebContextExt::plugins()].
    ///
    /// # Implements
    ///
    /// [`PluginExt`][trait@crate::prelude::PluginExt], [`trait@glib::ObjectExt`]
    #[doc(alias = "WebKitPlugin")]
    pub struct Plugin(Object<ffi::WebKitPlugin, ffi::WebKitPluginClass>);

    match fn {
        type_ => || ffi::webkit_plugin_get_type(),
    }
}

impl Plugin {
    pub const NONE: Option<&'static Plugin> = None;
}

/// Trait containing all [`struct@Plugin`] methods.
///
/// # Implementors
///
/// [`Plugin`][struct@crate::Plugin]
pub trait PluginExt: 'static {
    /// Obtain the plugin description.
    ///
    /// # Deprecated since 2.32
    ///
    ///
    /// # Returns
    ///
    /// description, as a string.
    #[cfg_attr(feature = "v2_32", deprecated = "Since 2.32")]
    #[doc(alias = "webkit_plugin_get_description")]
    #[doc(alias = "get_description")]
    fn description(&self) -> Option<glib::GString>;

    /// Get information about MIME types handled by the plugin.
    ///
    /// Get information about MIME types handled by the plugin,
    /// as a list of [`MimeInfo`][crate::MimeInfo].
    ///
    /// # Deprecated since 2.32
    ///
    ///
    /// # Returns
    ///
    /// a `GList` of [`MimeInfo`][crate::MimeInfo].
    #[cfg_attr(feature = "v2_32", deprecated = "Since 2.32")]
    #[doc(alias = "webkit_plugin_get_mime_info_list")]
    #[doc(alias = "get_mime_info_list")]
    fn mime_info_list(&self) -> Vec<MimeInfo>;

    /// Obtain the plugin name.
    ///
    /// # Deprecated since 2.32
    ///
    ///
    /// # Returns
    ///
    /// name, as a string.
    #[cfg_attr(feature = "v2_32", deprecated = "Since 2.32")]
    #[doc(alias = "webkit_plugin_get_name")]
    #[doc(alias = "get_name")]
    fn name(&self) -> Option<glib::GString>;

    /// Obtain the absolute path where the plugin is installed.
    ///
    /// # Deprecated since 2.32
    ///
    ///
    /// # Returns
    ///
    /// path, as a string.
    #[cfg_attr(feature = "v2_32", deprecated = "Since 2.32")]
    #[doc(alias = "webkit_plugin_get_path")]
    #[doc(alias = "get_path")]
    fn path(&self) -> Option<glib::GString>;
}

impl<O: IsA<Plugin>> PluginExt for O {
    fn description(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::webkit_plugin_get_description(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn mime_info_list(&self) -> Vec<MimeInfo> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(ffi::webkit_plugin_get_mime_info_list(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn name(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::webkit_plugin_get_name(self.as_ref().to_glib_none().0)) }
    }

    fn path(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::webkit_plugin_get_path(self.as_ref().to_glib_none().0)) }
    }
}

impl fmt::Display for Plugin {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("Plugin")
    }
}