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

use glib::translate::*;
use std::fmt;

glib::wrapper! {
    ///
    ///
    /// # Implements
    ///
    /// [`trait@glib::ObjectExt`]
    #[doc(alias = "DzlThemeManager")]
    pub struct ThemeManager(Object<ffi::DzlThemeManager, ffi::DzlThemeManagerClass>);

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

impl ThemeManager {
    #[doc(alias = "dzl_theme_manager_new")]
    pub fn new() -> ThemeManager {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::dzl_theme_manager_new()) }
    }

    /// This will automatically register resources found within `resource_path`.
    ///
    /// If `resource_path` starts with "resource://", embedded `GResources` will be
    /// used to locate the theme files. Otherwise, `resource_path` is expected to be
    /// a path on disk that may or may not exist.
    ///
    /// If the `resource_path` contains a directory named "themes", that directory
    /// will be traversed for files matching the theme name and variant. For
    /// example, if using the Adwaita theme, "themes/Adwaita.css" will be loaded. If
    /// the dark variant is being used, "themes/Adwaita-dark.css" will be loaeded. If
    /// no matching theme file is located, "themes/shared.css" will be loaded.
    ///
    /// When the current theme changes, the CSS will be reloaded to adapt.
    ///
    /// The "icons" sub-directory will be used to locate icon themes.
    /// ## `resource_path`
    /// A path to a `GResources` directory
    #[doc(alias = "dzl_theme_manager_add_resources")]
    pub fn add_resources(&self, resource_path: &str) {
        unsafe {
            ffi::dzl_theme_manager_add_resources(
                self.to_glib_none().0,
                resource_path.to_glib_none().0,
            );
        }
    }

    /// This removes the CSS providers that were registered using `resource_path`.
    ///
    /// You must have previously called [`add_resources()`][Self::add_resources()] for
    /// this function to do anything.
    ///
    /// Since icons cannot be unloaded, previously loaded icons will continue to
    /// be available even after calling this function.
    /// ## `resource_path`
    /// A previously registered resources path
    #[doc(alias = "dzl_theme_manager_remove_resources")]
    pub fn remove_resources(&self, resource_path: &str) {
        unsafe {
            ffi::dzl_theme_manager_remove_resources(
                self.to_glib_none().0,
                resource_path.to_glib_none().0,
            );
        }
    }
}

impl Default for ThemeManager {
    fn default() -> Self {
        Self::new()
    }
}

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