From fe21003777718efac8743bf99c5388b3d6477be2 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 4 Apr 2025 19:56:43 +0200 Subject: adw: implement basic StyleManager --- adw/src/stylemanager.cpp | 106 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 adw/src/stylemanager.cpp (limited to 'adw/src/stylemanager.cpp') diff --git a/adw/src/stylemanager.cpp b/adw/src/stylemanager.cpp new file mode 100644 index 0000000..74fe40a --- /dev/null +++ b/adw/src/stylemanager.cpp @@ -0,0 +1,106 @@ +#include "adwaitamm/stylemanager.hpp" + +#include "adwaitamm/enums.hpp" + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include +#include + +namespace Adwaita +{ + namespace + { + auto constinit _class = StyleManager::Class{}; + } // namespace + + auto StyleManager::Class::init() -> Glib::Class const & + { + if (!gtype_) + { + class_init_func_ = &StyleManager::Class::class_init_function; + register_derived_type(adw_style_manager_get_type()); + } + return *this; + } + + auto StyleManager::Class::class_init_function(void * gclass, void * data) -> void + { + auto const klass = static_cast(gclass); + Glib::Object_Class::class_init_function(klass, data); + } + + auto StyleManager::Class::wrap_new(GObject * object) -> Glib::ObjectBase * + { + return new StyleManager(ADW_STYLE_MANAGER(object)); + } + + auto StyleManager::get_default() -> StyleManager * + { + return Glib::wrap(adw_style_manager_get_default()); + } + + auto StyleManager::for_display(Gdk::Display & display) -> StyleManager * + { + return Glib::wrap(adw_style_manager_get_for_display(Glib::unwrap(&display))); + } + + auto StyleManager::get_type() -> GType + { + return _class.init().get_type(); + } + + auto StyleManager::get_base_type() -> GType + { + return adw_style_manager_get_type(); + } + + StyleManager::StyleManager(Glib::ConstructParams const & params) + : Glib::Object{params} + { + } + + StyleManager::StyleManager(BaseObjectType * gobj) + : Glib::Object(G_OBJECT(gobj)) + { + } + + StyleManager::StyleManager() + : Glib::ObjectBase{nullptr} + , Glib::Object{Glib::ConstructParams{_class.init()}} + { + adw_init(); + } + + auto StyleManager::get_accent_color() const -> AccentColor + { + return static_cast(adw_style_manager_get_accent_color(const_cast(unwrap(this)))); + } + + auto StyleManager::set_color_scheme(ColorScheme value) -> void + { + adw_style_manager_set_color_scheme(unwrap(this), static_cast(value)); + } + +} // namespace Adwaita + +namespace Glib +{ + auto wrap(AdwStyleManager * object) -> Adwaita::StyleManager * + { + return dynamic_cast(Glib::wrap_auto(G_OBJECT(object))); + } +} // namespace Glib \ No newline at end of file -- cgit v1.2.3