* Fixes NB#75822, the local account is selected if the last server account is deleted
authorSergio Villar Senin <svillar@igalia.com>
Tue, 13 Nov 2007 18:28:52 +0000 (18:28 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Tue, 13 Nov 2007 18:28:52 +0000 (18:28 +0000)
pmo-trunk-r3727

src/maemo/modest-main-window.c
src/widgets/modest-folder-view.c

index 818acea..ba1fbd1 100644 (file)
@@ -166,10 +166,10 @@ static gboolean  on_header_view_focus_in (GtkWidget *widget,
                                          GdkEventFocus *event,
                                          gpointer userdata);
 
                                          GdkEventFocus *event,
                                          gpointer userdata);
 
-static void      modest_main_window_on_folder_selection_changed (ModestFolderView *folder_view,
-                                                                TnyFolderStore *folder_store, 
-                                                                gboolean selected,
-                                                                ModestMainWindow *main_window);
+static void      on_folder_selection_changed (ModestFolderView *folder_view,
+                                             TnyFolderStore *folder_store, 
+                                             gboolean selected,
+                                             ModestMainWindow *main_window);
                                                
 static void set_at_least_one_account_visible(ModestMainWindow *self);
 
                                                
 static void set_at_least_one_account_visible(ModestMainWindow *self);
 
@@ -870,7 +870,7 @@ connect_signals (ModestMainWindow *self)
        priv->sighandlers = 
                modest_signal_mgr_connect (priv->sighandlers, G_OBJECT(priv->folder_view), 
                                           "folder_selection_changed",
        priv->sighandlers = 
                modest_signal_mgr_connect (priv->sighandlers, G_OBJECT(priv->folder_view), 
                                           "folder_selection_changed",
-                                          G_CALLBACK (modest_main_window_on_folder_selection_changed), 
+                                          G_CALLBACK (on_folder_selection_changed), 
                                           self);
        priv->sighandlers = 
                modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->folder_view), 
                                           self);
        priv->sighandlers = 
                modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->folder_view), 
@@ -2388,10 +2388,10 @@ on_header_view_focus_in (GtkWidget *widget,
 }
 
 static void 
 }
 
 static void 
-modest_main_window_on_folder_selection_changed (ModestFolderView *folder_view,
-                                               TnyFolderStore *folder_store, 
-                                               gboolean selected,
-                                               ModestMainWindow *main_window)
+on_folder_selection_changed (ModestFolderView *folder_view,
+                            TnyFolderStore *folder_store, 
+                            gboolean selected,
+                            ModestMainWindow *main_window)
 {
        ModestWindowPrivate *parent_priv = MODEST_WINDOW_GET_PRIVATE (main_window);
        GtkAction *action = NULL;
 {
        ModestWindowPrivate *parent_priv = MODEST_WINDOW_GET_PRIVATE (main_window);
        GtkAction *action = NULL;
index c104fde..2a178dc 100644 (file)
@@ -76,7 +76,8 @@ static void         tny_account_store_view_init (gpointer g,
 static void         modest_folder_view_set_account_store (TnyAccountStoreView *self, 
                                                          TnyAccountStore     *account_store);
 
 static void         modest_folder_view_set_account_store (TnyAccountStoreView *self, 
                                                          TnyAccountStore     *account_store);
 
-static void         on_selection_changed   (GtkTreeSelection *sel, gpointer data);
+static void         on_selection_changed   (GtkTreeSelection *sel, 
+                                           gpointer data);
 
 static void         on_account_removed     (TnyAccountStore *self, 
                                            TnyAccount *account,
 
 static void         on_account_removed     (TnyAccountStore *self, 
                                            TnyAccount *account,
@@ -1222,7 +1223,6 @@ on_account_changed (TnyAccountStore *account_store,
                    TnyAccount *tny_account,
                    gpointer user_data)
 {
                    TnyAccount *tny_account,
                    gpointer user_data)
 {
-       /* do nothing */
        ModestFolderViewPrivate *priv;
        GtkTreeModel *sort_model, *filter_model;
 
        ModestFolderViewPrivate *priv;
        GtkTreeModel *sort_model, *filter_model;
 
@@ -1236,7 +1236,7 @@ on_account_changed (TnyAccountStore *account_store,
        /* Get the inner model */
        filter_model = gtk_tree_view_get_model (GTK_TREE_VIEW (user_data));
        sort_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (filter_model));
        /* Get the inner model */
        filter_model = gtk_tree_view_get_model (GTK_TREE_VIEW (user_data));
        sort_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (filter_model));
-       
+
        /* Remove the account from the model */
        tny_list_remove (TNY_LIST (gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (sort_model))),
                         G_OBJECT (tny_account));
        /* Remove the account from the model */
        tny_list_remove (TNY_LIST (gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (sort_model))),
                         G_OBJECT (tny_account));
@@ -1249,6 +1249,19 @@ on_account_changed (TnyAccountStore *account_store,
        gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (filter_model));
 }
 
        gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (filter_model));
 }
 
+/**
+ *
+ * Selects the first inbox or the local account in an idle
+ */
+static gboolean
+on_idle_select_first_inbox_or_local (gpointer user_data)
+{
+       ModestFolderView *self = MODEST_FOLDER_VIEW (user_data);
+
+       modest_folder_view_select_first_inbox_or_local (self);
+
+       return FALSE;
+}
 
 
 static void
 
 
 static void
@@ -1330,7 +1343,7 @@ on_account_removed (TnyAccountStore *account_store,
        /* Select the first INBOX if the currently selected folder
           belongs to the account that is being deleted */
        if (same_account_selected)
        /* Select the first INBOX if the currently selected folder
           belongs to the account that is being deleted */
        if (same_account_selected)
-               modest_folder_view_select_first_inbox_or_local (self);
+               g_idle_add (on_idle_select_first_inbox_or_local, self);
 }
 
 void
 }
 
 void