From b6252045a1340a42a39426dfbb877d2a1f357b7f Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 15 Aug 2024 11:25:30 +0200 Subject: adw: add Toast and ToastOverlay classes --- adw/src/toast.cpp | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 adw/src/toast.cpp (limited to 'adw/src/toast.cpp') diff --git a/adw/src/toast.cpp b/adw/src/toast.cpp new file mode 100644 index 0000000..4f8d28a --- /dev/null +++ b/adw/src/toast.cpp @@ -0,0 +1,87 @@ +#include "turns/adw/toast.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +namespace turns::adw +{ + static_assert(static_cast(Toast::Priority::NORMAL) == ADW_TOAST_PRIORITY_NORMAL); + static_assert(static_cast(Toast::Priority::HIGH) == ADW_TOAST_PRIORITY_HIGH); + + struct Toast_Class : Glib::Class + { + auto init() -> Glib::Class const &; + auto static class_init_function(void * gclass, void * data) -> void; + auto static wrap_new(GObject * object) -> Glib::ObjectBase *; + }; + + auto Toast_Class::init() -> Glib::Class const & + { + if (!gtype_) + { + gtype_ = adw_toast_get_type(); + } + return *this; + } + + auto Toast_Class::wrap_new(GObject * object) -> Glib::ObjectBase * + { + return new Toast(ADW_TOAST(object)); + } + + Toast_Class Toast::s_class{}; + + Toast::Toast(Glib::ustring const & title) + : Glib::ObjectBase{nullptr} + , Glib::Object{Glib::ConstructParams{s_class.init(), "title", Glib::c_str_or_nullptr(title), nullptr}} + { + } + + auto Toast::get_type() -> GType + { + return s_class.init().get_type(); + } + + auto Toast::get_base_type() -> GType + { + return adw_toast_get_type(); + } + + auto Toast::dismiss() -> void + { + return adw_toast_dismiss(gobj()); + } + + Toast::Toast(Glib::ConstructParams const & params) + : Glib::Object{params} + { + } + + Toast::Toast(AdwToast * gobj) + : Glib::ObjectBase{nullptr} + , Glib::Object((GObject *)gobj) + { + } + +} // namespace turns::adw + +namespace Glib +{ + auto wrap(AdwToast * object, bool copy) -> Glib::RefPtr + { + return Glib::make_refptr_for_instance(dynamic_cast(Glib::wrap_auto(G_OBJECT(object), copy))); + } +} // namespace Glib \ No newline at end of file -- cgit v1.2.3