mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-29 15:01:23 +00:00
combobox: rename border->padding for code clarity
https://bugzilla.gnome.org/show_bug.cgi?id=646882
This commit is contained in:
parent
cfb54d81bd
commit
6116bcb78e
@ -1718,7 +1718,7 @@ gtk_combo_box_menu_position_below (GtkMenu *menu,
|
|||||||
GdkScreen *screen;
|
GdkScreen *screen;
|
||||||
gint monitor_num;
|
gint monitor_num;
|
||||||
GdkRectangle monitor;
|
GdkRectangle monitor;
|
||||||
GtkBorder border;
|
GtkBorder padding;
|
||||||
|
|
||||||
/* FIXME: is using the size request here broken? */
|
/* FIXME: is using the size request here broken? */
|
||||||
child = gtk_bin_get_child (GTK_BIN (combo_box));
|
child = gtk_bin_get_child (GTK_BIN (combo_box));
|
||||||
@ -1735,8 +1735,8 @@ gtk_combo_box_menu_position_below (GtkMenu *menu,
|
|||||||
|
|
||||||
gdk_window_get_root_coords (gtk_widget_get_window (child),
|
gdk_window_get_root_coords (gtk_widget_get_window (child),
|
||||||
sx, sy, &sx, &sy);
|
sx, sy, &sx, &sy);
|
||||||
get_widget_padding (GTK_WIDGET (combo_box), &border);
|
get_widget_padding (GTK_WIDGET (combo_box), &padding);
|
||||||
sx -= border.left;
|
sx -= padding.left;
|
||||||
|
|
||||||
if (combo_box->priv->popup_fixed_width)
|
if (combo_box->priv->popup_fixed_width)
|
||||||
gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
|
gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
|
||||||
@ -2375,13 +2375,13 @@ gtk_combo_box_popdown (GtkComboBox *combo_box)
|
|||||||
&req, NULL); \
|
&req, NULL); \
|
||||||
\
|
\
|
||||||
if (is_rtl) \
|
if (is_rtl) \
|
||||||
child.x = allocation->x + border.right; \
|
child.x = allocation->x + padding.right; \
|
||||||
else \
|
else \
|
||||||
child.x = allocation->x + allocation->width - req.width - border.left; \
|
child.x = allocation->x + allocation->width - req.width - padding.left; \
|
||||||
\
|
\
|
||||||
child.y = allocation->y + border.top; \
|
child.y = allocation->y + padding.top; \
|
||||||
child.width = req.width; \
|
child.width = req.width; \
|
||||||
child.height = allocation->height - (border.top + border.bottom); \
|
child.height = allocation->height - (padding.top + padding.bottom); \
|
||||||
child.width = MAX (1, child.width); \
|
child.width = MAX (1, child.width); \
|
||||||
child.height = MAX (1, child.height); \
|
child.height = MAX (1, child.height); \
|
||||||
\
|
\
|
||||||
@ -2399,11 +2399,11 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
|
|||||||
GtkAllocation child;
|
GtkAllocation child;
|
||||||
GtkRequisition req;
|
GtkRequisition req;
|
||||||
gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
|
gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
|
||||||
GtkBorder border;
|
GtkBorder padding;
|
||||||
|
|
||||||
gtk_widget_set_allocation (widget, allocation);
|
gtk_widget_set_allocation (widget, allocation);
|
||||||
child_widget = gtk_bin_get_child (GTK_BIN (widget));
|
child_widget = gtk_bin_get_child (GTK_BIN (widget));
|
||||||
get_widget_padding (widget, &border);
|
get_widget_padding (widget, &padding);
|
||||||
|
|
||||||
gtk_widget_style_get (widget,
|
gtk_widget_style_get (widget,
|
||||||
"focus-line-width", &focus_width,
|
"focus-line-width", &focus_width,
|
||||||
@ -2414,21 +2414,21 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
if (priv->cell_view)
|
if (priv->cell_view)
|
||||||
{
|
{
|
||||||
GtkBorder button_border;
|
GtkBorder button_padding;
|
||||||
gint width;
|
gint width;
|
||||||
guint border_width;
|
guint border_width;
|
||||||
|
|
||||||
/* menu mode */
|
/* menu mode */
|
||||||
allocation->x += border.left;
|
allocation->x += padding.left;
|
||||||
allocation->y += border.top;
|
allocation->y += padding.top;
|
||||||
allocation->width -= border.left + border.right;
|
allocation->width -= padding.left + padding.right;
|
||||||
allocation->height -= border.top + border.bottom;
|
allocation->height -= padding.top + padding.bottom;
|
||||||
|
|
||||||
gtk_widget_size_allocate (priv->button, allocation);
|
gtk_widget_size_allocate (priv->button, allocation);
|
||||||
|
|
||||||
/* set some things ready */
|
/* set some things ready */
|
||||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->button));
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->button));
|
||||||
get_widget_padding (priv->button, &button_border);
|
get_widget_padding (priv->button, &button_padding);
|
||||||
|
|
||||||
child.x = allocation->x;
|
child.x = allocation->x;
|
||||||
child.y = allocation->y;
|
child.y = allocation->y;
|
||||||
@ -2437,12 +2437,12 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
|
|||||||
|
|
||||||
if (!priv->is_cell_renderer)
|
if (!priv->is_cell_renderer)
|
||||||
{
|
{
|
||||||
child.x += border_width + button_border.left + focus_width + focus_pad;
|
child.x += border_width + button_padding.left + focus_width + focus_pad;
|
||||||
child.y += border_width + button_border.top + focus_width + focus_pad;
|
child.y += border_width + button_padding.top + focus_width + focus_pad;
|
||||||
width -= (2 * (border_width + focus_width + focus_pad)) +
|
width -= (2 * (border_width + focus_width + focus_pad)) +
|
||||||
button_border.left + button_border.right;
|
button_padding.left + button_padding.right;
|
||||||
child.height -= (2 * (border_width + focus_width + focus_pad)) +
|
child.height -= (2 * (border_width + focus_width + focus_pad)) +
|
||||||
button_border.top + button_border.bottom;
|
button_padding.top + button_padding.bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* handle the children */
|
/* handle the children */
|
||||||
@ -2474,7 +2474,7 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
child.width = child.x;
|
child.width = child.x;
|
||||||
child.x = allocation->x
|
child.x = allocation->x
|
||||||
+ border_width + button_border.left + focus_width + focus_pad;
|
+ border_width + button_padding.left + focus_width + focus_pad;
|
||||||
child.width -= child.x;
|
child.width -= child.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2512,11 +2512,11 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
|
|||||||
GTK_COMBO_BOX_SIZE_ALLOCATE_BUTTON
|
GTK_COMBO_BOX_SIZE_ALLOCATE_BUTTON
|
||||||
|
|
||||||
if (is_rtl)
|
if (is_rtl)
|
||||||
child.x = allocation->x + req.width + border.right;
|
child.x = allocation->x + req.width + padding.right;
|
||||||
else
|
else
|
||||||
child.x = allocation->x + border.left;
|
child.x = allocation->x + padding.left;
|
||||||
child.y = allocation->y + border.top;
|
child.y = allocation->y + padding.top;
|
||||||
child.width = allocation->width - req.width - (border.left + border.right);
|
child.width = allocation->width - req.width - (padding.left + padding.right);
|
||||||
child.width = MAX (1, child.width);
|
child.width = MAX (1, child.width);
|
||||||
child.height = MAX (1, child.height);
|
child.height = MAX (1, child.height);
|
||||||
gtk_widget_size_allocate (child_widget, &child);
|
gtk_widget_size_allocate (child_widget, &child);
|
||||||
@ -2542,32 +2542,32 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
|
|||||||
|
|
||||||
if (priv->cell_view_frame)
|
if (priv->cell_view_frame)
|
||||||
{
|
{
|
||||||
child.x += border.left + border_width;
|
child.x += padding.left + border_width;
|
||||||
child.y += border.top + border_width;
|
child.y += padding.top + border_width;
|
||||||
child.width = MAX (1, child.width - (2 * border_width) - (border.left + border.right));
|
child.width = MAX (1, child.width - (2 * border_width) - (padding.left + padding.right));
|
||||||
child.height = MAX (1, child.height - (2 * border_width) - (border.top + border.bottom));
|
child.height = MAX (1, child.height - (2 * border_width) - (padding.top + padding.bottom));
|
||||||
gtk_widget_size_allocate (priv->cell_view_frame, &child);
|
gtk_widget_size_allocate (priv->cell_view_frame, &child);
|
||||||
|
|
||||||
/* the sample */
|
/* the sample */
|
||||||
if (priv->has_frame)
|
if (priv->has_frame)
|
||||||
{
|
{
|
||||||
GtkBorder frame_border;
|
GtkBorder frame_padding;
|
||||||
|
|
||||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame));
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame));
|
||||||
get_widget_padding (priv->cell_view_frame, &frame_border);
|
get_widget_padding (priv->cell_view_frame, &frame_padding);
|
||||||
|
|
||||||
child.x += border_width + frame_border.left;
|
child.x += border_width + frame_padding.left;
|
||||||
child.y += border_width + frame_border.right;
|
child.y += border_width + frame_padding.right;
|
||||||
child.width -= (2 * border_width) + frame_border.left + frame_border.right;
|
child.width -= (2 * border_width) + frame_padding.left + frame_padding.right;
|
||||||
child.height -= (2 * border_width) + frame_border.top + frame_border.bottom;
|
child.height -= (2 * border_width) + frame_padding.top + frame_padding.bottom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
child.x += border.left + border_width;
|
child.x += padding.left + border_width;
|
||||||
child.y += border.top + border_width;
|
child.y += padding.top + border_width;
|
||||||
child.width -= (2 * border_width) - (border.left + border.right);
|
child.width -= (2 * border_width) - (padding.left + padding.right);
|
||||||
child.height -= (2 * border_width) - (border.top + border.bottom);
|
child.height -= (2 * border_width) - (padding.top + padding.bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gtk_widget_get_visible (priv->popup_window))
|
if (gtk_widget_get_visible (priv->popup_window))
|
||||||
@ -5269,7 +5269,7 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget,
|
|||||||
gint child_min, child_nat;
|
gint child_min, child_nat;
|
||||||
GtkStyleContext *style_context;
|
GtkStyleContext *style_context;
|
||||||
GtkStateFlags state;
|
GtkStateFlags state;
|
||||||
GtkBorder border;
|
GtkBorder padding;
|
||||||
gfloat arrow_scaling;
|
gfloat arrow_scaling;
|
||||||
|
|
||||||
child = gtk_bin_get_child (GTK_BIN (widget));
|
child = gtk_bin_get_child (GTK_BIN (widget));
|
||||||
@ -5287,7 +5287,7 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget,
|
|||||||
style_context = gtk_widget_get_style_context (widget);
|
style_context = gtk_widget_get_style_context (widget);
|
||||||
state = gtk_widget_get_state_flags (widget);
|
state = gtk_widget_get_state_flags (widget);
|
||||||
|
|
||||||
get_widget_padding (widget, &border);
|
get_widget_padding (widget, &padding);
|
||||||
gtk_style_context_get (style_context, state,
|
gtk_style_context_get (style_context, state,
|
||||||
"font", &font_desc,
|
"font", &font_desc,
|
||||||
NULL);
|
NULL);
|
||||||
@ -5311,16 +5311,16 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
gint sep_width, arrow_width;
|
gint sep_width, arrow_width;
|
||||||
gint border_width, xpad;
|
gint border_width, xpad;
|
||||||
GtkBorder button_border;
|
GtkBorder button_padding;
|
||||||
|
|
||||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (combo_box));
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (combo_box));
|
||||||
get_widget_padding (priv->button, &button_border);
|
get_widget_padding (priv->button, &button_padding);
|
||||||
|
|
||||||
gtk_widget_get_preferred_width (priv->separator, &sep_width, NULL);
|
gtk_widget_get_preferred_width (priv->separator, &sep_width, NULL);
|
||||||
gtk_widget_get_preferred_width (priv->arrow, &arrow_width, NULL);
|
gtk_widget_get_preferred_width (priv->arrow, &arrow_width, NULL);
|
||||||
|
|
||||||
xpad = 2 * (border_width + focus_width + focus_pad) +
|
xpad = 2 * (border_width + focus_width + focus_pad) +
|
||||||
button_border.left + button_border.right + border.left + border.right;
|
button_padding.left + button_padding.right + padding.left + padding.right;
|
||||||
|
|
||||||
minimum_width = child_min + sep_width + arrow_width + xpad;
|
minimum_width = child_min + sep_width + arrow_width + xpad;
|
||||||
natural_width = child_nat + sep_width + arrow_width + xpad;
|
natural_width = child_nat + sep_width + arrow_width + xpad;
|
||||||
@ -5353,11 +5353,11 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget,
|
|||||||
if (priv->has_frame)
|
if (priv->has_frame)
|
||||||
{
|
{
|
||||||
gint border_width, xpad;
|
gint border_width, xpad;
|
||||||
GtkBorder frame_border;
|
GtkBorder frame_padding;
|
||||||
|
|
||||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame));
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame));
|
||||||
get_widget_padding (priv->cell_view_frame, &frame_border);
|
get_widget_padding (priv->cell_view_frame, &frame_padding);
|
||||||
xpad = (2 * border_width) + frame_border.left + frame_border.right;
|
xpad = (2 * border_width) + frame_padding.left + frame_padding.right;
|
||||||
|
|
||||||
minimum_width += xpad;
|
minimum_width += xpad;
|
||||||
natural_width += xpad;
|
natural_width += xpad;
|
||||||
@ -5372,8 +5372,8 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget,
|
|||||||
natural_width += button_nat_width;
|
natural_width += button_nat_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
minimum_width += border.left + border.right;
|
minimum_width += padding.left + padding.right;
|
||||||
natural_width += border.left + border.right;
|
natural_width += padding.left + padding.right;
|
||||||
|
|
||||||
if (minimum_size)
|
if (minimum_size)
|
||||||
*minimum_size = minimum_width;
|
*minimum_size = minimum_width;
|
||||||
@ -5419,7 +5419,7 @@ gtk_combo_box_get_preferred_height_for_width (GtkWidget *widget,
|
|||||||
gint min_height = 0, nat_height = 0;
|
gint min_height = 0, nat_height = 0;
|
||||||
gint size;
|
gint size;
|
||||||
GtkWidget *child;
|
GtkWidget *child;
|
||||||
GtkBorder border;
|
GtkBorder padding;
|
||||||
|
|
||||||
gtk_widget_style_get (GTK_WIDGET (widget),
|
gtk_widget_style_get (GTK_WIDGET (widget),
|
||||||
"focus-line-width", &focus_width,
|
"focus-line-width", &focus_width,
|
||||||
@ -5428,8 +5428,8 @@ gtk_combo_box_get_preferred_height_for_width (GtkWidget *widget,
|
|||||||
|
|
||||||
child = gtk_bin_get_child (GTK_BIN (widget));
|
child = gtk_bin_get_child (GTK_BIN (widget));
|
||||||
|
|
||||||
get_widget_padding (widget, &border);
|
get_widget_padding (widget, &padding);
|
||||||
size = avail_size - border.left;
|
size = avail_size;
|
||||||
|
|
||||||
if (!priv->tree_view)
|
if (!priv->tree_view)
|
||||||
{
|
{
|
||||||
@ -5439,10 +5439,10 @@ gtk_combo_box_get_preferred_height_for_width (GtkWidget *widget,
|
|||||||
/* calculate x/y padding and separator/arrow size */
|
/* calculate x/y padding and separator/arrow size */
|
||||||
gint sep_width, arrow_width, sep_height, arrow_height;
|
gint sep_width, arrow_width, sep_height, arrow_height;
|
||||||
gint border_width, xpad, ypad;
|
gint border_width, xpad, ypad;
|
||||||
GtkBorder button_border;
|
GtkBorder button_padding;
|
||||||
|
|
||||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (combo_box));
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (combo_box));
|
||||||
get_widget_padding (priv->button, &button_border);
|
get_widget_padding (priv->button, &button_padding);
|
||||||
|
|
||||||
gtk_widget_get_preferred_width (priv->separator, &sep_width, NULL);
|
gtk_widget_get_preferred_width (priv->separator, &sep_width, NULL);
|
||||||
gtk_widget_get_preferred_width (priv->arrow, &arrow_width, NULL);
|
gtk_widget_get_preferred_width (priv->arrow, &arrow_width, NULL);
|
||||||
@ -5452,9 +5452,9 @@ gtk_combo_box_get_preferred_height_for_width (GtkWidget *widget,
|
|||||||
arrow_width, &arrow_height, NULL);
|
arrow_width, &arrow_height, NULL);
|
||||||
|
|
||||||
xpad = 2 * (border_width + focus_width + focus_pad) +
|
xpad = 2 * (border_width + focus_width + focus_pad) +
|
||||||
button_border.left + button_border.right;
|
button_padding.left + button_padding.right;
|
||||||
ypad = 2 * (border_width + focus_width + focus_pad) +
|
ypad = 2 * (border_width + focus_width + focus_pad) +
|
||||||
button_border.top + button_border.bottom;
|
button_padding.top + button_padding.bottom;
|
||||||
|
|
||||||
size -= sep_width + arrow_width + xpad;
|
size -= sep_width + arrow_width + xpad;
|
||||||
|
|
||||||
@ -5500,14 +5500,14 @@ gtk_combo_box_get_preferred_height_for_width (GtkWidget *widget,
|
|||||||
|
|
||||||
if (priv->cell_view_frame && priv->has_frame)
|
if (priv->cell_view_frame && priv->has_frame)
|
||||||
{
|
{
|
||||||
GtkBorder frame_border;
|
GtkBorder frame_padding;
|
||||||
gint border_width;
|
gint border_width;
|
||||||
|
|
||||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame));
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame));
|
||||||
get_widget_padding (GTK_WIDGET (priv->cell_view_frame), &frame_border);
|
get_widget_padding (GTK_WIDGET (priv->cell_view_frame), &frame_padding);
|
||||||
|
|
||||||
xpad = (2 * border_width) + border.left + frame_border.right;
|
xpad = (2 * border_width) + padding.left + frame_padding.right;
|
||||||
ypad = (2 * border_width) + border.top + frame_border.bottom;
|
ypad = (2 * border_width) + padding.top + frame_padding.bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
size -= but_width;
|
size -= but_width;
|
||||||
@ -5525,8 +5525,8 @@ gtk_combo_box_get_preferred_height_for_width (GtkWidget *widget,
|
|||||||
nat_height += ypad;
|
nat_height += ypad;
|
||||||
}
|
}
|
||||||
|
|
||||||
min_height += border.top + border.bottom;
|
min_height += padding.top + padding.bottom;
|
||||||
nat_height += border.top + border.bottom;
|
nat_height += padding.top + padding.bottom;
|
||||||
|
|
||||||
if (minimum_size)
|
if (minimum_size)
|
||||||
*minimum_size = min_height;
|
*minimum_size = min_height;
|
||||||
|
Loading…
Reference in New Issue
Block a user