* The update_model function of the folder view is now public
* The main window now unregisters some signals that was causing a lot of problems
* The Move to dialog now shows contents even if the main window do not exists. Fixes NB#59468
pmo-trunk-r2169
} else {
ModestWindowMgr *mgr = modest_runtime_get_window_mgr ();
modest_window_mgr_register_window (mgr, win);
} else {
ModestWindowMgr *mgr = modest_runtime_get_window_mgr ();
modest_window_mgr_register_window (mgr, win);
}
gtk_widget_show_all (GTK_WIDGET (win));
}
gtk_widget_show_all (GTK_WIDGET (win));
#include <widgets/modest-account-view-window.h>
#include <widgets/modest-details-dialog.h>
#include <widgets/modest-attachments-view.h>
#include <widgets/modest-account-view-window.h>
#include <widgets/modest-details-dialog.h>
#include <widgets/modest-attachments-view.h>
+#include "widgets/modest-folder-view.h"
#include "widgets/modest-global-settings-dialog.h"
#include "modest-connection-specific-smtp-window.h"
#include "modest-account-mgr-helpers.h"
#include "widgets/modest-global-settings-dialog.h"
#include "modest-connection-specific-smtp-window.h"
#include "modest-account-mgr-helpers.h"
/* Create folder view */
*tree_view = modest_folder_view_new (NULL);
/* Create folder view */
*tree_view = modest_folder_view_new (NULL);
- gtk_tree_view_set_model (GTK_TREE_VIEW (*tree_view),
- gtk_tree_view_get_model (GTK_TREE_VIEW (folder_view)));
+
+ /* It could happen that we're trying to move a message from a
+ window (msg window for example) after the main window was
+ closed, so we can not just get the model of the folder
+ view */
+ if (MODEST_IS_FOLDER_VIEW (folder_view))
+ gtk_tree_view_set_model (GTK_TREE_VIEW (*tree_view),
+ gtk_tree_view_get_model (GTK_TREE_VIEW (folder_view)));
+ else
+ modest_folder_view_update_model (MODEST_FOLDER_VIEW (*tree_view),
+ TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
+
gtk_container_add (GTK_CONTAINER (scroll), *tree_view);
/* Add scroll to dialog */
gtk_container_add (GTK_CONTAINER (scroll), *tree_view);
/* Add scroll to dialog */
/* Get the folder view */
main_window = MODEST_MAIN_WINDOW (modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ()));
/* Get the folder view */
main_window = MODEST_MAIN_WINDOW (modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ()));
- folder_view = modest_main_window_get_child_widget (main_window,
- MODEST_WIDGET_TYPE_FOLDER_VIEW);
+ if (main_window)
+ folder_view = modest_main_window_get_child_widget (main_window,
+ MODEST_WIDGET_TYPE_FOLDER_VIEW);
+ else
+ folder_view = NULL;
/* Create and run the dialog */
dialog = create_move_to_dialog (MODEST_WINDOW (win), folder_view, &tree_view);
/* Create and run the dialog */
dialog = create_move_to_dialog (MODEST_WINDOW (win), folder_view, &tree_view);
tranasfer_msgs_from_viewer_cb,
NULL);
g_object_unref (G_OBJECT (mail_op));
tranasfer_msgs_from_viewer_cb,
NULL);
g_object_unref (G_OBJECT (mail_op));
g_object_unref (headers);
g_object_unref (folder_store);
}
g_object_unref (headers);
g_object_unref (folder_store);
}
static void modest_folder_view_set_account_store (TnyAccountStoreView *self,
TnyAccountStore *account_store);
static void modest_folder_view_set_account_store (TnyAccountStoreView *self,
TnyAccountStore *account_store);
-static gboolean update_model (ModestFolderView *self,
- ModestTnyAccountStore *account_store);
-
static void on_selection_changed (GtkTreeSelection *sel, gpointer data);
static void on_account_update (TnyAccountStore *account_store,
static void on_selection_changed (GtkTreeSelection *sel, gpointer data);
static void on_account_update (TnyAccountStore *account_store,
on_account_update (TnyAccountStore *account_store, const gchar *account,
gpointer user_data)
{
on_account_update (TnyAccountStore *account_store, const gchar *account,
gpointer user_data)
{
- if (!update_model (MODEST_FOLDER_VIEW(user_data),
- MODEST_TNY_ACCOUNT_STORE(account_store)))
+ if (!modest_folder_view_update_model (MODEST_FOLDER_VIEW(user_data),
+ account_store))
g_printerr ("modest: failed to update model for changes in '%s'",
account);
}
g_printerr ("modest: failed to update model for changes in '%s'",
account);
}
ModestConf *conf = modest_runtime_get_conf ();
modest_widget_memory_save (conf, G_OBJECT (user_data), MODEST_CONF_FOLDER_VIEW_KEY);
ModestConf *conf = modest_runtime_get_conf ();
modest_widget_memory_save (conf, G_OBJECT (user_data), MODEST_CONF_FOLDER_VIEW_KEY);
- update_model (MODEST_FOLDER_VIEW (user_data),
- MODEST_TNY_ACCOUNT_STORE(account_store));
+ modest_folder_view_update_model (MODEST_FOLDER_VIEW (user_data), account_store);
modest_widget_memory_restore (conf, G_OBJECT (user_data), MODEST_CONF_FOLDER_VIEW_KEY);
}
modest_widget_memory_restore (conf, G_OBJECT (user_data), MODEST_CONF_FOLDER_VIEW_KEY);
}
-/*
-static void on_tnylist_accounts_debug_print(gpointer data, gpointer user_data)
-{
- TnyAccount* account = TNY_ACCOUNT(data);
- const gchar *prefix = (const gchar*)(user_data);
-
- printf("%s account id=%s\n", prefix, tny_account_get_id (account));
-}
-*/
-
-static gboolean
-update_model (ModestFolderView *self, ModestTnyAccountStore *account_store)
+gboolean
+modest_folder_view_update_model (ModestFolderView *self,
+ TnyAccountStore *account_store)
{
ModestFolderViewPrivate *priv;
GtkTreeModel *model /* , *old_model */;
{
ModestFolderViewPrivate *priv;
GtkTreeModel *model /* , *old_model */;
+ /* If it's the main window unset it */
+ if (priv->main_window == window)
+ priv->main_window = NULL;
+
/* Remove from list. Remove the reference to the window */
g_object_unref (win->data);
priv->window_list = g_list_remove_link (priv->window_list, win);
/* Remove from list. Remove the reference to the window */
g_object_unref (win->data);
priv->window_list = g_list_remove_link (priv->window_list, win);