* Fixes NB#92178, replaced an old logical id
[modest] / src / modest-ui-actions.c
index 8bd2526..5107431 100644 (file)
@@ -203,11 +203,11 @@ remote_folder_has_leave_on_server (TnyFolderStore *folder)
 gboolean
 modest_ui_actions_run_account_setup_wizard (ModestWindow *win)
 {
-       gboolean result = FALSE;        
+       gboolean result = FALSE;
        GtkWindow *wizard;
        gint dialog_response;
 
-       /* there is no such wizard yet */       
+       /* there is no such wizard yet */
        wizard = GTK_WINDOW (modest_platform_get_account_settings_wizard ());
        modest_window_mgr_set_modal (modest_runtime_get_window_mgr(), GTK_WINDOW (wizard), (GtkWindow *) win);
 
@@ -217,7 +217,7 @@ modest_ui_actions_run_account_setup_wizard (ModestWindow *win)
        if (!win) 
                win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(),
                                                         TRUE);  /* create if not existent */
-       
+
        gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win));
 
        /* make sure the mainwindow is visible. We need to present the
@@ -231,7 +231,7 @@ modest_ui_actions_run_account_setup_wizard (ModestWindow *win)
        gtk_window_present (GTK_WINDOW (win));
        gtk_window_present (GTK_WINDOW (wizard));
 #endif
-       
+
        dialog_response = gtk_dialog_run (GTK_DIALOG (wizard));
        gtk_widget_destroy (GTK_WIDGET (wizard));
        if (gtk_events_pending ())
@@ -714,10 +714,8 @@ modest_ui_actions_compose_msg(ModestWindow *win,
        ModestTnyAccountStore *store = modest_runtime_get_account_store();
        GnomeVFSFileSize total_size, allowed_size;
 
-       /* we check for low-mem; in that case, show a warning, and don't allow
-        * composing a message with attachments
-        */
-       if (attachments && modest_platform_check_memory_low (win, TRUE))
+       /* we check for low-mem */
+       if (modest_platform_check_memory_low (win, TRUE))
                goto cleanup;
 
 #ifdef MODEST_TOOLKIT_HILDON2
@@ -932,7 +930,7 @@ open_msg_cb (ModestMailOperation *mail_op,
                if (traccount) {
                        ModestTnySendQueue *send_queue = NULL;
                        ModestTnySendQueueStatus status;
-                       char *msg_id;
+                       gchar *msg_id;
                        account = g_strdup(modest_tny_account_get_parent_modest_account_name_for_server_account(
                                                   TNY_ACCOUNT(traccount)));
                        send_queue = modest_runtime_get_send_queue(traccount, TRUE);
@@ -2315,7 +2313,6 @@ modest_ui_actions_on_header_activated (ModestHeaderView *header_view,
                                       ModestMainWindow *main_window)
 {
        TnyList *headers;
-       GtkWidget *open_widget;
 
        g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
 
@@ -2334,9 +2331,6 @@ modest_ui_actions_on_header_activated (ModestHeaderView *header_view,
                return;
 
        modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (main_window));
-       open_widget = modest_window_get_action_widget (MODEST_WINDOW (main_window), "/MenuBar/EmailMenu/EmailOpenMenu");
-       if (!GTK_WIDGET_IS_SENSITIVE (open_widget))
-               return;
 
        headers = modest_header_view_get_selected_headers (header_view);
 
@@ -3390,7 +3384,7 @@ modest_ui_actions_on_rename_folder (GtkAction *action,
                return;
 
        if (TNY_IS_FOLDER (folder)) {
-               gchar *folder_name;
+               gchar *folder_name = NULL;
                gint response;
                const gchar *current_name;
                TnyFolderStore *parent;
@@ -3732,6 +3726,8 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
                                                           "username in the get_password() callback.\n", __FUNCTION__);
                                        }
                                } else {
+                                       g_free (*username);
+                                       *username = NULL;
                                        /* Show error */
                                        modest_platform_information_banner (GTK_WIDGET (dialog), NULL, 
                                                                            _("mcen_ib_username_pw_incorrect"));
@@ -3772,6 +3768,7 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
                *remember = FALSE;
 */
 
+       g_free (initial_username);
        gtk_widget_destroy (dialog);
        g_slice_free (PasswordDialogFields, fields);
        
@@ -4006,8 +4003,8 @@ modest_ui_actions_on_paste (GtkAction *action,
                        gtk_text_buffer_paste_clipboard (buffer, clipboard, NULL, TRUE);
                } else if (MODEST_IS_MSG_EDIT_WINDOW (window)) {
                        ModestMailOperation *mail_op;
-                       TnyFolder *src_folder;
-                       TnyList *data;
+                       TnyFolder *src_folder = NULL;
+                       TnyList *data = NULL;
                        gboolean delete;
                        PasteAsAttachmentHelper *helper = g_new0 (PasteAsAttachmentHelper, 1);
                        helper->window = MODEST_MSG_EDIT_WINDOW (window);
@@ -4027,6 +4024,12 @@ modest_ui_actions_on_paste (GtkAction *action,
                                                                     helper,
                                                                     paste_as_attachment_free);
                        }
+                       /* Free */
+                       if (data) 
+                               g_object_unref (data);
+                       if (src_folder) 
+                               g_object_unref (src_folder);
+
                }
        } else if (MODEST_IS_FOLDER_VIEW (focused_widget)) {
                ModestEmailClipboard *clipboard = NULL;
@@ -4392,7 +4395,7 @@ modest_ui_actions_on_toggle_toolbar (GtkToggleAction *toggle,
 
        active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (toggle));
 
-       /* Check if we want to toggle the toolbar vuew in fullscreen
+       /* Check if we want to toggle the toolbar view in fullscreen
           or normal mode */
        if (!strcmp (gtk_action_get_name (GTK_ACTION (toggle)), 
                     "ViewShowToolbarFullScreen")) {
@@ -6163,3 +6166,49 @@ modest_ui_actions_get_msg_already_deleted_error_msg (ModestWindow *win)
 
        return msg;
 }
+
+gboolean
+modest_ui_actions_on_delete_account (GtkWindow *parent_window,
+                                    const gchar *account_name,
+                                    const gchar *account_title)
+{
+       ModestAccountMgr *account_mgr;
+       gchar *txt = NULL;
+       gint response;
+       ModestProtocol *protocol;
+       gboolean removed = FALSE;
+
+       g_return_val_if_fail (account_name, FALSE);
+       g_return_val_if_fail (account_title, FALSE);
+
+       account_mgr = modest_runtime_get_account_mgr();
+
+       /* The warning text depends on the account type: */
+       protocol = modest_protocol_registry_get_protocol_by_type (modest_runtime_get_protocol_registry (),
+                                                                 modest_account_mgr_get_store_protocol (account_mgr,
+                                                                                                        account_name));
+       txt = modest_protocol_get_translation (protocol,
+                                              MODEST_PROTOCOL_TRANSLATION_DELETE_MAILBOX,
+                                              account_title);
+       if (txt == NULL)
+               txt = g_strdup_printf (_("emev_nc_delete_mailbox"), account_title);
+
+       response = modest_platform_run_confirmation_dialog (parent_window, txt);
+       g_free (txt);
+       txt = NULL;
+
+       if (response == GTK_RESPONSE_OK) {
+               /* Remove account. If it succeeds then it also removes
+                  the account from the ModestAccountView: */
+               gboolean is_default = FALSE;
+               gchar *default_account_name = modest_account_mgr_get_default_account (account_mgr);
+               if (default_account_name && (strcmp (default_account_name, account_name) == 0))
+                       is_default = TRUE;
+               g_free (default_account_name);
+
+               removed = modest_account_mgr_remove_account (account_mgr, account_name);
+               if (!removed)
+                       g_warning ("%s: modest_account_mgr_remove_account() failed.\n", __FUNCTION__);
+       }
+       return removed;
+}