diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-10-26 20:08:01 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-10-26 20:08:04 +0200 |
commit | 009d2f850e8fdd27d961423892920e0b6817c031 (patch) | |
tree | 4bac2fc384cf23c8a6c27610f588968228f9e997 /src/Window.cpp | |
parent | 000295e724345aed5c3bcf08edaf76069a9e2cfb (diff) |
Add window notification
Diffstat (limited to 'src/Window.cpp')
-rw-r--r-- | src/Window.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/Window.cpp b/src/Window.cpp index 6493b2d..38c187e 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -1,34 +1,39 @@ #include "../include/Window.hpp" #include "../include/Cache.hpp" #include "../include/ChannelDataType.hpp" +#include "../include/WindowNotification.hpp" namespace dchat { Window::Window() { set_border_width(0); - add(stack); + Gtk::Overlay *overlay = Gtk::manage(new Gtk::Overlay()); + WindowNotification *windowNotification = Gtk::manage(new WindowNotification()); + overlay->add_overlay(*windowNotification); + overlay->add(stack); + add(*overlay); stack.set_transition_type(Gtk::StackTransitionType::STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT); stack.set_transition_duration(250); stack.add(loginWindow, "login"); stack.add(chatWindow, "chat"); - show_all_children(); + show_all(); - loginWindow.setLoginHandler([this](const Glib::ustring &username, const Glib::ustring &password) + loginWindow.setLoginHandler([this, windowNotification](const Glib::ustring &username, const Glib::ustring &password) { if(!database) { - fprintf(stderr, "You are not connected to the bootstrap node yet! please wait...\n"); + windowNotification->show("You are not connected to the bootstrap node yet! please wait..."); return; } try { - printf("Trying to login with username %s\n", username.raw().c_str()); + fprintf(stderr, "Trying to login with username %s\n", username.raw().c_str()); auto storedNodes = database->getStoredNodeUserInfoDecrypted(username.raw(), password.raw()); - printf("Successfully logged in as %s\n", username.raw().c_str()); + fprintf(stderr, "Successfully logged in as %s\n", username.raw().c_str()); stack.set_visible_child(chatWindow); for(auto &nodeInfo : storedNodes) @@ -38,7 +43,9 @@ namespace dchat } catch(std::exception &e) { - fprintf(stderr, "Failed to login, reason: %s\n", e.what()); + Glib::ustring errMsg = "Failed to login, reason: "; + errMsg += e.what(); + windowNotification->show(errMsg); } }); @@ -74,9 +81,10 @@ namespace dchat std::lock_guard<std::mutex> lock(databaseCallbackMutex); }; - printf("Connecting...\n"); + fprintf(stderr, "Connecting...\n"); database = odhtdb::Database::connect("83.252.53.188", 27130, Cache::getDchatDir(), callbackFuncs).get(); stack.set_visible_child(loginWindow); + windowNotification->show("Connected to 83.252.53.188:27130"); } Window::~Window() |