aboutsummaryrefslogtreecommitdiff
path: root/include/LoginWindow.hpp
blob: d5585a53b3d122ad6edfec3b9c99afea64c8682f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once

#include <gtkmm/grid.h>
#include <gtkmm/entry.h>
#include <gtkmm/button.h>
#include <functional>

namespace dchat
{
    using LoginHandler = std::function<void(const Glib::ustring &username, const Glib::ustring &password)>;
    using RegisterHandler = std::function<void(const Glib::ustring &username, const Glib::ustring &password)>;
    using RegisterPasswordMismatchHandler = std::function<void()>;

    class LoginWindow : public Gtk::Grid
    {
    public:
        LoginWindow();

        void setLoginHandler(LoginHandler loginHandler);
        void setRegisterHandler(RegisterHandler registerHandler);
        void setRegisterPasswordMismatch(RegisterPasswordMismatchHandler passwordMismatchHandler);
    private:
        void setupLogin();
        void setupRegister();
    public:
        Gtk::Grid loginLayout;
        Gtk::Entry loginUsernameInput;
        Gtk::Entry loginPasswordInput;
        Gtk::Button loginButton;
        std::function<void()> loginHandler;
        LoginHandler loginHandlerUser;

        Gtk::Grid registerLayout;
        Gtk::Entry registerUsernameInput;
        Gtk::Entry registerPasswordInput;
        Gtk::Entry registerPasswordRepeatInput;
        Gtk::Button registerButton;
        std::function<void()> registerHandler;
        RegisterHandler registerHandlerUser;
        RegisterPasswordMismatchHandler passwordMismatchHandler;
    };
}