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 05524c3f6c
again.
This commit is contained in:
parent
e2450101c0
commit
c5acef8c53
|
@ -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, {});
|
||||
|
|
|
@ -337,7 +337,7 @@ void LaunchGApplication() {
|
|||
}();
|
||||
|
||||
app->add_action_with_parameter(
|
||||
"notification-reply",
|
||||
"notification-activate",
|
||||
notificationIdVariantType,
|
||||
[](const Glib::VariantBase ¶meter) {
|
||||
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
|
||||
|
|
Loading…
Reference in New Issue