diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2024-08-15 11:25:30 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2024-08-15 11:25:30 +0200 |
| commit | 0840ff9a28e627351a520437ec83902d88310fe5 (patch) | |
| tree | f31a81bd29fbdc893d1363ff4eef145d1030f71e /include/turns/adw/toast.hpp | |
| parent | ae57b8d35dc96c022cc34f7f32da4df5ef44b5fe (diff) | |
| download | libadwaitamm-0840ff9a28e627351a520437ec83902d88310fe5.tar.xz libadwaitamm-0840ff9a28e627351a520437ec83902d88310fe5.zip | |
adw: add Toast and ToastOverlay classes
Diffstat (limited to 'include/turns/adw/toast.hpp')
| -rw-r--r-- | include/turns/adw/toast.hpp | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/include/turns/adw/toast.hpp b/include/turns/adw/toast.hpp new file mode 100644 index 0000000..21ccdef --- /dev/null +++ b/include/turns/adw/toast.hpp @@ -0,0 +1,120 @@ +#ifndef TURNS_ADW_TOAST_HPP +#define TURNS_ADW_TOAST_HPP + +#include "turns/adw/helpers/gobj_cast.hpp" +#include "turns/adw/helpers/properties.hpp" + +#include <glibmm/object.h> +#include <glibmm/refptr.h> +#include <glibmm/ustring.h> +#include <glibmm/variant.h> + +#include <gtkmm/widget.h> + +using AdwToast = struct _AdwToast; + +namespace turns::adw +{ + struct Toast_Class; + + struct Toast : Glib::Object, + helpers::gobj_mixin<Toast, AdwToast> + { + enum class Priority + { + NORMAL, + HIGH, + }; + + using helpers::gobj_mixin<Toast, AdwToast>::gobj; + using helpers::gobj_mixin<Toast, AdwToast>::gobj_copy; + + Toast(Toast && other) noexcept = default; + auto operator=(Toast && other) noexcept -> Toast & = default; + + Toast(Toast const & other) = delete; + auto operator=(Toast const & other) noexcept -> Toast & = delete; + + explicit Toast(Glib::ustring const & title); + + auto static get_type() -> GType; + auto static get_base_type() -> GType; + + auto dismiss() -> void; + + // clang-format off + template<typename Self> auto property_action_name(this Self && self); + template<typename Self> auto property_action_target(this Self && self); + template<typename Self> auto property_button_label(this Self && self); + template<typename Self> auto property_custom_title(this Self && self); + template<typename Self> auto property_priority(this Self && self); + template<typename Self> auto property_timeout(this Self && self); + template<typename Self> auto property_title(this Self && self); + template<typename Self> auto property_use_markup(this Self && self); + // clang-format on + + protected: + explicit Toast(Glib::ConstructParams const & params); + explicit Toast(AdwToast * gobj); + + private: + friend Toast_Class; + static Toast_Class s_class; + }; + + template<typename Self> + auto Toast::property_action_name(this Self && self) + { + return helpers::make_property_proxy<Glib::ustring>(self, "action-name"); + } + + template<typename Self> + auto Toast::property_action_target(this Self && self) + { + return helpers::make_property_proxy<Glib::VariantBase>(self, "action-target"); + } + + template<typename Self> + auto Toast::property_button_label(this Self && self) + { + return helpers::make_property_proxy<Glib::ustring>(self, "button-label"); + } + + template<typename Self> + auto Toast::property_custom_title(this Self && self) + { + return helpers::make_property_proxy<Gtk::Widget *>(self, "custom-title"); + } + + template<typename Self> + auto Toast::property_priority(this Self && self) + { + return helpers::make_property_proxy<Priority>(self, "priority"); + } + + template<typename Self> + auto Toast::property_timeout(this Self && self) + { + return helpers::make_property_proxy<unsigned>(self, "timeout"); + } + + template<typename Self> + auto Toast::property_title(this Self && self) + { + return helpers::make_property_proxy<Glib::ustring>(self, "title"); + } + + template<typename Self> + auto Toast::property_use_markup(this Self && self) + { + return helpers::make_property_proxy<bool>(self, "use-markup"); + } + +} // namespace turns::adw + +namespace Glib +{ + auto wrap(AdwToast * object, bool copy = false) -> Glib::RefPtr<turns::adw::Toast>; +} // namespace Glib + +#endif
\ No newline at end of file |
