GdkEvent *event,
ModestMsgViewWindow *window);
-static void cancel_progressbar (GtkToolButton *toolbutton,
- ModestMsgViewWindow *self);
+static void cancel_progressbar (GtkToolButton *toolbutton,
+ ModestMsgViewWindow *self);
-static void on_queue_changed (ModestMailOperationQueue *queue,
- 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 on_queue_changed (ModestMailOperationQueue *queue,
+ ModestMailOperation *mail_op,
+ ModestMailOperationQueueNotification type,
+ ModestMsgViewWindow *self);
-static void view_msg_cb (ModestMailOperation *mail_op, TnyHeader *header, TnyMsg *msg, gpointer user_data);
+static void on_account_removed (TnyAccountStore *account_store,
+ TnyAccount *account,
+ gpointer user_data);
-static void set_toolbar_mode (ModestMsgViewWindow *self,
- ModestToolBarModes mode);
+static void view_msg_cb (ModestMailOperation *mail_op,
+ TnyHeader *header,
+ TnyMsg *msg,
+ gpointer user_data);
-static gboolean set_toolbar_transfer_mode (ModestMsgViewWindow *self);
+static void set_toolbar_mode (ModestMsgViewWindow *self,
+ ModestToolBarModes mode);
static void update_window_title (ModestMsgViewWindow *window);
+static gboolean set_toolbar_transfer_mode (ModestMsgViewWindow *self);
+
/* list my signals */
enum {
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (obj);
if (priv->clipboard_change_handler > 0) {
- g_signal_handler_disconnect (gtk_clipboard_get (GDK_SELECTION_PRIMARY), priv->clipboard_change_handler);
+ g_signal_handler_disconnect (gtk_clipboard_get (GDK_SELECTION_PRIMARY),
+ priv->clipboard_change_handler);
priv->clipboard_change_handler = 0;
}
if (priv->queue_change_handler > 0) {
- g_signal_handler_disconnect (G_OBJECT (modest_runtime_get_mail_operation_queue ()), priv->queue_change_handler);
+ 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);
+ g_signal_handler_disconnect (G_OBJECT (modest_runtime_get_account_store ()),
+ priv->account_removed_handler);
priv->account_removed_handler = 0;
}
if (priv->header_model != NULL) {
obj);
/* Account manager */
- priv->account_removed_handler = g_signal_connect (G_OBJECT(modest_runtime_get_account_mgr()),
- "account-removed",
+ priv->account_removed_handler = g_signal_connect (G_OBJECT (modest_runtime_get_account_store ()),
+ "account_removed",
G_CALLBACK(on_account_removed),
obj);
{
ModestMailOperation *mail_op = NULL;
ModestMailOperationTypeOperation op_type;
+ gboolean already_showing = FALSE;
+ ModestWindow *msg_window = NULL;
+ ModestWindowMgr *mgr;
g_return_val_if_fail (path != NULL, FALSE);
+ mgr = modest_runtime_get_window_mgr ();
+ already_showing = modest_window_mgr_find_registered_header (mgr, header, &msg_window);
+ if (already_showing && (msg_window != MODEST_WINDOW (window))) {
+ gboolean retval;
+ if (msg_window)
+ gtk_window_present (GTK_WINDOW (msg_window));
+ g_signal_emit_by_name (G_OBJECT (window), "delete-event", NULL, &retval);
+ return TRUE;
+ }
+
/* Msg download completed */
if (tny_header_get_flags (header) & TNY_HEADER_FLAG_CACHED) {
op_type = MODEST_MAIL_OPERATION_TYPE_OPEN;
g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window), FALSE);
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
- path = gtk_tree_row_reference_get_path (priv->next_row_reference);
- if (path == NULL)
+ /* Update the next row reference if it's not valid. This could
+ happen if for example the header which it was pointing to,
+ was deleted. The best place to do it is in the row-deleted
+ handler but the tinymail model do not work like the glib
+ tree models and reports the deletion when the row is still
+ there */
+ if (!gtk_tree_row_reference_valid (priv->next_row_reference)) {
+ if (gtk_tree_row_reference_valid (priv->row_reference)) {
+ priv->next_row_reference = gtk_tree_row_reference_copy (priv->row_reference);
+ select_next_valid_row (priv->header_model, &(priv->next_row_reference), FALSE);
+ }
+ }
+ if (priv->next_row_reference)
+ path = gtk_tree_row_reference_get_path (priv->next_row_reference);
+ if (path == NULL)
return FALSE;
gtk_tree_model_get_iter (priv->header_model,
}
static void
-on_account_removed (ModestAccountMgr *mgr,
- const gchar *account,
- gboolean server_account,
+on_account_removed (TnyAccountStore *account_store,
+ TnyAccount *account,
gpointer user_data)
{
- ModestTnyAccountStore *store = modest_runtime_get_account_store ();
- const gchar *our_acc = modest_window_get_active_account (MODEST_WINDOW (user_data));
+ /* Do nothing if it's a transport account, because we only
+ show the messages of a store account */
+ if (tny_account_get_account_type(account) == TNY_ACCOUNT_TYPE_STORE) {
+ const gchar *parent_acc = NULL;
+ const gchar *our_acc = NULL;
- 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);
+ our_acc = modest_window_get_active_account (MODEST_WINDOW (user_data));
+ parent_acc = modest_tny_account_get_parent_modest_account_name_for_server_account (account);
+
+ /* Close this window if I'm showing a message of the removed account */
if (strcmp (parent_acc, our_acc) == 0)
- {
- gtk_widget_destroy (GTK_WIDGET (user_data));
- }
+ modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (user_data));
}
}