+
+static void
+on_mail_operation_started (ModestMailOperation *mail_op,
+ gpointer user_data)
+{
+ ModestFolderWindow *self;
+ ModestMailOperationTypeOperation op_type;
+ GObject *source = NULL;
+
+ self = MODEST_FOLDER_WINDOW (user_data);
+ op_type = modest_mail_operation_get_type_operation (mail_op);
+ source = modest_mail_operation_get_source(mail_op);
+ if (G_OBJECT (self) == source) {
+ update_progress_hint (self);
+ }
+ g_object_unref (source);
+}
+
+static void
+on_mail_operation_finished (ModestMailOperation *mail_op,
+ gpointer user_data)
+{
+ ModestFolderWindow *self;
+
+ self = MODEST_FOLDER_WINDOW (user_data);
+
+ /* Don't disable the progress hint if there are more pending
+ operations from this window */
+ update_progress_hint (self);
+
+ modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (self));
+}
+
+static void
+on_queue_changed (ModestMailOperationQueue *queue,
+ ModestMailOperation *mail_op,
+ ModestMailOperationQueueNotification type,
+ ModestFolderWindow *self)
+{
+ ModestFolderWindowPrivate *priv;
+
+ priv = MODEST_FOLDER_WINDOW_GET_PRIVATE (self);
+
+ /* If this operations was created by another window, do nothing */
+ if (!modest_mail_operation_is_mine (mail_op, G_OBJECT(self)))
+ return;
+
+ if (type == MODEST_MAIL_OPERATION_QUEUE_OPERATION_ADDED) {
+ priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
+ G_OBJECT (mail_op),
+ "operation-started",
+ G_CALLBACK (on_mail_operation_started),
+ self);
+ priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
+ G_OBJECT (mail_op),
+ "operation-finished",
+ G_CALLBACK (on_mail_operation_finished),
+ self);
+ } else if (type == MODEST_MAIL_OPERATION_QUEUE_OPERATION_REMOVED) {
+ priv->sighandlers = modest_signal_mgr_disconnect (priv->sighandlers,
+ G_OBJECT (mail_op),
+ "operation-started");
+ priv->sighandlers = modest_signal_mgr_disconnect (priv->sighandlers,
+ G_OBJECT (mail_op),
+ "operation-finished");
+ }
+}
+
+static void
+on_activity_changed (ModestFolderView *view,
+ gboolean activity,
+ ModestFolderWindow *folder_window)
+{
+ g_return_if_fail (MODEST_IS_FOLDER_WINDOW (folder_window));
+
+ update_progress_hint (folder_window);
+}
+
+
+static void
+update_window_title (ModestFolderWindow *self,
+ TnyAccount *account)
+{
+ if (account) {
+ const gchar *name;
+ const gchar *mailbox;
+ gchar *title = NULL;
+ ModestFolderWindowPrivate *priv;
+
+ priv = MODEST_FOLDER_WINDOW_GET_PRIVATE (self);
+
+ mailbox = modest_folder_view_get_mailbox (MODEST_FOLDER_VIEW (priv->folder_view));
+ if (mailbox) {
+ title = g_strdup (mailbox);
+ } else {
+ name = modest_tny_account_get_parent_modest_account_name_for_server_account (account);
+ title = modest_account_mgr_get_display_name (modest_runtime_get_account_mgr(),
+ name);
+ }
+ if (title) {
+ gtk_window_set_title (GTK_WINDOW (self), title);
+ g_free (title);
+ } else {
+ gtk_window_set_title (GTK_WINDOW (self), _("mcen_ap_name"));
+ }
+ } else {
+ gtk_window_set_title (GTK_WINDOW (self), _("mcen_ap_name"));
+ }
+}
+
+static void
+on_visible_account_changed (ModestFolderView *folder_view,
+ const gchar *account_id,
+ gpointer user_data)
+{
+ TnyAccount *account;
+
+ if (!account_id)
+ return;
+
+ account = modest_tny_account_store_get_tny_account_by (modest_runtime_get_account_store(),
+ MODEST_TNY_ACCOUNT_STORE_QUERY_ID,
+ account_id);
+
+ /* Update window title */
+ if (account) {
+ update_window_title (MODEST_FOLDER_WINDOW (user_data), account);
+ g_object_unref (account);
+ }
+}
+
+static void
+on_account_changed (TnyAccountStore *account_store,
+ TnyAccount *account,
+ gpointer user_data)
+{
+ const gchar *acc_id, *visible;
+ ModestFolderWindowPrivate *priv;
+
+ if (!TNY_IS_STORE_ACCOUNT (account))
+ return;
+
+ priv = MODEST_FOLDER_WINDOW_GET_PRIVATE (user_data);
+
+ acc_id = tny_account_get_id (account);
+ visible = modest_folder_view_get_account_id_of_visible_server_account (MODEST_FOLDER_VIEW (priv->folder_view));
+
+ /* Update title if the visible account is the one that have just changed */
+ if (acc_id && visible && !g_utf8_collate (acc_id, visible))
+ update_window_title (MODEST_FOLDER_WINDOW (user_data), account);
+}