--- thunar-location-buttons.c.orig 2011-06-29 22:59:35.000000000 +0200 +++ thunar-location-buttons.c 2011-06-29 22:37:50.931096304 +0200 @@ -538,6 +538,10 @@ GtkRequisition child_requisition; GList *lp; gint spacing; + GtkSettings *settings; + gint size; + gint width; + gint height; gtk_widget_style_get (GTK_WIDGET (buttons), "spacing", &spacing, @@ -546,18 +550,24 @@ requisition->width = 0; requisition->height = 0; - /* calculate the size of the biggest button */ + /* calculate the height of the biggest button */ for (lp = buttons->list; lp != NULL; lp = lp->next) { gtk_widget_size_request (GTK_WIDGET (lp->data), &child_requisition); - requisition->width = MAX (child_requisition.width, requisition->width); requisition->height = MAX (child_requisition.height, requisition->height); } - /* add space for the sliders if we have more than one path */ + /* add to minimal size according to icon size */ + settings = gtk_settings_get_for_screen (gtk_widget_get_screen (widget)); + if (gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU, &width, &height)) + size = MAX (width, height); + else + size = 16; + requisition->width += 3 * (size/2); + + /* add space for the sliders */ buttons->slider_width = MIN (requisition->height * 2 / 3 + 5, requisition->height); - if (buttons->list != NULL && buttons->list->next != NULL) - requisition->width += (spacing + buttons->slider_width) * 2; + requisition->width += (spacing + buttons->slider_width) * 2; gtk_widget_size_request (buttons->left_slider, &child_requisition); gtk_widget_size_request (buttons->right_slider, &child_requisition); @@ -586,10 +596,14 @@ gint right_slider_offset = 0; gint allocation_width; gint border_width; - gint slider_space; + gint slider_space = 0; gint spacing; gint width; + gint max_button_width; + /* keep old width if new allocation is bigger */ + max_button_width = MIN((widget->allocation).width, allocation->width); + widget->allocation = *allocation; /* if no path is set, we don't have to allocate anything */ @@ -615,7 +629,7 @@ break; } - if (width <= allocation_width) + if (buttons->list->next == NULL) { if (G_LIKELY (buttons->fake_root_button != NULL)) first_button = buttons->fake_root_button; @@ -665,6 +679,10 @@ } } + /* set max button width according to slider and border size */ + max_button_width -= 2 * border_width + slider_space; + + /* Now we allocate space to the buttons */ child_allocation.y = allocation->y + border_width; child_allocation.height = MAX (1, allocation->height - border_width * 2); @@ -691,8 +709,15 @@ for (lp = first_button; lp != NULL; lp = lp->prev) { child = lp->data; - - child_allocation.width = child->requisition.width; + + /* don't allocate more space than available*/ + if (child->requisition.width > max_button_width) + { + child_allocation.width = max_button_width; + //allocation->width = MIN(allocation->width, old_allocation.width); + } + else + child_allocation.width = child->requisition.width; if (G_UNLIKELY (direction == GTK_TEXT_DIR_RTL)) child_allocation.x -= child_allocation.width;