headerbar: Remove hpadding and vpadding properties

We really want these to be set by the theme, not programmatically.

https://bugzilla.gnome.org/show_bug.cgi?id=706929
This commit is contained in:
Emmanuele Bassi 2013-08-28 11:48:29 +01:00
parent d4679c0a13
commit 889e63faed
2 changed files with 21 additions and 71 deletions

View File

@ -44,8 +44,6 @@
*/
#define DEFAULT_SPACING 6
#define DEFAULT_HPADDING 6
#define DEFAULT_VPADDING 6
struct _GtkHeaderBarPrivate
{
@ -59,8 +57,6 @@ struct _GtkHeaderBarPrivate
GtkWidget *close_button;
GtkWidget *separator;
gint spacing;
gint hpadding;
gint vpadding;
GList *children;
};
@ -298,8 +294,6 @@ gtk_header_bar_init (GtkHeaderBar *bar)
priv->separator = NULL;
priv->children = NULL;
priv->spacing = DEFAULT_SPACING;
priv->hpadding = DEFAULT_HPADDING;
priv->vpadding = DEFAULT_VPADDING;
init_sizing_box (bar);
construct_label_box (bar);
@ -413,13 +407,13 @@ gtk_header_bar_get_size (GtkWidget *widget,
if (GTK_ORIENTATION_HORIZONTAL == orientation)
{
minimum += 2 * priv->hpadding + css_borders.left + css_borders.right;
natural += 2 * priv->hpadding + css_borders.left + css_borders.right;
minimum += css_borders.left + css_borders.right;
natural += css_borders.left + css_borders.right;
}
else
{
minimum += 2 * priv->vpadding + css_borders.top + css_borders.bottom;
natural += 2 * priv->vpadding + css_borders.top + css_borders.bottom;
minimum += css_borders.top + css_borders.bottom;
natural += css_borders.top + css_borders.bottom;
}
if (minimum_size)
@ -445,8 +439,6 @@ gtk_header_bar_compute_size_for_orientation (GtkWidget *widget,
gint nvis_children;
GtkBorder css_borders;
avail_size -= 2 * priv->vpadding;
nvis_children = 0;
for (children = priv->children; children != NULL; children = children->next)
@ -504,8 +496,8 @@ gtk_header_bar_compute_size_for_orientation (GtkWidget *widget,
get_css_padding_and_border (widget, &css_borders);
required_size += 2 * priv->hpadding + css_borders.left + css_borders.right;
required_natural += 2 * priv->hpadding + css_borders.left + css_borders.right;
required_size += css_borders.left + css_borders.right;
required_natural += css_borders.left + css_borders.right;
if (minimum_size)
*minimum_size = required_size;
@ -529,7 +521,7 @@ gtk_header_bar_compute_size_for_opposing_orientation (GtkWidget *widget,
gint computed_natural = 0;
GtkRequestedSize *sizes;
GtkPackType packing;
gint size;
gint size = 0;
gint i;
gint child_size;
gint child_minimum;
@ -542,7 +534,6 @@ gtk_header_bar_compute_size_for_opposing_orientation (GtkWidget *widget,
return;
sizes = g_newa (GtkRequestedSize, nvis_children);
size = avail_size - 2 * priv->hpadding;
/* Retrieve desired size for visible children */
for (i = 0, children = priv->children; children; children = children->next)
@ -562,7 +553,7 @@ gtk_header_bar_compute_size_for_opposing_orientation (GtkWidget *widget,
}
/* Bring children up to size first */
size = gtk_distribute_natural_allocation (MAX (0, size), nvis_children, sizes);
size = gtk_distribute_natural_allocation (MAX (0, avail_size), nvis_children, sizes);
/* Allocate child positions. */
for (packing = GTK_PACK_START; packing <= GTK_PACK_END; ++packing)
@ -629,8 +620,8 @@ gtk_header_bar_compute_size_for_opposing_orientation (GtkWidget *widget,
get_css_padding_and_border (widget, &css_borders);
computed_minimum += 2 * priv->vpadding + css_borders.top + css_borders.bottom;
computed_natural += 2 * priv->vpadding + css_borders.top + css_borders.bottom;
computed_minimum += css_borders.top + css_borders.bottom;
computed_natural += css_borders.top + css_borders.bottom;
if (minimum_size)
*minimum_size = computed_minimum;
@ -705,9 +696,8 @@ gtk_header_bar_size_allocate (GtkWidget *widget,
sizes = g_newa (GtkRequestedSize, nvis_children);
get_css_padding_and_border (widget, &css_borders);
width = allocation->width - nvis_children * priv->spacing -
2 * priv->hpadding - css_borders.left - css_borders.right;
height = allocation->height - 2 * priv->vpadding - css_borders.top - css_borders.bottom;
width = allocation->width - nvis_children * priv->spacing - css_borders.left - css_borders.right;
height = allocation->height - css_borders.top - css_borders.bottom;
i = 0;
for (l = priv->children; l; l = l->next)
@ -762,12 +752,12 @@ gtk_header_bar_size_allocate (GtkWidget *widget,
side[0] = side[1] = 0;
for (packing = GTK_PACK_START; packing <= GTK_PACK_END; packing++)
{
child_allocation.y = allocation->y + priv->vpadding + css_borders.top;
child_allocation.y = allocation->y + css_borders.top;
child_allocation.height = height;
if (packing == GTK_PACK_START)
x = allocation->x + priv->hpadding + css_borders.left;
x = allocation->x + css_borders.left;
else
x = allocation->x + allocation->width - close_width - priv->hpadding - css_borders.right;
x = allocation->x + allocation->width - close_width - css_borders.right;
if (packing == GTK_PACK_START)
{
@ -823,7 +813,7 @@ gtk_header_bar_size_allocate (GtkWidget *widget,
side[GTK_PACK_END] += close_width;
child_allocation.y = allocation->y + priv->vpadding + css_borders.top;
child_allocation.y = allocation->y + css_borders.top;
child_allocation.height = height;
width = MAX (side[0], side[1]);
@ -854,16 +844,16 @@ gtk_header_bar_size_allocate (GtkWidget *widget,
if (priv->close_button)
{
if (direction == GTK_TEXT_DIR_RTL)
child_allocation.x = allocation->x + priv->hpadding + css_borders.left;
child_allocation.x = allocation->x + css_borders.left;
else
child_allocation.x = allocation->x + allocation->width - priv->hpadding - css_borders.right - close_button_width;
child_allocation.x = allocation->x + allocation->width - css_borders.right - close_button_width;
child_allocation.width = close_button_width;
gtk_widget_size_allocate (priv->close_button, &child_allocation);
if (direction == GTK_TEXT_DIR_RTL)
child_allocation.x = allocation->x + priv->hpadding + css_borders.left + close_button_width + priv->spacing;
child_allocation.x = allocation->x + css_borders.left + close_button_width + priv->spacing;
else
child_allocation.x = allocation->x + allocation->width - priv->hpadding - css_borders.right - close_button_width - priv->spacing - separator_width;
child_allocation.x = allocation->x + allocation->width - css_borders.right - close_button_width - priv->spacing - separator_width;
child_allocation.width = separator_width;
gtk_widget_size_allocate (priv->separator, &child_allocation);
}
@ -1108,14 +1098,6 @@ gtk_header_bar_get_property (GObject *object,
g_value_set_int (value, priv->spacing);
break;
case PROP_HPADDING:
g_value_set_int (value, priv->hpadding);
break;
case PROP_VPADDING:
g_value_set_int (value, priv->vpadding);
break;
case PROP_SHOW_CLOSE_BUTTON:
g_value_set_boolean (value, gtk_header_bar_get_show_close_button (bar));
break;
@ -1154,16 +1136,6 @@ gtk_header_bar_set_property (GObject *object,
gtk_widget_queue_resize (GTK_WIDGET (bar));
break;
case PROP_HPADDING:
priv->hpadding = g_value_get_int (value);
gtk_widget_queue_resize (GTK_WIDGET (bar));
break;
case PROP_VPADDING:
priv->vpadding = g_value_get_int (value);
gtk_widget_queue_resize (GTK_WIDGET (bar));
break;
case PROP_SHOW_CLOSE_BUTTON:
gtk_header_bar_set_show_close_button (bar, g_value_get_boolean (value));
break;
@ -1498,24 +1470,6 @@ gtk_header_bar_class_init (GtkHeaderBarClass *class)
DEFAULT_SPACING,
GTK_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_HPADDING,
g_param_spec_int ("hpadding",
P_("Horizontal padding"),
P_("The amount of space to the left and right of children"),
0, G_MAXINT,
DEFAULT_HPADDING,
GTK_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_VPADDING,
g_param_spec_int ("vpadding",
P_("Vertical padding"),
P_("The amount of space to the above and below children"),
0, G_MAXINT,
DEFAULT_VPADDING,
GTK_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_SHOW_CLOSE_BUTTON,
g_param_spec_boolean ("show-close-button",

View File

@ -5268,11 +5268,7 @@ create_titlebar (GtkWindow *window)
gchar *title;
titlebar = gtk_header_bar_new ();
g_object_set (titlebar,
"spacing", 0,
"hpadding", 0,
"vpadding", 0,
NULL);
g_object_set (titlebar, "spacing", 0, NULL);
context = gtk_widget_get_style_context (titlebar);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_TITLEBAR);
gtk_style_context_add_class (context, "default-decoration");