gtk/gtkexpander.c: use accessor functions to access GtkWidget
This commit is contained in:
parent
b62b834eb5
commit
f11207c33e
@ -430,7 +430,9 @@ gtk_expander_destroy (GtkObject *object)
|
|||||||
static void
|
static void
|
||||||
gtk_expander_realize (GtkWidget *widget)
|
gtk_expander_realize (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
|
GtkAllocation allocation;
|
||||||
GtkExpanderPrivate *priv;
|
GtkExpanderPrivate *priv;
|
||||||
|
GdkWindow *window;
|
||||||
GdkWindowAttr attributes;
|
GdkWindowAttr attributes;
|
||||||
gint attributes_mask;
|
gint attributes_mask;
|
||||||
gint border_width;
|
gint border_width;
|
||||||
@ -438,6 +440,7 @@ gtk_expander_realize (GtkWidget *widget)
|
|||||||
gint label_height;
|
gint label_height;
|
||||||
|
|
||||||
priv = GTK_EXPANDER (widget)->priv;
|
priv = GTK_EXPANDER (widget)->priv;
|
||||||
|
|
||||||
gtk_widget_set_realized (widget, TRUE);
|
gtk_widget_set_realized (widget, TRUE);
|
||||||
|
|
||||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
||||||
@ -454,10 +457,12 @@ gtk_expander_realize (GtkWidget *widget)
|
|||||||
else
|
else
|
||||||
label_height = 0;
|
label_height = 0;
|
||||||
|
|
||||||
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
|
||||||
attributes.window_type = GDK_WINDOW_CHILD;
|
attributes.window_type = GDK_WINDOW_CHILD;
|
||||||
attributes.x = widget->allocation.x + border_width;
|
attributes.x = allocation.x + border_width;
|
||||||
attributes.y = widget->allocation.y + border_width;
|
attributes.y = allocation.y + border_width;
|
||||||
attributes.width = MAX (widget->allocation.width - 2 * border_width, 1);
|
attributes.width = MAX (allocation.width - 2 * border_width, 1);
|
||||||
attributes.height = MAX (expander_rect.height, label_height - 2 * border_width);
|
attributes.height = MAX (expander_rect.height, label_height - 2 * border_width);
|
||||||
attributes.wclass = GDK_INPUT_ONLY;
|
attributes.wclass = GDK_INPUT_ONLY;
|
||||||
attributes.event_mask = gtk_widget_get_events (widget) |
|
attributes.event_mask = gtk_widget_get_events (widget) |
|
||||||
@ -468,14 +473,15 @@ gtk_expander_realize (GtkWidget *widget)
|
|||||||
|
|
||||||
attributes_mask = GDK_WA_X | GDK_WA_Y;
|
attributes_mask = GDK_WA_X | GDK_WA_Y;
|
||||||
|
|
||||||
widget->window = gtk_widget_get_parent_window (widget);
|
window = gtk_widget_get_parent_window (widget);
|
||||||
g_object_ref (widget->window);
|
gtk_widget_set_window (widget, window);
|
||||||
|
g_object_ref (window);
|
||||||
|
|
||||||
priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
|
priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
|
||||||
&attributes, attributes_mask);
|
&attributes, attributes_mask);
|
||||||
gdk_window_set_user_data (priv->event_window, widget);
|
gdk_window_set_user_data (priv->event_window, widget);
|
||||||
|
|
||||||
widget->style = gtk_style_attach (widget->style, widget->window);
|
gtk_widget_style_attach (widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -497,6 +503,7 @@ static void
|
|||||||
get_expander_bounds (GtkExpander *expander,
|
get_expander_bounds (GtkExpander *expander,
|
||||||
GdkRectangle *rect)
|
GdkRectangle *rect)
|
||||||
{
|
{
|
||||||
|
GtkAllocation allocation;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GtkExpanderPrivate *priv;
|
GtkExpanderPrivate *priv;
|
||||||
gint border_width;
|
gint border_width;
|
||||||
@ -510,6 +517,8 @@ get_expander_bounds (GtkExpander *expander,
|
|||||||
widget = GTK_WIDGET (expander);
|
widget = GTK_WIDGET (expander);
|
||||||
priv = expander->priv;
|
priv = expander->priv;
|
||||||
|
|
||||||
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
|
||||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
||||||
|
|
||||||
gtk_widget_style_get (widget,
|
gtk_widget_style_get (widget,
|
||||||
@ -522,20 +531,20 @@ get_expander_bounds (GtkExpander *expander,
|
|||||||
|
|
||||||
ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;
|
ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;
|
||||||
|
|
||||||
rect->x = widget->allocation.x + border_width;
|
rect->x = allocation.x + border_width;
|
||||||
rect->y = widget->allocation.y + border_width;
|
rect->y = allocation.y + border_width;
|
||||||
|
|
||||||
if (ltr)
|
if (ltr)
|
||||||
rect->x += expander_spacing;
|
rect->x += expander_spacing;
|
||||||
else
|
else
|
||||||
rect->x += widget->allocation.width - 2 * border_width -
|
rect->x += allocation.width - 2 * border_width -
|
||||||
expander_spacing - expander_size;
|
expander_spacing - expander_size;
|
||||||
|
|
||||||
if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
|
if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
|
||||||
{
|
{
|
||||||
GtkAllocation label_allocation;
|
GtkAllocation label_allocation;
|
||||||
|
|
||||||
label_allocation = priv->label_widget->allocation;
|
gtk_widget_get_allocation (priv->label_widget, &label_allocation);
|
||||||
|
|
||||||
if (expander_size < label_allocation.height)
|
if (expander_size < label_allocation.height)
|
||||||
rect->y += focus_width + focus_pad + (label_allocation.height - expander_size) / 2;
|
rect->y += focus_width + focus_pad + (label_allocation.height - expander_size) / 2;
|
||||||
@ -583,7 +592,7 @@ gtk_expander_size_allocate (GtkWidget *widget,
|
|||||||
|
|
||||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
||||||
|
|
||||||
widget->allocation = *allocation;
|
gtk_widget_set_allocation (widget, allocation);
|
||||||
|
|
||||||
gtk_widget_style_get (widget,
|
gtk_widget_style_get (widget,
|
||||||
"interior-focus", &interior_focus,
|
"interior-focus", &interior_focus,
|
||||||
@ -626,15 +635,14 @@ gtk_expander_size_allocate (GtkWidget *widget,
|
|||||||
ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;
|
ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;
|
||||||
|
|
||||||
if (priv->label_fill)
|
if (priv->label_fill)
|
||||||
label_allocation.x = widget->allocation.x + label_xoffset;
|
label_allocation.x = allocation->x + label_xoffset;
|
||||||
else if (ltr)
|
else if (ltr)
|
||||||
label_allocation.x = widget->allocation.x + label_xoffset;
|
label_allocation.x = allocation->x + label_xoffset;
|
||||||
else
|
else
|
||||||
label_allocation.x =
|
label_allocation.x = allocation->x + allocation->width -
|
||||||
widget->allocation.x + widget->allocation.width -
|
(label_allocation.width + label_xoffset);
|
||||||
(label_allocation.width + label_xoffset);
|
|
||||||
|
|
||||||
label_allocation.y = widget->allocation.y + border_width + focus_width + focus_pad;
|
label_allocation.y = allocation->y + border_width + focus_width + focus_pad;
|
||||||
label_allocation.height = MIN (label_height,
|
label_allocation.height = MIN (label_height,
|
||||||
allocation->height - 2 * border_width -
|
allocation->height - 2 * border_width -
|
||||||
2 * focus_width - 2 * focus_pad -
|
2 * focus_width - 2 * focus_pad -
|
||||||
@ -671,8 +679,8 @@ gtk_expander_size_allocate (GtkWidget *widget,
|
|||||||
top_height = MAX (top_min_height,
|
top_height = MAX (top_min_height,
|
||||||
label_height + (interior_focus ? 2 * focus_width + 2 * focus_pad : 0));
|
label_height + (interior_focus ? 2 * focus_width + 2 * focus_pad : 0));
|
||||||
|
|
||||||
child_allocation.x = widget->allocation.x + border_width;
|
child_allocation.x = allocation->x + border_width;
|
||||||
child_allocation.y = widget->allocation.y + top_height + child_yoffset;
|
child_allocation.y = allocation->y + top_height + child_yoffset;
|
||||||
|
|
||||||
child_allocation.width = MAX (allocation->width - 2 * border_width, 1);
|
child_allocation.width = MAX (allocation->width - 2 * border_width, 1);
|
||||||
child_allocation.height = allocation->height - top_height - child_ypad;
|
child_allocation.height = allocation->height - top_height - child_ypad;
|
||||||
@ -713,6 +721,7 @@ gtk_expander_unmap (GtkWidget *widget)
|
|||||||
static void
|
static void
|
||||||
gtk_expander_paint_prelight (GtkExpander *expander)
|
gtk_expander_paint_prelight (GtkExpander *expander)
|
||||||
{
|
{
|
||||||
|
GtkAllocation allocation;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GtkContainer *container;
|
GtkContainer *container;
|
||||||
GtkExpanderPrivate *priv;
|
GtkExpanderPrivate *priv;
|
||||||
@ -736,13 +745,20 @@ gtk_expander_paint_prelight (GtkExpander *expander)
|
|||||||
"expander-spacing", &expander_spacing,
|
"expander-spacing", &expander_spacing,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
|
||||||
border_width = gtk_container_get_border_width (container);
|
border_width = gtk_container_get_border_width (container);
|
||||||
area.x = widget->allocation.x + border_width;
|
area.x = allocation.x + border_width;
|
||||||
area.y = widget->allocation.y + border_width;
|
area.y = allocation.y + border_width;
|
||||||
area.width = widget->allocation.width - (2 * border_width);
|
area.width = allocation.width - (2 * border_width);
|
||||||
|
|
||||||
if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
|
if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
|
||||||
area.height = priv->label_widget->allocation.height;
|
{
|
||||||
|
GtkAllocation label_widget_allocation;
|
||||||
|
|
||||||
|
gtk_widget_get_allocation (priv->label_widget, &label_widget_allocation);
|
||||||
|
area.height = label_widget_allocation.height;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
area.height = 0;
|
area.height = 0;
|
||||||
|
|
||||||
@ -750,7 +766,8 @@ gtk_expander_paint_prelight (GtkExpander *expander)
|
|||||||
area.height = MAX (area.height, expander_size + 2 * expander_spacing);
|
area.height = MAX (area.height, expander_size + 2 * expander_spacing);
|
||||||
area.height += !interior_focus ? (focus_width + focus_pad) * 2 : 0;
|
area.height += !interior_focus ? (focus_width + focus_pad) * 2 : 0;
|
||||||
|
|
||||||
gtk_paint_flat_box (widget->style, widget->window,
|
gtk_paint_flat_box (gtk_widget_get_style (widget),
|
||||||
|
gtk_widget_get_window (widget),
|
||||||
GTK_STATE_PRELIGHT,
|
GTK_STATE_PRELIGHT,
|
||||||
GTK_SHADOW_ETCHED_OUT,
|
GTK_SHADOW_ETCHED_OUT,
|
||||||
&area, widget, "expander",
|
&area, widget, "expander",
|
||||||
@ -769,7 +786,7 @@ gtk_expander_paint (GtkExpander *expander)
|
|||||||
|
|
||||||
get_expander_bounds (expander, &clip);
|
get_expander_bounds (expander, &clip);
|
||||||
|
|
||||||
state = widget->state;
|
state = gtk_widget_get_state (widget);
|
||||||
if (expander->priv->prelight)
|
if (expander->priv->prelight)
|
||||||
{
|
{
|
||||||
state = GTK_STATE_PRELIGHT;
|
state = GTK_STATE_PRELIGHT;
|
||||||
@ -777,8 +794,8 @@ gtk_expander_paint (GtkExpander *expander)
|
|||||||
gtk_expander_paint_prelight (expander);
|
gtk_expander_paint_prelight (expander);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_paint_expander (widget->style,
|
gtk_paint_expander (gtk_widget_get_style (widget),
|
||||||
widget->window,
|
gtk_widget_get_window (widget),
|
||||||
state,
|
state,
|
||||||
&clip,
|
&clip,
|
||||||
widget,
|
widget,
|
||||||
@ -823,6 +840,10 @@ gtk_expander_paint_focus (GtkExpander *expander,
|
|||||||
|
|
||||||
if (priv->label_widget)
|
if (priv->label_widget)
|
||||||
{
|
{
|
||||||
|
GtkAllocation allocation;
|
||||||
|
|
||||||
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
|
||||||
if (gtk_widget_get_visible (priv->label_widget))
|
if (gtk_widget_get_visible (priv->label_widget))
|
||||||
{
|
{
|
||||||
GtkAllocation label_allocation;
|
GtkAllocation label_allocation;
|
||||||
@ -835,8 +856,8 @@ gtk_expander_paint_focus (GtkExpander *expander,
|
|||||||
width += 2 * focus_pad + 2 * focus_width;
|
width += 2 * focus_pad + 2 * focus_width;
|
||||||
height += 2 * focus_pad + 2 * focus_width;
|
height += 2 * focus_pad + 2 * focus_width;
|
||||||
|
|
||||||
x = widget->allocation.x + border_width;
|
x = allocation.x + border_width;
|
||||||
y = widget->allocation.y + border_width;
|
y = allocation.y + border_width;
|
||||||
|
|
||||||
if (ltr)
|
if (ltr)
|
||||||
{
|
{
|
||||||
@ -845,7 +866,7 @@ gtk_expander_paint_focus (GtkExpander *expander,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
x += widget->allocation.width - 2 * border_width
|
x += allocation.width - 2 * border_width
|
||||||
- expander_spacing * 2 - expander_size - width;
|
- expander_spacing * 2 - expander_size - width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -864,8 +885,10 @@ gtk_expander_paint_focus (GtkExpander *expander,
|
|||||||
width = rect.width + 2 * focus_pad;
|
width = rect.width + 2 * focus_pad;
|
||||||
height = rect.height + 2 * focus_pad;
|
height = rect.height + 2 * focus_pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_paint_focus (widget->style, widget->window, gtk_widget_get_state (widget),
|
gtk_paint_focus (gtk_widget_get_style (widget),
|
||||||
|
gtk_widget_get_window (widget),
|
||||||
|
gtk_widget_get_state (widget),
|
||||||
area, widget, "expander",
|
area, widget, "expander",
|
||||||
x, y, width, height);
|
x, y, width, height);
|
||||||
}
|
}
|
||||||
@ -939,12 +962,14 @@ gtk_expander_state_changed (GtkWidget *widget,
|
|||||||
static void
|
static void
|
||||||
gtk_expander_redraw_expander (GtkExpander *expander)
|
gtk_expander_redraw_expander (GtkExpander *expander)
|
||||||
{
|
{
|
||||||
GtkWidget *widget;
|
GtkAllocation allocation;
|
||||||
|
GtkWidget *widget = GTK_WIDGET (expander);
|
||||||
widget = GTK_WIDGET (expander);
|
|
||||||
|
|
||||||
if (gtk_widget_get_realized (widget))
|
if (gtk_widget_get_realized (widget))
|
||||||
gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);
|
{
|
||||||
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
gdk_window_invalidate_rect (gtk_widget_get_window (widget), &allocation, FALSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -1521,14 +1546,15 @@ static gboolean
|
|||||||
gtk_expander_animation_timeout (GtkExpander *expander)
|
gtk_expander_animation_timeout (GtkExpander *expander)
|
||||||
{
|
{
|
||||||
GtkExpanderPrivate *priv = expander->priv;
|
GtkExpanderPrivate *priv = expander->priv;
|
||||||
|
GtkWidget *widget = GTK_WIDGET (expander);
|
||||||
GtkWidget *child;
|
GtkWidget *child;
|
||||||
GdkRectangle area;
|
GdkRectangle area;
|
||||||
gboolean finish = FALSE;
|
gboolean finish = FALSE;
|
||||||
|
|
||||||
if (gtk_widget_get_realized (GTK_WIDGET (expander)))
|
if (gtk_widget_get_realized (widget))
|
||||||
{
|
{
|
||||||
get_expander_bounds (expander, &area);
|
get_expander_bounds (expander, &area);
|
||||||
gdk_window_invalidate_rect (GTK_WIDGET (expander)->window, &area, TRUE);
|
gdk_window_invalidate_rect (gtk_widget_get_window (widget), &area, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->expanded)
|
if (priv->expanded)
|
||||||
@ -1563,7 +1589,7 @@ gtk_expander_animation_timeout (GtkExpander *expander)
|
|||||||
child = gtk_bin_get_child (GTK_BIN (expander));
|
child = gtk_bin_get_child (GTK_BIN (expander));
|
||||||
if (child)
|
if (child)
|
||||||
gtk_widget_set_child_visible (child, priv->expanded);
|
gtk_widget_set_child_visible (child, priv->expanded);
|
||||||
gtk_widget_queue_resize (GTK_WIDGET (expander));
|
gtk_widget_queue_resize (widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
return !finish;
|
return !finish;
|
||||||
@ -1901,7 +1927,7 @@ gtk_expander_set_label_widget (GtkExpander *expander,
|
|||||||
|
|
||||||
g_return_if_fail (GTK_IS_EXPANDER (expander));
|
g_return_if_fail (GTK_IS_EXPANDER (expander));
|
||||||
g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget));
|
g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget));
|
||||||
g_return_if_fail (label_widget == NULL || label_widget->parent == NULL);
|
g_return_if_fail (label_widget == NULL || gtk_widget_get_parent (label_widget) == NULL);
|
||||||
|
|
||||||
priv = expander->priv;
|
priv = expander->priv;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user