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

use glib;
use glib::object::IsA;
use glib::translate::*;
use gtk_sys;
use std::fmt;
use StateFlags;
use StyleProvider;

glib_wrapper! {
    /// `[Deprecated since 3.16]` `StyleProperties` provides the storage for style information
    /// that is used by `StyleContext` and other `StyleProvider`
    /// implementations.
    ///
    /// Before style properties can be stored in `StyleProperties`, they
    /// must be registered with `StyleProperties::register_property`.
    ///
    /// Unless you are writing a `StyleProvider` implementation, you
    /// are unlikely to use this API directly, as `StyleContextExt::get`
    /// and its variants are the preferred way to access styling information
    /// from widget implementations and theming engine implementations
    /// should use the APIs provided by `ThemingEngine` instead.
    ///
    /// `StyleProperties` has been deprecated in GTK 3.16. The CSS
    /// machinery does not use it anymore and all users of this object
    /// have been deprecated.
    ///
    /// # Implements
    ///
    /// [`StylePropertiesExt`](trait.StylePropertiesExt.html), [`glib::object::ObjectExt`](../glib/object/trait.ObjectExt.html), [`StyleProviderExt`](trait.StyleProviderExt.html)
    pub struct StyleProperties(Object<gtk_sys::GtkStyleProperties, gtk_sys::GtkStylePropertiesClass, StylePropertiesClass>) @implements StyleProvider;

    match fn {
        get_type => || gtk_sys::gtk_style_properties_get_type(),
    }
}

impl StyleProperties {
    /// Returns a newly created `StyleProperties`
    ///
    /// # Deprecated since 3.16
    ///
    /// `StyleProperties` are deprecated.
    ///
    /// # Returns
    ///
    /// a new `StyleProperties`
    #[cfg_attr(feature = "v3_16", deprecated)]
    pub fn new() -> StyleProperties {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(gtk_sys::gtk_style_properties_new()) }
    }
}

#[cfg_attr(feature = "v3_16", deprecated)]
impl Default for StyleProperties {
    fn default() -> Self {
        Self::new()
    }
}

pub const NONE_STYLE_PROPERTIES: Option<&StyleProperties> = None;

/// `[Deprecated since 3.16]` Trait containing all `StyleProperties` methods.
///
/// # Implementors
///
/// [`StyleProperties`](struct.StyleProperties.html)
pub trait StylePropertiesExt: 'static {
    /// Clears all style information from `self`.
    ///
    /// # Deprecated since 3.16
    ///
    /// `StyleProperties` are deprecated.
    #[cfg_attr(feature = "v3_16", deprecated)]
    fn clear(&self);

    //#[cfg_attr(feature = "v3_16", deprecated)]
    //fn get(&self, state: StateFlags, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);

    /// Gets a style property from `self` for the given state. When done with `value`,
    /// `gobject::Value::unset` needs to be called to free any allocated memory.
    ///
    /// # Deprecated since 3.16
    ///
    /// `StyleProperties` are deprecated.
    /// ## `property`
    /// style property name
    /// ## `state`
    /// state to retrieve the property value for
    /// ## `value`
    /// return location for the style property value.
    ///
    /// # Returns
    ///
    /// `true` if the property exists in `self`, `false` otherwise
    #[cfg_attr(feature = "v3_16", deprecated)]
    fn get_property(&self, property: &str, state: StateFlags) -> Option<glib::Value>;

    //#[cfg_attr(feature = "v3_16", deprecated)]
    //fn get_valist(&self, state: StateFlags, args: /*Unknown conversion*//*Unimplemented*/Unsupported);

    /// Merges into `self` all the style information contained
    /// in `props_to_merge`. If `replace` is `true`, the values
    /// will be overwritten, if it is `false`, the older values
    /// will prevail.
    ///
    /// # Deprecated since 3.16
    ///
    /// `StyleProperties` are deprecated.
    /// ## `props_to_merge`
    /// a second `StyleProperties`
    /// ## `replace`
    /// whether to replace values or not
    #[cfg_attr(feature = "v3_16", deprecated)]
    fn merge<P: IsA<StyleProperties>>(&self, props_to_merge: &P, replace: bool);

    //#[cfg_attr(feature = "v3_16", deprecated)]
    //fn set(&self, state: StateFlags, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);

    /// Sets a styling property in `self`.
    ///
    /// # Deprecated since 3.16
    ///
    /// `StyleProperties` are deprecated.
    /// ## `property`
    /// styling property to set
    /// ## `state`
    /// state to set the value for
    /// ## `value`
    /// new value for the property
    #[cfg_attr(feature = "v3_16", deprecated)]
    fn set_property(&self, property: &str, state: StateFlags, value: &glib::Value);

    //#[cfg_attr(feature = "v3_16", deprecated)]
    //fn set_valist(&self, state: StateFlags, args: /*Unknown conversion*//*Unimplemented*/Unsupported);

    /// Unsets a style property in `self`.
    ///
    /// # Deprecated since 3.16
    ///
    /// `StyleProperties` are deprecated.
    /// ## `property`
    /// property to unset
    /// ## `state`
    /// state to unset
    #[cfg_attr(feature = "v3_16", deprecated)]
    fn unset_property(&self, property: &str, state: StateFlags);
}

impl<O: IsA<StyleProperties>> StylePropertiesExt for O {
    fn clear(&self) {
        unsafe {
            gtk_sys::gtk_style_properties_clear(self.as_ref().to_glib_none().0);
        }
    }

    //fn get(&self, state: StateFlags, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
    //    unsafe { TODO: call gtk_sys:gtk_style_properties_get() }
    //}

    fn get_property(&self, property: &str, state: StateFlags) -> Option<glib::Value> {
        unsafe {
            let mut value = glib::Value::uninitialized();
            let ret = from_glib(gtk_sys::gtk_style_properties_get_property(
                self.as_ref().to_glib_none().0,
                property.to_glib_none().0,
                state.to_glib(),
                value.to_glib_none_mut().0,
            ));
            if ret {
                Some(value)
            } else {
                None
            }
        }
    }

    //fn get_valist(&self, state: StateFlags, args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
    //    unsafe { TODO: call gtk_sys:gtk_style_properties_get_valist() }
    //}

    fn merge<P: IsA<StyleProperties>>(&self, props_to_merge: &P, replace: bool) {
        unsafe {
            gtk_sys::gtk_style_properties_merge(
                self.as_ref().to_glib_none().0,
                props_to_merge.as_ref().to_glib_none().0,
                replace.to_glib(),
            );
        }
    }

    //fn set(&self, state: StateFlags, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
    //    unsafe { TODO: call gtk_sys:gtk_style_properties_set() }
    //}

    fn set_property(&self, property: &str, state: StateFlags, value: &glib::Value) {
        unsafe {
            gtk_sys::gtk_style_properties_set_property(
                self.as_ref().to_glib_none().0,
                property.to_glib_none().0,
                state.to_glib(),
                value.to_glib_none().0,
            );
        }
    }

    //fn set_valist(&self, state: StateFlags, args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
    //    unsafe { TODO: call gtk_sys:gtk_style_properties_set_valist() }
    //}

    fn unset_property(&self, property: &str, state: StateFlags) {
        unsafe {
            gtk_sys::gtk_style_properties_unset_property(
                self.as_ref().to_glib_none().0,
                property.to_glib_none().0,
                state.to_glib(),
            );
        }
    }
}

impl fmt::Display for StyleProperties {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "StyleProperties")
    }
}