mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 21:21:21 +00:00
Do not use GtkBoxChild in GtkButtonBox.
Do not store the is_secondary bit in the deprecated parent struct, use a simple flag on the object instead. Fixes bug #624367.
This commit is contained in:
parent
133f0744b9
commit
0754f2d72f
@ -81,6 +81,8 @@ enum {
|
|||||||
CHILD_PROP_SECONDARY
|
CHILD_PROP_SECONDARY
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define GTK_BOX_SECONDARY_CHILD "gtk-box-secondary-child"
|
||||||
|
|
||||||
static void gtk_button_box_set_property (GObject *object,
|
static void gtk_button_box_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
const GValue *value,
|
const GValue *value,
|
||||||
@ -93,6 +95,8 @@ static void gtk_button_box_size_request (GtkWidget *widget,
|
|||||||
GtkRequisition *requisition);
|
GtkRequisition *requisition);
|
||||||
static void gtk_button_box_size_allocate (GtkWidget *widget,
|
static void gtk_button_box_size_allocate (GtkWidget *widget,
|
||||||
GtkAllocation *allocation);
|
GtkAllocation *allocation);
|
||||||
|
static void gtk_button_box_remove (GtkContainer *container,
|
||||||
|
GtkWidget *widget);
|
||||||
static void gtk_button_box_set_child_property (GtkContainer *container,
|
static void gtk_button_box_set_child_property (GtkContainer *container,
|
||||||
GtkWidget *child,
|
GtkWidget *child,
|
||||||
guint property_id,
|
guint property_id,
|
||||||
@ -128,6 +132,7 @@ gtk_button_box_class_init (GtkButtonBoxClass *class)
|
|||||||
widget_class->size_request = gtk_button_box_size_request;
|
widget_class->size_request = gtk_button_box_size_request;
|
||||||
widget_class->size_allocate = gtk_button_box_size_allocate;
|
widget_class->size_allocate = gtk_button_box_size_allocate;
|
||||||
|
|
||||||
|
container_class->remove = gtk_button_box_remove;
|
||||||
container_class->set_child_property = gtk_button_box_set_child_property;
|
container_class->set_child_property = gtk_button_box_set_child_property;
|
||||||
container_class->get_child_property = gtk_button_box_get_child_property;
|
container_class->get_child_property = gtk_button_box_get_child_property;
|
||||||
|
|
||||||
@ -283,6 +288,19 @@ gtk_button_box_get_child_property (GtkContainer *container,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_button_box_remove (GtkContainer *container,
|
||||||
|
GtkWidget *widget)
|
||||||
|
{
|
||||||
|
/* clear is_secondary flag in case the widget
|
||||||
|
* is added to another container */
|
||||||
|
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (container),
|
||||||
|
widget,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
|
GTK_CONTAINER_CLASS (gtk_button_box_parent_class)->remove (container, widget);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_button_box_set_layout:
|
* gtk_button_box_set_layout:
|
||||||
* @widget: a #GtkButtonBox
|
* @widget: a #GtkButtonBox
|
||||||
@ -341,33 +359,10 @@ gboolean
|
|||||||
gtk_button_box_get_child_secondary (GtkButtonBox *widget,
|
gtk_button_box_get_child_secondary (GtkButtonBox *widget,
|
||||||
GtkWidget *child)
|
GtkWidget *child)
|
||||||
{
|
{
|
||||||
GtkBoxChild *child_info = NULL;
|
|
||||||
GList *list, *children;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GTK_IS_BUTTON_BOX (widget), FALSE);
|
g_return_val_if_fail (GTK_IS_BUTTON_BOX (widget), FALSE);
|
||||||
g_return_val_if_fail (GTK_IS_WIDGET (child), FALSE);
|
g_return_val_if_fail (GTK_IS_WIDGET (child), FALSE);
|
||||||
|
|
||||||
list = children = gtk_container_get_children (GTK_CONTAINER (widget));
|
return (g_object_get_data (G_OBJECT (child), GTK_BOX_SECONDARY_CHILD) != NULL);
|
||||||
|
|
||||||
while (list)
|
|
||||||
{
|
|
||||||
child_info = list->data;
|
|
||||||
if (child_info->widget == child)
|
|
||||||
break;
|
|
||||||
|
|
||||||
list = list->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (list == NULL)
|
|
||||||
{
|
|
||||||
g_list_free (children);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_list_free (children);
|
|
||||||
return child_info->is_secondary;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -395,27 +390,13 @@ gtk_button_box_set_child_secondary (GtkButtonBox *widget,
|
|||||||
GtkWidget *child,
|
GtkWidget *child,
|
||||||
gboolean is_secondary)
|
gboolean is_secondary)
|
||||||
{
|
{
|
||||||
GList *list, *children;
|
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_BUTTON_BOX (widget));
|
g_return_if_fail (GTK_IS_BUTTON_BOX (widget));
|
||||||
g_return_if_fail (GTK_IS_WIDGET (child));
|
g_return_if_fail (GTK_IS_WIDGET (child));
|
||||||
g_return_if_fail (child->parent == GTK_WIDGET (widget));
|
g_return_if_fail (child->parent == GTK_WIDGET (widget));
|
||||||
|
|
||||||
|
g_object_set_data (G_OBJECT (child),
|
||||||
list = children = gtk_container_get_children (GTK_CONTAINER (widget));
|
GTK_BOX_SECONDARY_CHILD,
|
||||||
while (list)
|
is_secondary ? GINT_TO_POINTER (1) : NULL);
|
||||||
{
|
|
||||||
GtkBoxChild *child_info = list->data;
|
|
||||||
if (child_info->widget == child)
|
|
||||||
{
|
|
||||||
child_info->is_secondary = is_secondary;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
list = list->next;
|
|
||||||
}
|
|
||||||
g_list_free (children);
|
|
||||||
|
|
||||||
gtk_widget_child_notify (child, "secondary");
|
gtk_widget_child_notify (child, "secondary");
|
||||||
|
|
||||||
if (gtk_widget_get_visible (GTK_WIDGET (widget))
|
if (gtk_widget_get_visible (GTK_WIDGET (widget))
|
||||||
@ -429,13 +410,12 @@ gtk_button_box_set_child_secondary (GtkButtonBox *widget,
|
|||||||
void
|
void
|
||||||
_gtk_button_box_child_requisition (GtkWidget *widget,
|
_gtk_button_box_child_requisition (GtkWidget *widget,
|
||||||
int *nvis_children,
|
int *nvis_children,
|
||||||
int *nvis_secondaries,
|
int *nvis_secondaries,
|
||||||
int *width,
|
int *width,
|
||||||
int *height)
|
int *height)
|
||||||
{
|
{
|
||||||
GtkButtonBoxPriv *priv;
|
GtkButtonBoxPriv *priv;
|
||||||
GtkButtonBox *bbox;
|
GtkButtonBox *bbox;
|
||||||
GtkBoxChild *child;
|
|
||||||
GList *children, *list;
|
GList *children, *list;
|
||||||
gint nchildren;
|
gint nchildren;
|
||||||
gint nsecondaries;
|
gint nsecondaries;
|
||||||
@ -485,19 +465,24 @@ _gtk_button_box_child_requisition (GtkWidget *widget,
|
|||||||
|
|
||||||
while (children)
|
while (children)
|
||||||
{
|
{
|
||||||
|
GtkWidget *child;
|
||||||
|
gboolean is_secondary;
|
||||||
|
|
||||||
child = children->data;
|
child = children->data;
|
||||||
children = children->next;
|
children = children->next;
|
||||||
|
|
||||||
if (gtk_widget_get_visible (child->widget))
|
is_secondary = gtk_button_box_get_child_secondary (bbox, child);
|
||||||
|
|
||||||
|
if (gtk_widget_get_visible (child))
|
||||||
{
|
{
|
||||||
nchildren += 1;
|
nchildren += 1;
|
||||||
gtk_widget_size_request (child->widget, &child_requisition);
|
gtk_widget_size_request (child, &child_requisition);
|
||||||
|
|
||||||
if (child_requisition.width + ipad_w > needed_width)
|
if (child_requisition.width + ipad_w > needed_width)
|
||||||
needed_width = child_requisition.width + ipad_w;
|
needed_width = child_requisition.width + ipad_w;
|
||||||
if (child_requisition.height + ipad_h > needed_height)
|
if (child_requisition.height + ipad_h > needed_height)
|
||||||
needed_height = child_requisition.height + ipad_h;
|
needed_height = child_requisition.height + ipad_h;
|
||||||
if (child->is_secondary)
|
if (is_secondary)
|
||||||
nsecondaries++;
|
nsecondaries++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -614,7 +599,6 @@ gtk_button_box_size_allocate (GtkWidget *widget,
|
|||||||
GtkButtonBoxPriv *priv;
|
GtkButtonBoxPriv *priv;
|
||||||
GtkBox *base_box;
|
GtkBox *base_box;
|
||||||
GtkButtonBox *box;
|
GtkButtonBox *box;
|
||||||
GtkBoxChild *child;
|
|
||||||
GList *children, *list;
|
GList *children, *list;
|
||||||
GtkAllocation child_allocation;
|
GtkAllocation child_allocation;
|
||||||
gint nvis_children;
|
gint nvis_children;
|
||||||
@ -810,10 +794,15 @@ gtk_button_box_size_allocate (GtkWidget *widget,
|
|||||||
|
|
||||||
while (children)
|
while (children)
|
||||||
{
|
{
|
||||||
|
GtkWidget *child;
|
||||||
|
gboolean is_secondary;
|
||||||
|
|
||||||
child = children->data;
|
child = children->data;
|
||||||
children = children->next;
|
children = children->next;
|
||||||
|
|
||||||
if (gtk_widget_get_visible (child->widget))
|
is_secondary = gtk_button_box_get_child_secondary (box, child);
|
||||||
|
|
||||||
|
if (gtk_widget_get_visible (child))
|
||||||
{
|
{
|
||||||
child_allocation.width = child_width;
|
child_allocation.width = child_width;
|
||||||
child_allocation.height = child_height;
|
child_allocation.height = child_height;
|
||||||
@ -822,7 +811,7 @@ gtk_button_box_size_allocate (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
child_allocation.y = y;
|
child_allocation.y = y;
|
||||||
|
|
||||||
if (child->is_secondary)
|
if (is_secondary)
|
||||||
{
|
{
|
||||||
child_allocation.x = secondary_x;
|
child_allocation.x = secondary_x;
|
||||||
secondary_x += childspace;
|
secondary_x += childspace;
|
||||||
@ -841,7 +830,7 @@ gtk_button_box_size_allocate (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
child_allocation.x = x;
|
child_allocation.x = x;
|
||||||
|
|
||||||
if (child->is_secondary)
|
if (is_secondary)
|
||||||
{
|
{
|
||||||
child_allocation.y = secondary_y;
|
child_allocation.y = secondary_y;
|
||||||
secondary_y += childspace;
|
secondary_y += childspace;
|
||||||
@ -853,7 +842,7 @@ gtk_button_box_size_allocate (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_size_allocate (child->widget, &child_allocation);
|
gtk_widget_size_allocate (child, &child_allocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -829,7 +829,6 @@ gtk_box_pack (GtkBox *box,
|
|||||||
child_info->expand = expand ? TRUE : FALSE;
|
child_info->expand = expand ? TRUE : FALSE;
|
||||||
child_info->fill = fill ? TRUE : FALSE;
|
child_info->fill = fill ? TRUE : FALSE;
|
||||||
child_info->pack = pack_type;
|
child_info->pack = pack_type;
|
||||||
child_info->is_secondary = FALSE;
|
|
||||||
|
|
||||||
private->children = g_list_append (private->children, child_info);
|
private->children = g_list_append (private->children, child_info);
|
||||||
|
|
||||||
|
@ -76,7 +76,6 @@ struct _GtkBoxClass
|
|||||||
* being used as padding around the widget; set when packed, %TRUE by default.
|
* being used as padding around the widget; set when packed, %TRUE by default.
|
||||||
* @pack: one of #GtkPackType indicating whether the child is packed with
|
* @pack: one of #GtkPackType indicating whether the child is packed with
|
||||||
* reference to the start (top/left) or end (bottom/right) of the GtkBox.
|
* reference to the start (top/left) or end (bottom/right) of the GtkBox.
|
||||||
* @is_secondary: %TRUE if the child is secondary
|
|
||||||
*
|
*
|
||||||
* The #GtkBoxChild holds a child widget of #GtkBox and describes how the child
|
* The #GtkBoxChild holds a child widget of #GtkBox and describes how the child
|
||||||
* is to be packed into the #GtkBox. All fields of this #GtkBoxChild should be
|
* is to be packed into the #GtkBox. All fields of this #GtkBoxChild should be
|
||||||
@ -96,7 +95,6 @@ struct _GtkBoxChild
|
|||||||
guint expand : 1;
|
guint expand : 1;
|
||||||
guint fill : 1;
|
guint fill : 1;
|
||||||
guint pack : 1;
|
guint pack : 1;
|
||||||
guint is_secondary : 1;
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user