aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/e-mail-backend.c10
-rw-r--r--mail/e-mail-reader.c6
-rw-r--r--mail/e-mail-sidebar.c2
-rw-r--r--mail/e-mail-store.c4
-rw-r--r--mail/em-composer-utils.c2
-rw-r--r--mail/em-folder-selection-button.c10
-rw-r--r--mail/em-folder-tree-model.c325
-rw-r--r--mail/em-folder-tree-model.h9
-rw-r--r--mail/em-folder-tree.c2
-rw-r--r--mail/em-folder-utils.c8
-rw-r--r--mail/em-subscription-editor.c2
-rw-r--r--mail/em-vfolder-rule.c2
-rw-r--r--mail/message-list.c2
-rw-r--r--modules/mail/e-mail-shell-view.c2
-rw-r--r--plugins/mark-all-read/mark-all-read.c6
15 files changed, 186 insertions, 206 deletions
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index ff37b7a93a..0c6590805f 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -572,7 +572,7 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache,
folder_type = (flags & CAMEL_FOLDER_TYPE_MASK);
target->is_inbox = (folder_type == CAMEL_FOLDER_TYPE_INBOX);
- model = em_folder_tree_model_get_default (mail_backend);
+ model = em_folder_tree_model_get_default ();
target->display_name = em_folder_tree_model_get_folder_name (
model, store, folder_name);
@@ -773,8 +773,12 @@ mail_backend_constructed (GObject *object)
e_account_combo_box_set_session (CAMEL_SESSION (priv->session));
/* FIXME EMailBackend should own the default EMFolderTreeModel. */
- folder_tree_model = em_folder_tree_model_get_default (E_MAIL_BACKEND (shell_backend));
- em_folder_tree_model_set_session (folder_tree_model, priv->session);
+ folder_tree_model = em_folder_tree_model_get_default ();
+
+ /* FIXME This is creating a circular reference. Perhaps the
+ * should only hold a weak pointer to EMailBackend? */
+ em_folder_tree_model_set_backend (
+ folder_tree_model, E_MAIL_BACKEND (object));
g_signal_connect (
shell, "prepare-for-offline",
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index a8e3899ace..430f71dc4f 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -300,7 +300,7 @@ action_mail_copy_cb (GtkAction *action,
window = e_mail_reader_get_window (reader);
uids = e_mail_reader_get_selected_uids (reader);
- model = em_folder_tree_model_get_default (backend);
+ model = em_folder_tree_model_get_default ();
dialog = em_folder_selector_new (
window, backend, model,
@@ -732,7 +732,7 @@ action_mail_mark_unread_cb (GtkAction *action,
/* Notify the tree model that the user has marked messages as
* unread so it doesn't mistake the event as new mail arriving. */
- model = em_folder_tree_model_get_default (e_mail_reader_get_backend (reader));
+ model = em_folder_tree_model_get_default ();
folder = e_mail_reader_get_folder (reader);
em_folder_tree_model_user_marked_unread (model, folder, n_marked);
}
@@ -806,7 +806,7 @@ action_mail_move_cb (GtkAction *action,
uids = e_mail_reader_get_selected_uids (reader);
window = e_mail_reader_get_window (reader);
- model = em_folder_tree_model_get_default (backend);
+ model = em_folder_tree_model_get_default ();
dialog = em_folder_selector_new (
window, backend, model,
diff --git a/mail/e-mail-sidebar.c b/mail/e-mail-sidebar.c
index 6a971ea51f..35048f8293 100644
--- a/mail/e-mail-sidebar.c
+++ b/mail/e-mail-sidebar.c
@@ -471,7 +471,7 @@ e_mail_sidebar_new (EMailBackend *backend,
g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
g_return_val_if_fail (E_IS_ALERT_SINK (alert_sink), NULL);
- model = em_folder_tree_model_get_default (backend);
+ model = em_folder_tree_model_get_default ();
return g_object_new (
E_TYPE_MAIL_SIDEBAR,
diff --git a/mail/e-mail-store.c b/mail/e-mail-store.c
index 7b7774399d..fe54dd057c 100644
--- a/mail/e-mail-store.c
+++ b/mail/e-mail-store.c
@@ -194,7 +194,7 @@ mail_store_add (EMailSession *session,
g_return_if_fail (store != NULL);
g_return_if_fail (CAMEL_IS_STORE (store));
- default_model = em_folder_tree_model_get_default (NULL);
+ default_model = em_folder_tree_model_get_default ();
folder_cache = e_mail_session_get_folder_cache (session);
store_info = store_info_new (store);
@@ -417,7 +417,7 @@ e_mail_store_remove (EMailSession *session,
folder_cache = e_mail_session_get_folder_cache (session);
mail_folder_cache_note_store_remove (folder_cache, store);
- default_model = em_folder_tree_model_get_default (NULL);
+ default_model = em_folder_tree_model_get_default ();
em_folder_tree_model_remove_store (default_model, store);
mail_disconnect_store (store);
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index e42559ab3b..8c98040ada 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -2989,7 +2989,7 @@ post_header_clicked_cb (EComposerPostHeader *header,
shell_backend = e_shell_get_backend_by_name (shell, "mail");
/* FIXME Limit the folder tree to the NNTP account? */
- model = em_folder_tree_model_get_default (E_MAIL_BACKEND (shell_backend));
+ model = em_folder_tree_model_get_default ();
dialog = em_folder_selector_new (
GTK_WINDOW (composer),
diff --git a/mail/em-folder-selection-button.c b/mail/em-folder-selection-button.c
index 26a3c9c2b0..9aa198fa8e 100644
--- a/mail/em-folder-selection-button.c
+++ b/mail/em-folder-selection-button.c
@@ -268,17 +268,13 @@ folder_selection_button_clicked (GtkButton *button)
parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
if (priv->store != NULL) {
- EMailSession *session;
-
- session = e_mail_backend_get_session (priv->backend);
-
- model = em_folder_tree_model_new (priv->backend);
- em_folder_tree_model_set_session (model, session);
+ model = em_folder_tree_model_new ();
+ em_folder_tree_model_set_backend (model, priv->backend);
em_folder_tree_model_add_store (model, priv->store);
}
if (model == NULL)
- model = g_object_ref (em_folder_tree_model_get_default (priv->backend));
+ model = g_object_ref (em_folder_tree_model_get_default ());
dialog = em_folder_selector_new (
parent, priv->backend, model,
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c
index 2116faf854..5f8e9dd41d 100644
--- a/mail/em-folder-tree-model.c
+++ b/mail/em-folder-tree-model.c
@@ -68,7 +68,6 @@ struct _EMFolderTreeModelPrivate {
GtkTreeSelection *selection; /* weak reference */
EAccountList *accounts;
- EMailSession *session;
EMailBackend *backend;
/* CamelStore -> EMFolderTreeStoreInfo */
@@ -85,7 +84,6 @@ struct _EMFolderTreeModelPrivate {
enum {
PROP_0,
PROP_SELECTION,
- PROP_SESSION,
PROP_BACKEND
};
@@ -124,9 +122,10 @@ static gint
folder_tree_model_sort (GtkTreeModel *model,
GtkTreeIter *a,
GtkTreeIter *b,
- gpointer user_data)
+ gpointer unused)
{
- EShell *shell = user_data;
+ EMFolderTreeModel *folder_tree_model;
+ EMailBackend *backend;
gchar *aname, *bname;
CamelStore *store;
gboolean is_store;
@@ -134,6 +133,10 @@ folder_tree_model_sort (GtkTreeModel *model,
guint asortorder, bsortorder;
gint rv = -2;
+ folder_tree_model = EM_FOLDER_TREE_MODEL (model);
+ backend = em_folder_tree_model_get_backend (folder_tree_model);
+ g_return_val_if_fail (backend != NULL, -1);
+
gtk_tree_model_get (
model, a,
COL_BOOL_IS_STORE, &is_store,
@@ -151,7 +154,16 @@ folder_tree_model_sort (GtkTreeModel *model,
-1);
if (is_store) {
- if (e_shell_settings_get_boolean (e_shell_get_shell_settings (shell), "mail-sort-accounts-alpha")) {
+ EShell *shell;
+ EShellBackend *shell_backend;
+ EShellSettings *shell_settings;
+
+ shell_backend = E_SHELL_BACKEND (backend);
+ shell = e_shell_backend_get_shell (shell_backend);
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ if (e_shell_settings_get_boolean (
+ shell_settings, "mail-sort-accounts-alpha")) {
const gchar *on_this_computer = _("On This Computer");
const gchar *search_folders = _("Search Folders");
@@ -226,10 +238,12 @@ account_changed_cb (EAccountList *accounts,
EAccount *account,
EMFolderTreeModel *model)
{
+ EMailBackend *backend;
EMailSession *session;
CamelService *service;
- session = em_folder_tree_model_get_session (model);
+ backend = em_folder_tree_model_get_backend (model);
+ session = e_mail_backend_get_session (backend);
service = camel_session_get_service (
CAMEL_SESSION (session), account->uid);
@@ -251,10 +265,12 @@ account_removed_cb (EAccountList *accounts,
EAccount *account,
EMFolderTreeModel *model)
{
+ EMailBackend *backend;
EMailSession *session;
CamelService *service;
- session = em_folder_tree_model_get_session (model);
+ backend = em_folder_tree_model_get_backend (model);
+ session = e_mail_backend_get_session (backend);
service = camel_session_get_service (
CAMEL_SESSION (session), account->uid);
@@ -271,9 +287,12 @@ account_added_cb (EAccountList *accounts,
EAccount *account,
EMFolderTreeModel *model)
{
+ EMailBackend *backend;
EMailSession *session;
- session = em_folder_tree_model_get_session (model);
+ backend = em_folder_tree_model_get_backend (model);
+ session = e_mail_backend_get_session (backend);
+
e_mail_store_add_by_account (session, account);
}
@@ -281,7 +300,6 @@ static void
folder_tree_model_sort_changed (EMFolderTreeModel *tree_model)
{
GtkTreeModel *model;
- EShellBackend *shell_backend;
g_return_if_fail (tree_model != NULL);
g_return_if_fail (EM_IS_FOLDER_TREE_MODEL (tree_model));
@@ -290,12 +308,10 @@ folder_tree_model_sort_changed (EMFolderTreeModel *tree_model)
if (!model)
return;
- shell_backend = E_SHELL_BACKEND (em_folder_tree_model_get_backend (tree_model));
-
/* this invokes also sort on a GtkTreeStore */
gtk_tree_sortable_set_default_sort_func (
GTK_TREE_SORTABLE (model),
- folder_tree_model_sort, e_shell_backend_get_shell (shell_backend), NULL);
+ folder_tree_model_sort, NULL, NULL);
}
static void
@@ -339,14 +355,19 @@ account_sort_order_changed_cb (EMFolderTreeModel *folder_tree_model)
}
static void
-add_remove_special_folder (EMFolderTreeModel *model, const gchar *account_uid, gboolean add)
+add_remove_special_folder (EMFolderTreeModel *model,
+ const gchar *account_uid,
+ gboolean add)
{
+ EMailBackend *backend;
EMailSession *session;
CamelService *service;
- session = em_folder_tree_model_get_session (model);
+ backend = em_folder_tree_model_get_backend (model);
+ session = e_mail_backend_get_session (backend);
- service = camel_session_get_service (CAMEL_SESSION (session), account_uid);
+ service = camel_session_get_service (
+ CAMEL_SESSION (session), account_uid);
if (!CAMEL_IS_STORE (service))
return;
@@ -358,7 +379,9 @@ add_remove_special_folder (EMFolderTreeModel *model, const gchar *account_uid, g
}
static void
-enable_local_folders_changed_cb (EMFolderTreeModel *model, GParamSpec *spec, EShellSettings *shell_settings)
+enable_local_folders_changed_cb (EMFolderTreeModel *model,
+ GParamSpec *spec,
+ EShellSettings *shell_settings)
{
g_return_if_fail (model != NULL);
g_return_if_fail (shell_settings != NULL);
@@ -368,7 +391,9 @@ enable_local_folders_changed_cb (EMFolderTreeModel *model, GParamSpec *spec, ESh
}
static void
-enable_search_folders_changed_cb (EMFolderTreeModel *model, GParamSpec *spec, EShellSettings *shell_settings)
+enable_search_folders_changed_cb (EMFolderTreeModel *model,
+ GParamSpec *spec,
+ EShellSettings *shell_settings)
{
g_return_if_fail (model != NULL);
g_return_if_fail (shell_settings != NULL);
@@ -398,11 +423,6 @@ folder_tree_model_set_property (GObject *object,
g_value_get_object (value));
return;
- case PROP_SESSION:
- em_folder_tree_model_set_session (
- EM_FOLDER_TREE_MODEL (object),
- g_value_get_object (value));
- return;
case PROP_BACKEND:
em_folder_tree_model_set_backend (
EM_FOLDER_TREE_MODEL (object),
@@ -427,12 +447,6 @@ folder_tree_model_get_property (GObject *object,
EM_FOLDER_TREE_MODEL (object)));
return;
- case PROP_SESSION:
- g_value_set_object (
- value,
- em_folder_tree_model_get_session (
- EM_FOLDER_TREE_MODEL (object)));
- return;
case PROP_BACKEND:
g_value_set_object (
value,
@@ -446,62 +460,6 @@ folder_tree_model_get_property (GObject *object,
static void
-folder_tree_model_constructed (GObject *object)
-{
- EShell *shell;
- EShellSettings *shell_settings;
- EMFolderTreeModel *model;
-
- GType col_types[] = {
- G_TYPE_STRING, /* display name */
- G_TYPE_POINTER, /* store object */
- G_TYPE_STRING, /* full name */
- G_TYPE_STRING, /* icon name */
- G_TYPE_STRING, /* uri */
- G_TYPE_UINT, /* unread count */
- G_TYPE_UINT, /* flags */
- G_TYPE_BOOLEAN, /* is a store node */
- G_TYPE_BOOLEAN, /* is a folder node */
- G_TYPE_BOOLEAN, /* has not-yet-loaded subfolders */
- G_TYPE_UINT, /* last known unread count */
- G_TYPE_BOOLEAN, /* folder is a draft folder */
- G_TYPE_UINT /* user's sortorder */
- };
-
- model = EM_FOLDER_TREE_MODEL (object);
- shell = e_shell_backend_get_shell (E_SHELL_BACKEND (model->priv->backend));
- shell_settings = e_shell_get_shell_settings (shell);
-
- gtk_tree_store_set_column_types (
- GTK_TREE_STORE (model), NUM_COLUMNS, col_types);
- gtk_tree_sortable_set_default_sort_func (
- GTK_TREE_SORTABLE (model),
- folder_tree_model_sort, shell, NULL);
- gtk_tree_sortable_set_sort_column_id (
- GTK_TREE_SORTABLE (model),
- GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
- GTK_SORT_ASCENDING);
-
- model->priv->accounts = e_get_account_list ();
- model->priv->account_changed_id = g_signal_connect (
- model->priv->accounts, "account-changed",
- G_CALLBACK (account_changed_cb), model);
- model->priv->account_removed_id = g_signal_connect (
- model->priv->accounts, "account-removed",
- G_CALLBACK (account_removed_cb), model);
- model->priv->account_added_id = g_signal_connect (
- model->priv->accounts, "account-added",
- G_CALLBACK (account_added_cb), model);
-
- g_signal_connect_swapped (model->priv->backend, "account-sort-order-changed", G_CALLBACK (account_sort_order_changed_cb), model);
- g_signal_connect_swapped (shell_settings, "notify::mail-sort-accounts-alpha", G_CALLBACK (account_sort_order_changed_cb), model);
- g_signal_connect_swapped (shell_settings, "notify::mail-enable-local-folders", G_CALLBACK (enable_local_folders_changed_cb), model);
- g_signal_connect_swapped (shell_settings, "notify::mail-enable-search-folders", G_CALLBACK (enable_search_folders_changed_cb), model);
-
- G_OBJECT_CLASS (parent_class)->constructed (object);
-}
-
-static void
folder_tree_model_dispose (GObject *object)
{
EMFolderTreeModelPrivate *priv;
@@ -515,24 +473,23 @@ folder_tree_model_dispose (GObject *object)
priv->selection = NULL;
}
- if (priv->session != NULL) {
- g_object_unref (priv->session);
- priv->session = NULL;
- }
-
- if (priv->backend) {
+ if (priv->backend != NULL) {
EShell *shell;
+ EShellBackend *shell_backend;
EShellSettings *shell_settings;
- EMFolderTreeModel *model;
- model = EM_FOLDER_TREE_MODEL (object);
- shell = e_shell_backend_get_shell (E_SHELL_BACKEND (priv->backend));
+ shell_backend = E_SHELL_BACKEND (priv->backend);
+ shell = e_shell_backend_get_shell (shell_backend);
shell_settings = e_shell_get_shell_settings (shell);
- g_signal_handlers_disconnect_by_func (priv->backend, G_CALLBACK (account_sort_order_changed_cb), model);
- g_signal_handlers_disconnect_by_func (shell_settings, G_CALLBACK (account_sort_order_changed_cb), model);
- g_signal_handlers_disconnect_by_func (shell_settings, G_CALLBACK (enable_local_folders_changed_cb), model);
- g_signal_handlers_disconnect_by_func (shell_settings, G_CALLBACK (enable_search_folders_changed_cb), model);
+ g_signal_handlers_disconnect_by_func (
+ priv->backend, account_sort_order_changed_cb, object);
+ g_signal_handlers_disconnect_by_func (
+ shell_settings, account_sort_order_changed_cb, object);
+ g_signal_handlers_disconnect_by_func (
+ shell_settings, enable_local_folders_changed_cb, object);
+ g_signal_handlers_disconnect_by_func (
+ shell_settings, enable_search_folders_changed_cb, object);
g_object_unref (priv->backend);
priv->backend = NULL;
@@ -564,6 +521,54 @@ folder_tree_model_finalize (GObject *object)
}
static void
+folder_tree_model_constructed (GObject *object)
+{
+ EMFolderTreeModelPrivate *priv;
+
+ GType col_types[] = {
+ G_TYPE_STRING, /* display name */
+ G_TYPE_POINTER, /* store object */
+ G_TYPE_STRING, /* full name */
+ G_TYPE_STRING, /* icon name */
+ G_TYPE_STRING, /* uri */
+ G_TYPE_UINT, /* unread count */
+ G_TYPE_UINT, /* flags */
+ G_TYPE_BOOLEAN, /* is a store node */
+ G_TYPE_BOOLEAN, /* is a folder node */
+ G_TYPE_BOOLEAN, /* has not-yet-loaded subfolders */
+ G_TYPE_UINT, /* last known unread count */
+ G_TYPE_BOOLEAN, /* folder is a draft folder */
+ G_TYPE_UINT /* user's sortorder */
+ };
+
+ priv = EM_FOLDER_TREE_MODEL_GET_PRIVATE (object);
+
+ gtk_tree_store_set_column_types (
+ GTK_TREE_STORE (object), NUM_COLUMNS, col_types);
+ gtk_tree_sortable_set_default_sort_func (
+ GTK_TREE_SORTABLE (object),
+ folder_tree_model_sort, NULL, NULL);
+ gtk_tree_sortable_set_sort_column_id (
+ GTK_TREE_SORTABLE (object),
+ GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
+ GTK_SORT_ASCENDING);
+
+ priv->accounts = e_get_account_list ();
+ priv->account_changed_id = g_signal_connect (
+ priv->accounts, "account-changed",
+ G_CALLBACK (account_changed_cb), object);
+ priv->account_removed_id = g_signal_connect (
+ priv->accounts, "account-removed",
+ G_CALLBACK (account_removed_cb), object);
+ priv->account_added_id = g_signal_connect (
+ priv->accounts, "account-added",
+ G_CALLBACK (account_added_cb), object);
+
+ /* Chain up to parent's constructed() method. */
+ G_OBJECT_CLASS (parent_class)->constructed (object);
+}
+
+static void
em_folder_tree_model_class_init (EMFolderTreeModelClass *class)
{
GObjectClass *object_class;
@@ -574,39 +579,29 @@ em_folder_tree_model_class_init (EMFolderTreeModelClass *class)
object_class = G_OBJECT_CLASS (class);
object_class->set_property = folder_tree_model_set_property;
object_class->get_property = folder_tree_model_get_property;
- object_class->constructed = folder_tree_model_constructed;
object_class->dispose = folder_tree_model_dispose;
object_class->finalize = folder_tree_model_finalize;
+ object_class->constructed = folder_tree_model_constructed;
g_object_class_install_property (
object_class,
- PROP_SELECTION,
- g_param_spec_object (
- "selection",
- "Selection",
- NULL,
- GTK_TYPE_TREE_SELECTION,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_SESSION,
+ PROP_BACKEND,
g_param_spec_object (
- "session",
+ "backend",
NULL,
NULL,
- E_TYPE_MAIL_SESSION,
+ E_TYPE_MAIL_BACKEND,
G_PARAM_READWRITE));
g_object_class_install_property (
object_class,
- PROP_BACKEND,
+ PROP_SELECTION,
g_param_spec_object (
- "backend",
- NULL,
+ "selection",
+ "Selection",
NULL,
- E_TYPE_MAIL_BACKEND,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ GTK_TYPE_TREE_SELECTION,
+ G_PARAM_READWRITE));
signals[LOADING_ROW] = g_signal_new (
"loading-row",
@@ -708,26 +703,18 @@ em_folder_tree_model_init (EMFolderTreeModel *model)
}
EMFolderTreeModel *
-em_folder_tree_model_new (EMailBackend *mail_backend)
+em_folder_tree_model_new (void)
{
- return g_object_new (EM_TYPE_FOLDER_TREE_MODEL, "backend", mail_backend, NULL);
+ return g_object_new (EM_TYPE_FOLDER_TREE_MODEL, NULL);
}
EMFolderTreeModel *
-em_folder_tree_model_get_default (EMailBackend *mail_backend)
+em_folder_tree_model_get_default (void)
{
static EMFolderTreeModel *default_folder_tree_model;
- if (G_UNLIKELY (default_folder_tree_model == NULL)) {
- if (!mail_backend) {
- EShell *shell;
-
- shell = e_shell_get_default ();
- mail_backend = E_MAIL_BACKEND (e_shell_get_backend_by_name (shell, "mail"));
- }
-
- default_folder_tree_model = em_folder_tree_model_new (mail_backend);
- }
+ if (G_UNLIKELY (default_folder_tree_model == NULL))
+ default_folder_tree_model = em_folder_tree_model_new ();
return default_folder_tree_model;
}
@@ -766,71 +753,67 @@ em_folder_tree_model_set_selection (EMFolderTreeModel *model,
g_object_notify (G_OBJECT (model), "selection");
}
-EMailSession *
-em_folder_tree_model_get_session (EMFolderTreeModel *model)
+EMailBackend *
+em_folder_tree_model_get_backend (EMFolderTreeModel *model)
{
g_return_val_if_fail (EM_IS_FOLDER_TREE_MODEL (model), NULL);
- return model->priv->session;
+ return model->priv->backend;
}
void
-em_folder_tree_model_set_session (EMFolderTreeModel *model,
- EMailSession *session)
+em_folder_tree_model_set_backend (EMFolderTreeModel *model,
+ EMailBackend *backend)
{
g_return_if_fail (EM_IS_FOLDER_TREE_MODEL (model));
- if (session != NULL) {
- g_return_if_fail (E_IS_MAIL_SESSION (session));
- g_object_ref (session);
+ if (backend != NULL) {
+ g_return_if_fail (E_IS_MAIL_BACKEND (backend));
+ g_object_ref (backend);
}
- if (model->priv->session != NULL)
- g_object_unref (model->priv->session);
+ if (model->priv->backend != NULL)
+ g_object_unref (model->priv->backend);
- model->priv->session = session;
+ model->priv->backend = backend;
/* FIXME Technically we should be disconnecting this signal
- * when replacing an old session with a new session,
+ * when replacing an old backend with a new backend,
* but at present this function is only called once. */
- if (session != NULL) {
+ if (backend != NULL) {
MailFolderCache *folder_cache;
+ EMailSession *session;
+ EShell *shell;
+ EShellBackend *shell_backend;
+ EShellSettings *shell_settings;
+ shell_backend = E_SHELL_BACKEND (backend);
+ shell = e_shell_backend_get_shell (shell_backend);
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ session = e_mail_backend_get_session (backend);
folder_cache = e_mail_session_get_folder_cache (session);
g_signal_connect_swapped (
+ backend, "account-sort-order-changed",
+ G_CALLBACK (account_sort_order_changed_cb), model);
+
+ g_signal_connect_swapped (
+ shell_settings, "notify::mail-sort-accounts-alpha",
+ G_CALLBACK (account_sort_order_changed_cb), model);
+ g_signal_connect_swapped (
+ shell_settings, "notify::mail-enable-local-folders",
+ G_CALLBACK (enable_local_folders_changed_cb), model);
+ g_signal_connect_swapped (
+ shell_settings, "notify::mail-enable-search-folders",
+ G_CALLBACK (enable_search_folders_changed_cb), model);
+
+ g_signal_connect_swapped (
folder_cache, "folder-unread-updated",
G_CALLBACK (folder_tree_model_set_unread_count),
model);
}
- g_object_notify (G_OBJECT (model), "session");
-}
-
-EMailBackend *
-em_folder_tree_model_get_backend (EMFolderTreeModel *model)
-{
- g_return_val_if_fail (EM_IS_FOLDER_TREE_MODEL (model), NULL);
-
- return model->priv->backend;
-}
-
-void
-em_folder_tree_model_set_backend (EMFolderTreeModel *model,
- EMailBackend *backend)
-{
- g_return_if_fail (EM_IS_FOLDER_TREE_MODEL (model));
-
- if (backend != NULL) {
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
- g_object_ref (backend);
- }
-
- if (model->priv->backend != NULL)
- g_object_unref (model->priv->backend);
-
- model->priv->backend = backend;
-
g_object_notify (G_OBJECT (model), "backend");
}
@@ -844,6 +827,7 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model,
GtkTreeRowReference *uri_row, *path_row;
GtkTreeStore *tree_store;
MailFolderCache *folder_cache;
+ EMailBackend *backend;
EMailSession *session;
EAccount *account;
guint unread;
@@ -868,7 +852,8 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model,
tree_store = GTK_TREE_STORE (model);
- session = em_folder_tree_model_get_session (model);
+ backend = em_folder_tree_model_get_backend (model);
+ session = e_mail_backend_get_session (backend);
folder_cache = e_mail_session_get_folder_cache (session);
uid = camel_service_get_uid (CAMEL_SERVICE (si->store));
diff --git a/mail/em-folder-tree-model.h b/mail/em-folder-tree-model.h
index 3765cfea11..0ed007aa96 100644
--- a/mail/em-folder-tree-model.h
+++ b/mail/em-folder-tree-model.h
@@ -111,20 +111,15 @@ struct _EMFolderTreeModelClass {
GType em_folder_tree_model_get_type (void);
EMFolderTreeModel *
- em_folder_tree_model_new (EMailBackend *mail_backend);
+ em_folder_tree_model_new (void);
EMFolderTreeModel *
- em_folder_tree_model_get_default (EMailBackend *mail_backend);
+ em_folder_tree_model_get_default (void);
GtkTreeSelection *
em_folder_tree_model_get_selection
(EMFolderTreeModel *model);
void em_folder_tree_model_set_selection
(EMFolderTreeModel *model,
GtkTreeSelection *selection);
-EMailSession * em_folder_tree_model_get_session
- (EMFolderTreeModel *model);
-void em_folder_tree_model_set_session
- (EMFolderTreeModel *model,
- EMailSession *session);
EMailBackend * em_folder_tree_model_get_backend
(EMFolderTreeModel *model);
void em_folder_tree_model_set_backend
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index 6212f8a8ca..061c3540f7 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -1770,7 +1770,7 @@ em_folder_tree_new (EMailBackend *backend,
g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
g_return_val_if_fail (E_IS_ALERT_SINK (alert_sink), NULL);
- model = em_folder_tree_model_get_default (backend);
+ model = em_folder_tree_model_get_default ();
return em_folder_tree_new_with_model (backend, alert_sink, model);
}
diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c
index 54586ad763..e72b8014ad 100644
--- a/mail/em-folder-utils.c
+++ b/mail/em-folder-utils.c
@@ -487,7 +487,7 @@ em_folder_utils_copy_folder (GtkWindow *parent,
label = delete ? _("_Move") : _("C_opy");
title = delete ? _("Move Folder To") : _("Copy Folder To");
- model = em_folder_tree_model_get_default (backend);
+ model = em_folder_tree_model_get_default ();
dialog = em_folder_selector_new (
parent, backend, model,
@@ -565,10 +565,10 @@ em_folder_utils_create_folder (GtkWindow *parent,
shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
shell_settings = e_shell_get_shell_settings (shell);
- model = em_folder_tree_model_new (backend);
- session = e_mail_backend_get_session (backend);
- em_folder_tree_model_set_session (model, session);
+ model = em_folder_tree_model_new ();
+ em_folder_tree_model_set_backend (model, backend);
+ session = e_mail_backend_get_session (backend);
list = camel_session_list_services (CAMEL_SESSION (session));
for (link = list; link != NULL; link = g_list_next (link)) {
diff --git a/mail/em-subscription-editor.c b/mail/em-subscription-editor.c
index 2dca93b51a..e2452d70bf 100644
--- a/mail/em-subscription-editor.c
+++ b/mail/em-subscription-editor.c
@@ -1077,7 +1077,7 @@ subscription_editor_realize (GtkWidget *widget)
/* Find stores to display, and watch for the initial store. */
- model = em_folder_tree_model_get_default (NULL);
+ model = em_folder_tree_model_get_default ();
list = em_folder_tree_model_list_stores (model);
for (link = list; link != NULL; link = g_list_next (link)) {
diff --git a/mail/em-vfolder-rule.c b/mail/em-vfolder-rule.c
index fbb711738f..be18f2c248 100644
--- a/mail/em-vfolder-rule.c
+++ b/mail/em-vfolder-rule.c
@@ -610,7 +610,7 @@ source_add (GtkWidget *widget,
backend = em_vfolder_rule_get_backend (data->vr);
- model = em_folder_tree_model_get_default (backend);
+ model = em_folder_tree_model_get_default ();
dialog = em_folder_selector_new (
parent, backend, model,
diff --git a/mail/message-list.c b/mail/message-list.c
index cd44b9506a..d98f860f8c 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -4191,7 +4191,7 @@ on_click (ETree *tree,
if (col == COL_MESSAGE_STATUS && (flags & CAMEL_MESSAGE_SEEN)) {
EMFolderTreeModel *model;
- model = em_folder_tree_model_get_default (list->priv->backend);
+ model = em_folder_tree_model_get_default ();
em_folder_tree_model_user_marked_unread (
model, list->folder, 1);
}
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index 3a92ce284b..5759b5830f 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -868,7 +868,7 @@ mail_shell_view_update_actions (EShellView *shell_view)
shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
state = e_shell_sidebar_check_state (shell_sidebar);
- model = em_folder_tree_model_get_default (e_mail_reader_get_backend (reader));
+ model = em_folder_tree_model_get_default ();
folder_allows_children =
(state & E_MAIL_SIDEBAR_FOLDER_ALLOWS_CHILDREN);
diff --git a/plugins/mark-all-read/mark-all-read.c b/plugins/mark-all-read/mark-all-read.c
index ab8549495b..4fe19cf71b 100644
--- a/plugins/mark-all-read/mark-all-read.c
+++ b/plugins/mark-all-read/mark-all-read.c
@@ -318,7 +318,7 @@ scan_folder_tree_for_unread_helper (GtkTreeModel *model,
}
static gint
-scan_folder_tree_for_unread (EMailBackend *backend, const gchar *folder_uri)
+scan_folder_tree_for_unread (const gchar *folder_uri)
{
GtkTreeRowReference *reference;
EMFolderTreeModel *model;
@@ -338,7 +338,7 @@ scan_folder_tree_for_unread (EMailBackend *backend, const gchar *folder_uri)
if (folder_uri == NULL)
return 0;
- model = em_folder_tree_model_get_default (backend);
+ model = em_folder_tree_model_get_default ();
reference = em_folder_tree_model_lookup_uri (model, folder_uri);
if (gtk_tree_row_reference_valid (reference)) {
@@ -602,7 +602,7 @@ update_actions_cb (EShellView *shell_view,
g_object_get (shell_sidebar, "folder-tree", &folder_tree, NULL);
folder_uri = em_folder_tree_get_selected_uri (folder_tree);
- visible = (scan_folder_tree_for_unread (E_MAIL_BACKEND (e_shell_view_get_shell_backend (shell_view)), folder_uri) > 0);
+ visible = (scan_folder_tree_for_unread (folder_uri) > 0);
gtk_action_set_visible (action, visible);
g_object_unref (folder_tree);