From 0489db9d4ed582aecd48b26cdd71f3ade843a16d Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Wed, 28 Feb 2007 13:31:21 +0000 Subject: [PATCH] * Removed the modest send/receive custom icon * Removed the drag-data-delete handler of the header view * Added a folder observer for each refreshed folder * Fixed a memory issue pmo-trunk-r867 --- src/gtk/modest-icon-names.h | 2 +- src/gtk/modest-msg-view-window.c | 2 +- src/maemo/modest-main-window-ui.h | 2 +- src/modest-runtime.c | 4 +-- src/modest-tny-account-store.c | 2 +- src/modest-tny-account.c | 2 +- src/widgets/modest-folder-view.c | 11 +++--- src/widgets/modest-header-view.c | 69 ++++++++----------------------------- 8 files changed, 28 insertions(+), 66 deletions(-) diff --git a/src/gtk/modest-icon-names.h b/src/gtk/modest-icon-names.h index e9f7c53..6fddd7d 100644 --- a/src/gtk/modest-icon-names.h +++ b/src/gtk/modest-icon-names.h @@ -67,7 +67,7 @@ /* toolbar */ #define MODEST_TOOLBAR_ICON_MAIL_SEND PIXMAP_PREFIX "qgn_list_messagin_sent.png" #define MODEST_TOOLBAR_ICON_NEW_MAIL PIXMAP_PREFIX "mail-message-new.png" -#define MODEST_TOOLBAR_ICON_SEND_RECEIVE PIXMAP_PREFIX "gtk-refresh.png" +/* #define MODEST_TOOLBAR_ICON_SEND_RECEIVE PIXMAP_PREFIX "gtk-refresh.png" */ #define MODEST_TOOLBAR_ICON_REPLY PIXMAP_PREFIX "mail-reply-sender.png" #define MODEST_TOOLBAR_ICON_REPLY_ALL PIXMAP_PREFIX "mail-reply-all.png" #define MODEST_TOOLBAR_ICON_FORWARD PIXMAP_PREFIX "mail-forward.png" diff --git a/src/gtk/modest-msg-view-window.c b/src/gtk/modest-msg-view-window.c index e2c5989..32af224 100644 --- a/src/gtk/modest-msg-view-window.c +++ b/src/gtk/modest-msg-view-window.c @@ -88,7 +88,7 @@ static const GtkActionEntry modest_action_entries [] = { { "ActionsReplyAll", MODEST_STOCK_REPLY_ALL, N_("Reply to all"), NULL, N_("Reply to all"), G_CALLBACK (modest_ui_actions_on_reply_all) }, { "ActionsForward", MODEST_STOCK_FORWARD, N_("_Forward"), NULL, N_("Forward a message"), G_CALLBACK (modest_ui_actions_on_forward) }, { "ActionsBounce", NULL, N_("_Bounce"), NULL, N_("Bounce a message"), NULL }, - { "ActionsSendReceive", MODEST_STOCK_SEND_RECEIVE, N_("Send/Receive"), NULL, N_("Send and receive messages"), NULL }, + { "ActionsSendReceive", GTK_STOCK_REFRESH, N_("Send/Receive"), NULL, N_("Send and receive messages"), NULL }, { "ActionsDelete", MODEST_STOCK_DELETE, N_("Delete message"), NULL, N_("Delete messages"), G_CALLBACK (modest_ui_actions_on_delete) }, /* HELP */ diff --git a/src/maemo/modest-main-window-ui.h b/src/maemo/modest-main-window-ui.h index 8fd93cd..a0d7797 100644 --- a/src/maemo/modest-main-window-ui.h +++ b/src/maemo/modest-main-window-ui.h @@ -113,7 +113,7 @@ static const GtkActionEntry modest_action_entries [] = { { "ToolbarMessageReply", MODEST_STOCK_REPLY, N_("Reply a message"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_reply) }, { "ToolbarMessageReplyAll", MODEST_STOCK_REPLY_ALL, N_("Reply to all"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_reply_all) }, { "ToolbarMessageForward", MODEST_STOCK_FORWARD, N_("Forward a message"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_forward) }, - { "ToolbarSendReceive", MODEST_STOCK_SEND_RECEIVE, N_("Send & receive"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_send_receive) }, + { "ToolbarSendReceive", GTK_STOCK_REFRESH, N_("Send & receive"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_send_receive) }, { "ToolbarToggleView", GTK_STOCK_CDROM, N_("Toggle view"), "t", NULL, G_CALLBACK (modest_ui_actions_toggle_view) }, { "ToolbarDeleteMessage", GTK_STOCK_DELETE, N_("Delete message"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_delete) }, }; diff --git a/src/modest-runtime.c b/src/modest-runtime.c index 6badb49..f071ce9 100644 --- a/src/modest-runtime.c +++ b/src/modest-runtime.c @@ -566,7 +566,7 @@ init_stock_icons (void) static GtkStockItem items[] = { { MODEST_STOCK_MAIL_SEND, "send mail", 0, 0, NULL }, { MODEST_STOCK_NEW_MAIL, "new mail", 0, 0, NULL }, - { MODEST_STOCK_SEND_RECEIVE, "send receive", 0, 0, NULL }, +/* { MODEST_STOCK_SEND_RECEIVE, "send receive", 0, 0, NULL }, */ { MODEST_STOCK_REPLY, "reply", 0, 0, NULL }, { MODEST_STOCK_REPLY_ALL, "reply all", 0, 0, NULL }, { MODEST_STOCK_FORWARD, "forward", 0, 0, NULL }, @@ -579,7 +579,7 @@ init_stock_icons (void) static gchar *items_names [] = { MODEST_TOOLBAR_ICON_MAIL_SEND, MODEST_TOOLBAR_ICON_NEW_MAIL, - MODEST_TOOLBAR_ICON_SEND_RECEIVE, +/* MODEST_TOOLBAR_ICON_SEND_RECEIVE, */ MODEST_TOOLBAR_ICON_REPLY, MODEST_TOOLBAR_ICON_REPLY_ALL, MODEST_TOOLBAR_ICON_FORWARD, diff --git a/src/modest-tny-account-store.c b/src/modest-tny-account-store.c index 5d88be9..20e0680 100644 --- a/src/modest-tny-account-store.c +++ b/src/modest-tny-account-store.c @@ -406,7 +406,7 @@ modest_tny_account_store_new (ModestAccountMgr *account_mgr, TnyDevice *device) /* FIXME: unref this in the end? */ tny_session_camel_set_async_connecting (priv->session, TRUE); -/* /\* force a cache fill... ugly *\/ */ + /* force a cache fill... ugly */ list = TNY_LIST(tny_simple_list_new()); tny_account_store_get_accounts (TNY_ACCOUNT_STORE(obj), list, TNY_ACCOUNT_STORE_BOTH); diff --git a/src/modest-tny-account.c b/src/modest-tny-account.c index cd653c6..cd39a21 100644 --- a/src/modest-tny-account.c +++ b/src/modest-tny-account.c @@ -221,7 +221,7 @@ modest_tny_account_new_from_account (ModestAccountMgr *account_mgr, const gchar tny_account_set_name (tny_account, account_data->display_name); g_object_set_data_full (G_OBJECT(tny_account), "modest_account", - (gpointer*)account_name, g_free); + (gpointer*) g_strdup (account_name), g_free); modest_account_mgr_free_account_data (account_mgr, account_data); return tny_account; diff --git a/src/widgets/modest-folder-view.c b/src/widgets/modest-folder-view.c index d034076..74671b0 100644 --- a/src/widgets/modest-folder-view.c +++ b/src/widgets/modest-folder-view.c @@ -834,11 +834,14 @@ on_progress_changed (ModestMailOperation *mail_op, gpointer user_data) modest_mail_operation_queue_remove (queue, mail_op); g_object_unref (G_OBJECT (mail_op)); - /* Save and clean */ - save_and_clean (helper, success); + /* Save and clean. HACK: Force success to FALSE in order not + to save data in the source widget */ + gtk_tree_path_free (helper->source_row); + save_and_clean (helper, FALSE); - /* Notify the drag source */ - gtk_drag_finish (helper->context, success, (success && helper->delete_source), helper->time); + /* Notify the drag source. Never call delete, the monitor will + do the job if needed */ + gtk_drag_finish (helper->context, success, FALSE, helper->time); /* Free the helper */ g_slice_free (DndHelper, helper); diff --git a/src/widgets/modest-header-view.c b/src/widgets/modest-header-view.c index 08e0852..5d8a0ec 100644 --- a/src/widgets/modest-header-view.c +++ b/src/widgets/modest-header-view.c @@ -64,7 +64,6 @@ static void setup_drag_and_drop (GtkTreeView *self); typedef struct _ModestHeaderViewPrivate ModestHeaderViewPrivate; struct _ModestHeaderViewPrivate { TnyFolder *folder; - TnyList *headers; ModestHeaderViewStyle style; TnyFolderMonitor *monitor; @@ -358,7 +357,6 @@ modest_header_view_init (ModestHeaderView *obj) priv = MODEST_HEADER_VIEW_GET_PRIVATE(obj); priv->folder = NULL; - priv->headers = NULL; priv->monitor = NULL; priv->monitor_lock = g_mutex_new (); @@ -376,11 +374,6 @@ modest_header_view_finalize (GObject *obj) self = MODEST_HEADER_VIEW(obj); priv = MODEST_HEADER_VIEW_GET_PRIVATE(self); - if (priv->headers) { - g_object_unref (G_OBJECT(priv->headers)); - priv->headers = NULL; - } - g_mutex_lock (priv->monitor_lock); if (priv->monitor) { tny_folder_monitor_stop (priv->monitor); @@ -609,7 +602,6 @@ modest_header_view_get_style (ModestHeaderView *self) return MODEST_HEADER_VIEW_GET_PRIVATE(self)->style; } - static void on_refresh_folder (TnyFolder *folder, gboolean cancelled, @@ -620,11 +612,12 @@ on_refresh_folder (TnyFolder *folder, ModestHeaderView *self; ModestHeaderViewPrivate *priv; GList *cols, *cursor; + TnyList *headers; if (cancelled) { GtkTreeSelection *selection; - g_warning ("Operation_cancelled %s\n", (*error) ? (*error)->message : "unknown"); + g_warning ("Operation cancelled %s\n", (*error) ? (*error)->message : "unknown"); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (user_data)); gtk_tree_selection_unselect_all (selection); @@ -634,17 +627,12 @@ on_refresh_folder (TnyFolder *folder, self = MODEST_HEADER_VIEW(user_data); priv = MODEST_HEADER_VIEW_GET_PRIVATE(self); - if (priv->headers) { - g_object_unref (priv->headers); - modest_runtime_verify_object_death(priv->headers,""); - } + headers = TNY_LIST(tny_gtk_header_list_model_new ()); - priv->headers = TNY_LIST(tny_gtk_header_list_model_new ()); - - tny_gtk_header_list_model_set_folder (TNY_GTK_HEADER_LIST_MODEL(priv->headers), + tny_gtk_header_list_model_set_folder (TNY_GTK_HEADER_LIST_MODEL(headers), folder, TRUE); - sortable = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL(priv->headers)); + sortable = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL(headers)); /* install our special sorting functions */ cursor = cols = gtk_tree_view_get_columns (GTK_TREE_VIEW(self)); @@ -661,14 +649,14 @@ on_refresh_folder (TnyFolder *folder, /* Add a folder observer */ g_mutex_lock (priv->monitor_lock); - -/* if (priv->monitor) { */ -/* tny_folder_monitor_stop (priv->monitor); */ -/* g_object_unref (G_OBJECT (priv->monitor)); */ -/* } */ -/* priv->monitor = TNY_FOLDER_MONITOR (tny_folder_monitor_new (folder)); */ -/* tny_folder_monitor_add_list (priv->monitor, TNY_LIST (priv->headers)); */ -/* tny_folder_monitor_start (priv->monitor); */ + if (priv->monitor) { + tny_folder_monitor_stop (priv->monitor); + g_object_unref (G_OBJECT (priv->monitor)); + } + priv->monitor = TNY_FOLDER_MONITOR (tny_folder_monitor_new (folder)); + tny_folder_monitor_add_list (priv->monitor, TNY_LIST (headers)); + g_object_unref (G_OBJECT (headers)); + tny_folder_monitor_start (priv->monitor); g_mutex_unlock (priv->monitor_lock); @@ -948,6 +936,7 @@ cmp_rows (GtkTreeModel *tree_model, GtkTreeIter *iter1, GtkTreeIter *iter2, } } +/* Drag and drop stuff */ static void drag_data_get_cb (GtkWidget *widget, GdkDragContext *context, @@ -972,31 +961,6 @@ drag_data_get_cb (GtkWidget *widget, gtk_tree_path_free (source_row); } -static void -drag_data_delete_cb (GtkWidget *widget, - GdkDragContext *context, - gpointer user_data) -{ - GtkTreeIter iter; - GtkTreePath *source_row; - GtkTreeModel *model_sort, *model; - TnyHeader *header; - - model_sort = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (model_sort)); - source_row = g_object_steal_data (G_OBJECT (widget), ROW_REF_DATA_NAME); - - /* Delete the source row */ - gtk_tree_model_get_iter (model, &iter, source_row); - gtk_tree_model_get (model, &iter, - TNY_GTK_HEADER_LIST_MODEL_INSTANCE_COLUMN, &header, - -1); - tny_list_remove (TNY_LIST (model), G_OBJECT (header)); - g_object_unref (G_OBJECT (header)); - - gtk_tree_path_free (source_row); -} - /* Header view drag types */ const GtkTargetEntry header_view_drag_types[] = { @@ -1016,9 +980,4 @@ setup_drag_and_drop (GtkTreeView *self) "drag_data_get", GTK_SIGNAL_FUNC(drag_data_get_cb), NULL); - - gtk_signal_connect(GTK_OBJECT (self), - "drag_data_delete", - GTK_SIGNAL_FUNC(drag_data_delete_cb), - NULL); } -- 1.7.9.5