diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-10-26 21:51:44 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-10-26 21:51:47 +0200 |
commit | 206a58f9996a36693b1e73460191b08db1db0327 (patch) | |
tree | fd7fdeba9020dba673f858c9755ef129333f91b4 | |
parent | 009d2f850e8fdd27d961423892920e0b6817c031 (diff) |
Change window notification style
-rw-r--r-- | css/style.css | 6 | ||||
-rw-r--r-- | include/WindowNotification.hpp | 1 | ||||
-rw-r--r-- | src/WindowNotification.cpp | 30 |
3 files changed, 27 insertions, 10 deletions
diff --git a/css/style.css b/css/style.css index bcafa69..c024481 100644 --- a/css/style.css +++ b/css/style.css @@ -120,4 +120,8 @@ textview text { #chat-input { padding: 10px 10px 10px 10px; } -*/
\ No newline at end of file +*/ + +.window-notification { + background-color: #aa3030; +}
\ No newline at end of file diff --git a/include/WindowNotification.hpp b/include/WindowNotification.hpp index 87111de..595169d 100644 --- a/include/WindowNotification.hpp +++ b/include/WindowNotification.hpp @@ -15,5 +15,6 @@ namespace dchat Gtk::Revealer revealer; Gtk::Label label; sigc::connection hideTimer; + sigc::connection visibilityTimer; }; }
\ No newline at end of file diff --git a/src/WindowNotification.cpp b/src/WindowNotification.cpp index acb47da..9e17108 100644 --- a/src/WindowNotification.cpp +++ b/src/WindowNotification.cpp @@ -1,34 +1,46 @@ #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); + label.set_halign(Gtk::ALIGN_CENTER); revealer.add(label); - add(revealer); + revealer.set_hexpand(true); + + Gtk::Grid *grid = Gtk::manage(new Gtk::Grid()); + grid->add(revealer); + grid->get_style_context()->add_class("window-notification"); + + add(*grid); set_valign(Gtk::ALIGN_START); - set_halign(Gtk::ALIGN_CENTER); - revealer.get_style_context()->add_class("window-notification"); + set_hexpand(true); show_all(); + set_visible(false); } void WindowNotification::show(const Glib::ustring &text) { hideTimer.disconnect(); + visibilityTimer.disconnect(); label.set_text(text); + set_visible(true); revealer.set_reveal_child(true); - int showTime = (int)std::max(1.0, (double)text.size() * 0.1); - hideTimer = Glib::signal_timeout().connect_seconds([this] + int showTime = (int)std::max(1.0, (double)text.size() * 0.1) * 1000; + + hideTimer = Glib::signal_timeout().connect([this] { revealer.set_reveal_child(false); return false; }, showTime); + + visibilityTimer = Glib::signal_timeout().connect([this] + { + set_visible(false); + return false; + }, showTime + revealer.get_transition_duration()); } }
\ No newline at end of file |