Commit e483ab95 authored by Paolo Borelli's avatar Paolo Borelli Committed by Ignacio Casal Quinteiro

Fix slowdown when closing all tabs

We were O^2 stupid: for each tab we were getting its position, which in
turns requires walking the list of children and then we were removing
the tab, which in turns requires gtk to re-walk the list of tabs to find
the one we want to remove. Besides removing tabs starting from the first
is bad for gtknotebook since even/odd css of each tab is recalculated
over and over: we can remove tabs in reverse order.
parent e39946e1
......@@ -621,15 +621,23 @@ gedit_notebook_remove_tab (GeditNotebook *nb,
*/
void
gedit_notebook_remove_all_tabs (GeditNotebook *nb)
{
{
GList *tabs, *t;
g_return_if_fail (GEDIT_IS_NOTEBOOK (nb));
g_list_free (nb->priv->focused_pages);
nb->priv->focused_pages = NULL;
gtk_container_foreach (GTK_CONTAINER (nb),
(GtkCallback)remove_tab,
nb);
/* Remove tabs in reverse order since it is faster
* due to how gtknotebook works */
tabs = gtk_container_get_children (GTK_CONTAINER (nb));
for (t = g_list_last (tabs); t != NULL; t = t->prev)
{
gtk_container_remove (GTK_CONTAINER (nb), GTK_WIDGET (t->data));
}
g_list_free (tabs);
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment