static void gtk_toolbar_reconfigured (GtkToolbar *toolbar);
static GtkReliefStyle get_button_relief (GtkToolbar *toolbar);
-static gint get_internal_padding (GtkToolbar *toolbar);
static gint get_max_child_expand (GtkToolbar *toolbar);
static GtkShadowType get_shadow_type (GtkToolbar *toolbar);
return FALSE;
}
+static void
+get_widget_padding_and_border (GtkWidget *widget,
+ GtkBorder *padding)
+{
+ GtkStyleContext *context;
+ GtkStateFlags state;
+ GtkBorder tmp;
+ gint ipadding = 0;
+
+ context = gtk_widget_get_style_context (widget);
+ state = gtk_style_context_get_state (context);
+
+ gtk_style_context_get_padding (context, state, padding);
+ gtk_style_context_get_border (context, state, &tmp);
+
+ gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
+
+ padding->top += tmp.top + ipadding;
+ padding->right += tmp.right + ipadding;
+ padding->bottom += tmp.bottom + ipadding;
+ padding->left += tmp.left + ipadding;
+}
+
static void
gtk_toolbar_size_request (GtkWidget *widget,
GtkRequisition *requisition)
gint homogeneous_size;
gint long_req;
gint pack_front_size;
- gint ipadding;
+ GtkBorder padding;
guint border_width;
GtkRequisition arrow_requisition;
requisition->height = long_req;
requisition->width = MAX (max_child_width, arrow_requisition.width);
}
-
- /* Extra spacing */
- ipadding = get_internal_padding (toolbar);
+ /* Extra spacing */
+ get_widget_padding_and_border (widget, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (toolbar));
- requisition->width += 2 * (ipadding + border_width);
- requisition->height += 2 * (ipadding + border_width);
-
+
+ requisition->width += 2 * border_width + padding.left + padding.right;
+ requisition->height += 2 * border_width + padding.top + padding.bottom;
+
if (get_shadow_type (toolbar) != GTK_SHADOW_NONE)
{
GtkStyleContext *context;
GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (toolbar);
GtkToolbarPrivate *priv = toolbar->priv;
- GtkStyleContext *context;
- GtkStateFlags state;
- GtkBorder padding;
GList *list;
gint cur_x;
gint cur_y;
gint border_width;
+ GtkBorder padding;
gboolean rtl;
gboolean vertical;
priv->idle_id = gdk_threads_add_idle (slide_idle_handler, toolbar);
gtk_widget_get_allocation (widget, &allocation);
- context = gtk_widget_get_style_context (widget);
- state = gtk_widget_get_state_flags (widget);
- gtk_style_context_get_padding (context, state, &padding);
rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
vertical = (priv->orientation == GTK_ORIENTATION_VERTICAL);
- border_width = get_internal_padding (toolbar) + gtk_container_get_border_width (GTK_CONTAINER (toolbar));
-
+
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (toolbar));
+ get_widget_padding_and_border (GTK_WIDGET (toolbar), &padding);
+
if (rtl)
{
cur_x = allocation.width - border_width - padding.right;
GtkAllocation *allocations;
ItemState *new_states;
GtkAllocation arrow_allocation;
- GtkStyleContext *context;
- GtkStateFlags state;
GtkBorder padding;
gint arrow_size;
gint size, pos, short_size;
GtkAllocation item_area;
GtkShadowType shadow_type;
- context = gtk_widget_get_style_context (widget);
- state = gtk_widget_get_state_flags (widget);
- gtk_style_context_get_padding (context, state, &padding);
-
gtk_widget_get_allocation (widget, &widget_allocation);
size_changed = FALSE;
if (widget_allocation.x != allocation->x ||
allocation->width - border_width * 2,
allocation->height - border_width * 2);
- border_width += get_internal_padding (toolbar);
gtk_widget_get_preferred_size (priv->arrow_button,
&arrow_requisition, NULL);
shadow_type = get_shadow_type (toolbar);
+ get_widget_padding_and_border (widget, &padding);
+
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
- available_size = size = allocation->width - 2 * border_width;
- short_size = allocation->height - 2 * border_width;
+ available_size = size = allocation->width - 2 * border_width - padding.left - padding.right;
+ short_size = allocation->height - 2 * border_width - padding.top - padding.bottom;
arrow_size = arrow_requisition.width;
if (shadow_type != GTK_SHADOW_NONE)
}
else
{
- available_size = size = allocation->height - 2 * border_width;
- short_size = allocation->width - 2 * border_width;
+ available_size = size = allocation->height - 2 * border_width - padding.top - padding.bottom;
+ short_size = allocation->width - 2 * border_width - padding.left - padding.right;
arrow_size = arrow_requisition.height;
if (shadow_type != GTK_SHADOW_NONE)
}
/* position items */
- pos = border_width;
+ pos = border_width + padding.left;
for (list = priv->content, i = 0; list != NULL; list = list->next, ++i)
{
/* Both NORMAL and OVERFLOWN items get a position.
if (new_states[i] == NORMAL || new_states[i] == OVERFLOWN)
{
allocations[i].x = pos;
- allocations[i].y = border_width;
+ allocations[i].y = border_width + padding.top;
allocations[i].height = short_size;
pos += allocations[i].width;
/* position arrow */
if (need_arrow)
{
- arrow_allocation.x = available_size - border_width - arrow_allocation.width;
- arrow_allocation.y = border_width;
+ arrow_allocation.x = available_size - border_width - padding.left - arrow_allocation.width;
+ arrow_allocation.y = border_width + padding.top;
}
- item_area.x = border_width;
- item_area.y = border_width;
+ item_area.x = border_width + padding.left;
+ item_area.y = border_width + padding.top;
item_area.width = available_size - (need_arrow? arrow_size : 0);
item_area.height = short_size;
return button_relief;
}
-static gint
-get_internal_padding (GtkToolbar *toolbar)
-{
- gint ipadding = 0;
-
- gtk_widget_style_get (GTK_WIDGET (toolbar),
- "internal-padding", &ipadding,
- NULL);
-
- return ipadding;
-}
-
static gint
get_max_child_expand (GtkToolbar *toolbar)
{