timers work, fix crash when vscode window closes after timeout
This commit is contained in:
@@ -81,8 +81,8 @@ void BaseNotification::start_auto_close_timeout(int timeoutMs) {
|
||||
}
|
||||
|
||||
autoCloseDeadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(timeoutMs);
|
||||
autoCloseConnection = Glib::signal_timeout().connect([this]() {
|
||||
this->getSignalClose().emit(this->notificationId);
|
||||
autoCloseConnection = Glib::signal_timeout().connect([self = shared_from_this()]() {
|
||||
self->getSignalClose().emit(self->getNotificationId());
|
||||
return false; // Don't repeat
|
||||
},
|
||||
timeoutMs);
|
||||
|
||||
@@ -44,23 +44,29 @@ NotificationWindow::NotificationWindow(uint64_t notificationId, std::shared_ptr<
|
||||
header_box->append(*img);
|
||||
}
|
||||
|
||||
auto app_label = Gtk::make_managed<Gtk::Label>(StringHelper::trimToSize(notify.app_name, 24));
|
||||
auto app_label = Gtk::make_managed<Gtk::Label>(notify.app_name);
|
||||
app_label->set_halign(Gtk::Align::START);
|
||||
app_label->set_ellipsize(Pango::EllipsizeMode::END);
|
||||
app_label->set_max_width_chars(24);
|
||||
app_label->set_wrap(false);
|
||||
app_label->add_css_class("notification-app-name");
|
||||
header_box->append(*app_label);
|
||||
vbox->append(*header_box);
|
||||
|
||||
// Summary label
|
||||
auto summary_label = Gtk::make_managed<Gtk::Label>("<b>" + StringHelper::trimToSize(notify.summary, 20) + "</b>");
|
||||
auto summary_label = Gtk::make_managed<Gtk::Label>("<b>" + notify.summary + "</b>");
|
||||
summary_label->set_use_markup(true);
|
||||
summary_label->set_halign(Gtk::Align::START);
|
||||
summary_label->set_ellipsize(Pango::EllipsizeMode::END);
|
||||
summary_label->set_lines(1);
|
||||
summary_label->set_wrap(true);
|
||||
vbox->append(*summary_label);
|
||||
|
||||
auto body_label = Gtk::make_managed<Gtk::Label>(StringHelper::trimToSize(notify.body, 100));
|
||||
auto body_label = Gtk::make_managed<Gtk::Label>(notify.body);
|
||||
body_label->set_use_markup(true);
|
||||
body_label->set_halign(Gtk::Align::START);
|
||||
body_label->set_ellipsize(Pango::EllipsizeMode::END);
|
||||
body_label->set_lines(3);
|
||||
body_label->set_wrap(true);
|
||||
vbox->append(*body_label);
|
||||
|
||||
|
||||
@@ -36,10 +36,12 @@ SpotifyNotification::SpotifyNotification(uint64_t notificationId, std::shared_pt
|
||||
|
||||
auto artistLabel = Gtk::make_managed<Gtk::Label>();
|
||||
if (!mpris.artist.empty()) {
|
||||
artistLabel->set_text(StringHelper::trimToSize(mpris.artist[0], 30));
|
||||
artistLabel->set_text(mpris.artist[0]);
|
||||
} else {
|
||||
artistLabel->set_text("Unknown Artist");
|
||||
}
|
||||
artistLabel->set_ellipsize(Pango::EllipsizeMode::END);
|
||||
artistLabel->set_max_width_chars(30);
|
||||
artistLabel->set_hexpand(true);
|
||||
artistLabel->set_halign(Gtk::Align::CENTER);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user