Commit ebff86d6 authored by Matthias Clasen's avatar Matthias Clasen

box gadget: Make it possible to draw focus

There are widgets which use a box gadget and take focus,
like GtkCheckButton.
parent e837aa69
......@@ -36,6 +36,7 @@
typedef struct _GtkBoxGadgetPrivate GtkBoxGadgetPrivate;
struct _GtkBoxGadgetPrivate {
GtkOrientation orientation;
gboolean draw_focus;
GArray *children;
};
......@@ -448,6 +449,7 @@ gtk_box_gadget_draw (GtkCssGadget *gadget,
int height)
{
GtkBoxGadgetPrivate *priv = gtk_box_gadget_get_instance_private (GTK_BOX_GADGET (gadget));
GtkWidget *owner = gtk_css_gadget_get_owner (gadget);
guint i;
for (i = 0 ; i < priv->children->len; i++)
......@@ -455,18 +457,14 @@ gtk_box_gadget_draw (GtkCssGadget *gadget,
GtkBoxGadgetChild *child = &g_array_index (priv->children, GtkBoxGadgetChild, i);
if (GTK_IS_WIDGET (child->object))
{
gtk_container_propagate_draw (GTK_CONTAINER (gtk_css_gadget_get_owner (gadget)),
GTK_WIDGET (child->object),
cr);
}
gtk_container_propagate_draw (GTK_CONTAINER (owner), GTK_WIDGET (child->object), cr);
else
{
gtk_css_gadget_draw (GTK_CSS_GADGET (child->object),
cr);
}
gtk_css_gadget_draw (GTK_CSS_GADGET (child->object), cr);
}
if (priv->draw_focus && gtk_widget_has_visible_focus (owner))
return TRUE;
return FALSE;
}
......@@ -552,6 +550,15 @@ gtk_box_gadget_set_orientation (GtkBoxGadget *gadget,
priv->orientation = orientation;
}
void
gtk_box_gadget_set_draw_focus (GtkBoxGadget *gadget,
gboolean draw_focus)
{
GtkBoxGadgetPrivate *priv = gtk_box_gadget_get_instance_private (gadget);
priv->draw_focus = draw_focus;
}
static GtkCssNode *
get_css_node (GObject *child)
{
......
......@@ -56,6 +56,8 @@ GtkCssGadget * gtk_box_gadget_new_for_node (GtkCssNode
void gtk_box_gadget_set_orientation (GtkBoxGadget *gadget,
GtkOrientation orientation);
void gtk_box_gadget_set_draw_focus (GtkBoxGadget *gadget,
gboolean draw_focus);
void gtk_box_gadget_insert_widget (GtkBoxGadget *gadget,
int pos,
......
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