add confirmation dialog to leave guild

This commit is contained in:
ouwou
2020-10-12 00:36:18 -04:00
parent 1ff177ad5a
commit 21fdada41c
4 changed files with 51 additions and 1 deletions

30
dialogs/confirm.cpp Normal file
View File

@@ -0,0 +1,30 @@
#include "confirm.hpp"
ConfirmDialog::ConfirmDialog(Gtk::Window &parent)
: Gtk::Dialog("Confirm", parent, true)
, m_layout(Gtk::ORIENTATION_VERTICAL)
, m_bbox(Gtk::ORIENTATION_HORIZONTAL)
, m_ok("OK")
, m_cancel("Cancel") {
set_default_size(300, 50);
m_label.set_text("Are you sure?");
m_ok.signal_clicked().connect([&]() {
response(Gtk::RESPONSE_OK);
});
m_cancel.signal_clicked().connect([&]() {
response(Gtk::RESPONSE_CANCEL);
});
m_bbox.pack_start(m_ok, Gtk::PACK_SHRINK);
m_bbox.pack_start(m_cancel, Gtk::PACK_SHRINK);
m_bbox.set_layout(Gtk::BUTTONBOX_END);
m_layout.add(m_label);
m_layout.add(m_bbox);
get_content_area()->add(m_layout);
show_all_children();
}

14
dialogs/confirm.hpp Normal file
View File

@@ -0,0 +1,14 @@
#pragma once
#include <gtkmm.h>
class ConfirmDialog : public Gtk::Dialog {
public:
ConfirmDialog(Gtk::Window &parent);
protected:
Gtk::Label m_label;
Gtk::Box m_layout;
Gtk::Button m_ok;
Gtk::Button m_cancel;
Gtk::ButtonBox m_bbox;
};