Commit 02cd5737 authored by Matthias Clasen's avatar Matthias Clasen

Don't let themes override explicit border-width in dialogs

This fixes an issue where the theme-provided border-width prevents
dialog contents from lining up properly with the headerbar. To make
this work in message dialogs, we have to explicitly set the border-
width of the action area to 0.
parent 7da97a36
......@@ -247,6 +247,7 @@ struct _GtkContainerPrivate
guint resize_handler;
guint border_width : 16;
guint border_width_set : 1;
guint has_focus_chain : 1;
guint reallocate_redraws : 1;
......@@ -1381,6 +1382,7 @@ gtk_container_init (GtkContainer *container)
priv->border_width = 0;
priv->resize_mode = GTK_RESIZE_PARENT;
priv->reallocate_redraws = FALSE;
priv->border_width_set = FALSE;
}
static void
......@@ -1462,6 +1464,31 @@ gtk_container_get_property (GObject *object,
}
}
gboolean
_gtk_container_get_border_width_set (GtkContainer *container)
{
GtkContainerPrivate *priv;
g_return_val_if_fail (GTK_IS_CONTAINER (container), FALSE);
priv = container->priv;
return priv->border_width_set;
}
void
_gtk_container_set_border_width_set (GtkContainer *container,
gboolean border_width_set)
{
GtkContainerPrivate *priv;
g_return_if_fail (GTK_IS_CONTAINER (container));
priv = container->priv;
priv->border_width_set = border_width_set ? TRUE : FALSE;
}
/**
* gtk_container_set_border_width:
* @container: a #GtkContainer
......@@ -1492,6 +1519,8 @@ gtk_container_set_border_width (GtkContainer *container,
if (priv->border_width != border_width)
{
priv->border_width = border_width;
_gtk_container_set_border_width_set (container, TRUE);
g_object_notify (G_OBJECT (container), "border-width");
if (gtk_widget_get_realized (GTK_WIDGET (container)))
......
......@@ -41,6 +41,9 @@ gboolean _gtk_container_get_reallocate_redraws (GtkContainer *container);
void _gtk_container_stop_idle_sizer (GtkContainer *container);
void _gtk_container_maybe_start_idle_sizer (GtkContainer *container);
gboolean _gtk_container_get_border_width_set (GtkContainer *container);
void _gtk_container_set_border_width_set (GtkContainer *container,
gboolean border_width_set);
G_END_DECLS
......
......@@ -35,6 +35,7 @@
#include "gtkmarshalers.h"
#include "gtkbox.h"
#include "gtkboxprivate.h"
#include "gtkcontainerprivate.h"
#include "gtkmain.h"
#include "gtkintl.h"
#include "gtkbindings.h"
......@@ -566,6 +567,15 @@ gtk_dialog_class_init (GtkDialogClass *class)
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* GtkDialog:content-area-border:
*
* The default border width used around the
* content area of the dialog, as returned by
* gtk_dialog_get_content_area(), unless gtk_container_set_border_width()
* was called on that widget directly.
*
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("content-area-border",
P_("Content area border"),
......@@ -656,9 +666,11 @@ update_spacings (GtkDialog *dialog)
"button-spacing", &button_spacing,
"action-area-border", &action_area_border,
NULL);
gtk_container_set_border_width (GTK_CONTAINER (priv->vbox),
content_area_border);
if (!_gtk_container_get_border_width_set (GTK_CONTAINER (priv->vbox)))
gtk_container_set_border_width (GTK_CONTAINER (priv->vbox),
content_area_border);
if (!_gtk_box_get_spacing_set (GTK_BOX (priv->vbox)))
{
gtk_box_set_spacing (GTK_BOX (priv->vbox), content_area_spacing);
......@@ -667,8 +679,10 @@ update_spacings (GtkDialog *dialog)
gtk_box_set_spacing (GTK_BOX (priv->action_area),
button_spacing);
gtk_container_set_border_width (GTK_CONTAINER (priv->action_area),
action_area_border);
if (!_gtk_container_get_border_width_set (GTK_CONTAINER (priv->action_area)))
gtk_container_set_border_width (GTK_CONTAINER (priv->action_area),
action_area_border);
}
static void
......
......@@ -87,6 +87,11 @@
<property name="position">0</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="border_width">0</property>
</object>
</child>
</object>
</child>
</template>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment