gtk4/
style_context.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::translate::*;
4
5use crate::{ffi, prelude::*, StyleContext, StyleProvider};
6
7impl StyleContext {
8    /// Adds a global style provider to @display, which will be used
9    /// in style construction for all `GtkStyleContexts` under @display.
10    ///
11    /// GTK uses this to make styling information from [`Settings`][crate::Settings]
12    /// available.
13    ///
14    /// Note: If both priorities are the same, A [`StyleProvider`][crate::StyleProvider]
15    /// added through [`StyleContextExt::add_provider()`][crate::prelude::StyleContextExt::add_provider()] takes
16    /// precedence over another added through this function.
17    /// ## `display`
18    /// a [`gdk::Display`][crate::gdk::Display]
19    /// ## `provider`
20    /// a [`StyleProvider`][crate::StyleProvider]
21    /// ## `priority`
22    /// the priority of the style provider. The lower
23    ///   it is, the earlier it will be used in the style construction.
24    ///   Typically this will be in the range between
25    ///   `GTK_STYLE_PROVIDER_PRIORITY_FALLBACK` and
26    ///   `GTK_STYLE_PROVIDER_PRIORITY_USER`
27    #[deprecated(note = "Use gtk::style_context_add_provider_for_display instead.")]
28    #[doc(alias = "gtk_style_context_add_provider_for_display")]
29    pub fn add_provider_for_display(
30        display: &impl IsA<gdk::Display>,
31        provider: &impl IsA<StyleProvider>,
32        priority: u32,
33    ) {
34        skip_assert_initialized!();
35        unsafe {
36            ffi::gtk_style_context_add_provider_for_display(
37                display.as_ref().to_glib_none().0,
38                provider.as_ref().to_glib_none().0,
39                priority,
40            );
41        }
42    }
43
44    /// Removes @provider from the global style providers list in @display.
45    /// ## `display`
46    /// a [`gdk::Display`][crate::gdk::Display]
47    /// ## `provider`
48    /// a [`StyleProvider`][crate::StyleProvider]
49    #[deprecated(note = "Use gtk::style_context_remove_provider_for_display instead.")]
50    #[doc(alias = "gtk_style_context_remove_provider_for_display")]
51    pub fn remove_provider_for_display(
52        display: &impl IsA<gdk::Display>,
53        provider: &impl IsA<StyleProvider>,
54    ) {
55        skip_assert_initialized!();
56        unsafe {
57            ffi::gtk_style_context_remove_provider_for_display(
58                display.as_ref().to_glib_none().0,
59                provider.as_ref().to_glib_none().0,
60            );
61        }
62    }
63}