#include "../include/WindowNotification.hpp" #include static Gtk::Overlay *overlay = nullptr; static Gtk::Label *label = nullptr; namespace dchat { WindowNotification::WindowNotification() { label.set_line_wrap(true); label.set_line_wrap_mode(Pango::WRAP_WORD_CHAR); label.set_halign(Gtk::ALIGN_START); revealer.add(label); add(revealer); set_valign(Gtk::ALIGN_START); set_halign(Gtk::ALIGN_CENTER); revealer.get_style_context()->add_class("window-notification"); show_all(); } void WindowNotification::show(const Glib::ustring &text) { hideTimer.disconnect(); label.set_text(text); revealer.set_reveal_child(true); int showTime = (int)std::max(1.0, (double)text.size() * 0.1); hideTimer = Glib::signal_timeout().connect_seconds([this] { revealer.set_reveal_child(false); return false; }, showTime); } }