diff options
Diffstat (limited to 'adw/src/toast.cpp')
| -rw-r--r-- | adw/src/toast.cpp | 87 |
1 files changed, 87 insertions, 0 deletions
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 <glibmm/class.h> +#include <glibmm/object.h> +#include <glibmm/objectbase.h> +#include <glibmm/private/object_p.h> +#include <glibmm/propertyproxy.h> +#include <glibmm/refptr.h> +#include <glibmm/ustring.h> +#include <glibmm/utility.h> +#include <glibmm/variant.h> + +#include <gtkmm/widget.h> + +#include <adwaita.h> +#include <gio/gio.h> +#include <glib-object.h> + +namespace turns::adw +{ + static_assert(static_cast<int>(Toast::Priority::NORMAL) == ADW_TOAST_PRIORITY_NORMAL); + static_assert(static_cast<int>(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<turns::adw::Toast> + { + return Glib::make_refptr_for_instance<turns::adw::Toast>(dynamic_cast<turns::adw::Toast *>(Glib::wrap_auto(G_OBJECT(object), copy))); + } +} // namespace Glib
\ No newline at end of file |
