diff --git a/design.glade b/design.glade
index e6a6524..8848f4c 100644
--- a/design.glade
+++ b/design.glade
@@ -1,4 +1,5 @@
+
-
-
diff --git a/main.cpp b/main.cpp
index 255b45f..ebce8cc 100644
--- a/main.cpp
+++ b/main.cpp
@@ -29,11 +29,13 @@
static std::unique_ptr client = nullptr;
-static std::unordered_map channelRowToId;
+static std::unordered_map channelRowToChannel;
static std::unordered_map> messages;
static std::string currentChannelId;
-static Gtk::Window* window;
+static Gtk::ApplicationWindow* loginWindow;
+static Gtk::ApplicationWindow* chatWindow;
+static Gtk::HeaderBar* chatHeader;
static Gtk::Widget* loginInterface;
static Gtk::Entry* domainEntry;
@@ -66,7 +68,7 @@ void addChannel(const Brainlet::Channel channel) {
row->show_all_children();
row->show();
- channelRowToId.emplace(row, channel.id);
+ channelRowToChannel.emplace(row, channel);
messages.emplace(
std::piecewise_construct,
std::forward_as_tuple(channel.id),
@@ -100,7 +102,9 @@ int main(int argc, char* argv[]) {
Glib::RefPtr app = Gtk::Application::create("org.hiimgoodpack.brainlet_client");
Glib::RefPtr builder = Gtk::Builder::create_from_file("./design.glade");
- builder->get_widget("Window", window);
+ builder->get_widget("LoginWindow", loginWindow);
+ builder->get_widget("ChatWindow", chatWindow);
+ builder->get_widget("ChatHeader", chatHeader);
builder->get_widget("Login", loginInterface);
builder->get_widget("Domain", domainEntry);
@@ -120,8 +124,9 @@ int main(int argc, char* argv[]) {
const std::string username = usernameEntry->get_text();
const std::string password = passwordEntry->get_text();
usernameLabel->set_text(username.c_str());
- window->remove();
- window->add(*chatInterface);
+ app->add_window(*chatWindow);
+ chatWindow->show_all();
+ loginWindow->close();
client.reset(new Brainlet::Client(domainEntry->get_text()));
client->login(username, password);
@@ -143,7 +148,10 @@ int main(int argc, char* argv[]) {
messageList->foreach(std::bind(std::mem_fn(&Gtk::ListBox::remove), messageList, std::placeholders::_1));
// Add messages in the channel selected
- currentChannelId = channelRowToId.at(row);
+ currentChannelId = channelRowToChannel.at(row).id;
+
+ // Set the title in the HeaderBar to the currently selected channel's name
+ chatHeader->set_title(channelRowToChannel.at(row).name);
const std::vector& channelMessages = messages.at(currentChannelId);
std::for_each(channelMessages.begin(), channelMessages.end(), addMessage);
@@ -157,7 +165,5 @@ int main(int argc, char* argv[]) {
messageEntry->set_text("");
});
- window->add(*loginInterface);
-
- app->run(*window);
+ app->run(*loginWindow);
}