#pragma once #include "User.hpp" #include #include #include #include #include #include #include #include #include #include namespace dchat { class ChatMessage; class ChatWindow : public Gtk::Grid { public: ChatWindow(); void addChannel(const odhtdb::Hash &nodeHash); void addLocalMessage(const odhtdb::Hash &channelId, const odhtdb::Signature::PublicKey &userPublicKey, uint32_t timestampSeconds, Glib::ustring msg); void addUser(const odhtdb::Signature::PublicKey &userPublicKey); void setUserNickname(const odhtdb::Signature::PublicKey &userPublicKey, const Glib::ustring &name); // Returns nullptr if user with @publicKey is not found User* getUserByPublicKey(const odhtdb::Signature::PublicKey &publicKey) const; private: void setupTopBar(); void setupLeftPanel(Gtk::Paned *sidePanels); void setupMessageArea(Gtk::Grid *rightPanel); void setupChatInput(Gtk::Grid *rightPanel); private: Gtk::Grid topbar; Gtk::Entry topbarSearchBar; Gtk::Grid leftPanelChannels; Gtk::Grid leftPanelUsers; Gtk::Label currentChannelTitle; Gtk::ScrolledWindow chatArea; Gtk::Grid chatAreaLayout; Gtk::TextView chatInput; struct ChannelData { Gtk::ToggleButton *button; int messageCount; }; odhtdb::MapHash channelDataById; int channelCount; std::vector users; ChatMessage *lastMessage; }; }