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 
5 use crate::Border;
6 use crate::CssSection;
7 use crate::JunctionSides;
8 use crate::StateFlags;
9 #[cfg(any(feature = "v3_20", feature = "dox"))]
10 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
11 use crate::StyleContextPrintFlags;
12 use crate::StyleProvider;
13 use crate::TextDirection;
14 use crate::WidgetPath;
15 use glib::object::Cast;
16 use glib::object::IsA;
17 use glib::signal::connect_raw;
18 use glib::signal::SignalHandlerId;
19 use glib::translate::*;
20 use glib::StaticType;
21 use glib::ToValue;
22 use std::boxed::Box as Box_;
23 use std::fmt;
24 use std::mem::transmute;
25 
26 glib::wrapper! {
27     #[doc(alias = "GtkStyleContext")]
28     pub struct StyleContext(Object<ffi::GtkStyleContext, ffi::GtkStyleContextClass>);
29 
30     match fn {
31         type_ => || ffi::gtk_style_context_get_type(),
32     }
33 }
34 
35 impl StyleContext {
36     #[doc(alias = "gtk_style_context_new")]
new() -> StyleContext37     pub fn new() -> StyleContext {
38         assert_initialized_main_thread!();
39         unsafe { from_glib_full(ffi::gtk_style_context_new()) }
40     }
41 
42     // rustdoc-stripper-ignore-next
43     /// Creates a new builder-pattern struct instance to construct [`StyleContext`] objects.
44     ///
45     /// This method returns an instance of [`StyleContextBuilder`] which can be used to create [`StyleContext`] objects.
builder() -> StyleContextBuilder46     pub fn builder() -> StyleContextBuilder {
47         StyleContextBuilder::default()
48     }
49 
50     #[doc(alias = "gtk_style_context_add_provider_for_screen")]
add_provider_for_screen<P: IsA<StyleProvider>>( screen: &gdk::Screen, provider: &P, priority: u32, )51     pub fn add_provider_for_screen<P: IsA<StyleProvider>>(
52         screen: &gdk::Screen,
53         provider: &P,
54         priority: u32,
55     ) {
56         skip_assert_initialized!();
57         unsafe {
58             ffi::gtk_style_context_add_provider_for_screen(
59                 screen.to_glib_none().0,
60                 provider.as_ref().to_glib_none().0,
61                 priority,
62             );
63         }
64     }
65 
66     #[doc(alias = "gtk_style_context_remove_provider_for_screen")]
remove_provider_for_screen<P: IsA<StyleProvider>>(screen: &gdk::Screen, provider: &P)67     pub fn remove_provider_for_screen<P: IsA<StyleProvider>>(screen: &gdk::Screen, provider: &P) {
68         skip_assert_initialized!();
69         unsafe {
70             ffi::gtk_style_context_remove_provider_for_screen(
71                 screen.to_glib_none().0,
72                 provider.as_ref().to_glib_none().0,
73             );
74         }
75     }
76 
77     #[doc(alias = "gtk_style_context_reset_widgets")]
reset_widgets(screen: &gdk::Screen)78     pub fn reset_widgets(screen: &gdk::Screen) {
79         assert_initialized_main_thread!();
80         unsafe {
81             ffi::gtk_style_context_reset_widgets(screen.to_glib_none().0);
82         }
83     }
84 }
85 
86 impl Default for StyleContext {
default() -> Self87     fn default() -> Self {
88         Self::new()
89     }
90 }
91 
92 #[derive(Clone, Default)]
93 // rustdoc-stripper-ignore-next
94 /// A [builder-pattern] type to construct [`StyleContext`] objects.
95 ///
96 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
97 pub struct StyleContextBuilder {
98     direction: Option<TextDirection>,
99     paint_clock: Option<gdk::FrameClock>,
100     parent: Option<StyleContext>,
101     screen: Option<gdk::Screen>,
102 }
103 
104 impl StyleContextBuilder {
105     // rustdoc-stripper-ignore-next
106     /// Create a new [`StyleContextBuilder`].
new() -> Self107     pub fn new() -> Self {
108         Self::default()
109     }
110 
111     // rustdoc-stripper-ignore-next
112     /// Build the [`StyleContext`].
build(self) -> StyleContext113     pub fn build(self) -> StyleContext {
114         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
115         if let Some(ref direction) = self.direction {
116             properties.push(("direction", direction));
117         }
118         if let Some(ref paint_clock) = self.paint_clock {
119             properties.push(("paint-clock", paint_clock));
120         }
121         if let Some(ref parent) = self.parent {
122             properties.push(("parent", parent));
123         }
124         if let Some(ref screen) = self.screen {
125             properties.push(("screen", screen));
126         }
127         glib::Object::new::<StyleContext>(&properties)
128             .expect("Failed to create an instance of StyleContext")
129     }
130 
direction(mut self, direction: TextDirection) -> Self131     pub fn direction(mut self, direction: TextDirection) -> Self {
132         self.direction = Some(direction);
133         self
134     }
135 
paint_clock(mut self, paint_clock: &gdk::FrameClock) -> Self136     pub fn paint_clock(mut self, paint_clock: &gdk::FrameClock) -> Self {
137         self.paint_clock = Some(paint_clock.clone());
138         self
139     }
140 
parent<P: IsA<StyleContext>>(mut self, parent: &P) -> Self141     pub fn parent<P: IsA<StyleContext>>(mut self, parent: &P) -> Self {
142         self.parent = Some(parent.clone().upcast());
143         self
144     }
145 
screen(mut self, screen: &gdk::Screen) -> Self146     pub fn screen(mut self, screen: &gdk::Screen) -> Self {
147         self.screen = Some(screen.clone());
148         self
149     }
150 }
151 
152 pub const NONE_STYLE_CONTEXT: Option<&StyleContext> = None;
153 
154 pub trait StyleContextExt: 'static {
155     #[doc(alias = "gtk_style_context_add_class")]
add_class(&self, class_name: &str)156     fn add_class(&self, class_name: &str);
157 
158     #[doc(alias = "gtk_style_context_add_provider")]
add_provider<P: IsA<StyleProvider>>(&self, provider: &P, priority: u32)159     fn add_provider<P: IsA<StyleProvider>>(&self, provider: &P, priority: u32);
160 
161     //#[doc(alias = "gtk_style_context_get")]
162     //fn get(&self, state: StateFlags, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);
163 
164     #[doc(alias = "gtk_style_context_get_border")]
165     #[doc(alias = "get_border")]
border(&self, state: StateFlags) -> Border166     fn border(&self, state: StateFlags) -> Border;
167 
168     #[doc(alias = "gtk_style_context_get_color")]
169     #[doc(alias = "get_color")]
color(&self, state: StateFlags) -> gdk::RGBA170     fn color(&self, state: StateFlags) -> gdk::RGBA;
171 
172     #[doc(alias = "gtk_style_context_get_frame_clock")]
173     #[doc(alias = "get_frame_clock")]
frame_clock(&self) -> Option<gdk::FrameClock>174     fn frame_clock(&self) -> Option<gdk::FrameClock>;
175 
176     #[doc(alias = "gtk_style_context_get_junction_sides")]
177     #[doc(alias = "get_junction_sides")]
junction_sides(&self) -> JunctionSides178     fn junction_sides(&self) -> JunctionSides;
179 
180     #[doc(alias = "gtk_style_context_get_margin")]
181     #[doc(alias = "get_margin")]
margin(&self, state: StateFlags) -> Border182     fn margin(&self, state: StateFlags) -> Border;
183 
184     #[doc(alias = "gtk_style_context_get_padding")]
185     #[doc(alias = "get_padding")]
padding(&self, state: StateFlags) -> Border186     fn padding(&self, state: StateFlags) -> Border;
187 
188     #[doc(alias = "gtk_style_context_get_parent")]
189     #[doc(alias = "get_parent")]
parent(&self) -> Option<StyleContext>190     fn parent(&self) -> Option<StyleContext>;
191 
192     #[doc(alias = "gtk_style_context_get_path")]
193     #[doc(alias = "get_path")]
path(&self) -> Option<WidgetPath>194     fn path(&self) -> Option<WidgetPath>;
195 
196     #[doc(alias = "gtk_style_context_get_property")]
197     #[doc(alias = "get_property")]
style_property_for_state(&self, property: &str, state: StateFlags) -> glib::Value198     fn style_property_for_state(&self, property: &str, state: StateFlags) -> glib::Value;
199 
200     #[doc(alias = "gtk_style_context_get_scale")]
201     #[doc(alias = "get_scale")]
scale(&self) -> i32202     fn scale(&self) -> i32;
203 
204     #[doc(alias = "gtk_style_context_get_screen")]
205     #[doc(alias = "get_screen")]
screen(&self) -> Option<gdk::Screen>206     fn screen(&self) -> Option<gdk::Screen>;
207 
208     #[doc(alias = "gtk_style_context_get_section")]
209     #[doc(alias = "get_section")]
section(&self, property: &str) -> Option<CssSection>210     fn section(&self, property: &str) -> Option<CssSection>;
211 
212     #[doc(alias = "gtk_style_context_get_state")]
213     #[doc(alias = "get_state")]
state(&self) -> StateFlags214     fn state(&self) -> StateFlags;
215 
216     //#[doc(alias = "gtk_style_context_get_style")]
217     //#[doc(alias = "get_style")]
218     //fn style(&self, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);
219 
220     #[doc(alias = "gtk_style_context_get_style_property")]
221     #[doc(alias = "get_style_property")]
style_property(&self, property_name: &str) -> glib::Value222     fn style_property(&self, property_name: &str) -> glib::Value;
223 
224     //#[doc(alias = "gtk_style_context_get_style_valist")]
225     //#[doc(alias = "get_style_valist")]
226     //fn style_valist(&self, args: /*Unknown conversion*//*Unimplemented*/Unsupported);
227 
228     //#[doc(alias = "gtk_style_context_get_valist")]
229     //#[doc(alias = "get_valist")]
230     //fn valist(&self, state: StateFlags, args: /*Unknown conversion*//*Unimplemented*/Unsupported);
231 
232     #[doc(alias = "gtk_style_context_has_class")]
has_class(&self, class_name: &str) -> bool233     fn has_class(&self, class_name: &str) -> bool;
234 
235     #[doc(alias = "gtk_style_context_list_classes")]
list_classes(&self) -> Vec<glib::GString>236     fn list_classes(&self) -> Vec<glib::GString>;
237 
238     #[doc(alias = "gtk_style_context_lookup_color")]
lookup_color(&self, color_name: &str) -> Option<gdk::RGBA>239     fn lookup_color(&self, color_name: &str) -> Option<gdk::RGBA>;
240 
241     #[doc(alias = "gtk_style_context_remove_class")]
remove_class(&self, class_name: &str)242     fn remove_class(&self, class_name: &str);
243 
244     #[doc(alias = "gtk_style_context_remove_provider")]
remove_provider<P: IsA<StyleProvider>>(&self, provider: &P)245     fn remove_provider<P: IsA<StyleProvider>>(&self, provider: &P);
246 
247     #[doc(alias = "gtk_style_context_restore")]
restore(&self)248     fn restore(&self);
249 
250     #[doc(alias = "gtk_style_context_save")]
save(&self)251     fn save(&self);
252 
253     #[doc(alias = "gtk_style_context_set_frame_clock")]
set_frame_clock(&self, frame_clock: &gdk::FrameClock)254     fn set_frame_clock(&self, frame_clock: &gdk::FrameClock);
255 
256     #[doc(alias = "gtk_style_context_set_junction_sides")]
set_junction_sides(&self, sides: JunctionSides)257     fn set_junction_sides(&self, sides: JunctionSides);
258 
259     #[doc(alias = "gtk_style_context_set_parent")]
set_parent<P: IsA<StyleContext>>(&self, parent: Option<&P>)260     fn set_parent<P: IsA<StyleContext>>(&self, parent: Option<&P>);
261 
262     #[doc(alias = "gtk_style_context_set_path")]
set_path(&self, path: &WidgetPath)263     fn set_path(&self, path: &WidgetPath);
264 
265     #[doc(alias = "gtk_style_context_set_scale")]
set_scale(&self, scale: i32)266     fn set_scale(&self, scale: i32);
267 
268     #[doc(alias = "gtk_style_context_set_screen")]
set_screen(&self, screen: &gdk::Screen)269     fn set_screen(&self, screen: &gdk::Screen);
270 
271     #[doc(alias = "gtk_style_context_set_state")]
set_state(&self, flags: StateFlags)272     fn set_state(&self, flags: StateFlags);
273 
274     #[cfg(any(feature = "v3_20", feature = "dox"))]
275     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
276     #[doc(alias = "gtk_style_context_to_string")]
to_string(&self, flags: StyleContextPrintFlags) -> Option<glib::GString>277     fn to_string(&self, flags: StyleContextPrintFlags) -> Option<glib::GString>;
278 
direction(&self) -> TextDirection279     fn direction(&self) -> TextDirection;
280 
set_direction(&self, direction: TextDirection)281     fn set_direction(&self, direction: TextDirection);
282 
283     #[doc(alias = "paint-clock")]
paint_clock(&self) -> Option<gdk::FrameClock>284     fn paint_clock(&self) -> Option<gdk::FrameClock>;
285 
286     #[doc(alias = "paint-clock")]
set_paint_clock(&self, paint_clock: Option<&gdk::FrameClock>)287     fn set_paint_clock(&self, paint_clock: Option<&gdk::FrameClock>);
288 
289     #[doc(alias = "changed")]
connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId290     fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
291 
292     #[doc(alias = "direction")]
connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId293     fn connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
294 
295     #[doc(alias = "paint-clock")]
connect_paint_clock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId296     fn connect_paint_clock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
297 
298     #[doc(alias = "parent")]
connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId299     fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
300 
301     #[doc(alias = "screen")]
connect_screen_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId302     fn connect_screen_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
303 }
304 
305 impl<O: IsA<StyleContext>> StyleContextExt for O {
add_class(&self, class_name: &str)306     fn add_class(&self, class_name: &str) {
307         unsafe {
308             ffi::gtk_style_context_add_class(
309                 self.as_ref().to_glib_none().0,
310                 class_name.to_glib_none().0,
311             );
312         }
313     }
314 
add_provider<P: IsA<StyleProvider>>(&self, provider: &P, priority: u32)315     fn add_provider<P: IsA<StyleProvider>>(&self, provider: &P, priority: u32) {
316         unsafe {
317             ffi::gtk_style_context_add_provider(
318                 self.as_ref().to_glib_none().0,
319                 provider.as_ref().to_glib_none().0,
320                 priority,
321             );
322         }
323     }
324 
325     //fn get(&self, state: StateFlags, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
326     //    unsafe { TODO: call ffi:gtk_style_context_get() }
327     //}
328 
border(&self, state: StateFlags) -> Border329     fn border(&self, state: StateFlags) -> Border {
330         unsafe {
331             let mut border = Border::uninitialized();
332             ffi::gtk_style_context_get_border(
333                 self.as_ref().to_glib_none().0,
334                 state.into_glib(),
335                 border.to_glib_none_mut().0,
336             );
337             border
338         }
339     }
340 
color(&self, state: StateFlags) -> gdk::RGBA341     fn color(&self, state: StateFlags) -> gdk::RGBA {
342         unsafe {
343             let mut color = gdk::RGBA::uninitialized();
344             ffi::gtk_style_context_get_color(
345                 self.as_ref().to_glib_none().0,
346                 state.into_glib(),
347                 color.to_glib_none_mut().0,
348             );
349             color
350         }
351     }
352 
frame_clock(&self) -> Option<gdk::FrameClock>353     fn frame_clock(&self) -> Option<gdk::FrameClock> {
354         unsafe {
355             from_glib_none(ffi::gtk_style_context_get_frame_clock(
356                 self.as_ref().to_glib_none().0,
357             ))
358         }
359     }
360 
junction_sides(&self) -> JunctionSides361     fn junction_sides(&self) -> JunctionSides {
362         unsafe {
363             from_glib(ffi::gtk_style_context_get_junction_sides(
364                 self.as_ref().to_glib_none().0,
365             ))
366         }
367     }
368 
margin(&self, state: StateFlags) -> Border369     fn margin(&self, state: StateFlags) -> Border {
370         unsafe {
371             let mut margin = Border::uninitialized();
372             ffi::gtk_style_context_get_margin(
373                 self.as_ref().to_glib_none().0,
374                 state.into_glib(),
375                 margin.to_glib_none_mut().0,
376             );
377             margin
378         }
379     }
380 
padding(&self, state: StateFlags) -> Border381     fn padding(&self, state: StateFlags) -> Border {
382         unsafe {
383             let mut padding = Border::uninitialized();
384             ffi::gtk_style_context_get_padding(
385                 self.as_ref().to_glib_none().0,
386                 state.into_glib(),
387                 padding.to_glib_none_mut().0,
388             );
389             padding
390         }
391     }
392 
parent(&self) -> Option<StyleContext>393     fn parent(&self) -> Option<StyleContext> {
394         unsafe {
395             from_glib_none(ffi::gtk_style_context_get_parent(
396                 self.as_ref().to_glib_none().0,
397             ))
398         }
399     }
400 
path(&self) -> Option<WidgetPath>401     fn path(&self) -> Option<WidgetPath> {
402         unsafe {
403             from_glib_none(ffi::gtk_style_context_get_path(
404                 self.as_ref().to_glib_none().0,
405             ))
406         }
407     }
408 
style_property_for_state(&self, property: &str, state: StateFlags) -> glib::Value409     fn style_property_for_state(&self, property: &str, state: StateFlags) -> glib::Value {
410         unsafe {
411             let mut value = glib::Value::uninitialized();
412             ffi::gtk_style_context_get_property(
413                 self.as_ref().to_glib_none().0,
414                 property.to_glib_none().0,
415                 state.into_glib(),
416                 value.to_glib_none_mut().0,
417             );
418             value
419         }
420     }
421 
scale(&self) -> i32422     fn scale(&self) -> i32 {
423         unsafe { ffi::gtk_style_context_get_scale(self.as_ref().to_glib_none().0) }
424     }
425 
screen(&self) -> Option<gdk::Screen>426     fn screen(&self) -> Option<gdk::Screen> {
427         unsafe {
428             from_glib_none(ffi::gtk_style_context_get_screen(
429                 self.as_ref().to_glib_none().0,
430             ))
431         }
432     }
433 
section(&self, property: &str) -> Option<CssSection>434     fn section(&self, property: &str) -> Option<CssSection> {
435         unsafe {
436             from_glib_none(ffi::gtk_style_context_get_section(
437                 self.as_ref().to_glib_none().0,
438                 property.to_glib_none().0,
439             ))
440         }
441     }
442 
state(&self) -> StateFlags443     fn state(&self) -> StateFlags {
444         unsafe {
445             from_glib(ffi::gtk_style_context_get_state(
446                 self.as_ref().to_glib_none().0,
447             ))
448         }
449     }
450 
451     //fn style(&self, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
452     //    unsafe { TODO: call ffi:gtk_style_context_get_style() }
453     //}
454 
style_property(&self, property_name: &str) -> glib::Value455     fn style_property(&self, property_name: &str) -> glib::Value {
456         unsafe {
457             let mut value = glib::Value::uninitialized();
458             ffi::gtk_style_context_get_style_property(
459                 self.as_ref().to_glib_none().0,
460                 property_name.to_glib_none().0,
461                 value.to_glib_none_mut().0,
462             );
463             value
464         }
465     }
466 
467     //fn style_valist(&self, args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
468     //    unsafe { TODO: call ffi:gtk_style_context_get_style_valist() }
469     //}
470 
471     //fn valist(&self, state: StateFlags, args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
472     //    unsafe { TODO: call ffi:gtk_style_context_get_valist() }
473     //}
474 
has_class(&self, class_name: &str) -> bool475     fn has_class(&self, class_name: &str) -> bool {
476         unsafe {
477             from_glib(ffi::gtk_style_context_has_class(
478                 self.as_ref().to_glib_none().0,
479                 class_name.to_glib_none().0,
480             ))
481         }
482     }
483 
list_classes(&self) -> Vec<glib::GString>484     fn list_classes(&self) -> Vec<glib::GString> {
485         unsafe {
486             FromGlibPtrContainer::from_glib_container(ffi::gtk_style_context_list_classes(
487                 self.as_ref().to_glib_none().0,
488             ))
489         }
490     }
491 
lookup_color(&self, color_name: &str) -> Option<gdk::RGBA>492     fn lookup_color(&self, color_name: &str) -> Option<gdk::RGBA> {
493         unsafe {
494             let mut color = gdk::RGBA::uninitialized();
495             let ret = from_glib(ffi::gtk_style_context_lookup_color(
496                 self.as_ref().to_glib_none().0,
497                 color_name.to_glib_none().0,
498                 color.to_glib_none_mut().0,
499             ));
500             if ret {
501                 Some(color)
502             } else {
503                 None
504             }
505         }
506     }
507 
remove_class(&self, class_name: &str)508     fn remove_class(&self, class_name: &str) {
509         unsafe {
510             ffi::gtk_style_context_remove_class(
511                 self.as_ref().to_glib_none().0,
512                 class_name.to_glib_none().0,
513             );
514         }
515     }
516 
remove_provider<P: IsA<StyleProvider>>(&self, provider: &P)517     fn remove_provider<P: IsA<StyleProvider>>(&self, provider: &P) {
518         unsafe {
519             ffi::gtk_style_context_remove_provider(
520                 self.as_ref().to_glib_none().0,
521                 provider.as_ref().to_glib_none().0,
522             );
523         }
524     }
525 
restore(&self)526     fn restore(&self) {
527         unsafe {
528             ffi::gtk_style_context_restore(self.as_ref().to_glib_none().0);
529         }
530     }
531 
save(&self)532     fn save(&self) {
533         unsafe {
534             ffi::gtk_style_context_save(self.as_ref().to_glib_none().0);
535         }
536     }
537 
set_frame_clock(&self, frame_clock: &gdk::FrameClock)538     fn set_frame_clock(&self, frame_clock: &gdk::FrameClock) {
539         unsafe {
540             ffi::gtk_style_context_set_frame_clock(
541                 self.as_ref().to_glib_none().0,
542                 frame_clock.to_glib_none().0,
543             );
544         }
545     }
546 
set_junction_sides(&self, sides: JunctionSides)547     fn set_junction_sides(&self, sides: JunctionSides) {
548         unsafe {
549             ffi::gtk_style_context_set_junction_sides(
550                 self.as_ref().to_glib_none().0,
551                 sides.into_glib(),
552             );
553         }
554     }
555 
set_parent<P: IsA<StyleContext>>(&self, parent: Option<&P>)556     fn set_parent<P: IsA<StyleContext>>(&self, parent: Option<&P>) {
557         unsafe {
558             ffi::gtk_style_context_set_parent(
559                 self.as_ref().to_glib_none().0,
560                 parent.map(|p| p.as_ref()).to_glib_none().0,
561             );
562         }
563     }
564 
set_path(&self, path: &WidgetPath)565     fn set_path(&self, path: &WidgetPath) {
566         unsafe {
567             ffi::gtk_style_context_set_path(self.as_ref().to_glib_none().0, path.to_glib_none().0);
568         }
569     }
570 
set_scale(&self, scale: i32)571     fn set_scale(&self, scale: i32) {
572         unsafe {
573             ffi::gtk_style_context_set_scale(self.as_ref().to_glib_none().0, scale);
574         }
575     }
576 
set_screen(&self, screen: &gdk::Screen)577     fn set_screen(&self, screen: &gdk::Screen) {
578         unsafe {
579             ffi::gtk_style_context_set_screen(
580                 self.as_ref().to_glib_none().0,
581                 screen.to_glib_none().0,
582             );
583         }
584     }
585 
set_state(&self, flags: StateFlags)586     fn set_state(&self, flags: StateFlags) {
587         unsafe {
588             ffi::gtk_style_context_set_state(self.as_ref().to_glib_none().0, flags.into_glib());
589         }
590     }
591 
592     #[cfg(any(feature = "v3_20", feature = "dox"))]
593     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
to_string(&self, flags: StyleContextPrintFlags) -> Option<glib::GString>594     fn to_string(&self, flags: StyleContextPrintFlags) -> Option<glib::GString> {
595         unsafe {
596             from_glib_full(ffi::gtk_style_context_to_string(
597                 self.as_ref().to_glib_none().0,
598                 flags.into_glib(),
599             ))
600         }
601     }
602 
direction(&self) -> TextDirection603     fn direction(&self) -> TextDirection {
604         unsafe {
605             let mut value = glib::Value::from_type(<TextDirection as StaticType>::static_type());
606             glib::gobject_ffi::g_object_get_property(
607                 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject,
608                 b"direction\0".as_ptr() as *const _,
609                 value.to_glib_none_mut().0,
610             );
611             value
612                 .get()
613                 .expect("Return Value for property `direction` getter")
614         }
615     }
616 
set_direction(&self, direction: TextDirection)617     fn set_direction(&self, direction: TextDirection) {
618         unsafe {
619             glib::gobject_ffi::g_object_set_property(
620                 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject,
621                 b"direction\0".as_ptr() as *const _,
622                 direction.to_value().to_glib_none().0,
623             );
624         }
625     }
626 
paint_clock(&self) -> Option<gdk::FrameClock>627     fn paint_clock(&self) -> Option<gdk::FrameClock> {
628         unsafe {
629             let mut value = glib::Value::from_type(<gdk::FrameClock as StaticType>::static_type());
630             glib::gobject_ffi::g_object_get_property(
631                 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject,
632                 b"paint-clock\0".as_ptr() as *const _,
633                 value.to_glib_none_mut().0,
634             );
635             value
636                 .get()
637                 .expect("Return Value for property `paint-clock` getter")
638         }
639     }
640 
set_paint_clock(&self, paint_clock: Option<&gdk::FrameClock>)641     fn set_paint_clock(&self, paint_clock: Option<&gdk::FrameClock>) {
642         unsafe {
643             glib::gobject_ffi::g_object_set_property(
644                 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject,
645                 b"paint-clock\0".as_ptr() as *const _,
646                 paint_clock.to_value().to_glib_none().0,
647             );
648         }
649     }
650 
connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId651     fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
652         unsafe extern "C" fn changed_trampoline<P: IsA<StyleContext>, F: Fn(&P) + 'static>(
653             this: *mut ffi::GtkStyleContext,
654             f: glib::ffi::gpointer,
655         ) {
656             let f: &F = &*(f as *const F);
657             f(StyleContext::from_glib_borrow(this).unsafe_cast_ref())
658         }
659         unsafe {
660             let f: Box_<F> = Box_::new(f);
661             connect_raw(
662                 self.as_ptr() as *mut _,
663                 b"changed\0".as_ptr() as *const _,
664                 Some(transmute::<_, unsafe extern "C" fn()>(
665                     changed_trampoline::<Self, F> as *const (),
666                 )),
667                 Box_::into_raw(f),
668             )
669         }
670     }
671 
connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId672     fn connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
673         unsafe extern "C" fn notify_direction_trampoline<
674             P: IsA<StyleContext>,
675             F: Fn(&P) + 'static,
676         >(
677             this: *mut ffi::GtkStyleContext,
678             _param_spec: glib::ffi::gpointer,
679             f: glib::ffi::gpointer,
680         ) {
681             let f: &F = &*(f as *const F);
682             f(StyleContext::from_glib_borrow(this).unsafe_cast_ref())
683         }
684         unsafe {
685             let f: Box_<F> = Box_::new(f);
686             connect_raw(
687                 self.as_ptr() as *mut _,
688                 b"notify::direction\0".as_ptr() as *const _,
689                 Some(transmute::<_, unsafe extern "C" fn()>(
690                     notify_direction_trampoline::<Self, F> as *const (),
691                 )),
692                 Box_::into_raw(f),
693             )
694         }
695     }
696 
connect_paint_clock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId697     fn connect_paint_clock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
698         unsafe extern "C" fn notify_paint_clock_trampoline<
699             P: IsA<StyleContext>,
700             F: Fn(&P) + 'static,
701         >(
702             this: *mut ffi::GtkStyleContext,
703             _param_spec: glib::ffi::gpointer,
704             f: glib::ffi::gpointer,
705         ) {
706             let f: &F = &*(f as *const F);
707             f(StyleContext::from_glib_borrow(this).unsafe_cast_ref())
708         }
709         unsafe {
710             let f: Box_<F> = Box_::new(f);
711             connect_raw(
712                 self.as_ptr() as *mut _,
713                 b"notify::paint-clock\0".as_ptr() as *const _,
714                 Some(transmute::<_, unsafe extern "C" fn()>(
715                     notify_paint_clock_trampoline::<Self, F> as *const (),
716                 )),
717                 Box_::into_raw(f),
718             )
719         }
720     }
721 
connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId722     fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
723         unsafe extern "C" fn notify_parent_trampoline<P: IsA<StyleContext>, F: Fn(&P) + 'static>(
724             this: *mut ffi::GtkStyleContext,
725             _param_spec: glib::ffi::gpointer,
726             f: glib::ffi::gpointer,
727         ) {
728             let f: &F = &*(f as *const F);
729             f(StyleContext::from_glib_borrow(this).unsafe_cast_ref())
730         }
731         unsafe {
732             let f: Box_<F> = Box_::new(f);
733             connect_raw(
734                 self.as_ptr() as *mut _,
735                 b"notify::parent\0".as_ptr() as *const _,
736                 Some(transmute::<_, unsafe extern "C" fn()>(
737                     notify_parent_trampoline::<Self, F> as *const (),
738                 )),
739                 Box_::into_raw(f),
740             )
741         }
742     }
743 
connect_screen_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId744     fn connect_screen_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
745         unsafe extern "C" fn notify_screen_trampoline<P: IsA<StyleContext>, F: Fn(&P) + 'static>(
746             this: *mut ffi::GtkStyleContext,
747             _param_spec: glib::ffi::gpointer,
748             f: glib::ffi::gpointer,
749         ) {
750             let f: &F = &*(f as *const F);
751             f(StyleContext::from_glib_borrow(this).unsafe_cast_ref())
752         }
753         unsafe {
754             let f: Box_<F> = Box_::new(f);
755             connect_raw(
756                 self.as_ptr() as *mut _,
757                 b"notify::screen\0".as_ptr() as *const _,
758                 Some(transmute::<_, unsafe extern "C" fn()>(
759                     notify_screen_trampoline::<Self, F> as *const (),
760                 )),
761                 Box_::into_raw(f),
762             )
763         }
764     }
765 }
766 
767 impl fmt::Display for StyleContext {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result768     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
769         f.write_str("StyleContext")
770     }
771 }
772