[evolution] I#1353 - mail-notification: Show folder name in the notification
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] I#1353 - mail-notification: Show folder name in the notification
- Date: Mon, 15 Feb 2021 10:22:06 +0000 (UTC)
commit 11687c438dd32273f1898e003639376461a3f6a4
Author: Milan Crha <mcrha redhat com>
Date: Mon Feb 15 11:20:59 2021 +0100
I#1353 - mail-notification: Show folder name in the notification
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1353
src/mail/e-mail-backend.c | 7 ++++
src/mail/em-event.c | 1 +
src/mail/em-event.h | 1 +
src/plugins/mail-notification/mail-notification.c | 49 ++++++++++-------------
4 files changed, 30 insertions(+), 28 deletions(-)
---
diff --git a/src/mail/e-mail-backend.c b/src/mail/e-mail-backend.c
index a70ba6189f..ef0e499c1c 100644
--- a/src/mail/e-mail-backend.c
+++ b/src/mail/e-mail-backend.c
@@ -844,6 +844,7 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache,
EMEvent *event = em_event_peek ();
EMEventTargetFolder *target;
EMFolderTreeModel *model;
+ CamelFolder *folder;
gchar *folder_uri;
gint folder_type;
CamelFolderInfoFlags flags = 0;
@@ -866,6 +867,12 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache,
target->display_name = em_folder_tree_model_get_folder_name (
model, store, folder_name);
+ folder = mail_folder_cache_ref_folder (folder_cache, store, folder_name);
+ if (folder) {
+ target->full_display_name = e_mail_folder_to_full_display_name (folder, NULL);
+ g_clear_object (&folder);
+ }
+
if (target->new > 0) {
EShell *shell;
EShellBackend *shell_backend;
diff --git a/src/mail/em-event.c b/src/mail/em-event.c
index c4733365d1..ce8d6eaa75 100644
--- a/src/mail/em-event.c
+++ b/src/mail/em-event.c
@@ -42,6 +42,7 @@ eme_target_free (EEvent *ep,
g_object_unref (s->store);
g_free (s->folder_name);
g_free (s->display_name);
+ g_free (s->full_display_name);
g_free (s->msg_uid);
g_free (s->msg_sender);
g_free (s->msg_subject);
diff --git a/src/mail/em-event.h b/src/mail/em-event.h
index c62ca00d2f..099150224e 100644
--- a/src/mail/em-event.h
+++ b/src/mail/em-event.h
@@ -95,6 +95,7 @@ struct _EMEventTargetFolder {
guint new;
gboolean is_inbox;
gchar *display_name;
+ gchar *full_display_name;
/* valid (non-NULL) when only one new message reported */
gchar *msg_uid;
diff --git a/src/plugins/mail-notification/mail-notification.c
b/src/plugins/mail-notification/mail-notification.c
index 1cffe09e8e..6d63ca391b 100644
--- a/src/plugins/mail-notification/mail-notification.c
+++ b/src/plugins/mail-notification/mail-notification.c
@@ -487,67 +487,60 @@ static void
new_notify_status (EMEventTargetFolder *t)
{
gchar *escaped_text;
- gchar *text;
+ GString *text;
const gchar *summary;
const gchar *icon_name;
status_count += t->new;
- text = g_strdup_printf (ngettext (
+ text = g_string_sized_new (256);
+
+ g_string_append_printf (text, ngettext (
/* Translators: '%d' is the count of mails received. */
"You have received %d new message.",
"You have received %d new messages.",
status_count), status_count);
+ if (t->full_display_name) {
+ g_string_append_c (text, '\n');
+
+ /* Translators: The '%s' is replaced by the folder name, where a new
+ * mail message arrived. Example: "Folder: On This Computer : Inbox" */
+ g_string_append_printf (text, _("Folder: %s"), t->full_display_name);
+ }
+
if (t->msg_sender) {
- gchar *tmp, *str;
+ g_string_append_c (text, '\n');
/* Translators: "From:" is preceding a new mail
* sender address, like "From: user example com" */
- str = g_strdup_printf (_("From: %s"), t->msg_sender);
- tmp = g_strconcat (text, "\n", str, NULL);
-
- g_free (text);
- g_free (str);
-
- text = tmp;
+ g_string_append_printf (text, _("From: %s"), t->msg_sender);
}
if (t->msg_subject) {
- gchar *tmp, *str;
+ g_string_append_c (text, '\n');
/* Translators: "Subject:" is preceding a new mail
* subject, like "Subject: It happened again" */
- str = g_strdup_printf (_("Subject: %s"), t->msg_subject);
- tmp = g_strconcat (text, "\n", str, NULL);
-
- g_free (text);
- g_free (str);
-
- text = tmp;
+ g_string_append_printf (text, _("Subject: %s"), t->msg_subject);
}
if (status_count > 1 && (t->msg_sender || t->msg_subject)) {
- gchar *tmp, *str;
guint additional_messages = status_count - 1;
- str = g_strdup_printf (ngettext (
+ g_string_append_c (text, '\n');
+
+ g_string_append_printf (text, ngettext (
/* Translators: %d is the count of mails received in addition
* to the one displayed in this notification. */
"(and %d more)",
"(and %d more)",
additional_messages), additional_messages);
- tmp = g_strconcat (text, "\n", str, NULL);
-
- g_free (text);
- g_free (str);
-
- text = tmp;
}
icon_name = "evolution";
summary = _("New email in Evolution");
- escaped_text = g_markup_escape_text (text, strlen (text));
+ escaped_text = g_markup_escape_text (text->str, -1);
if (notify) {
notify_notification_update (
@@ -606,7 +599,7 @@ new_notify_status (EMEventTargetFolder *t)
(GDestroyNotify) g_object_unref);
g_free (escaped_text);
- g_free (text);
+ g_string_free (text, TRUE);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]