diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-05-03 02:21:21 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-06-30 00:42:05 +0800 |
commit | 2c2c46289502eaf0455dcbc24cb1144be2ce545c (patch) | |
tree | d2f9573e90bfcf884c1d827febcc7515e84b82fa | |
parent | bb99cdc5de522ad7dac209d0c3fe357493cbf6ac (diff) | |
download | gsoc2013-evolution-2c2c46289502eaf0455dcbc24cb1144be2ce545c.tar.gz gsoc2013-evolution-2c2c46289502eaf0455dcbc24cb1144be2ce545c.tar.zst gsoc2013-evolution-2c2c46289502eaf0455dcbc24cb1144be2ce545c.zip |
EMEventTargetFolder: Add an EAccount member.
The mail-notification plugin can use the EAccount member directly
instead of searching for it by URI.
-rw-r--r-- | mail/e-mail-backend.c | 7 | ||||
-rw-r--r-- | mail/em-event.c | 7 | ||||
-rw-r--r-- | mail/em-event.h | 2 | ||||
-rw-r--r-- | plugins/mail-notification/mail-notification.c | 20 |
4 files changed, 23 insertions, 13 deletions
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c index dd8f69ac53..7ccfa729dc 100644 --- a/mail/e-mail-backend.c +++ b/mail/e-mail-backend.c @@ -361,6 +361,8 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache, EMEvent *event = em_event_peek (); EMEventTargetFolder *target; EMFolderTreeModel *model; + EAccount *account; + const gchar *uid; gint folder_type; gint flags = 0; @@ -370,8 +372,11 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache, folder_cache, folder, &flags)) g_return_if_reached (); + uid = camel_service_get_uid (CAMEL_SERVICE (store)); + account = e_get_account_by_uid (uid); + target = em_event_target_new_folder ( - event, folder_uri, new_messages, + event, account, folder_uri, new_messages, msg_uid, msg_sender, msg_subject); folder_type = (flags & CAMEL_FOLDER_TYPE_MASK); diff --git a/mail/em-event.c b/mail/em-event.c index 084c857968..a1b0442024 100644 --- a/mail/em-event.c +++ b/mail/em-event.c @@ -42,6 +42,8 @@ eme_target_free (EEvent *ep, EEventTarget *t) switch (t->type) { case EM_EVENT_TARGET_FOLDER: { EMEventTargetFolder *s = (EMEventTargetFolder *)t; + if (s->account != NULL) + g_object_unref (s->account); g_free (s->name); g_free (s->uri); g_free (s->msg_uid); @@ -108,6 +110,7 @@ em_event_peek (void) EMEventTargetFolder * em_event_target_new_folder (EMEvent *eme, + EAccount *account, const gchar *uri, guint new, const gchar *msg_uid, @@ -120,6 +123,10 @@ em_event_target_new_folder (EMEvent *eme, t = e_event_target_new ( &eme->popup, EM_EVENT_TARGET_FOLDER, sizeof (*t)); + if (E_IS_ACCOUNT (account)) + t->account = g_object_ref (account); + else + t->account = NULL; t->uri = g_strdup (uri); t->target.mask = ~flags; t->new = new; diff --git a/mail/em-event.h b/mail/em-event.h index 34441c558f..644ba211ef 100644 --- a/mail/em-event.h +++ b/mail/em-event.h @@ -74,6 +74,7 @@ typedef struct _EMEventTargetFolder EMEventTargetFolder; struct _EMEventTargetFolder { EEventTarget target; + EAccount *account; gchar *uri; guint new; gboolean is_inbox; @@ -136,6 +137,7 @@ GType em_event_get_type (void); EMEvent * em_event_peek (void); EMEventTargetFolder * em_event_target_new_folder (EMEvent *emp, + EAccount *account, const gchar *uri, guint32 count_new_msgs, const gchar *msg_uid, diff --git a/plugins/mail-notification/mail-notification.c b/plugins/mail-notification/mail-notification.c index 5cde1fbf69..9f236c072a 100644 --- a/plugins/mail-notification/mail-notification.c +++ b/plugins/mail-notification/mail-notification.c @@ -379,16 +379,13 @@ new_notify_status (EMEventTargetFolder *t) gchar *msg; if (!status_count) { - EAccount *account; - gchar *name = t->name; + gchar *folder_name; - account = e_get_account_by_source_url (t->uri); - - if (account != NULL) { - name = g_strdup_printf ( - "%s/%s", e_account_get_string ( - account, E_ACCOUNT_NAME), name); - } + if (t->account != NULL) + folder_name = g_strdup_printf ( + "%s/%s", t->account->name, t->name); + else + folder_name = g_strdup (t->name); status_count = t->new; @@ -397,10 +394,9 @@ new_notify_status (EMEventTargetFolder *t) msg = g_strdup_printf (ngettext ( "You have received %d new message\nin %s.", "You have received %d new messages\nin %s.", - status_count), status_count, name); + status_count), status_count, folder_name); - if (name != t->name) - g_free (name); + g_free (folder_name); if (t->msg_sender) { gchar *tmp, *str; |