diff options
| -rw-r--r-- | adw/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | adw/include/adwaitamm/alertdialog.hpp | 69 | ||||
| -rw-r--r-- | adw/src/alertdialog.cpp | 85 | ||||
| -rw-r--r-- | adw/src/wrap_init.cpp | 3 |
4 files changed, 158 insertions, 0 deletions
diff --git a/adw/CMakeLists.txt b/adw/CMakeLists.txt index ccf3818..c6bbd3a 100644 --- a/adw/CMakeLists.txt +++ b/adw/CMakeLists.txt @@ -16,6 +16,7 @@ pkg_check_modules("glibmm" IMPORTED_TARGET REQUIRED "glibmm-2.68>=2.80") add_library("adwaitamm" "src/actionrow.cpp" + "src/alertdialog.cpp" "src/application.cpp" "src/applicationwindow.cpp" "src/breakpoint.cpp" diff --git a/adw/include/adwaitamm/alertdialog.hpp b/adw/include/adwaitamm/alertdialog.hpp new file mode 100644 index 0000000..9da8488 --- /dev/null +++ b/adw/include/adwaitamm/alertdialog.hpp @@ -0,0 +1,69 @@ +#ifndef LIBADWAITAMM_ALERT_DIALOG_HPP +#define LIBADWAITAMM_ALERT_DIALOG_HPP + +#include "adwaitamm/dialog.hpp" +#include "adwaitamm/helpers/gobj_mixin.hpp" + +#include <glibmm/class.h> +#include <glibmm/object.h> +#include <glibmm/objectbase.h> +#include <glibmm/refptr.h> +#include <glibmm/ustring.h> + +#include <gtkmm/widget.h> + +#include <glib-object.h> + +using AdwAlertDialog = struct _AdwAlertDialog; +using AdwAlertDialogClass = struct _AdwAlertDialogClass; + +namespace Adwaita +{ + struct Dialog_Class; + + struct AlertDialog : Dialog, + helpers::gobj_mixin<AlertDialog, AdwAlertDialog> + { + struct Class : Glib::Class + { + using BaseClassParent = AdwDialogClass; + using BaseClassType = AdwAlertDialogClass; + using BaseObjectType = AdwAlertDialog; + using CppClassParent = Dialog::Class; + using CppObjectType = AlertDialog; + + auto init() -> Glib::Class const &; + auto static class_init_function(void * gclass, void * data) -> void; + auto static wrap_new(GObject * object) -> Glib::ObjectBase *; + }; + + using BaseObjectType = Class::BaseObjectType; + using BaseClassType = Class::BaseClassType; + using CppObjectType = Class::CppObjectType; + using CppClassType = Class; + + using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj; + using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj_copy; + + AlertDialog(Glib::ustring heading, Glib::ustring body); + AlertDialog(AlertDialog const & other) = delete; + AlertDialog(AlertDialog && other) noexcept = default; + + auto operator=(AlertDialog const & other) noexcept -> AlertDialog & = delete; + auto operator=(AlertDialog && other) noexcept -> AlertDialog & = default; + + auto static get_type() -> GType; + auto static get_base_type() -> GType; + + protected: + explicit AlertDialog(Glib::ConstructParams const & params); + explicit AlertDialog(BaseObjectType * gobj); + }; +} // namespace Adwaita + +namespace Glib +{ + auto wrap(AdwAlertDialog * object, bool copy = false) -> Adwaita::AlertDialog *; +} // namespace Glib + +#endif
\ No newline at end of file diff --git a/adw/src/alertdialog.cpp b/adw/src/alertdialog.cpp new file mode 100644 index 0000000..83afaa1 --- /dev/null +++ b/adw/src/alertdialog.cpp @@ -0,0 +1,85 @@ +#include "adwaitamm/alertdialog.hpp" + +#include <glibmm/class.h> +#include <glibmm/object.h> +#include <glibmm/objectbase.h> +#include <glibmm/refptr.h> +#include <glibmm/ustring.h> +#include <glibmm/utility.h> +#include <glibmm/wrap.h> + +#include <gtkmm/init.h> +#include <gtkmm/object.h> +#include <gtkmm/private/widget_p.h> +#include <gtkmm/widget.h> + +#include <adwaitamm/dialog.hpp> + +#include <adwaita.h> +#include <glib-object.h> +#include <gtk/gtk.h> + +namespace Adwaita +{ + + namespace + { + auto constinit _class = AlertDialog::Class{}; + } // namespace + + auto AlertDialog::Class::init() -> Glib::Class const & + { + if (!gtype_) + { + class_init_func_ = &class_init_function; + register_derived_type(adw_alert_dialog_get_type()); + } + return *this; + } + + auto AlertDialog::Class::class_init_function(void * gclass, void * data) -> void + { + auto const klass = static_cast<BaseClassType *>(gclass); + CppClassParent::class_init_function(klass, data); + } + + auto AlertDialog::Class::wrap_new(GObject * object) -> Glib::ObjectBase * + { + return Gtk::manage(new AlertDialog(ADW_ALERT_DIALOG(object))); + } + + auto AlertDialog::get_type() -> GType + { + return _class.init().get_type(); + } + + auto AlertDialog::get_base_type() -> GType + { + return adw_alert_dialog_get_type(); + } + + AlertDialog::AlertDialog(Glib::ConstructParams const & params) + : Dialog{params} + { + } + + AlertDialog::AlertDialog(BaseObjectType * gobj) + : Dialog(ADW_DIALOG(gobj)) + { + } + + AlertDialog::AlertDialog(Glib::ustring heading, Glib::ustring body) + : Glib::ObjectBase{nullptr} + , Dialog{Glib::ConstructParams{_class.init(), "heading", heading.c_str(), "body", Glib::c_str_or_nullptr(body), nullptr}} + { + } + +} // namespace Adwaita + +namespace Glib +{ + auto wrap(AdwAlertDialog * object, bool copy) -> Adwaita::AlertDialog * + { + return dynamic_cast<Adwaita::AlertDialog *>(Glib::wrap_auto(G_OBJECT(object), copy)); + } +} // namespace Glib
\ No newline at end of file diff --git a/adw/src/wrap_init.cpp b/adw/src/wrap_init.cpp index b48ecd0..8cad77d 100644 --- a/adw/src/wrap_init.cpp +++ b/adw/src/wrap_init.cpp @@ -1,6 +1,7 @@ #include "adwaitamm/wrap_init.hpp" #include "adwaitamm/actionrow.hpp" +#include "adwaitamm/alertdialog.hpp" #include "adwaitamm/application.hpp" #include "adwaitamm/applicationwindow.hpp" #include "adwaitamm/breakpoint.hpp" @@ -25,6 +26,7 @@ namespace Adwaita auto wrap_init() -> void { WRAP_CLASS(ActionRow, action_row); + WRAP_CLASS(AlertDialog, alert_dialog); WRAP_CLASS(Application, application); WRAP_CLASS(ApplicationWindow, application_window); WRAP_CLASS(Breakpoint, breakpoint); @@ -37,6 +39,7 @@ namespace Adwaita WRAP_CLASS(ToastOverlay, toast_overlay); ENSURE_TYPE(ActionRow); + ENSURE_TYPE(AlertDialog); ENSURE_TYPE(Application); ENSURE_TYPE(ApplicationWindow); ENSURE_TYPE(Breakpoint); |
