aboutsummaryrefslogtreecommitdiff
path: root/src/WindowNotification.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/WindowNotification.cpp')
-rw-r--r--src/WindowNotification.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/WindowNotification.cpp b/src/WindowNotification.cpp
new file mode 100644
index 0000000..acb47da
--- /dev/null
+++ b/src/WindowNotification.cpp
@@ -0,0 +1,34 @@
+#include "../include/WindowNotification.hpp"
+#include <gtkmm.h>
+
+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);
+ }
+} \ No newline at end of file