X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-ui-actions.c;h=bfbe71f86cb102159bbee4d5b49a33ac8fae3b3d;hp=6c1b443a931f84e67ed1980dc61a37ea8d1e3ffa;hb=e70b51e165105320dc0131e239d195f1434367e4;hpb=eb5a63f4cdac2b517105e145d0e5ba6b5e0767a2 diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 6c1b443..bfbe71f 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -177,10 +177,12 @@ static void modest_ui_actions_on_main_window_move_to (GtkAction *action, GtkWidget *folder_view, TnyFolderStore *dst_folder, ModestMainWindow *win); +#ifdef MODEST_TOOLKIT_HILDON2 static void modest_ui_actions_on_folder_window_move_to (GtkWidget *folder_view, TnyFolderStore *dst_folder, TnyList *selection, GtkWindow *win); +#endif static void modest_ui_actions_on_window_move_to (GtkAction *action, TnyList *list_to_move, @@ -3124,11 +3126,10 @@ modest_ui_actions_on_select_editor_background_color (GtkAction *action, } void -modest_ui_actions_on_insert_image (GtkAction *action, +modest_ui_actions_on_insert_image (GObject *object, ModestMsgEditWindow *window) { g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window)); - g_return_if_fail (GTK_IS_ACTION (action)); if (modest_platform_check_memory_low (MODEST_WINDOW(window), TRUE)) @@ -3266,17 +3267,17 @@ do_create_folder (GtkWindow *parent_window, { gint result; gchar *folder_name = NULL; - TnyFolderStore *parent_folder; + TnyFolderStore *parent_folder = NULL; result = modest_platform_run_new_folder_dialog (GTK_WINDOW (parent_window), suggested_parent, (gchar *) suggested_name, &folder_name, &parent_folder); - + if (result == GTK_RESPONSE_ACCEPT && parent_folder) { ModestMailOperation *mail_op; - + mail_op = modest_mail_operation_new ((GObject *) parent_window); modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); @@ -3287,7 +3288,9 @@ do_create_folder (GtkWindow *parent_window, folder_name); g_object_unref (mail_op); } - g_object_unref (parent_folder); + + if (parent_folder) + g_object_unref (parent_folder); } static void @@ -3321,34 +3324,38 @@ modest_ui_actions_create_folder(GtkWidget *parent_window, #ifdef MODEST_TOOLKIT_HILDON2 const gchar *active_account; TnyAccount *account; + ModestTnyAccountStore *acc_store; /* In hildon 2.2 we use the current account as default parent */ + acc_store = modest_runtime_get_account_store (); active_account = modest_window_get_active_account (MODEST_WINDOW (parent_window)); - account = modest_tny_account_store_get_server_account (modest_runtime_get_account_store (), - active_account, - TNY_ACCOUNT_TYPE_STORE); - parent_folder = TNY_FOLDER_STORE (account); + if (active_account) { + account = modest_tny_account_store_get_server_account (acc_store, + active_account, + TNY_ACCOUNT_TYPE_STORE); + parent_folder = TNY_FOLDER_STORE (account); + } else { + parent_folder = (TnyFolderStore *) + modest_tny_account_store_get_local_folders_account (acc_store); + } #else parent_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view)); #endif - + if (parent_folder) { /* The parent folder will be freed in the callback */ - modest_platform_connect_if_remote_and_perform (GTK_WINDOW (parent_window), + modest_platform_connect_if_remote_and_perform (GTK_WINDOW (parent_window), TRUE, parent_folder, - create_folder_performer, + create_folder_performer, parent_folder); } -#ifdef MODEST_TOOLKIT_HILDON2 - g_object_unref (parent_folder); -#endif } -void +void modest_ui_actions_on_new_folder (GtkAction *action, ModestWindow *window) { - + g_return_if_fail (MODEST_IS_WINDOW(window)); if (MODEST_IS_MAIN_WINDOW (window)) { @@ -3506,6 +3513,8 @@ modest_ui_actions_on_edit_mode_rename_folder (ModestWindow *window) } else if (MODEST_IS_FOLDER_WINDOW (window)) { folder_view = GTK_WIDGET (modest_folder_window_get_folder_view (MODEST_FOLDER_WINDOW (window))); #endif + } else { + return FALSE; } folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view)); @@ -3583,6 +3592,10 @@ on_delete_folder_cb (gboolean canceled, } else if (MODEST_IS_FOLDER_WINDOW (parent_window)) { folder_view = GTK_WIDGET (modest_folder_window_get_folder_view (MODEST_FOLDER_WINDOW (parent_window))); #endif + } else { + g_object_unref (G_OBJECT (info->folder)); + g_free (info); + return; } /* Unselect the folder before deleting it to free the headers */ @@ -3624,6 +3637,8 @@ delete_folder (ModestWindow *window, gboolean move_to_trash) } else if (MODEST_IS_FOLDER_WINDOW (window)) { folder_view = GTK_WIDGET (modest_folder_window_get_folder_view (MODEST_FOLDER_WINDOW (window))); #endif + } else { + return FALSE; } if (!folder_view) return FALSE; @@ -4793,7 +4808,7 @@ on_move_to_dialog_response (GtkDialog *dialog, TnyFolderStore *dst_folder; case MODEST_GTK_RESPONSE_NEW_FOLDER: - modest_ui_actions_create_folder (GTK_WIDGET (dialog), folder_view); + modest_ui_actions_create_folder (GTK_WIDGET (parent_win), folder_view); return; case GTK_RESPONSE_NONE: case GTK_RESPONSE_CANCEL: @@ -4830,7 +4845,8 @@ on_move_to_dialog_response (GtkDialog *dialog, } /* Free the helper and exit */ - g_object_unref (helper->list); + if (helper->list) + g_object_unref (helper->list); g_slice_free (MoveToInfo, helper); gtk_widget_destroy (GTK_WIDGET (dialog)); } @@ -4998,40 +5014,42 @@ move_to_cb (ModestMailOperation *mail_op, gpointer user_data) { MoveToHelper *helper = (MoveToHelper *) user_data; + GObject *object = modest_mail_operation_get_source (mail_op); /* Note that the operation could have failed, in that case do nothing */ - if (modest_mail_operation_get_status (mail_op) == - MODEST_MAIL_OPERATION_STATUS_SUCCESS) { - - GObject *object = modest_mail_operation_get_source (mail_op); - if (MODEST_IS_MSG_VIEW_WINDOW (object)) { - ModestMsgViewWindow *self = MODEST_MSG_VIEW_WINDOW (object); + if (modest_mail_operation_get_status (mail_op) != + MODEST_MAIL_OPERATION_STATUS_SUCCESS) + goto frees; - if (!modest_msg_view_window_select_next_message (self) && - !modest_msg_view_window_select_previous_message (self)) { - /* No more messages to view, so close this window */ - modest_ui_actions_on_close_window (NULL, MODEST_WINDOW(self)); - } - } else if (MODEST_IS_MAIN_WINDOW (object) && - gtk_tree_row_reference_valid (helper->reference)) { - GtkWidget *header_view; - GtkTreePath *path; - GtkTreeSelection *sel; + if (MODEST_IS_MSG_VIEW_WINDOW (object)) { + ModestMsgViewWindow *self = MODEST_MSG_VIEW_WINDOW (object); - header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(object), - MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW); - sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (header_view)); - path = gtk_tree_row_reference_get_path (helper->reference); - /* We need to unselect the previous one - because we could be copying instead of - moving */ - gtk_tree_selection_unselect_all (sel); - gtk_tree_selection_select_path (sel, path); - gtk_tree_path_free (path); + if (!modest_msg_view_window_select_next_message (self) && + !modest_msg_view_window_select_previous_message (self)) { + /* No more messages to view, so close this window */ + modest_ui_actions_on_close_window (NULL, MODEST_WINDOW(self)); } - g_object_unref (object); - } + } else if (MODEST_IS_MAIN_WINDOW (object) && + gtk_tree_row_reference_valid (helper->reference)) { + GtkWidget *header_view; + GtkTreePath *path; + GtkTreeSelection *sel; + + header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(object), + MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW); + sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (header_view)); + path = gtk_tree_row_reference_get_path (helper->reference); + /* We need to unselect the previous one + because we could be copying instead of + moving */ + gtk_tree_selection_unselect_all (sel); + gtk_tree_selection_select_path (sel, path); + gtk_tree_path_free (path); + } + g_object_unref (object); + + frees: /* Destroy the helper */ move_to_helper_destroyer (helper); } @@ -5324,20 +5342,12 @@ static void xfer_messages_error_handler (ModestMailOperation *mail_op, gpointer user_data) { - ModestWindow *main_window = NULL; - - /* Disable next automatic folder selection */ - main_window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (), - FALSE); /* don't create */ - if (main_window) { - GObject *win = modest_mail_operation_get_source (mail_op); - modest_platform_run_information_dialog ((GtkWindow *) win, - _("mail_in_ui_folder_move_target_error"), - FALSE); - if (win) - g_object_unref (win); - } - move_to_helper_destroyer (user_data); + GObject *win = modest_mail_operation_get_source (mail_op); + modest_platform_run_information_dialog ((GtkWindow *) win, + _("mail_in_ui_folder_move_target_error"), + FALSE); + if (win) + g_object_unref (win); } typedef struct { @@ -5391,12 +5401,15 @@ xfer_messages_performer (gboolean canceled, } movehelper = g_new0 (MoveToHelper, 1); + +#ifndef MODEST_TOOLKIT_HILDON2 movehelper->banner = modest_platform_animation_banner (GTK_WIDGET (win), NULL, _CS("ckct_nw_pasting")); if (movehelper->banner != NULL) { g_object_ref (movehelper->banner); gtk_widget_show (GTK_WIDGET (movehelper->banner)); } +#endif if (MODEST_IS_MAIN_WINDOW (win)) { GtkWidget *header_view = @@ -6135,12 +6148,19 @@ modest_ui_actions_on_open_addressbook (GtkAction *action, ModestWindow *win) void -modest_ui_actions_on_toggle_find_in_page (GtkToggleAction *action, +modest_ui_actions_on_toggle_find_in_page (GtkAction *action, ModestWindow *window) { + gboolean active; g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window)); - modest_msg_edit_window_toggle_find_toolbar (MODEST_MSG_EDIT_WINDOW (window), gtk_toggle_action_get_active (action)); + if (GTK_IS_TOGGLE_ACTION (action)) + active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); + else + active = TRUE; + + modest_msg_edit_window_toggle_find_toolbar (MODEST_MSG_EDIT_WINDOW (window), + active); } static void