#include <gtkhtml/gtkhtml-search.h>
#include "modest-ui-dimming-manager.h"
#include <gdk/gdkkeysyms.h>
+#include <modest-tny-account.h>
#define DEFAULT_FOLDER "MyDocs/.documents"
ModestMailOperation *mail_op,
ModestMailOperationQueueNotification type,
ModestMsgViewWindow *self);
+static void on_account_removed (ModestAccountMgr *obj,
+ const gchar *account,
+ gboolean server_account,
+ gpointer user_data);
static void view_msg_cb (ModestMailOperation *mail_op, TnyHeader *header, TnyMsg *msg, gpointer user_data);
guint clipboard_change_handler;
guint queue_change_handler;
+ guint account_removed_handler;
guint progress_bar_timeout;
priv->msg_view = NULL;
priv->header_model = NULL;
priv->clipboard_change_handler = 0;
+ priv->queue_change_handler = 0;
+ priv->account_removed_handler = 0;
priv->current_toolbar_mode = TOOLBAR_MODE_NORMAL;
priv->optimized_view = FALSE;
gtk_container_add (GTK_CONTAINER(obj), main_vbox);
priv->find_toolbar = hildon_find_toolbar_new (NULL);
+ hildon_window_add_toolbar (HILDON_WINDOW (obj), GTK_TOOLBAR (priv->find_toolbar));
gtk_widget_set_no_show_all (priv->find_toolbar, TRUE);
g_signal_connect (G_OBJECT (priv->find_toolbar), "close", G_CALLBACK (modest_msg_view_window_find_toolbar_close), obj);
g_signal_connect (G_OBJECT (priv->find_toolbar), "search", G_CALLBACK (modest_msg_view_window_find_toolbar_search), obj);
priv->clipboard_change_handler = g_signal_connect (G_OBJECT (gtk_clipboard_get (GDK_SELECTION_PRIMARY)), "owner-change", G_CALLBACK (modest_msg_view_window_clipboard_owner_change), obj);
gtk_widget_show_all (GTK_WIDGET(main_vbox));
- gtk_box_pack_end (GTK_BOX (main_vbox), priv->find_toolbar, FALSE, FALSE, 0);
}
g_signal_handler_disconnect (G_OBJECT (modest_runtime_get_mail_operation_queue ()), priv->queue_change_handler);
priv->queue_change_handler = 0;
}
+ if (priv->account_removed_handler > 0) {
+ g_signal_handler_disconnect (G_OBJECT (modest_runtime_get_account_mgr ()), priv->account_removed_handler);
+ priv->account_removed_handler = 0;
+ }
if (priv->header_model != NULL) {
g_object_unref (priv->header_model);
priv->header_model = NULL;
}
- /* disconnet operations queue observer */
-
if (priv->progress_bar_timeout > 0) {
g_source_remove (priv->progress_bar_timeout);
priv->progress_bar_timeout = 0;
ModestWindow *
modest_msg_view_window_new_with_header_model (TnyMsg *msg,
- const gchar *account_name,
+ const gchar *modest_account_name,
const gchar *msg_uid,
GtkTreeModel *model,
GtkTreeRowReference *row_reference)
ModestMsgViewWindow *window = NULL;
ModestMsgViewWindowPrivate *priv = NULL;
- window = MODEST_MSG_VIEW_WINDOW(modest_msg_view_window_new (msg, account_name, msg_uid));
+ window = MODEST_MSG_VIEW_WINDOW(modest_msg_view_window_new (msg, modest_account_name, msg_uid));
g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window), NULL);
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
ModestWindow *
modest_msg_view_window_new (TnyMsg *msg,
- const gchar *account_name,
+ const gchar *modest_account_name,
const gchar *msg_uid)
{
ModestMsgViewWindow *self = NULL;
G_CALLBACK (on_queue_changed),
obj);
- modest_window_set_active_account (MODEST_WINDOW(obj), account_name);
+ /* Account manager */
+ priv->account_removed_handler = g_signal_connect (G_OBJECT(modest_runtime_get_account_mgr()),
+ "account-removed",
+ G_CALLBACK(on_account_removed),
+ obj);
+
+ modest_window_set_active_account (MODEST_WINDOW(obj), modest_account_name);
priv->last_search = NULL;
return (const gchar*) priv->msg_uid;
}
-static void
-toggle_action_set_active_block_notify (GtkToggleAction *action,
- gboolean value)
-{
- GSList *proxies = NULL;
-
- for (proxies = gtk_action_get_proxies (GTK_ACTION (action));
- proxies != NULL; proxies = g_slist_next (proxies)) {
- GtkWidget *widget = (GtkWidget *) proxies->data;
- gtk_action_block_activate_from (GTK_ACTION (action), widget);
- }
-
- gtk_toggle_action_set_active (action, value);
-
- for (proxies = gtk_action_get_proxies (GTK_ACTION (action));
- proxies != NULL; proxies = g_slist_next (proxies)) {
- GtkWidget *widget = (GtkWidget *) proxies->data;
- gtk_action_unblock_activate_from (GTK_ACTION (action), widget);
- }
-}
-
-
static void
modest_msg_view_window_toggle_find_toolbar (GtkToggleAction *toggle,
gpointer data)
/* update the toggle buttons status */
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/FindInMessage");
- toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), is_active);
+ modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), is_active);
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ToolsMenu/ToolsFindInMessageMenu");
- toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), is_active);
+ modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), is_active);
}
gchar *current_search;
ModestMsgViewWindowPrivate *priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (obj);
+ if (modest_msg_view_get_message_is_empty (MODEST_MSG_VIEW (priv->msg_view))) {
+ hildon_banner_show_information (NULL, NULL, _("mail_ib_nothing_to_find"));
+ return;
+ }
+
g_object_get (G_OBJECT (widget), "prefix", ¤t_search, NULL);
if ((current_search == NULL) || (strcmp (current_search, "") == 0)) {
message_reader (ModestMsgViewWindow *window,
ModestMsgViewWindowPrivate *priv,
TnyHeader *header,
- GtkTreeIter iter)
+ GtkTreePath *path)
{
ModestMailOperation *mail_op = NULL;
- GtkTreePath *path = NULL;
ModestMailOperationTypeOperation op_type;
+ g_return_val_if_fail (path != NULL, FALSE);
+
/* Msg download completed */
if (tny_header_get_flags (header) & TNY_HEADER_FLAG_CACHED) {
op_type = MODEST_MAIL_OPERATION_TYPE_OPEN;
}
}
- /* Get the path, will be freed by the callback */
- path = gtk_tree_model_get_path (priv->header_model, &iter);
-
/* New mail operation */
mail_op = modest_mail_operation_new_with_error_handling (op_type,
G_OBJECT(window),
&header, -1);
/* Read the message & show it */
- if (!message_reader (window, priv, header, tmp_iter))
+ if (!message_reader (window, priv, header, path)) {
retval = FALSE;
+ gtk_tree_path_free (path);
+ }
/* Free */
g_object_unref (header);
- gtk_tree_path_free (path);
return retval;
}
ModestMsgViewWindowPrivate *priv = NULL;
TnyHeader *header = NULL;
GtkTreeIter iter;
+ GtkTreePath *path;
g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (self), FALSE);
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self);
&iter,
TNY_GTK_HEADER_LIST_MODEL_INSTANCE_COLUMN,
&header, -1);
-
g_return_val_if_fail (TNY_IS_HEADER (header), FALSE);
if (tny_header_get_flags (header) & TNY_HEADER_FLAG_DELETED) {
g_object_unref (header);
return modest_msg_view_window_select_next_message (self);
}
+ path = gtk_tree_model_get_path (priv->header_model, &iter);
+
/* Read the message & show it */
- message_reader (self, priv, header, iter);
+ message_reader (self, priv, header, path);
/* Free */
g_object_unref (header);
}
/* Read the message & show it */
- if (!message_reader (window, priv, header, iter)) {
+ if (!message_reader (window, priv, header, path)) {
g_object_unref (header);
break;
}
return is_empty;
}
+static void
+on_account_removed (ModestAccountMgr *mgr,
+ const gchar *account,
+ gboolean server_account,
+ gpointer user_data)
+{
+ ModestTnyAccountStore *store = modest_runtime_get_account_store ();
+ const gchar *our_acc = modest_window_get_active_account (MODEST_WINDOW (user_data));
+
+ TnyAccount *tny_acc = modest_tny_account_store_get_tny_account_by (store, MODEST_TNY_ACCOUNT_STORE_QUERY_ID, account);
+ if(tny_acc != NULL)
+ {
+ const gchar* parent_acc = modest_tny_account_get_parent_modest_account_name_for_server_account (tny_acc);
+ if (strcmp (parent_acc, our_acc) == 0)
+ {
+ gtk_widget_destroy (GTK_WIDGET (user_data));
+ }
+ }
+}
static void
on_queue_changed (ModestMailOperationQueue *queue,