From ee599d7d62c16bb59603bedb62f03c01504a1893 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 3 Apr 2025 18:41:43 +0200 Subject: adw: prepare files for extraction --- adw/include/adwaitamm/helpers/gobj_mixin.hpp | 37 ++++++++++++++++++++++++++++ adw/include/adwaitamm/helpers/properties.hpp | 35 ++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 adw/include/adwaitamm/helpers/gobj_mixin.hpp create mode 100644 adw/include/adwaitamm/helpers/properties.hpp (limited to 'adw/include/adwaitamm/helpers') diff --git a/adw/include/adwaitamm/helpers/gobj_mixin.hpp b/adw/include/adwaitamm/helpers/gobj_mixin.hpp new file mode 100644 index 0000000..2a6aa37 --- /dev/null +++ b/adw/include/adwaitamm/helpers/gobj_mixin.hpp @@ -0,0 +1,37 @@ +#ifndef LIBADWAITAMM_HELPERS_GOBJ_MIXIN_HPP +#define LIBADWAITAMM_HELPERS_GOBJ_MIXIN_HPP + +#include + +#include + +namespace turns::adw::helpers +{ + + template + struct gobj_mixin + { + template + auto gobj(this Self && self) noexcept + { + using clean_type = std::remove_reference_t; + using gobj_type = std::conditional_t, std::add_const_t, Glib::Object>; + using cast_type = std::conditional_t, std::add_const_t, AdwType>; + + return reinterpret_cast(static_cast(self).gobj()); + } + + template + auto gobj_copy(this Self && self) noexcept -> AdwType * + { + using clean_type = std::remove_reference_t; + using gobj_type = std::conditional_t, std::add_const_t, Glib::Object>; + + static_cast(self).reference(); + return const_cast(self.gobj()); + } + }; + +} // namespace turns::adw::helpers + +#endif \ No newline at end of file diff --git a/adw/include/adwaitamm/helpers/properties.hpp b/adw/include/adwaitamm/helpers/properties.hpp new file mode 100644 index 0000000..6a7f7aa --- /dev/null +++ b/adw/include/adwaitamm/helpers/properties.hpp @@ -0,0 +1,35 @@ +#ifndef LIBADWAITAMM_HELPERS_PROPERTIES_HPP +#define LIBADWAITAMM_HELPERS_PROPERTIES_HPP + +#include +#include + +#include + +namespace turns::adw::helpers +{ + + template + struct deduced_property_proxy + { + using type = Glib::PropertyProxy; + }; + + template + struct deduced_property_proxy + { + using type = Glib::PropertyProxy_ReadOnly; + }; + + template + using deduced_property_proxy_t = typename deduced_property_proxy::type; + + template + auto make_property_proxy(ObjectType && object, char const * property) + { + return deduced_property_proxy_t>{&object, property}; + } + +} // namespace turns::adw::helpers + +#endif \ No newline at end of file -- cgit v1.2.3