diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2025-04-04 16:31:38 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2025-04-04 16:31:38 +0200 |
| commit | 67c561efbeaa26131258c41b208f1890cb4865c5 (patch) | |
| tree | 9fbb1be4094a05c371c5c6977dae733a6b4758fb /adw/src/alertdialog.cpp | |
| parent | b6d9a37966e34db8b5217a7e5466b2660f43a4ba (diff) | |
| download | turns-67c561efbeaa26131258c41b208f1890cb4865c5.tar.xz turns-67c561efbeaa26131258c41b208f1890cb4865c5.zip | |
adw: implement required AlertDialog functions
Diffstat (limited to 'adw/src/alertdialog.cpp')
| -rw-r--r-- | adw/src/alertdialog.cpp | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/adw/src/alertdialog.cpp b/adw/src/alertdialog.cpp index 83afaa1..ea9cdca 100644 --- a/adw/src/alertdialog.cpp +++ b/adw/src/alertdialog.cpp @@ -1,6 +1,9 @@ #include "adwaitamm/alertdialog.hpp" +#include "adwaitamm/dialog.hpp" + #include <glibmm/class.h> +#include <glibmm/exceptionhandler.h> #include <glibmm/object.h> #include <glibmm/objectbase.h> #include <glibmm/refptr.h> @@ -8,20 +11,28 @@ #include <glibmm/utility.h> #include <glibmm/wrap.h> +#include <giomm/asyncresult.h> +#include <giomm/cancellable.h> + #include <gtkmm/init.h> #include <gtkmm/object.h> #include <gtkmm/private/widget_p.h> #include <gtkmm/widget.h> -#include <adwaitamm/dialog.hpp> +#include <adwaitamm/helpers/async_callback.hpp> #include <adwaita.h> #include <glib-object.h> +#include <glib.h> #include <gtk/gtk.h> namespace Adwaita { + static_assert(static_cast<int>(AlertDialog::ResponseAppearance::_default) == ADW_RESPONSE_DEFAULT); + static_assert(static_cast<int>(AlertDialog::ResponseAppearance::suggested) == ADW_RESPONSE_SUGGESTED); + static_assert(static_cast<int>(AlertDialog::ResponseAppearance::destructive) == ADW_RESPONSE_DESTRUCTIVE); + namespace { auto constinit _class = AlertDialog::Class{}; @@ -48,6 +59,11 @@ namespace Adwaita return Gtk::manage(new AlertDialog(ADW_ALERT_DIALOG(object))); } + auto AlertDialog::create(Glib::ustring heading, Glib::ustring body) -> Glib::RefPtr<AlertDialog> + { + return Glib::RefPtr<AlertDialog>{new AlertDialog(heading, body)}; + } + auto AlertDialog::get_type() -> GType { return _class.init().get_type(); @@ -74,6 +90,40 @@ namespace Adwaita { } + auto AlertDialog::add_response(Glib::ustring id, Glib::ustring label) -> void + { + adw_alert_dialog_add_response(Glib::unwrap(this), id.c_str(), label.c_str()); + } + + auto AlertDialog::choose(Gtk::Widget & parent, Glib::RefPtr<Gio::Cancellable> const & cancellable, Gio::SlotAsyncReady const & slot) -> void + { + adw_alert_dialog_choose(unwrap(this), + parent.gobj(), + const_cast<GCancellable *>(unwrap(cancellable)), + &helpers::async_callback, + new Gio::SlotAsyncReady(slot)); + } + + auto AlertDialog::choose_finish(Glib::RefPtr<Gio::AsyncResult> const & result) -> Glib::ustring + { + return adw_alert_dialog_choose_finish(Glib::unwrap(this), Glib::unwrap(result)); + } + + auto AlertDialog::set_close_response(Glib::ustring id) -> void + { + adw_alert_dialog_set_close_response(unwrap(this), id.c_str()); + } + + auto AlertDialog::set_default_response(Glib::ustring id) -> void + { + adw_alert_dialog_set_default_response(unwrap(this), id.c_str()); + } + + auto AlertDialog::set_response_appearance(Glib::ustring id, ResponseAppearance value) -> void + { + adw_alert_dialog_set_response_appearance(unwrap(this), id.c_str(), static_cast<AdwResponseAppearance>(static_cast<int>(value))); + } + } // namespace Adwaita namespace Glib |
