From c5acef8c5386b7b10cc4cdff5166f82e93882033 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 2 Mar 2023 13:19:53 +0400 Subject: [PATCH] Deduplicate notification actions on Linux As there are notification daemons with quick reply support and GNotification API having mandatory default action support now, it's the time to reconsider button arrangement. This also makes it possible for legacy notification daemons without default action support opening the chat when no buttons are allowed since 05524c3f6c5a1a4688ed111b51317970b22fac8e again. --- .../linux/notifications_manager_linux.cpp | 45 +++++++------------ .../platform/linux/specific_linux.cpp | 2 +- 2 files changed, 17 insertions(+), 30 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index 11863c4cb8..2298299534 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -439,7 +439,7 @@ bool NotificationData::init( const auto idTuple = _id.toTuple(); _notification->set_default_action( - "app.notification-reply", + "app.notification-activate", idTuple); if (!options.hideMarkAsRead) { @@ -449,13 +449,6 @@ bool NotificationData::init( idTuple); } - if (!options.hideReplyButton) { - _notification->add_button( - tr::lng_notification_reply(tr::now).toStdString(), - "app.notification-reply", - idTuple); - } - return true; } @@ -535,33 +528,28 @@ bool NotificationData::init( if (capabilities.contains("actions")) { _actions.push_back("default"); - _actions.push_back({}); + _actions.push_back(tr::lng_open_link(tr::now).toStdString()); if (!options.hideMarkAsRead) { + // icon name according to https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html _actions.push_back("mail-mark-read"); _actions.push_back( tr::lng_context_mark_read(tr::now).toStdString()); } - if (!options.hideReplyButton) { - if (capabilities.contains("inline-reply")) { - _actions.push_back("inline-reply"); - _actions.push_back( - tr::lng_notification_reply(tr::now).toStdString()); + if (capabilities.contains("inline-reply") + && !options.hideReplyButton) { + _actions.push_back("inline-reply"); + _actions.push_back( + tr::lng_notification_reply(tr::now).toStdString()); - _notificationRepliedSignalId = - _dbusConnection->signal_subscribe( - signalEmitted, - std::string(kService), - std::string(kInterface), - "NotificationReplied", - std::string(kObjectPath)); - } else { - // icon name according to https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html - _actions.push_back("mail-reply-sender"); - _actions.push_back( - tr::lng_notification_reply(tr::now).toStdString()); - } + _notificationRepliedSignalId = + _dbusConnection->signal_subscribe( + signalEmitted, + std::string(kService), + std::string(kInterface), + "NotificationReplied", + std::string(kObjectPath)); } _actionInvokedSignalId = _dbusConnection->signal_subscribe( @@ -781,8 +769,7 @@ void NotificationData::actionInvoked( return; } - if (actionName == "default" - || actionName == "mail-reply-sender") { + if (actionName == "default") { _manager->notificationActivated(_id); } else if (actionName == "mail-mark-read") { _manager->notificationReplied(_id, {}); diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index 7e33d5c944..98665706fb 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -337,7 +337,7 @@ void LaunchGApplication() { }(); app->add_action_with_parameter( - "notification-reply", + "notification-activate", notificationIdVariantType, [](const Glib::VariantBase ¶meter) { Core::Sandbox::Instance().customEnterFromEventLoop([&] {