From 094f45e53a4c6f44daec128b31615e9f349a14dd Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Wed, 13 Jun 2007 13:19:19 +0000 Subject: [PATCH] * Moved back the contents style code to the UI actions pmo-trunk-r2205 --- src/maemo/modest-main-window.c | 4 +-- src/modest-mail-operation.c | 2 +- src/modest-main.c | 13 ++++++++++ src/modest-tny-account.c | 8 +++--- src/modest-ui-actions.c | 51 +++++++++++++++++++++++++++----------- src/widgets/modest-header-view.c | 40 ++++++++---------------------- src/widgets/modest-header-view.h | 14 ++++++++++- 7 files changed, 79 insertions(+), 53 deletions(-) diff --git a/src/maemo/modest-main-window.c b/src/maemo/modest-main-window.c index 5b875cc..8523cdf 100644 --- a/src/maemo/modest-main-window.c +++ b/src/maemo/modest-main-window.c @@ -393,8 +393,8 @@ save_state (ModestWindow *window) MODEST_CONF_MAIN_WINDOW_KEY); modest_widget_memory_save (conf, G_OBJECT(priv->main_paned), MODEST_CONF_MAIN_PANED_KEY); - modest_widget_memory_save (conf, G_OBJECT(priv->header_view), - MODEST_CONF_HEADER_VIEW_KEY); +/* modest_widget_memory_save (conf, G_OBJECT(priv->header_view), */ +/* MODEST_CONF_HEADER_VIEW_KEY); */ modest_widget_memory_save (conf, G_OBJECT(priv->folder_view), MODEST_CONF_FOLDER_VIEW_KEY); } diff --git a/src/modest-mail-operation.c b/src/modest-mail-operation.c index 2ff8baa..b0e77eb 100644 --- a/src/modest-mail-operation.c +++ b/src/modest-mail-operation.c @@ -2007,11 +2007,11 @@ on_refresh_folder (TnyFolder *folder, priv->status = MODEST_MAIL_OPERATION_STATUS_SUCCESS; + out: /* Call user defined callback, if it exists */ if (helper->user_callback) helper->user_callback (priv->source, folder, helper->user_data); - out: /* Free */ g_object_unref (helper->mail_op); g_slice_free (RefreshAsyncHelper, helper); diff --git a/src/modest-main.c b/src/modest-main.c index 44a3505..ba4242f 100644 --- a/src/modest-main.c +++ b/src/modest-main.c @@ -85,6 +85,17 @@ on_show (GtkWidget *widget, gpointer user_data) modest_platform_connect_and_wait(NULL); } +static void +log_default_handler (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer unused_data) +{ + if (log_level == G_LOG_LEVEL_ERROR || + log_level == G_LOG_LEVEL_CRITICAL) + g_print ("EEEEE ------ %s\n", message); +} + int main (int argc, char *argv[]) { @@ -128,6 +139,8 @@ main (int argc, char *argv[]) } g_option_context_free (context); + g_log_set_default_handler (log_default_handler, NULL); + if (!modest_init_init_core ()) { g_printerr ("modest: cannot init modest core\n"); return MODEST_ERR_INIT; diff --git a/src/modest-tny-account.c b/src/modest-tny-account.c index 834e9c2..70df25f 100644 --- a/src/modest-tny-account.c +++ b/src/modest-tny-account.c @@ -324,7 +324,7 @@ modest_tny_account_new_from_server_account (ModestAccountMgr *account_mgr, /* FIXME: for debugging. * Let's keep this because it is very useful for debugging. */ url = tny_account_get_url_string (TNY_ACCOUNT(tny_account)); - printf ("DEBUG %s:\n account-url: %s\n", __FUNCTION__, url); + /* printf ("DEBUG %s:\n account-url: %s\n", __FUNCTION__, url); */ g_free (url); /***********************/ @@ -431,7 +431,7 @@ on_modest_file_system_info(HildonFileSystemInfoHandle *handle, TnyAccount *account = TNY_ACCOUNT (data); if (error) { - printf (" DEBUG: %s: error=%s\n", __FUNCTION__, error->message); +/* printf (" DEBUG: %s: error=%s\n", __FUNCTION__, error->message); */ } const gchar *display_name = NULL; @@ -487,7 +487,7 @@ modest_tny_account_new_for_local_folders (ModestAccountMgr *account_mgr, TnySess url_string = camel_url_to_string (url, 0); tny_account_set_url_string (TNY_ACCOUNT(tny_account), url_string); - printf("DEBUG: %s:\n url=%s\n", __FUNCTION__, url_string); +/* printf("DEBUG: %s:\n url=%s\n", __FUNCTION__, url_string); */ /* TODO: Use a more generic way of identifying memory card paths, * and of marking accounts as memory card accounts, maybe @@ -582,7 +582,7 @@ modest_tny_account_new_for_per_account_local_outbox_folder (ModestAccountMgr *ac camel_url_free (url); tny_account_set_url_string (TNY_ACCOUNT(tny_account), url_string); - printf("DEBUG: %s:\n url=%s\n", __FUNCTION__, url_string); +/* printf("DEBUG: %s:\n url=%s\n", __FUNCTION__, url_string); */ g_free (url_string); /* This text should never been seen, diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 37ee649..2976f09 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -1228,6 +1228,36 @@ set_active_account_from_tny_account (TnyAccount *account, g_object_unref (modest_server_account); } + +static void +folder_refreshed_cb (const GObject *obj, + TnyFolder *folder, + gpointer user_data) +{ + ModestMainWindow *win = NULL; + GtkWidget *header_view; + + g_return_if_fail (TNY_IS_FOLDER (folder)); + + win = MODEST_MAIN_WINDOW (user_data); + header_view = + modest_main_window_get_child_widget(win, MODEST_WIDGET_TYPE_HEADER_VIEW); + + /* Check if folder is empty and set headers view contents style */ + if (tny_folder_get_all_count (folder) == 0) { + modest_main_window_set_contents_style (win, + MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY); + } else { + modest_main_window_set_contents_style (win, + MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS); + + /* Restore configuration */ + modest_widget_memory_restore (modest_runtime_get_conf (), + G_OBJECT(header_view), + MODEST_CONF_HEADER_VIEW_KEY); + } +} + void modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view, TnyFolderStore *folder_store, @@ -1263,24 +1293,15 @@ modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view, /* Set folder on header view */ modest_header_view_set_folder (MODEST_HEADER_VIEW(header_view), - TNY_FOLDER (folder_store)); - - /* Resore configuration */ - modest_widget_memory_restore (conf, G_OBJECT(header_view), - MODEST_CONF_HEADER_VIEW_KEY); - - /* Set main view style */ -/* modest_main_window_set_contents_style (main_window, */ -/* MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS); */ -/* modest_widget_memory_restore (conf, G_OBJECT(header_view), */ -/* MODEST_CONF_HEADER_VIEW_KEY); */ - + TNY_FOLDER (folder_store), + folder_refreshed_cb, + main_window); } else { /* Update the active account */ modest_window_set_active_account (MODEST_WINDOW (main_window), NULL); /* Do not show folder */ modest_widget_memory_save (conf, G_OBJECT (header_view), MODEST_CONF_HEADER_VIEW_KEY); - modest_header_view_set_folder (MODEST_HEADER_VIEW(header_view), NULL); + modest_header_view_clear (MODEST_HEADER_VIEW(header_view)); } } @@ -1814,7 +1835,7 @@ modest_ui_actions_on_rename_folder (GtkAction *action, modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); - modest_header_view_set_folder (MODEST_HEADER_VIEW (header_view), NULL); + modest_header_view_clear (MODEST_HEADER_VIEW (header_view)); modest_mail_operation_rename_folder (mail_op, TNY_FOLDER (folder), @@ -2689,7 +2710,7 @@ modest_ui_actions_on_main_window_move_to (GtkAction *action, src_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view)); /* Clean folder on header view before moving it */ - modest_header_view_set_folder (MODEST_HEADER_VIEW (header_view), NULL); + modest_header_view_clear (MODEST_HEADER_VIEW (header_view)); if (TNY_IS_FOLDER (src_folder)) { mail_op = diff --git a/src/widgets/modest-header-view.c b/src/widgets/modest-header-view.c index 4fc28a4..decad30 100644 --- a/src/widgets/modest-header-view.c +++ b/src/widgets/modest-header-view.c @@ -76,8 +76,6 @@ static void folder_monitor_update (TnyFolderObserver *self, static void tny_folder_observer_init (TnyFolderObserverIface *klass); -static void _on_new_folder_assigned (const GObject *obj, TnyFolder *folder, gpointer user_data); - typedef struct _ModestHeaderViewPrivate ModestHeaderViewPrivate; struct _ModestHeaderViewPrivate { @@ -520,7 +518,7 @@ modest_header_view_new (TnyFolder *folder, ModestHeaderViewStyle style) priv = MODEST_HEADER_VIEW_GET_PRIVATE(self); modest_header_view_set_style (self, style); - modest_header_view_set_folder (self, NULL); + modest_header_view_set_folder (self, NULL, NULL, NULL); gtk_tree_view_columns_autosize (GTK_TREE_VIEW(obj)); gtk_tree_view_set_fixed_height_mode (GTK_TREE_VIEW(obj),TRUE); @@ -895,7 +893,10 @@ modest_header_view_get_sort_type (ModestHeaderView *self, } void -modest_header_view_set_folder (ModestHeaderView *self, TnyFolder *folder) +modest_header_view_set_folder (ModestHeaderView *self, + TnyFolder *folder, + RefreshAsyncUserCallback callback, + gpointer user_data) { ModestHeaderViewPrivate *priv; ModestMailOperation *mail_op = NULL; @@ -934,8 +935,8 @@ modest_header_view_set_folder (ModestHeaderView *self, TnyFolder *folder) /* Refresh the folder asynchronously */ modest_mail_operation_refresh_folder (mail_op, folder, - _on_new_folder_assigned, - NULL); + callback, + user_data); /* Free */ g_object_unref (mail_op); @@ -1309,29 +1310,8 @@ folder_monitor_update (TnyFolderObserver *self, } } - -static void -_on_new_folder_assigned (const GObject *obj, TnyFolder *folder, gpointer user_data) +void +modest_header_view_clear (ModestHeaderView *self) { - ModestMainWindow *win = NULL; - gboolean folder_empty = FALSE; - - g_return_if_fail (TNY_IS_FOLDER (folder)); - - if (!MODEST_IS_MAIN_WINDOW (obj)) return; - win = MODEST_MAIN_WINDOW (obj); - - /* Check if folder is empty and set headers view contents style */ - folder_empty = tny_folder_get_all_count (folder) == 0; - if (folder_empty) { - modest_main_window_set_contents_style (win, - MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY); - } - else { - modest_main_window_set_contents_style (win, - MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS); -/* modest_widget_memory_restore (conf, G_OBJECT(header_view), */ -/* MODEST_CONF_HEADER_VIEW_KEY); */ - } - + modest_header_view_set_folder (self, NULL, NULL, NULL); } diff --git a/src/widgets/modest-header-view.h b/src/widgets/modest-header-view.h index 7ea0647..3859bb6 100644 --- a/src/widgets/modest-header-view.h +++ b/src/widgets/modest-header-view.h @@ -36,6 +36,7 @@ #include #include #include +#include "modest-mail-operation.h" G_BEGIN_DECLS @@ -153,7 +154,9 @@ GtkWidget* modest_header_view_new (TnyFolder *folder, * set the folder for this ModestHeaderView */ void modest_header_view_set_folder (ModestHeaderView *self, - TnyFolder *folder); + TnyFolder *folder, + RefreshAsyncUserCallback callback, + gpointer user_data); /** * modest_header_view_get_folder: @@ -315,6 +318,15 @@ modest_header_view_sort_by_column_id (ModestHeaderView *self, guint sort_colid, GtkSortType sort_type); +/** + * modest_header_view_clear: + * @self: a #ModestHeaderView + * + * Clear the contents of a header view. It internally calls the + * set_folder function with last three arguments as NULL + **/ +void +modest_header_view_clear (ModestHeaderView *self); G_END_DECLS -- 1.7.9.5