* Fixes NB#86725, fixes NB#86266, show the error banner whenever folder creation...
[modest] / src / modest-ui-actions.c
index 4d96175..074f866 100644 (file)
@@ -217,10 +217,17 @@ modest_ui_actions_run_account_setup_wizard (ModestWindow *win)
                win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(),
                                                         TRUE);  /* create if not existent */
        
-       /* make sure the mainwindow is visible */
        gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win));
-       gtk_widget_show_all (GTK_WIDGET(win));
-       gtk_window_present (GTK_WINDOW(win));
+
+       /* make sure the mainwindow is visible. We need to present the
+          wizard again to give it the focus back. show_all are needed
+          in order to get the widgets properly drawn (MainWindow main
+          paned won't be in its right position and the dialog will be
+          missplaced */
+       gtk_widget_show_all (GTK_WIDGET (win));
+       gtk_widget_show_all (GTK_WIDGET (wizard));
+       gtk_window_present (GTK_WINDOW (win));
+       gtk_window_present (GTK_WINDOW (wizard));
        
        dialog_response = gtk_dialog_run (GTK_DIALOG (wizard));
        gtk_widget_destroy (GTK_WIDGET (wizard));
@@ -514,7 +521,6 @@ modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win)
 
                        /* Select next or previous row */
                        if (gtk_tree_row_reference_valid (next_row_reference)) {
-/*                             next_path = gtk_tree_row_reference_get_path (row_reference); */
                                gtk_tree_selection_select_path (sel, next_path);
                        }
                        else if (gtk_tree_row_reference_valid (prev_row_reference)) {                           
@@ -533,8 +539,10 @@ modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win)
                }
                
                /* Update toolbar dimming state */
-               if (main_window)
+               if (main_window) {
+                       modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (main_window));
                        modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (main_window));
+               }
 
                /* Free */
                g_list_foreach (sel_list, (GFunc) gtk_tree_path_free, NULL);
@@ -775,8 +783,6 @@ cleanup:
                g_object_unref (G_OBJECT(account));
        if (folder)
                g_object_unref (G_OBJECT(folder));
-       if (msg_win)
-               g_object_unref (G_OBJECT(msg_win));
        if (msg)
                g_object_unref (G_OBJECT(msg));
 }
@@ -988,7 +994,6 @@ open_msg_cb (ModestMailOperation *mail_op,
        if (win != NULL) {
                mgr = modest_runtime_get_window_mgr ();
                modest_window_mgr_register_window (mgr, win);
-               g_object_unref (win);
                gtk_widget_show_all (GTK_WIDGET(win));
        }
 
@@ -1584,8 +1589,6 @@ reply_forward_cb (ModestMailOperation *mail_op,
        gtk_widget_show_all (GTK_WIDGET (msg_win));
 
 cleanup:
-       if (msg_win)
-               g_object_unref (msg_win);
        if (new_msg)
                g_object_unref (G_OBJECT (new_msg));
        if (account)
@@ -3052,6 +3055,38 @@ modest_ui_actions_on_remove_attachments (GtkAction *action,
        modest_msg_edit_window_remove_attachments (window, NULL);
 }
 
+
+#ifdef MODEST_PLATFORM_MAEMO
+typedef struct {
+       guint handler;
+       gchar *name;
+       GtkWindow *win;
+       TnyFolderStore *folder;
+} CreateFolderHelper;
+
+static gboolean
+show_create_folder_in_timeout (gpointer data)
+{
+       CreateFolderHelper *helper = (CreateFolderHelper *) data;
+
+       /* Remove the timeout ASAP, we can not wait until the dialog
+          is shown because it could take a lot of time and so the
+          timeout could be called twice or more times */
+       g_source_remove (helper->handler);
+
+       gdk_threads_enter ();
+       do_create_folder (helper->win, helper->folder, helper->name);
+       gdk_threads_leave ();
+
+       g_object_unref (helper->win);
+       g_object_unref (helper->folder);
+       g_free (helper->name);
+       g_slice_free (CreateFolderHelper, helper);
+
+       return FALSE;
+}
+#endif
+
 static void
 do_create_folder_cb (ModestMailOperation *mail_op,
                     TnyFolderStore *parent_folder, 
@@ -3076,7 +3111,21 @@ do_create_folder_cb (ModestMailOperation *mail_op,
                /* Try again. Do *NOT* show any error because the mail
                   operations system will do it for us because we
                   created the mail_op with new_with_error_handler */
+#ifdef MODEST_PLATFORM_MAEMO
+               CreateFolderHelper *helper;
+               helper = g_slice_new0 (CreateFolderHelper);
+               helper->name = g_strdup (suggested_name);
+               helper->folder = g_object_ref (parent_folder);
+               helper->win = g_object_ref (source_win);
+
+               /* Ugly but neccesary stuff. The problem is that the
+                  dialog when is shown calls a function that destroys
+                  all the temporary windows, so the banner is
+                  destroyed */
+               helper->handler = g_timeout_add (2000, show_create_folder_in_timeout, helper);
+#else
                do_create_folder (source_win, parent_folder, (const gchar *) suggested_name);
+#endif
        } else {
                /* the 'source_win' is either the ModestMainWindow, or the 'Move to folder'-dialog
                 * FIXME: any other? */         
@@ -4068,9 +4117,9 @@ modest_ui_actions_on_select_all (GtkAction *action,
                /* Set focuse on header view */
                gtk_widget_grab_focus (header_view);
 
-
                /* Enable window dimming management */
                modest_window_enable_dimming (MODEST_WINDOW(window));
+               modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (window));
                modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (window));
        }