From b95258f419c62f7f38ec6128568df5897e4f5696 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 4 Apr 2025 22:15:41 +0200 Subject: adw: clean up property definitions --- adw/include/adwaitamm/actionrow.hpp | 28 ++++++++----- adw/include/adwaitamm/breakpoint.hpp | 1 + adw/include/adwaitamm/helpers/properties.hpp | 35 ---------------- adw/include/adwaitamm/preferencesrow.hpp | 62 ++++++---------------------- adw/include/adwaitamm/switchrow.hpp | 20 +++------ adw/include/adwaitamm/toast.hpp | 9 ++++ adw/include/adwaitamm/toastoverlay.hpp | 1 + 7 files changed, 46 insertions(+), 110 deletions(-) delete mode 100644 adw/include/adwaitamm/helpers/properties.hpp (limited to 'adw/include/adwaitamm') diff --git a/adw/include/adwaitamm/actionrow.hpp b/adw/include/adwaitamm/actionrow.hpp index c7ff6c2..5b99ab7 100644 --- a/adw/include/adwaitamm/actionrow.hpp +++ b/adw/include/adwaitamm/actionrow.hpp @@ -1,8 +1,8 @@ #ifndef LIBADWAITAMM_ACTION_ROW_HPP #define LIBADWAITAMM_ACTION_ROW_HPP -#include "helpers/gobj_mixin.hpp" #include "adwaitamm/preferencesrow.hpp" +#include "helpers/gobj_mixin.hpp" #include #include @@ -55,9 +55,9 @@ namespace Adwaita auto static get_type() -> GType; auto static get_base_type() -> GType; - auto add_prefix(Gtk::Widget & widget) -> ActionRow &; - auto add_suffix(Gtk::Widget & widget) -> ActionRow &; - auto remove(Gtk::Widget & widget) -> ActionRow &; + auto add_prefix(Gtk::Widget & widget) -> void; + auto add_suffix(Gtk::Widget & widget) -> void; + auto remove(Gtk::Widget & widget) -> void; auto get_activatable_widget() const noexcept -> Glib::RefPtr; [[deprecated("replaced by add_prefix")]] auto get_icon_name() const -> Glib::ustring; @@ -66,19 +66,25 @@ namespace Adwaita auto get_subtitle_selectable() const noexcept -> bool; auto get_title_lines() const noexcept -> int; + auto set_activatable_widget(Gtk::Widget & widget) noexcept -> void; + [[deprecated("replaced by add_prefix")]] auto set_icon_name(Glib::ustring const & name) -> void; + auto set_subtitle(Glib::ustring const & subtitle) -> void; + auto set_subtitle_lines(int subtitle_lines) noexcept -> void; + auto set_subtitle_selectable(bool subtitle_selectable) noexcept -> void; + auto set_title_lines(int title_lines) noexcept -> void; + auto property_activatable_widget() noexcept -> Glib::PropertyProxy; + auto property_activatable_widget() const noexcept -> Glib::PropertyProxy_ReadOnly; [[deprecated("replaced by add_prefix")]] auto property_icon_name() noexcept -> Glib::PropertyProxy; + [[deprecated("replaced by add_prefix")]] auto property_icon_name() const noexcept -> Glib::PropertyProxy_ReadOnly; auto property_subtitle() noexcept -> Glib::PropertyProxy; + auto property_subtitle() const noexcept -> Glib::PropertyProxy_ReadOnly; auto property_subtitle_lines() noexcept -> Glib::PropertyProxy; + auto property_subtitle_lines() const noexcept -> Glib::PropertyProxy_ReadOnly; auto property_subtitle_selectable() noexcept -> Glib::PropertyProxy; + auto property_subtitle_selectable() const noexcept -> Glib::PropertyProxy_ReadOnly; auto property_title_lines() noexcept -> Glib::PropertyProxy; - - auto set_activatable_widget(Gtk::Widget & widget) noexcept -> CppObjectType &; - [[deprecated("replaced by add_prefix")]] auto set_icon_name(Glib::ustring const & name) -> CppObjectType &; - auto set_subtitle(Glib::ustring const & subtitle) -> CppObjectType &; - auto set_subtitle_lines(int subtitle_lines) noexcept -> CppObjectType &; - auto set_subtitle_selectable(bool subtitle_selectable) noexcept -> CppObjectType &; - auto set_title_lines(int title_lines) noexcept -> CppObjectType &; + auto property_title_lines() const noexcept -> Glib::PropertyProxy_ReadOnly; protected: explicit ActionRow(Glib::ConstructParams const & params); diff --git a/adw/include/adwaitamm/breakpoint.hpp b/adw/include/adwaitamm/breakpoint.hpp index 529344d..13e9f1e 100644 --- a/adw/include/adwaitamm/breakpoint.hpp +++ b/adw/include/adwaitamm/breakpoint.hpp @@ -84,6 +84,7 @@ namespace Adwaita auto static get_base_type() -> GType; auto property_condition() -> Glib::PropertyProxy; + auto property_condition() const -> Glib::PropertyProxy_ReadOnly; protected: explicit Breakpoint(BreakpointCondition & condition); diff --git a/adw/include/adwaitamm/helpers/properties.hpp b/adw/include/adwaitamm/helpers/properties.hpp deleted file mode 100644 index fad99d6..0000000 --- a/adw/include/adwaitamm/helpers/properties.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef LIBADWAITAMM_HELPERS_PROPERTIES_HPP -#define LIBADWAITAMM_HELPERS_PROPERTIES_HPP - -#include -#include - -#include - -namespace Adwaita::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 Adwaita::helpers - -#endif \ No newline at end of file diff --git a/adw/include/adwaitamm/preferencesrow.hpp b/adw/include/adwaitamm/preferencesrow.hpp index b4fde1e..6c1d6bb 100644 --- a/adw/include/adwaitamm/preferencesrow.hpp +++ b/adw/include/adwaitamm/preferencesrow.hpp @@ -2,11 +2,11 @@ #define LIBADWAITAMM_PREFERENCES_ROW_HPP #include "helpers/gobj_mixin.hpp" -#include "adwaitamm/helpers/properties.hpp" #include #include #include +#include #include #include @@ -53,66 +53,30 @@ namespace Adwaita auto static get_type() -> GType; auto static get_base_type() -> GType; - auto get_title(this auto && self); - auto get_title_selectable(this auto && self) noexcept; - auto get_use_markup(this auto && self) noexcept; - auto get_use_underline(this auto && self) noexcept; + auto get_title() const -> Glib::ustring; + auto get_title_selectable() const noexcept -> bool; + auto get_use_markup() const noexcept -> bool; + auto get_use_underline() const noexcept -> bool; auto set_title(Glib::ustring const & title) -> CppObjectType &; auto set_title_selectable(bool selectable) noexcept -> CppObjectType &; auto set_use_markup(bool use) noexcept -> CppObjectType &; auto set_use_underline(bool use) noexcept -> CppObjectType &; - auto property_title(this auto && self); - auto property_title_selectable(this auto && self); - auto property_use_markup(this auto && self); - auto property_use_underline(this auto && self); + auto property_title_selectable() -> Glib::PropertyProxy; + auto property_title_selectable() const -> Glib::PropertyProxy_ReadOnly; + auto property_title() -> Glib::PropertyProxy; + auto property_title() const -> Glib::PropertyProxy_ReadOnly; + auto property_use_markup() -> Glib::PropertyProxy; + auto property_use_markup() const -> Glib::PropertyProxy_ReadOnly; + auto property_use_underline() -> Glib::PropertyProxy; + auto property_use_underline() const -> Glib::PropertyProxy_ReadOnly; protected: explicit PreferencesRow(Glib::ConstructParams const & params); explicit PreferencesRow(BaseObjectType * gobj); }; - auto PreferencesRow::get_title(this auto && self) - { - return self.property_title().value(); - } - - auto PreferencesRow::get_title_selectable(this auto && self) noexcept - { - return self.property_title_selectable().value(); - } - - auto PreferencesRow::get_use_markup(this auto && self) noexcept - { - return self.property_use_markup().value(); - } - - auto PreferencesRow::get_use_underline(this auto && self) noexcept - { - return self.property_use_underline().value(); - } - - auto PreferencesRow::property_title(this auto && self) - { - return helpers::make_property_proxy(self, "title"); - } - - auto PreferencesRow::property_title_selectable(this auto && self) - { - return helpers::make_property_proxy(self, "title-selectable"); - } - - auto PreferencesRow::property_use_markup(this auto && self) - { - return helpers::make_property_proxy(self, "use-markup"); - } - - auto PreferencesRow::property_use_underline(this auto && self) - { - return helpers::make_property_proxy(self, "use-underline"); - } - } // namespace Adwaita namespace Glib diff --git a/adw/include/adwaitamm/switchrow.hpp b/adw/include/adwaitamm/switchrow.hpp index 37e2e05..622b58a 100644 --- a/adw/include/adwaitamm/switchrow.hpp +++ b/adw/include/adwaitamm/switchrow.hpp @@ -3,11 +3,11 @@ #include "helpers/gobj_mixin.hpp" #include "adwaitamm/actionrow.hpp" -#include "adwaitamm/helpers/properties.hpp" #include #include #include +#include #include #include @@ -57,27 +57,17 @@ namespace Adwaita auto static get_type() -> GType; auto static get_base_type() -> GType; - auto get_active(this auto && self) noexcept; + auto get_active() const noexcept -> bool; + auto set_active(bool value) noexcept -> void; - auto get_active(Gtk::Widget & widget) noexcept -> CppObjectType &; - - auto property_active(this auto && self); + auto property_active() -> Glib::PropertyProxy; + auto property_active() const -> Glib::PropertyProxy_ReadOnly; protected: explicit SwitchRow(Glib::ConstructParams const & params); explicit SwitchRow(BaseObjectType * gobj); }; - auto SwitchRow::get_active(this auto && self) noexcept - { - return self.property_active().value(); - } - - auto SwitchRow::property_active(this auto && self) - { - return helpers::make_property_proxy(self, "active"); - } - } // namespace Adwaita namespace Glib diff --git a/adw/include/adwaitamm/toast.hpp b/adw/include/adwaitamm/toast.hpp index ba82497..2c4718b 100644 --- a/adw/include/adwaitamm/toast.hpp +++ b/adw/include/adwaitamm/toast.hpp @@ -2,6 +2,7 @@ #define LIBADWAITAMM_TOAST_HPP #include "adwaitamm/helpers/gobj_mixin.hpp" + #include #include @@ -80,13 +81,21 @@ namespace Adwaita auto set_use_markup(bool value) -> void; auto property_action_name() -> Glib::PropertyProxy; + auto property_action_name() const -> Glib::PropertyProxy_ReadOnly; auto property_action_target() -> Glib::PropertyProxy; + auto property_action_target() const -> Glib::PropertyProxy_ReadOnly; auto property_button_label() -> Glib::PropertyProxy; + auto property_button_label() const -> Glib::PropertyProxy_ReadOnly; auto property_custom_title() -> Glib::PropertyProxy; + auto property_custom_title() const -> Glib::PropertyProxy_ReadOnly; auto property_priority() -> Glib::PropertyProxy; + auto property_priority() const -> Glib::PropertyProxy_ReadOnly; auto property_timeout() -> Glib::PropertyProxy; + auto property_timeout() const -> Glib::PropertyProxy_ReadOnly; auto property_title() -> Glib::PropertyProxy; + auto property_title() const -> Glib::PropertyProxy_ReadOnly; auto property_use_markup() -> Glib::PropertyProxy; + auto property_use_markup() const -> Glib::PropertyProxy_ReadOnly; auto signal_button_clicked() -> Glib::SignalProxy; auto signal_dismissed() -> Glib::SignalProxy; diff --git a/adw/include/adwaitamm/toastoverlay.hpp b/adw/include/adwaitamm/toastoverlay.hpp index 9872c1b..5e2742d 100644 --- a/adw/include/adwaitamm/toastoverlay.hpp +++ b/adw/include/adwaitamm/toastoverlay.hpp @@ -59,6 +59,7 @@ namespace Adwaita auto set_child(Gtk::Widget & value) -> void; auto property_child() -> Glib::PropertyProxy; + auto property_child() const -> Glib::PropertyProxy_ReadOnly; protected: explicit ToastOverlay(Glib::ConstructParams const & params); -- cgit v1.2.3