diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-11-17 00:18:55 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-11-17 08:24:02 +0800 |
commit | a3c859d68a0e3b7aa2d4b59652fa63dc6e190ef9 (patch) | |
tree | 2373d8aeb3cdc6883cecd8bd2867e3c29c5dccdc /modules | |
parent | 0890977f437fe163279ec08b1faeb3eb388d758c (diff) | |
download | gsoc2013-evolution-a3c859d68a0e3b7aa2d4b59652fa63dc6e190ef9.tar gsoc2013-evolution-a3c859d68a0e3b7aa2d4b59652fa63dc6e190ef9.tar.gz gsoc2013-evolution-a3c859d68a0e3b7aa2d4b59652fa63dc6e190ef9.tar.bz2 gsoc2013-evolution-a3c859d68a0e3b7aa2d4b59652fa63dc6e190ef9.tar.lz gsoc2013-evolution-a3c859d68a0e3b7aa2d4b59652fa63dc6e190ef9.tar.xz gsoc2013-evolution-a3c859d68a0e3b7aa2d4b59652fa63dc6e190ef9.tar.zst gsoc2013-evolution-a3c859d68a0e3b7aa2d4b59652fa63dc6e190ef9.zip |
EMailShellView cleanups.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/mail/e-mail-shell-view-actions.c | 54 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view.c | 47 |
2 files changed, 57 insertions, 44 deletions
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index ef69f05a1c..b7dc6c78ca 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -47,7 +47,8 @@ action_mail_account_disable_cb (GtkAction *action, backend = E_MAIL_BACKEND (shell_backend); session = e_mail_backend_get_session (backend); - account_store = e_mail_ui_session_get_account_store (E_MAIL_UI_SESSION (session)); + account_store = e_mail_ui_session_get_account_store ( + E_MAIL_UI_SESSION (session)); folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); store = em_folder_tree_get_selected_store (folder_tree); @@ -135,25 +136,30 @@ static void action_mail_account_refresh_cb (GtkAction *action, EMailShellView *mail_shell_view) { + EMailShellContent *mail_shell_content; EMailShellSidebar *mail_shell_sidebar; EMFolderTree *folder_tree; - EMailReader *reader; + EMailView *mail_view; EActivity *activity; CamelStore *store; GCancellable *cancellable; + mail_shell_content = mail_shell_view->priv->mail_shell_content; mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; + folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); store = em_folder_tree_get_selected_store (folder_tree); g_return_if_fail (store != NULL); - reader = E_MAIL_READER (e_mail_shell_content_get_mail_view (mail_shell_view->priv->mail_shell_content)); - activity = e_mail_reader_new_activity (reader); + mail_view = e_mail_shell_content_get_mail_view (mail_shell_content); + activity = e_mail_reader_new_activity (E_MAIL_READER (mail_view)); cancellable = e_activity_get_cancellable (activity); camel_store_get_folder_info ( - store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE, - G_PRIORITY_DEFAULT, cancellable, account_refresh_folder_info_received_cb, activity); + store, NULL, + CAMEL_STORE_FOLDER_INFO_RECURSIVE, + G_PRIORITY_DEFAULT, cancellable, + account_refresh_folder_info_received_cb, activity); } static void @@ -435,13 +441,14 @@ mark_all_read_thread (GSimpleAsyncResult *simple, store = CAMEL_STORE (object); while (!g_queue_is_empty (&context->folder_names) && !error) { - gchar *folder_name = g_queue_pop_head (&context->folder_names); - - folder = camel_store_get_folder_sync (store, folder_name, 0, cancellable, &error); + gchar *folder_name; + folder_name = g_queue_pop_head (&context->folder_names); + folder = camel_store_get_folder_sync ( + store, folder_name, 0, cancellable, &error); g_free (folder_name); - if (!folder) + if (folder == NULL) break; camel_folder_freeze (folder); @@ -655,7 +662,8 @@ e_mail_shell_view_actions_mark_all_read (EMailShellView *mail_shell_view, cancellable = camel_operation_new (); e_activity_set_cancellable (context->activity, cancellable); - camel_operation_push_message (cancellable, _("Marking messages as read...")); + camel_operation_push_message ( + cancellable, _("Marking messages as read...")); e_shell_backend_add_activity (shell_backend, context->activity); @@ -704,28 +712,20 @@ static void action_mail_popup_folder_mark_all_as_read_cb (GtkAction *action, EMailShellView *mail_shell_view) { - EShellSidebar *shell_sidebar; + EMailShellSidebar *mail_shell_sidebar; EMFolderTree *folder_tree; - CamelStore *store; - gchar *folder_name; - - shell_sidebar = e_shell_view_get_shell_sidebar (E_SHELL_VIEW (mail_shell_view)); + CamelStore *store = NULL; + gchar *folder_name = NULL; - g_object_get (shell_sidebar, "folder-tree", &folder_tree, NULL); + mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; + folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); + em_folder_tree_get_selected (folder_tree, &store, &folder_name); /* This action should only be activatable if a folder is selected. */ - if (!em_folder_tree_get_selected (folder_tree, &store, &folder_name)) { - g_object_unref (folder_tree); - g_return_if_reached (); - } - - g_object_unref (folder_tree); + g_return_if_fail (store != NULL && folder_name != NULL); e_mail_shell_view_actions_mark_all_read ( - mail_shell_view, - store, - folder_name, - TRUE); + mail_shell_view, store, folder_name, TRUE); g_object_unref (store); g_free (folder_name); diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c index ed6f685164..1442ba78f0 100644 --- a/modules/mail/e-mail-shell-view.c +++ b/modules/mail/e-mail-shell-view.c @@ -121,10 +121,13 @@ search_results_exec (SearchResultsMsg *msg, GCancellable *cancellable, GError **error) { - GList *folders = NULL, *iter; + GList *folders = NULL, *link; - for (iter = msg->stores_list; iter && !g_cancellable_is_cancelled (cancellable); iter = iter->next) { - CamelStore *store = iter->data; + for (link = msg->stores_list; link != NULL; link = link->next) { + CamelStore *store = CAMEL_STORE (link->data); + + if (g_cancellable_is_cancelled (cancellable)) + break; add_folders_from_store (&folders, store, cancellable, error); } @@ -343,7 +346,8 @@ mail_shell_view_execute_search (EShellView *shell_view) message_list = e_mail_reader_get_message_list (reader); registry = e_mail_session_get_registry (session); - label_store = e_mail_ui_session_get_label_store (E_MAIL_UI_SESSION (session)); + label_store = e_mail_ui_session_get_label_store ( + E_MAIL_UI_SESSION (session)); action = ACTION (MAIL_SEARCH_SUBJECT_OR_ADDRESSES_CONTAIN); value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action)); @@ -576,8 +580,9 @@ all_accounts: * avoid search conflicts, so we can't just grab the * folder URI and let the asynchronous callbacks run * after we've already kicked off the search. */ - if (em_folder_tree_get_selected (folder_tree, &selected_store, &selected_folder_name) && - selected_store && selected_folder_name) { + em_folder_tree_get_selected ( + folder_tree, &selected_store, &selected_folder_name); + if (selected_store != NULL && selected_folder_name != NULL) { folder = camel_store_get_folder_sync ( selected_store, selected_folder_name, CAMEL_STORE_FOLDER_INFO_FAST, NULL, NULL); @@ -585,8 +590,7 @@ all_accounts: g_object_unref (folder); } - if (selected_store) - g_object_unref (selected_store); + g_clear_object (&selected_store); g_free (selected_folder_name); gtk_widget_set_sensitive (GTK_WIDGET (combo_box), TRUE); @@ -597,9 +601,13 @@ all_accounts: search_folder = priv->search_account_all; /* Skip the search if we already have the results. */ - if (search_folder != NULL) - if (g_strcmp0 (query, camel_vee_folder_get_expression (search_folder)) == 0) + if (search_folder != NULL) { + const gchar *vf_query; + + vf_query = camel_vee_folder_get_expression (search_folder); + if (g_strcmp0 (query, vf_query) == 0) goto all_accounts_setup; + } /* Disable the scope combo while search is in progress. */ gtk_widget_set_sensitive (GTK_WIDGET (combo_box), FALSE); @@ -680,8 +688,9 @@ current_account: * avoid search conflicts, so we can't just grab the * folder URI and let the asynchronous callbacks run * after we've already kicked off the search. */ - if (em_folder_tree_get_selected (folder_tree, &selected_store, &selected_folder_name) && - selected_store && selected_folder_name) { + em_folder_tree_get_selected ( + folder_tree, &selected_store, &selected_folder_name); + if (selected_store != NULL && selected_folder_name != NULL) { folder = camel_store_get_folder_sync ( selected_store, selected_folder_name, CAMEL_STORE_FOLDER_INFO_FAST, NULL, NULL); @@ -689,8 +698,7 @@ current_account: g_object_unref (folder); } - if (selected_store) - g_object_unref (selected_store); + g_clear_object (&selected_store); g_free (selected_folder_name); gtk_widget_set_sensitive (GTK_WIDGET (combo_box), TRUE); @@ -701,9 +709,13 @@ current_account: search_folder = priv->search_account_current; /* Skip the search if we already have the results. */ - if (search_folder != NULL) - if (g_strcmp0 (query, camel_vee_folder_get_expression (search_folder)) == 0) + if (search_folder != NULL) { + const gchar *vf_query; + + vf_query = camel_vee_folder_get_expression (search_folder); + if (g_strcmp0 (query, vf_query) == 0) goto current_accout_setup; + } /* Disable the scope combo while search is in progress. */ gtk_widget_set_sensitive (GTK_WIDGET (combo_box), FALSE); @@ -947,7 +959,8 @@ mail_shell_view_update_actions (EShellView *shell_view) GTK_TREE_MODEL (model), &iter, path); has_unread_mail ( GTK_TREE_MODEL (model), &iter, - TRUE, &folder_has_unread, &folder_has_unread_rec); + TRUE, &folder_has_unread, + &folder_has_unread_rec); gtk_tree_path_free (path); } |