* Optimization, do not emit the folder selection changed signal when there is nothin...
authorSergio Villar Senin <svillar@igalia.com>
Tue, 13 Nov 2007 16:46:46 +0000 (16:46 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Tue, 13 Nov 2007 16:46:46 +0000 (16:46 +0000)
* The focus is changed to the first inbox if the removed account is the visible account (there is something still not working related to this)

pmo-trunk-r3725

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

index 5d583b1..818acea 100644 (file)
@@ -868,14 +868,20 @@ connect_signals (ModestMainWindow *self)
                                           G_OBJECT(priv->folder_view), "key-press-event",
                                           G_CALLBACK(on_inner_widgets_key_pressed), self);
        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), self);
+               modest_signal_mgr_connect (priv->sighandlers, G_OBJECT(priv->folder_view), 
+                                          "folder_selection_changed",
+                                          G_CALLBACK (modest_main_window_on_folder_selection_changed), 
+                                          self);
        priv->sighandlers = 
-               modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->folder_view), "folder-display-name-changed",
-                                          G_CALLBACK (modest_ui_actions_on_folder_display_name_changed), self);
+               modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->folder_view), 
+                                          "folder-display-name-changed",
+                                          G_CALLBACK (modest_ui_actions_on_folder_display_name_changed), 
+                                          self);
        priv->sighandlers = 
-               modest_signal_mgr_connect (priv->sighandlers,G_OBJECT (priv->folder_view), "focus-in-event", 
-                                          G_CALLBACK (on_folder_view_focus_in), self);
+               modest_signal_mgr_connect (priv->sighandlers,G_OBJECT (priv->folder_view), 
+                                          "focus-in-event", 
+                                          G_CALLBACK (on_folder_view_focus_in), 
+                                          self);
 
        /* Folder view CSM */
        menu = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/FolderViewCSM");
index b400c29..c104fde 100644 (file)
@@ -1260,6 +1260,7 @@ on_account_removed (TnyAccountStore *account_store,
        ModestFolderViewPrivate *priv;
        GtkTreeModel *sort_model, *filter_model;
        GtkTreeSelection *sel = NULL;
+       gboolean same_account_selected = FALSE;
 
        /* Ignore transport account removals, we're not showing them
           in the folder view */
@@ -1285,6 +1286,7 @@ on_account_removed (TnyAccountStore *account_store,
                if (selected_folder_account == account) {
                        sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (self));
                        gtk_tree_selection_unselect_all (sel);
+                       same_account_selected = TRUE;
                }
                g_object_unref (selected_folder_account);
        }
@@ -1296,7 +1298,7 @@ on_account_removed (TnyAccountStore *account_store,
 
                folder_to_select_account = tny_folder_get_account (priv->folder_to_select);
                if (folder_to_select_account == account) {
-/*                     modest_folder_view_disable_next_folder_selection (self); */
+                       modest_folder_view_disable_next_folder_selection (self);
                        g_object_unref (priv->folder_to_select);
                        priv->folder_to_select = NULL;
                }
@@ -1327,16 +1329,8 @@ on_account_removed (TnyAccountStore *account_store,
 
        /* Select the first INBOX if the currently selected folder
           belongs to the account that is being deleted */
-       if (priv->cur_folder_store) {
-               TnyAccount *folder_selected_account;
-
-               folder_selected_account = (TNY_IS_FOLDER (priv->cur_folder_store)) ?
-                       modest_tny_folder_get_account (TNY_FOLDER (priv->cur_folder_store)) :
-                       TNY_ACCOUNT (g_object_ref (priv->cur_folder_store));
-               if (account == folder_selected_account)
-                       modest_folder_view_select_first_inbox_or_local (self);
-               g_object_unref (folder_selected_account);
-       }
+       if (same_account_selected)
+               modest_folder_view_select_first_inbox_or_local (self);
 }
 
 void
@@ -1659,10 +1653,13 @@ on_selection_changed (GtkTreeSelection *sel, gpointer user_data)
        /* New current references */
        priv->cur_folder_store = folder;
 
-       /* New folder has been selected */
-       g_signal_emit (G_OBJECT(tree_view),
-                      signals[FOLDER_SELECTION_CHANGED_SIGNAL],
-                      0, priv->cur_folder_store, TRUE);
+       /* New folder has been selected. Do not notify if there is
+          nothing new selected */
+       if (selected) {
+               g_signal_emit (G_OBJECT(tree_view),
+                              signals[FOLDER_SELECTION_CHANGED_SIGNAL],
+                              0, priv->cur_folder_store, TRUE);
+       }
 }
 
 TnyFolderStore *