X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-ui-actions.c;h=432e45b27b1c6397635cde14b9183b7c1a3ea89e;hp=ad8f48d4f3d736bc2da225b010cbfb1a0e2f55a7;hb=a3966167004d901791014719da71326403dbdf3e;hpb=ccbc39e676aa41b58eb946660118d01465161ed4 diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index ad8f48d..432e45b 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -789,11 +789,6 @@ modest_ui_actions_compose_msg(ModestWindow *win, attachments = g_slist_next(attachments); } modest_window_mgr_register_window (modest_runtime_get_window_mgr(), msg_win); - - if (win) { - gtk_window_set_transient_for (GTK_WINDOW (msg_win), - GTK_WINDOW (win)); - } gtk_widget_show_all (GTK_WIDGET (msg_win)); cleanup: @@ -818,6 +813,26 @@ modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win) modest_ui_actions_compose_msg(win, NULL, NULL, NULL, NULL, NULL, NULL); } +void +modest_ui_actions_on_new_msg_or_folder (GtkAction *action, ModestWindow *win) +{ + g_return_if_fail (MODEST_IS_WINDOW (win)); + + /* Check first if the header view has the focus */ + if (MODEST_IS_MAIN_WINDOW (win)) { + GtkWidget *w; + w = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win), + MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW); + if (gtk_widget_is_focus (w)) { + modest_ui_actions_on_new_folder (action, MODEST_MAIN_WINDOW(win)); + return; + } + } + + modest_ui_actions_on_new_msg (action, win); +} + + gboolean modest_ui_actions_msg_retrieval_check (ModestMailOperation *mail_op, TnyHeader *header, @@ -1225,7 +1240,7 @@ open_msgs_from_headers (TnyList *headers, ModestWindow *win) /* Connect to the account and perform */ if (uncached_msgs > 0) { - modest_platform_connect_and_perform ((GtkWindow *) win, g_object_ref (account), + modest_platform_connect_and_perform ((GtkWindow *) win, TRUE, g_object_ref (account), open_msgs_performer, g_object_ref (not_opened_headers)); } else { /* Call directly the performer, do not need to connect */ @@ -1774,7 +1789,8 @@ modest_ui_actions_do_send_receive (const gchar *account_name, TNY_ACCOUNT_TYPE_STORE); /* Invoke the connect and perform */ - modest_platform_connect_and_perform ((win) ? GTK_WINDOW (win) : NULL, info->account, + modest_platform_connect_and_perform ((win) ? GTK_WINDOW (win) : NULL, + (win) ? TRUE : FALSE, info->account, do_send_receive_performer, info); } @@ -2040,8 +2056,6 @@ folder_refreshed_cb (ModestMailOperation *mail_op, { ModestMainWindow *win = NULL; GtkWidget *header_view; - gboolean folder_empty = FALSE; - gboolean all_marked_as_deleted = FALSE; g_return_if_fail (TNY_IS_FOLDER (folder)); @@ -2056,14 +2070,12 @@ folder_refreshed_cb (ModestMailOperation *mail_op, if (current_folder != NULL && folder != current_folder) { g_object_unref (current_folder); return; - } - g_object_unref (current_folder); + } else if (current_folder) + g_object_unref (current_folder); } /* Check if folder is empty and set headers view contents style */ - folder_empty = (tny_folder_get_all_count (folder) == 0); - all_marked_as_deleted = modest_header_view_is_empty (MODEST_HEADER_VIEW(header_view)); - if (folder_empty || all_marked_as_deleted) + if (tny_folder_get_all_count (folder) == 0) modest_main_window_set_contents_style (win, MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY); } @@ -2304,7 +2316,7 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi from = modest_account_mgr_get_from_string (account_mgr, account_name); /* Create the mail operation */ - mail_operation = modest_mail_operation_new (G_OBJECT(edit_window)); + mail_operation = modest_mail_operation_new (NULL); modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation); modest_mail_operation_save_to_drafts (mail_operation, @@ -2392,7 +2404,7 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) ModestAccountMgr *account_mgr = modest_runtime_get_account_mgr(); gchar *account_name = g_strdup (data->account_name); if (!account_name) - g_strdup(modest_window_get_active_account (MODEST_WINDOW(edit_window))); + account_name = g_strdup(modest_window_get_active_account (MODEST_WINDOW(edit_window))); if (!account_name) account_name = modest_account_mgr_get_default_account (account_mgr); @@ -2400,8 +2412,9 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) if (!account_name) { modest_msg_edit_window_free_msg_data (edit_window, data); /* Run account setup wizard */ - if (!modest_ui_actions_run_account_setup_wizard (MODEST_WINDOW(edit_window))) + if (!modest_ui_actions_run_account_setup_wizard (MODEST_WINDOW(edit_window))) { return; + } } /* Get the currently-active transport account for this modest account: */ @@ -2412,6 +2425,7 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) } if (!transport_account) { + modest_msg_edit_window_free_msg_data (edit_window, data); /* Run account setup wizard */ if (!modest_ui_actions_run_account_setup_wizard(MODEST_WINDOW(edit_window))) return; @@ -2420,7 +2434,7 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) gchar *from = modest_account_mgr_get_from_string (account_mgr, account_name); /* Create the mail operation */ - ModestMailOperation *mail_operation = modest_mail_operation_new (G_OBJECT(edit_window)); + ModestMailOperation *mail_operation = modest_mail_operation_new (NULL); modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation); modest_mail_operation_send_new_mail (mail_operation, @@ -2607,7 +2621,7 @@ do_create_folder_cb (ModestMailOperation *mail_op, { gchar *suggested_name = (gchar *) user_data; GtkWindow *source_win = (GtkWindow *) modest_mail_operation_get_source (mail_op); - + if (modest_mail_operation_get_error (mail_op)) { /* Show an error */ modest_platform_information_banner (GTK_WIDGET (source_win), NULL, @@ -2698,6 +2712,7 @@ modest_ui_actions_create_folder(GtkWidget *parent_window, if (parent_folder) { /* The parent folder will be freed in the callback */ modest_platform_connect_if_remote_and_perform (GTK_WINDOW (parent_window), + TRUE, parent_folder, create_folder_performer, parent_folder); @@ -2751,8 +2766,21 @@ typedef struct { } RenameFolderInfo; static void -on_rename_folder_cb (gboolean canceled, GError *err, GtkWindow *parent_window, - TnyAccount *account, gpointer user_data) +on_rename_folder_cb (ModestMailOperation *mail_op, + TnyFolder *new_folder, + gpointer user_data) +{ + /* Select now */ + modest_folder_view_select_folder (MODEST_FOLDER_VIEW (user_data), + new_folder, FALSE); +} + +static void +on_rename_folder_performer (gboolean canceled, + GError *err, + GtkWindow *parent_window, + TnyAccount *account, + gpointer user_data) { ModestMailOperation *mail_op = NULL; GtkTreeSelection *sel = NULL; @@ -2777,20 +2805,12 @@ on_rename_folder_cb (gboolean canceled, GError *err, GtkWindow *parent_window, sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (folder_view)); gtk_tree_selection_unselect_all (sel); - /* Select *after* the changes */ - modest_folder_view_select_folder (MODEST_FOLDER_VIEW(folder_view), - TNY_FOLDER(data->folder), TRUE); - /* Actually rename the folder */ modest_mail_operation_rename_folder (mail_op, - TNY_FOLDER (data->folder), - (const gchar *) (data->new_name)); - - /* TODO folder view filter refilter */ - /* - GtkTreeModel *tree_model = gtk_tree_view_get_model (GTK_TREE_VIEW (folder_view)); - if (GTK_IS_TREE_MODEL_FILTER (tree_model)) - gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (tree_model)); */ + TNY_FOLDER (data->folder), + (const gchar *) (data->new_name), + on_rename_folder_cb, + folder_view); } g_object_unref (mail_op); @@ -2844,8 +2864,8 @@ modest_ui_actions_on_rename_folder (GtkAction *action, RenameFolderInfo *rename_folder_data = g_new0 (RenameFolderInfo, 1); rename_folder_data->folder = folder; rename_folder_data->new_name = folder_name; - modest_platform_connect_if_remote_and_perform (GTK_WINDOW(main_window), - folder, on_rename_folder_cb, rename_folder_data); + modest_platform_connect_if_remote_and_perform (GTK_WINDOW(main_window), TRUE, + folder, on_rename_folder_performer, rename_folder_data); } } g_object_unref (folder); @@ -2947,9 +2967,11 @@ delete_folder (ModestMainWindow *main_window, gboolean move_to_trash) info->folder = folder; info->move_to_trash = move_to_trash; g_object_ref (G_OBJECT (info->folder)); - TnyAccount *account = tny_folder_get_account(TNY_FOLDER(folder)); - modest_platform_connect_and_perform (GTK_WINDOW (main_window), - account, on_delete_folder_cb, info); + TnyAccount *account = tny_folder_get_account (TNY_FOLDER (folder)); + modest_platform_connect_if_remote_and_perform (GTK_WINDOW (main_window), + TRUE, + TNY_FOLDER_STORE (account), + on_delete_folder_cb, info); g_object_unref (account); } g_object_unref (G_OBJECT (folder)); @@ -3319,7 +3341,17 @@ modest_ui_actions_on_redo (GtkAction *action, static void -destroy_information_note (ModestMailOperation *mail_op, gpointer user_data) +destroy_information_note (ModestMailOperation *mail_op, + gpointer user_data) +{ + /* destroy information note */ + gtk_widget_destroy (GTK_WIDGET(user_data)); +} + +static void +destroy_folder_information_note (ModestMailOperation *mail_op, + TnyFolder *new_folder, + gpointer user_data) { /* destroy information note */ gtk_widget_destroy (GTK_WIDGET(user_data)); @@ -3464,7 +3496,7 @@ modest_ui_actions_on_paste (GtkAction *action, src_folder, folder_store, delete, - destroy_information_note, + destroy_folder_information_note, inf_note); } @@ -3816,16 +3848,16 @@ modest_ui_actions_on_folder_display_name_changed (ModestFolderView *folder_view, * updating the display name apparently is expensive */ const gchar* old_name = gtk_window_get_title (window); + if (display_name == NULL) + display_name = " "; + if (old_name && display_name && strcmp (old_name, display_name) == 0) return; /* don't do anything */ /* This is usually used to change the title of the main window, which * is the one that holds the folder view. Note that this change can * happen even when the widget doesn't have the focus. */ - if (display_name) - gtk_window_set_title (window, display_name); - else - gtk_window_set_title (window, " "); + gtk_window_set_title (window, display_name); } @@ -4197,10 +4229,9 @@ modest_ui_actions_msgs_move_to_confirmation (ModestWindow *win, return response; } - - static void -move_to_cb (ModestMailOperation *mail_op, gpointer user_data) +move_to_cb (ModestMailOperation *mail_op, + gpointer user_data) { MoveToHelper *helper = (MoveToHelper *) user_data; @@ -4239,6 +4270,21 @@ move_to_cb (ModestMailOperation *mail_op, gpointer user_data) g_free (helper); } +static void +folder_move_to_cb (ModestMailOperation *mail_op, + TnyFolder *new_folder, + gpointer user_data) +{ + move_to_cb (mail_op, user_data); +} + +static void +msgs_move_to_cb (ModestMailOperation *mail_op, + gpointer user_data) +{ + move_to_cb (mail_op, user_data); +} + void modest_ui_actions_move_folder_error_handler (ModestMailOperation *mail_op, gpointer user_data) @@ -4517,7 +4563,7 @@ xfer_messages_from_move_to_cb (gboolean canceled, GError *err, headers, TNY_FOLDER (dst_folder), TRUE, - move_to_cb, + msgs_move_to_cb, helper); g_object_unref (G_OBJECT (mail_op)); @@ -4583,11 +4629,13 @@ on_move_folder_cb (gboolean canceled, GError *err, GtkWindow *parent_window, TNY_FOLDER (info->src_folder), info->dst_folder, info->delete_original, - move_to_cb, + folder_move_to_cb, helper); - - modest_folder_view_select_folder (MODEST_FOLDER_VIEW(info->folder_view), - TNY_FOLDER (info->dst_folder), TRUE); + + if (modest_mail_operation_get_status (mail_op) == MODEST_MAIL_OPERATION_STATUS_SUCCESS) { + modest_folder_view_select_folder (MODEST_FOLDER_VIEW(info->folder_view), + TNY_FOLDER (info->dst_folder), TRUE); + } /* Unref mail operation */ g_object_unref (G_OBJECT (mail_op)); @@ -4645,7 +4693,7 @@ modest_ui_actions_on_main_window_move_to (GtkAction *action, info->folder_view = folder_view; g_object_ref (G_OBJECT (info->src_folder)); g_object_ref (G_OBJECT (info->dst_folder)); - modest_platform_connect_if_remote_and_perform(GTK_WINDOW (win), + modest_platform_connect_if_remote_and_perform(GTK_WINDOW (win), TRUE, TNY_FOLDER_STORE (dst_folder), on_move_folder_cb, info); } } else if (gtk_widget_is_focus (GTK_WIDGET(header_view))) { @@ -4664,7 +4712,7 @@ modest_ui_actions_on_main_window_move_to (GtkAction *action, } if (do_xfer) /* Transfer messages */ { g_object_ref (dst_folder); - modest_platform_connect_if_remote_and_perform(GTK_WINDOW (win), + modest_platform_connect_if_remote_and_perform(GTK_WINDOW (win), TRUE, TNY_FOLDER_STORE (dst_folder), xfer_messages_from_move_to_cb, dst_folder); } } @@ -4708,7 +4756,7 @@ modest_ui_actions_on_msg_view_window_move_to (GtkAction *action, if (do_xfer) { g_object_ref (dst_folder); - modest_platform_connect_if_remote_and_perform(GTK_WINDOW (win), + modest_platform_connect_if_remote_and_perform(GTK_WINDOW (win), TRUE, TNY_FOLDER_STORE (dst_folder), xfer_messages_from_move_to_cb, dst_folder); } g_object_unref (account); @@ -4939,7 +4987,7 @@ modest_ui_actions_on_retrieve_msg_contents (GtkAction *action, g_object_unref (iter); /* Connect and perform the message retrieval */ - modest_platform_connect_and_perform ((GtkWindow *) window, + modest_platform_connect_and_perform ((GtkWindow *) window, TRUE, g_object_ref (account), retrieve_msg_contents_performer, g_object_ref (headers)); @@ -4950,13 +4998,31 @@ modest_ui_actions_on_retrieve_msg_contents (GtkAction *action, } void +modest_ui_actions_check_toolbar_dimming_rules (ModestWindow *window) +{ + g_return_if_fail (MODEST_IS_WINDOW (window)); + + /* Update dimmed */ + modest_window_check_dimming_rules_group (window, MODEST_DIMMING_RULES_TOOLBAR); +} + +void +modest_ui_actions_check_menu_dimming_rules (ModestWindow *window) +{ + g_return_if_fail (MODEST_IS_WINDOW (window)); + + /* Update dimmed */ + modest_window_check_dimming_rules_group (window, MODEST_DIMMING_RULES_MENU); +} + +void modest_ui_actions_on_email_menu_activated (GtkAction *action, ModestWindow *window) { g_return_if_fail (MODEST_IS_WINDOW (window)); - /* Update dimmed */ - modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules"); + /* Update dimmed */ + modest_ui_actions_check_menu_dimming_rules (window); } void @@ -4965,8 +5031,8 @@ modest_ui_actions_on_edit_menu_activated (GtkAction *action, { g_return_if_fail (MODEST_IS_WINDOW (window)); - /* Update dimmed */ - modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules"); + /* Update dimmed */ + modest_ui_actions_check_menu_dimming_rules (window); } void @@ -4975,8 +5041,8 @@ modest_ui_actions_on_view_menu_activated (GtkAction *action, { g_return_if_fail (MODEST_IS_WINDOW (window)); - /* Update dimmed */ - modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules"); + /* Update dimmed */ + modest_ui_actions_check_menu_dimming_rules (window); } void @@ -4985,8 +5051,8 @@ modest_ui_actions_on_format_menu_activated (GtkAction *action, { g_return_if_fail (MODEST_IS_WINDOW (window)); - /* Update dimmed */ - modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules"); + /* Update dimmed */ + modest_ui_actions_check_menu_dimming_rules (window); } void @@ -4995,8 +5061,8 @@ modest_ui_actions_on_tools_menu_activated (GtkAction *action, { g_return_if_fail (MODEST_IS_WINDOW (window)); - /* Update dimmed */ - modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules"); + /* Update dimmed */ + modest_ui_actions_check_menu_dimming_rules (window); } void @@ -5005,8 +5071,8 @@ modest_ui_actions_on_attachment_menu_activated (GtkAction *action, { g_return_if_fail (MODEST_IS_WINDOW (window)); - /* Update dimmed */ - modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules"); + /* Update dimmed */ + modest_ui_actions_check_menu_dimming_rules (window); } void @@ -5015,8 +5081,8 @@ modest_ui_actions_on_toolbar_csm_menu_activated (GtkAction *action, { g_return_if_fail (MODEST_IS_WINDOW (window)); - /* Update dimmed */ - modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules"); + /* Update dimmed */ + modest_ui_actions_check_menu_dimming_rules (window); } void @@ -5025,8 +5091,8 @@ modest_ui_actions_on_folder_view_csm_menu_activated (GtkAction *action, { g_return_if_fail (MODEST_IS_WINDOW (window)); - /* Update dimmed */ - modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules"); + /* Update dimmed */ + modest_ui_actions_check_menu_dimming_rules (window); } void @@ -5035,17 +5101,8 @@ modest_ui_actions_on_header_view_csm_menu_activated (GtkAction *action, { g_return_if_fail (MODEST_IS_WINDOW (window)); - /* Update dimmed */ - modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules"); -} - -void -modest_ui_actions_check_toolbar_dimming_rules (ModestWindow *window) -{ - g_return_if_fail (MODEST_IS_WINDOW (window)); - - /* Update dimmed */ - modest_window_check_dimming_rules_group (window, "ModestToolbarDimmingRules"); + /* Update dimmed */ + modest_ui_actions_check_menu_dimming_rules (window); } void