pathbar: Only invalidate styles in allocate if stuff really changed

I still don't like queueing restyles in size_allocate(), but I can't
come up with a better mechanims for the way the pathbar works today.
This commit is contained in:
Benjamin Otte 2012-05-02 05:08:19 +02:00
parent 532c66df81
commit 01b75f19a6

View File

@ -526,6 +526,7 @@ gtk_path_bar_size_allocate (GtkWidget *widget,
gboolean need_sliders = FALSE; gboolean need_sliders = FALSE;
gint up_slider_offset = 0; gint up_slider_offset = 0;
GtkRequisition child_requisition; GtkRequisition child_requisition;
gboolean needs_reorder = FALSE;
gtk_widget_set_allocation (widget, allocation); gtk_widget_set_allocation (widget, allocation);
@ -687,6 +688,7 @@ gtk_path_bar_size_allocate (GtkWidget *widget,
else if (gtk_widget_get_has_tooltip (child)) else if (gtk_widget_get_has_tooltip (child))
gtk_widget_set_tooltip_text (child, NULL); gtk_widget_set_tooltip_text (child, NULL);
needs_reorder |= gtk_widget_get_child_visible (child) == FALSE;
gtk_widget_set_child_visible (child, TRUE); gtk_widget_set_child_visible (child, TRUE);
gtk_widget_size_allocate (child, &child_allocation); gtk_widget_size_allocate (child, &child_allocation);
@ -698,11 +700,13 @@ gtk_path_bar_size_allocate (GtkWidget *widget,
/* Now we go hide all the widgets that don't fit */ /* Now we go hide all the widgets that don't fit */
while (list) while (list)
{ {
needs_reorder |= gtk_widget_get_child_visible (child) == TRUE;
gtk_widget_set_child_visible (BUTTON_DATA (list->data)->button, FALSE); gtk_widget_set_child_visible (BUTTON_DATA (list->data)->button, FALSE);
list = list->prev; list = list->prev;
} }
for (list = first_button->next; list; list = list->next) for (list = first_button->next; list; list = list->next)
{ {
needs_reorder |= gtk_widget_get_child_visible (child) == TRUE;
gtk_widget_set_child_visible (BUTTON_DATA (list->data)->button, FALSE); gtk_widget_set_child_visible (BUTTON_DATA (list->data)->button, FALSE);
} }
@ -712,11 +716,15 @@ gtk_path_bar_size_allocate (GtkWidget *widget,
child_allocation.x = up_slider_offset + allocation->x; child_allocation.x = up_slider_offset + allocation->x;
gtk_widget_size_allocate (path_bar->up_slider_button, &child_allocation); gtk_widget_size_allocate (path_bar->up_slider_button, &child_allocation);
needs_reorder |= gtk_widget_get_child_visible (path_bar->up_slider_button) == FALSE;
gtk_widget_set_child_visible (path_bar->up_slider_button, TRUE); gtk_widget_set_child_visible (path_bar->up_slider_button, TRUE);
gtk_widget_show_all (path_bar->up_slider_button); gtk_widget_show_all (path_bar->up_slider_button);
} }
else else
gtk_widget_set_child_visible (path_bar->up_slider_button, FALSE); {
needs_reorder |= gtk_widget_get_child_visible (path_bar->up_slider_button) == TRUE;
gtk_widget_set_child_visible (path_bar->up_slider_button, FALSE);
}
if (need_sliders) if (need_sliders)
{ {
@ -731,14 +739,19 @@ gtk_path_bar_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (path_bar->down_slider_button, &child_allocation); gtk_widget_size_allocate (path_bar->down_slider_button, &child_allocation);
needs_reorder |= gtk_widget_get_child_visible (path_bar->down_slider_button) == FALSE;
gtk_widget_set_child_visible (path_bar->down_slider_button, TRUE); gtk_widget_set_child_visible (path_bar->down_slider_button, TRUE);
gtk_widget_show_all (path_bar->down_slider_button); gtk_widget_show_all (path_bar->down_slider_button);
gtk_path_bar_update_slider_buttons (path_bar); gtk_path_bar_update_slider_buttons (path_bar);
} }
else else
gtk_widget_set_child_visible (path_bar->down_slider_button, FALSE); {
needs_reorder |= gtk_widget_get_child_visible (path_bar->down_slider_button) == TRUE;
gtk_widget_set_child_visible (path_bar->down_slider_button, FALSE);
}
child_ordering_changed (path_bar); if (needs_reorder)
child_ordering_changed (path_bar);
} }
static void static void