blob: acb47daec84c21a06b9c8d121efe1605fd34a5d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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);
}
}
|