From 51babee1fc579cd99d32d1b7156ee553ed847339 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 4 Apr 2025 20:26:02 +0200 Subject: adw: move ToastPriority --- adw/include/adwaitamm/enums.hpp | 7 +++++++ adw/include/adwaitamm/toast.hpp | 14 +++++--------- adw/src/enums.cpp | 4 ++++ adw/src/toast.cpp | 14 ++++++-------- 4 files changed, 22 insertions(+), 17 deletions(-) (limited to 'adw') diff --git a/adw/include/adwaitamm/enums.hpp b/adw/include/adwaitamm/enums.hpp index 2fca425..03f5dc9 100644 --- a/adw/include/adwaitamm/enums.hpp +++ b/adw/include/adwaitamm/enums.hpp @@ -50,6 +50,12 @@ namespace Adwaita Destructive, }; + enum class ToastPriority + { + Normal, + High, + }; + } // namespace Adwaita namespace Glib @@ -68,6 +74,7 @@ namespace Glib VALUE_SPECIALIZATION(LengthType); VALUE_SPECIALIZATION(RatioType); VALUE_SPECIALIZATION(ResponseAppearance); + VALUE_SPECIALIZATION(ToastPriority); #undef VALUE_SPECIALIZATION diff --git a/adw/include/adwaitamm/toast.hpp b/adw/include/adwaitamm/toast.hpp index 4f69c1e..ba82497 100644 --- a/adw/include/adwaitamm/toast.hpp +++ b/adw/include/adwaitamm/toast.hpp @@ -24,6 +24,8 @@ using AdwToast = struct _AdwToast; namespace Adwaita { + enum struct ToastPriority; + struct Toast final : Glib::Object, helpers::gobj_mixin { @@ -45,12 +47,6 @@ namespace Adwaita using CppObjectType = Class::CppObjectType; using CppClassType = Class; - enum class Priority - { - NORMAL, - HIGH, - }; - using helpers::gobj_mixin::gobj; using helpers::gobj_mixin::gobj_copy; @@ -69,7 +65,7 @@ namespace Adwaita auto get_action_target_value() const -> Glib::VariantBase; auto get_button_label() const -> Glib::ustring; auto get_custom_title() const -> Gtk::Widget *; - auto get_priority() const -> Priority; + auto get_priority() const -> ToastPriority; auto get_timeout() const -> unsigned; auto get_title() const -> Glib::ustring; auto get_use_markup() const -> bool; @@ -78,7 +74,7 @@ namespace Adwaita auto set_button_label(Glib::ustring value) -> void; auto set_custom_title(Gtk::Widget * value) -> void; auto set_detailed_action_name(Glib::ustring value) -> void; - auto set_priority(Priority value) -> void; + auto set_priority(ToastPriority value) -> void; auto set_timeout(unsigned value) -> void; auto set_title(Glib::ustring value) -> void; auto set_use_markup(bool value) -> void; @@ -87,7 +83,7 @@ namespace Adwaita auto property_action_target() -> Glib::PropertyProxy; auto property_button_label() -> Glib::PropertyProxy; auto property_custom_title() -> Glib::PropertyProxy; - auto property_priority() -> Glib::PropertyProxy; + auto property_priority() -> Glib::PropertyProxy; auto property_timeout() -> Glib::PropertyProxy; auto property_title() -> Glib::PropertyProxy; auto property_use_markup() -> Glib::PropertyProxy; diff --git a/adw/src/enums.cpp b/adw/src/enums.cpp index 9891845..9261387 100644 --- a/adw/src/enums.cpp +++ b/adw/src/enums.cpp @@ -45,6 +45,9 @@ namespace Adwaita static_assert(matches); static_assert(matches); + static_assert(matches); + static_assert(matches); + } // namespace Adwaita namespace Glib @@ -60,6 +63,7 @@ namespace Glib VALUE_SPECIALIZATION(LengthType, breakpoint_condition) VALUE_SPECIALIZATION(RatioType, breakpoint_condition) VALUE_SPECIALIZATION(ResponseAppearance, response_appearance) + VALUE_SPECIALIZATION(ToastPriority, toast_priority) #undef VALUE_SPECIALIZATION } // namespace Glib \ No newline at end of file diff --git a/adw/src/toast.cpp b/adw/src/toast.cpp index 9ec0a5b..205e69f 100644 --- a/adw/src/toast.cpp +++ b/adw/src/toast.cpp @@ -1,5 +1,6 @@ #include "adwaitamm/toast.hpp" +#include "adwaitamm/enums.hpp" #include "adwaitamm/helpers/properties.hpp" #include @@ -23,9 +24,6 @@ namespace Adwaita { - static_assert(static_cast(Toast::Priority::NORMAL) == ADW_TOAST_PRIORITY_NORMAL); - static_assert(static_cast(Toast::Priority::HIGH) == ADW_TOAST_PRIORITY_HIGH); - namespace { auto constinit _class = Toast::Class{}; @@ -118,9 +116,9 @@ namespace Adwaita return Glib::wrap(adw_toast_get_custom_title(const_cast(Glib::unwrap(this)))); } - auto Toast::get_priority() const -> Priority + auto Toast::get_priority() const -> ToastPriority { - return static_cast(adw_toast_get_priority(const_cast(Glib::unwrap(this)))); + return static_cast(adw_toast_get_priority(const_cast(Glib::unwrap(this)))); } auto Toast::get_timeout() const -> unsigned @@ -163,7 +161,7 @@ namespace Adwaita adw_toast_set_detailed_action_name(Glib::unwrap(this), Glib::c_str_or_nullptr(value)); } - auto Toast::set_priority(Priority value) -> void + auto Toast::set_priority(ToastPriority value) -> void { adw_toast_set_priority(Glib::unwrap(this), static_cast(value)); } @@ -203,9 +201,9 @@ namespace Adwaita return helpers::make_property_proxy(*this, "custom-title"); } - auto Toast::property_priority() -> Glib::PropertyProxy + auto Toast::property_priority() -> Glib::PropertyProxy { - return helpers::make_property_proxy(*this, "priority"); + return helpers::make_property_proxy(*this, "priority"); } auto Toast::property_timeout() -> Glib::PropertyProxy -- cgit v1.2.3