[gtk+/refactor: 8/96] gtk/gtktreeview.c: use accessor functions to access GtkWidget
- From: Javier Jardón <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/refactor: 8/96] gtk/gtktreeview.c: use accessor functions to access GtkWidget
- Date: Sat, 14 Aug 2010 05:04:41 +0000 (UTC)
commit 277c585e568a7ac255a5f4806f67a0fe4ee1f92e
Author: Javier Jardón <jjardon gnome org>
Date: Wed Aug 11 22:50:44 2010 +0200
gtk/gtktreeview.c: use accessor functions to access GtkWidget
gtk/gtktreeview.c | 335 +++++++++++++++++++++++++++++++++++------------------
1 files changed, 222 insertions(+), 113 deletions(-)
---
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 7bbb4e4..15040d1 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -1776,25 +1776,30 @@ gtk_tree_view_map (GtkWidget *widget)
gtk_tree_view_map_buttons (tree_view);
- gdk_window_show (widget->window);
+ gdk_window_show (gtk_widget_get_window (widget));
}
static void
gtk_tree_view_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
+ GtkStyle *style;
GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
- GList *tmp_list;
+ GdkWindow *window;
GdkWindowAttr attributes;
+ GList *tmp_list;
gint attributes_mask;
gtk_widget_set_realized (widget, TRUE);
+ gtk_widget_get_allocation (widget, &allocation);
+
/* Make the main, clipping window */
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
@@ -1802,15 +1807,18 @@ gtk_tree_view_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, widget);
+
+ gtk_widget_get_allocation (widget, &allocation);
/* Make the window for the tree */
attributes.x = 0;
attributes.y = TREE_VIEW_HEADER_HEIGHT (tree_view);
- attributes.width = MAX (tree_view->priv->width, widget->allocation.width);
- attributes.height = widget->allocation.height;
+ attributes.width = MAX (tree_view->priv->width, allocation.width);
+ attributes.height = allocation.height;
attributes.event_mask = (GDK_EXPOSURE_MASK |
GDK_SCROLL_MASK |
GDK_POINTER_MOTION_MASK |
@@ -1820,14 +1828,16 @@ gtk_tree_view_realize (GtkWidget *widget)
GDK_BUTTON_RELEASE_MASK |
gtk_widget_get_events (widget));
- tree_view->priv->bin_window = gdk_window_new (widget->window,
+ tree_view->priv->bin_window = gdk_window_new (window,
&attributes, attributes_mask);
gdk_window_set_user_data (tree_view->priv->bin_window, widget);
+ gtk_widget_get_allocation (widget, &allocation);
+
/* Make the column header window */
attributes.x = 0;
attributes.y = 0;
- attributes.width = MAX (tree_view->priv->width, widget->allocation.width);
+ attributes.width = MAX (tree_view->priv->width, allocation.width);
attributes.height = tree_view->priv->header_height;
attributes.event_mask = (GDK_EXPOSURE_MASK |
GDK_SCROLL_MASK |
@@ -1839,15 +1849,17 @@ gtk_tree_view_realize (GtkWidget *widget)
GDK_KEY_RELEASE_MASK |
gtk_widget_get_events (widget));
- tree_view->priv->header_window = gdk_window_new (widget->window,
+ tree_view->priv->header_window = gdk_window_new (window,
&attributes, attributes_mask);
gdk_window_set_user_data (tree_view->priv->header_window, widget);
/* Add them all up. */
- widget->style = gtk_style_attach (widget->style, widget->window);
- gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
- gdk_window_set_background (tree_view->priv->bin_window, &widget->style->base[widget->state]);
- gtk_style_set_background (widget->style, tree_view->priv->header_window, GTK_STATE_NORMAL);
+ gtk_widget_style_attach (widget);
+ gdk_window_set_back_pixmap (window, NULL, FALSE);
+ style = gtk_widget_get_style (widget);
+ gdk_window_set_background (tree_view->priv->bin_window,
+ &style->base[gtk_widget_get_state (widget)]);
+ gtk_style_set_background (style, tree_view->priv->header_window, GTK_STATE_NORMAL);
tmp_list = tree_view->priv->children;
while (tmp_list)
@@ -2104,14 +2116,16 @@ invalidate_column (GtkTreeView *tree_view,
GtkTreeViewColumn *tmpcolumn = list->data;
if (tmpcolumn == column)
{
+ GtkAllocation allocation;
GdkRectangle invalid_rect;
-
+
+ gtk_widget_get_allocation (widget, &allocation);
invalid_rect.x = column_offset;
invalid_rect.y = 0;
invalid_rect.width = column->width;
- invalid_rect.height = widget->allocation.height;
-
- gdk_window_invalidate_rect (widget->window, &invalid_rect, TRUE);
+ invalid_rect.height = allocation.height;
+
+ gdk_window_invalidate_rect (gtk_widget_get_window (widget), &invalid_rect, TRUE);
break;
}
@@ -2181,6 +2195,7 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
GList *list, *first_column, *last_column;
GtkTreeViewColumn *column;
GtkAllocation allocation;
+ GtkAllocation widget_allocation;
gint width = 0;
gint extra, extra_per_column, extra_for_last;
gint full_requested_width = 0;
@@ -2234,14 +2249,15 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
tree_view->priv->post_validation_flag = FALSE;
+ gtk_widget_get_allocation (widget, &widget_allocation);
if (!update_expand)
{
extra = tree_view->priv->last_extra_space;
- extra_for_last = MAX (widget->allocation.width - full_requested_width - extra, 0);
+ extra_for_last = MAX (widget_allocation.width - full_requested_width - extra, 0);
}
else
{
- extra = MAX (widget->allocation.width - full_requested_width, 0);
+ extra = MAX (widget_allocation.width - full_requested_width, 0);
extra_for_last = 0;
tree_view->priv->last_extra_space = extra;
@@ -2352,15 +2368,18 @@ static void
gtk_tree_view_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
+ GtkAllocation widget_allocation;
GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
GList *tmp_list;
gboolean width_changed = FALSE;
- gint old_width = widget->allocation.width;
+ gint old_width;
- if (allocation->width != widget->allocation.width)
+ gtk_widget_get_allocation (widget, &widget_allocation);
+ old_width = widget_allocation.width;
+ if (allocation->width != widget_allocation.width)
width_changed = TRUE;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
tmp_list = tree_view->priv->children;
@@ -2439,7 +2458,7 @@ gtk_tree_view_size_allocate (GtkWidget *widget,
if (gtk_widget_get_realized (widget))
{
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x, allocation->y,
allocation->width, allocation->height);
gdk_window_move_resize (tree_view->priv->header_window,
@@ -2893,6 +2912,7 @@ gtk_tree_view_button_press (GtkWidget *widget,
column->resizable &&
column->window)
{
+ GtkAllocation button_allocation;
gpointer drag_data;
if (event->type == GDK_2BUTTON_PRESS &&
@@ -2922,8 +2942,9 @@ gtk_tree_view_button_press (GtkWidget *widget,
0, 0, NULL, NULL,
drag_data);
+ gtk_widget_get_allocation (column->button, &button_allocation);
tree_view->priv->drag_pos = i;
- tree_view->priv->x_drag = column->button->allocation.x + (rtl ? 0 : column->button->allocation.width);
+ tree_view->priv->x_drag = button_allocation.x + (rtl ? 0 : button_allocation.width);
if (!gtk_widget_has_focus (widget))
gtk_widget_grab_focus (widget);
@@ -3397,12 +3418,20 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view)
arrow_type = DRAG_COLUMN_WINDOW_STATE_ORIGINAL;
else if (reorder->left_column || reorder->right_column)
{
+ GtkAllocation left_allocation, right_allocation;
GdkRectangle visible_rect;
+
gtk_tree_view_get_visible_rect (tree_view, &visible_rect);
if (reorder->left_column)
- x = reorder->left_column->button->allocation.x + reorder->left_column->button->allocation.width;
+ {
+ gtk_widget_get_allocation (reorder->left_column->button, &left_allocation);
+ x = left_allocation.x + left_allocation.width;
+ }
else
- x = reorder->right_column->button->allocation.x;
+ {
+ gtk_widget_get_allocation (reorder->right_column->button, &right_allocation);
+ x = right_allocation.x;
+ }
if (x < visible_rect.x)
arrow_type = DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT;
@@ -3417,6 +3446,8 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view)
{
if (tree_view->priv->drag_column_window_state != DRAG_COLUMN_WINDOW_STATE_ORIGINAL)
{
+ GtkAllocation drag_allocation;
+
if (tree_view->priv->drag_highlight_window)
{
gdk_window_set_user_data (tree_view->priv->drag_highlight_window,
@@ -3428,8 +3459,9 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view)
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.x = tree_view->priv->drag_column_x;
attributes.y = 0;
- width = attributes.width = tree_view->priv->drag_column->button->allocation.width;
- height = attributes.height = tree_view->priv->drag_column->button->allocation.height;
+ gtk_widget_get_allocation (tree_view->priv->drag_column->button, &drag_allocation);
+ width = attributes.width = drag_allocation.width;
+ height = attributes.height = drag_allocation.height;
attributes.visual = gtk_widget_get_visual (GTK_WIDGET (tree_view));
attributes.colormap = gtk_widget_get_colormap (GTK_WIDGET (tree_view));
attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK;
@@ -3455,19 +3487,23 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view)
}
else if (arrow_type == DRAG_COLUMN_WINDOW_STATE_ARROW)
{
+ GtkAllocation button_allocation;
+
width = tree_view->priv->expander_size;
/* Get x, y, width, height of arrow */
gdk_window_get_origin (tree_view->priv->header_window, &x, &y);
if (reorder->left_column)
{
- x += reorder->left_column->button->allocation.x + reorder->left_column->button->allocation.width - width/2;
- height = reorder->left_column->button->allocation.height;
+ gtk_widget_get_allocation (reorder->left_column->button, &button_allocation);
+ x += button_allocation.x + button_allocation.width - width/2;
+ height = button_allocation.height;
}
else
{
- x += reorder->right_column->button->allocation.x - width/2;
- height = reorder->right_column->button->allocation.height;
+ gtk_widget_get_allocation (reorder->right_column->button, &button_allocation);
+ x += button_allocation.x - width/2;
+ height = button_allocation.height;
}
y -= tree_view->priv->expander_size/2; /* The arrow takes up only half the space */
height += tree_view->priv->expander_size;
@@ -3522,18 +3558,30 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view)
else if (arrow_type == DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT ||
arrow_type == DRAG_COLUMN_WINDOW_STATE_ARROW_RIGHT)
{
+ GtkAllocation allocation;
+
width = tree_view->priv->expander_size;
/* Get x, y, width, height of arrow */
width = width/2; /* remember, the arrow only takes half the available width */
- gdk_window_get_origin (widget->window, &x, &y);
+ gdk_window_get_origin (gtk_widget_get_window (widget),
+ &x, &y);
if (arrow_type == DRAG_COLUMN_WINDOW_STATE_ARROW_RIGHT)
- x += widget->allocation.width - width;
+ {
+ gtk_widget_get_allocation (widget, &allocation);
+ x += allocation.width - width;
+ }
if (reorder->left_column)
- height = reorder->left_column->button->allocation.height;
+ {
+ gtk_widget_get_allocation (reorder->left_column->button, &allocation);
+ height = allocation.height;
+ }
else
- height = reorder->right_column->button->allocation.height;
+ {
+ gtk_widget_get_allocation (reorder->right_column->button, &allocation);
+ height = allocation.height;
+ }
y -= tree_view->priv->expander_size;
height += 2*tree_view->priv->expander_size;
@@ -3613,7 +3661,7 @@ gtk_tree_view_motion_resize_column (GtkWidget *widget,
column = gtk_tree_view_get_column (tree_view, tree_view->priv->drag_pos);
- if (event->is_hint || event->window != widget->window)
+ if (event->is_hint || event->window != gtk_widget_get_window (widget))
gtk_widget_get_pointer (widget, &x, NULL);
else
x = event->x;
@@ -3717,6 +3765,7 @@ static gboolean
gtk_tree_view_motion_drag_column (GtkWidget *widget,
GdkEventMotion *event)
{
+ GtkAllocation allocation, button_allocation;
GtkTreeView *tree_view = (GtkTreeView *) widget;
GtkTreeViewColumn *column = tree_view->priv->drag_column;
gint x, y;
@@ -3728,8 +3777,10 @@ gtk_tree_view_motion_drag_column (GtkWidget *widget,
/* Handle moving the header */
gdk_window_get_position (tree_view->priv->drag_window, &x, &y);
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_allocation (column->button, &button_allocation);
x = CLAMP (x + (gint)event->x - column->drag_x, 0,
- MAX (tree_view->priv->width, GTK_WIDGET (tree_view)->allocation.width) - column->button->allocation.width);
+ MAX (tree_view->priv->width, allocation.width) - button_allocation.width);
gdk_window_move (tree_view->priv->drag_window, x, y);
/* autoscroll, if needed */
@@ -4048,6 +4099,7 @@ static void
gtk_tree_view_paint_rubber_band (GtkTreeView *tree_view,
GdkRectangle *area)
{
+ GtkStyle *style;
cairo_t *cr;
GdkRectangle rect;
GdkRectangle rubber_rect;
@@ -4063,10 +4115,12 @@ gtk_tree_view_paint_rubber_band (GtkTreeView *tree_view,
cr = gdk_cairo_create (tree_view->priv->bin_window);
cairo_set_line_width (cr, 1.0);
+ style = gtk_widget_get_style (GTK_WIDGET (tree_view));
+
cairo_set_source_rgba (cr,
- GTK_WIDGET (tree_view)->style->fg[GTK_STATE_NORMAL].red / 65535.,
- GTK_WIDGET (tree_view)->style->fg[GTK_STATE_NORMAL].green / 65535.,
- GTK_WIDGET (tree_view)->style->fg[GTK_STATE_NORMAL].blue / 65535.,
+ style->fg[GTK_STATE_NORMAL].red / 65535.,
+ style->fg[GTK_STATE_NORMAL].green / 65535.,
+ style->fg[GTK_STATE_NORMAL].blue / 65535.,
.25);
gdk_cairo_rectangle (cr, &rect);
@@ -4074,9 +4128,9 @@ gtk_tree_view_paint_rubber_band (GtkTreeView *tree_view,
cairo_paint (cr);
cairo_set_source_rgb (cr,
- GTK_WIDGET (tree_view)->style->fg[GTK_STATE_NORMAL].red / 65535.,
- GTK_WIDGET (tree_view)->style->fg[GTK_STATE_NORMAL].green / 65535.,
- GTK_WIDGET (tree_view)->style->fg[GTK_STATE_NORMAL].blue / 65535.);
+ style->fg[GTK_STATE_NORMAL].red / 65535.,
+ style->fg[GTK_STATE_NORMAL].green / 65535.,
+ style->fg[GTK_STATE_NORMAL].blue / 65535.);
cairo_rectangle (cr,
rubber_rect.x + 0.5, rubber_rect.y + 0.5,
@@ -4248,7 +4302,7 @@ gtk_tree_view_draw_line (GtkTreeView *tree_view,
case GTK_TREE_VIEW_FOREGROUND_LINE:
cairo_set_line_width (cr, 1.0);
gdk_cairo_set_source_color (cr,
- >K_WIDGET (tree_view)->style->fg[gtk_widget_get_state (GTK_WIDGET (tree_view))]);
+ >k_widget_get_style (GTK_WIDGET (tree_view))->fg[gtk_widget_get_state (GTK_WIDGET (tree_view))]);
break;
}
@@ -4305,6 +4359,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
{
GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
GtkTreePath *path;
+ GtkStyle *style;
GtkRBTree *tree;
GList *list;
GtkRBNode *node;
@@ -4362,6 +4417,8 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
validate_visible_area (tree_view);
+ style = gtk_widget_get_style (widget);
+
new_y = TREE_WINDOW_Y_TO_RBTREE_Y (tree_view, event->area.y);
if (new_y < 0)
@@ -4372,9 +4429,9 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
if (tree_view->priv->height < bin_window_height)
{
- gtk_paint_flat_box (widget->style,
+ gtk_paint_flat_box (style,
event->window,
- widget->state,
+ gtk_widget_get_state (widget),
GTK_SHADOW_NONE,
&event->area,
widget,
@@ -4611,7 +4668,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
g_assert (detail);
- if (widget->state == GTK_STATE_INSENSITIVE)
+ if (gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE)
state = GTK_STATE_INSENSITIVE;
else if (flags & GTK_CELL_RENDERER_SELECTED)
state = GTK_STATE_SELECTED;
@@ -4638,7 +4695,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
else
g_snprintf (new_detail, 128, "%s_middle", detail);
- gtk_paint_flat_box (widget->style,
+ gtk_paint_flat_box (style,
event->window,
state,
GTK_SHADOW_NONE,
@@ -4652,7 +4709,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
}
else
{
- gtk_paint_flat_box (widget->style,
+ gtk_paint_flat_box (style,
event->window,
state,
GTK_SHADOW_NONE,
@@ -4686,7 +4743,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
expander_cell_width = cell_area.width;
if (is_separator)
- gtk_paint_hline (widget->style,
+ gtk_paint_hline (style,
event->window,
state,
&cell_area,
@@ -4721,7 +4778,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
else
{
if (is_separator)
- gtk_paint_hline (widget->style,
+ gtk_paint_hline (style,
event->window,
state,
&cell_area,
@@ -4876,7 +4933,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
&width, NULL);
if (row_ending_details)
- gtk_paint_focus (widget->style,
+ gtk_paint_focus (style,
tree_view->priv->bin_window,
gtk_widget_get_state (widget),
&event->area,
@@ -4889,7 +4946,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
width, ROW_HEIGHT (tree_view, BACKGROUND_HEIGHT (node))
- focus_line_width + 1);
else
- gtk_paint_focus (widget->style,
+ gtk_paint_focus (style,
tree_view->priv->bin_window,
gtk_widget_get_state (widget),
&event->area,
@@ -4943,7 +5000,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
}
if (row_ending_details)
- gtk_paint_focus (widget->style,
+ gtk_paint_focus (style,
tree_view->priv->bin_window,
focus_rect_state,
&event->area,
@@ -4954,7 +5011,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
0, tmp_y,
width, tmp_height);
else
- gtk_paint_focus (widget->style,
+ gtk_paint_focus (style,
tree_view->priv->bin_window,
focus_rect_state,
&event->area,
@@ -5381,11 +5438,17 @@ gtk_tree_view_key_press (GtkWidget *widget,
column->resized_width = 0;
if (column->min_width == -1)
- column->resized_width = MAX (column->button->requisition.width,
- column->resized_width);
+ {
+ GtkRequisition button_requisition;
+ gtk_widget_get_requisition (column->button, &button_requisition);
+ column->resized_width = MAX (button_requisition.width,
+ column->resized_width);
+ }
else
- column->resized_width = MAX (column->min_width,
- column->resized_width);
+ {
+ column->resized_width = MAX (column->min_width,
+ column->resized_width);
+ }
if (column->max_width != -1)
column->resized_width = MIN (column->resized_width,
@@ -5504,7 +5567,7 @@ gtk_tree_view_key_press (GtkWidget *widget,
old_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (tree_view->priv->search_entry)));
new_event = gdk_event_copy ((GdkEvent *) event);
g_object_unref (((GdkEventKey *) new_event)->window);
- ((GdkEventKey *) new_event)->window = g_object_ref (tree_view->priv->search_window->window);
+ ((GdkEventKey *) new_event)->window = g_object_ref (gtk_widget_get_window (tree_view->priv->search_window));
gtk_widget_realize (tree_view->priv->search_window);
popup_menu_id = g_signal_connect (tree_view->priv->search_entry,
@@ -5663,15 +5726,17 @@ gtk_tree_view_node_queue_redraw (GtkTreeView *tree_view,
GtkRBTree *tree,
GtkRBNode *node)
{
+ GtkAllocation allocation;
gint y;
y = _gtk_rbtree_node_find_offset (tree, node)
- tree_view->priv->vadjustment->value
+ TREE_VIEW_HEADER_HEIGHT (tree_view);
+ gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
gtk_widget_queue_draw_area (GTK_WIDGET (tree_view),
0, y,
- GTK_WIDGET (tree_view)->allocation.width,
+ allocation.width,
GTK_RBNODE_GET_HEIGHT (node));
}
@@ -5829,6 +5894,7 @@ validate_row (GtkTreeView *tree_view,
static void
validate_visible_area (GtkTreeView *tree_view)
{
+ GtkAllocation allocation;
GtkTreePath *path = NULL;
GtkTreePath *above_path = NULL;
GtkTreeIter iter;
@@ -5847,7 +5913,8 @@ validate_visible_area (GtkTreeView *tree_view)
tree_view->priv->scroll_to_path == NULL)
return;
- total_height = GTK_WIDGET (tree_view)->allocation.height - TREE_VIEW_HEADER_HEIGHT (tree_view);
+ gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
+ total_height = allocation.height - TREE_VIEW_HEADER_HEIGHT (tree_view);
if (total_height == 0)
return;
@@ -8058,14 +8125,17 @@ gtk_tree_view_style_set (GtkWidget *widget,
GtkStyle *previous_style)
{
GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
+ GtkStyle *style;
GList *list;
GtkTreeViewColumn *column;
if (gtk_widget_get_realized (widget))
{
- gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
- gdk_window_set_background (tree_view->priv->bin_window, &widget->style->base[widget->state]);
- gtk_style_set_background (widget->style, tree_view->priv->header_window, GTK_STATE_NORMAL);
+ gdk_window_set_back_pixmap (gtk_widget_get_window (widget), NULL, FALSE);
+ style = gtk_widget_get_style (widget);
+ gdk_window_set_background (tree_view->priv->bin_window,
+ &style->base[gtk_widget_get_state (widget)]);
+ gtk_style_set_background (style, tree_view->priv->header_window, GTK_STATE_NORMAL);
gtk_tree_view_set_grid_lines (tree_view, tree_view->priv->grid_lines);
gtk_tree_view_set_enable_tree_lines (tree_view, tree_view->priv->tree_lines_enabled);
@@ -8928,13 +8998,15 @@ gtk_tree_view_clamp_column_visible (GtkTreeView *tree_view,
GtkTreeViewColumn *column,
gboolean focus_to_cell)
{
+ GtkAllocation allocation;
gint x, width;
if (column == NULL)
return;
- x = column->button->allocation.x;
- width = column->button->allocation.width;
+ gtk_widget_get_allocation (column->button, &allocation);
+ x = allocation.x;
+ width = allocation.width;
if (width > tree_view->priv->hadjustment->page_size)
{
@@ -9295,10 +9367,13 @@ gtk_tree_view_set_column_drag_info (GtkTreeView *tree_view,
reorder->left_align = left;
if (tmp_list->next != NULL)
{
+ GtkAllocation right_allocation, left_allocation;
+
g_assert (tmp_list->next->data);
- left = reorder->right_align = (reorder->right_column->button->allocation.x +
- reorder->right_column->button->allocation.width +
- ((GtkTreeViewColumnReorder *)tmp_list->next->data)->left_column->button->allocation.x)/2;
+
+ gtk_widget_get_allocation (reorder->right_column->button, &right_allocation);
+ gtk_widget_get_allocation (((GtkTreeViewColumnReorder *)tmp_list->next->data)->left_column->button, &left_allocation);
+ left = reorder->right_align = (right_allocation.x + right_allocation.width + left_allocation.x) / 2;
}
else
{
@@ -9317,6 +9392,7 @@ _gtk_tree_view_column_start_drag (GtkTreeView *tree_view,
{
GdkEvent *send_event;
GtkAllocation allocation;
+ GtkAllocation button_allocation;
gint x, y, width, height;
GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (tree_view));
GdkDisplay *display = gdk_screen_get_display (screen);
@@ -9334,12 +9410,14 @@ _gtk_tree_view_column_start_drag (GtkTreeView *tree_view,
GdkWindowAttr attributes;
guint attributes_mask;
+ gtk_widget_get_allocation (column->button, &button_allocation);
+
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.x = column->button->allocation.x;
+ attributes.x = button_allocation.x;
attributes.y = 0;
- attributes.width = column->button->allocation.width;
- attributes.height = column->button->allocation.height;
+ attributes.width = button_allocation.width;
+ attributes.height = button_allocation.height;
attributes.visual = gtk_widget_get_visual (GTK_WIDGET (tree_view));
attributes.colormap = gtk_widget_get_colormap (GTK_WIDGET (tree_view));
attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK;
@@ -9390,8 +9468,9 @@ _gtk_tree_view_column_start_drag (GtkTreeView *tree_view,
gtk_widget_set_parent (column->button, GTK_WIDGET (tree_view));
g_object_unref (column->button);
- tree_view->priv->drag_column_x = column->button->allocation.x;
- allocation = column->button->allocation;
+ gtk_widget_get_allocation (column->button, &button_allocation);
+ tree_view->priv->drag_column_x = button_allocation.x;
+ allocation = button_allocation;
allocation.x = 0;
gtk_widget_size_allocate (column->button, &allocation);
gtk_widget_set_parent_window (column->button, tree_view->priv->drag_window);
@@ -9422,13 +9501,15 @@ gtk_tree_view_queue_draw_arrow (GtkTreeView *tree_view,
GtkRBNode *node,
const GdkRectangle *clip_rect)
{
+ GtkAllocation allocation;
GdkRectangle rect;
if (!gtk_widget_get_realized (GTK_WIDGET (tree_view)))
return;
+ gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
rect.x = 0;
- rect.width = MAX (tree_view->priv->expander_size, MAX (tree_view->priv->width, GTK_WIDGET (tree_view)->allocation.width));
+ rect.width = MAX (tree_view->priv->expander_size, MAX (tree_view->priv->width, allocation.width));
rect.y = BACKGROUND_FIRST_PIXEL (tree_view, tree, node);
rect.height = ROW_HEIGHT (tree_view, BACKGROUND_HEIGHT (node));
@@ -9453,13 +9534,15 @@ _gtk_tree_view_queue_draw_node (GtkTreeView *tree_view,
GtkRBNode *node,
const GdkRectangle *clip_rect)
{
+ GtkAllocation allocation;
GdkRectangle rect;
if (!gtk_widget_get_realized (GTK_WIDGET (tree_view)))
return;
+ gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
rect.x = 0;
- rect.width = MAX (tree_view->priv->width, GTK_WIDGET (tree_view)->allocation.width);
+ rect.width = MAX (tree_view->priv->width, allocation.width);
rect.y = BACKGROUND_FIRST_PIXEL (tree_view, tree, node);
rect.height = ROW_HEIGHT (tree_view, BACKGROUND_HEIGHT (node));
@@ -9558,7 +9641,7 @@ gtk_tree_view_draw_arrow (GtkTreeView *tree_view,
else
expander_style = GTK_EXPANDER_COLLAPSED;
- gtk_paint_expander (widget->style,
+ gtk_paint_expander (gtk_widget_get_style (widget),
tree_view->priv->bin_window,
state,
&area,
@@ -10329,21 +10412,24 @@ send_focus_change (GtkWidget *widget,
{
GdkDevice *dev = d->data;
GdkEvent *fevent;
+ GdkWindow *window;
if (dev->source != GDK_SOURCE_KEYBOARD)
continue;
+ window = gtk_widget_get_window (widget);
+
/* Skip non-master keyboards that haven't
* selected for events from this window
*/
if (gdk_device_get_device_type (dev) != GDK_DEVICE_TYPE_MASTER &&
- !gdk_window_get_device_events (widget->window, dev))
+ !gdk_window_get_device_events (window, dev))
continue;
fevent = gdk_event_new (GDK_FOCUS_CHANGE);
fevent->focus_change.type = GDK_FOCUS_CHANGE;
- fevent->focus_change.window = g_object_ref (widget->window);
+ fevent->focus_change.window = g_object_ref (window);
fevent->focus_change.in = in;
gdk_event_set_device (fevent, device);
@@ -10532,6 +10618,8 @@ gtk_tree_view_new_column_width (GtkTreeView *tree_view,
gint i,
gint *x)
{
+ GtkAllocation allocation;
+ GtkRequisition button_requisition;
GtkTreeViewColumn *column;
gint width;
gboolean rtl;
@@ -10541,20 +10629,23 @@ gtk_tree_view_new_column_width (GtkTreeView *tree_view,
*/
rtl = (gtk_widget_get_direction (GTK_WIDGET (tree_view)) == GTK_TEXT_DIR_RTL);
column = g_list_nth (tree_view->priv->columns, i)->data;
- width = rtl ? (column->button->allocation.x + column->button->allocation.width - *x) : (*x - column->button->allocation.x);
-
+ gtk_widget_get_allocation (column->button, &allocation);
+ width = rtl ? (allocation.x + allocation.width - *x) : (*x - allocation.x);
+
/* Clamp down the value */
if (column->min_width == -1)
- width = MAX (column->button->requisition.width,
- width);
+ {
+ gtk_widget_get_requisition (column->button, &button_requisition);
+ width = MAX (button_requisition.width, width);
+ }
else
width = MAX (column->min_width,
width);
if (column->max_width != -1)
width = MIN (width, column->max_width);
- *x = rtl ? (column->button->allocation.x + column->button->allocation.width - width) : (column->button->allocation.x + width);
-
+ *x = rtl ? (allocation.x + allocation.width - width) : (allocation.x + width);
+
return width;
}
@@ -10572,25 +10663,27 @@ typedef struct
/* The window to which widget->window is relative */
#define ALLOCATION_WINDOW(widget) \
- (!gtk_widget_get_has_window (widget) ? \
- (widget)->window : \
- gdk_window_get_parent ((widget)->window))
+ (!gtk_widget_get_has_window (widget) ? \
+ gtk_widget_get_window (widget) : \
+ gdk_window_get_parent (gtk_widget_get_window (widget)))
static void
adjust_allocation_recurse (GtkWidget *widget,
gpointer data)
{
+ GtkAllocation allocation;
ScrollData *scroll_data = data;
/* Need to really size allocate instead of just poking
* into widget->allocation if the widget is not realized.
* FIXME someone figure out why this was.
*/
+ gtk_widget_get_allocation (widget, &allocation);
if (!gtk_widget_get_realized (widget))
{
if (gtk_widget_get_visible (widget))
{
- GdkRectangle tmp_rectangle = widget->allocation;
+ GdkRectangle tmp_rectangle = allocation;
tmp_rectangle.x += scroll_data->dx;
tmp_rectangle.y += scroll_data->dy;
@@ -10601,9 +10694,10 @@ adjust_allocation_recurse (GtkWidget *widget,
{
if (ALLOCATION_WINDOW (widget) == scroll_data->window)
{
- widget->allocation.x += scroll_data->dx;
- widget->allocation.y += scroll_data->dy;
-
+ allocation.x += scroll_data->dx;
+ allocation.y += scroll_data->dy;
+ gtk_widget_set_allocation (widget, &allocation);
+
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget),
adjust_allocation_recurse,
@@ -11021,6 +11115,7 @@ gtk_tree_view_set_headers_visible (GtkTreeView *tree_view,
gint x, y;
GList *list;
GtkTreeViewColumn *column;
+ GtkAllocation allocation;
g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
@@ -11039,7 +11134,10 @@ gtk_tree_view_set_headers_visible (GtkTreeView *tree_view,
gdk_window_get_position (tree_view->priv->bin_window, &x, &y);
if (headers_visible)
{
- gdk_window_move_resize (tree_view->priv->bin_window, x, y + TREE_VIEW_HEADER_HEIGHT (tree_view), tree_view->priv->width, GTK_WIDGET (tree_view)->allocation.height - + TREE_VIEW_HEADER_HEIGHT (tree_view));
+ gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
+ gdk_window_move_resize (tree_view->priv->bin_window,
+ x, y + TREE_VIEW_HEADER_HEIGHT (tree_view),
+ tree_view->priv->width, allocation.height - + TREE_VIEW_HEADER_HEIGHT (tree_view));
if (gtk_widget_get_mapped (GTK_WIDGET (tree_view)))
gtk_tree_view_map_buttons (tree_view);
@@ -11057,8 +11155,9 @@ gtk_tree_view_set_headers_visible (GtkTreeView *tree_view,
}
}
- tree_view->priv->vadjustment->page_size = GTK_WIDGET (tree_view)->allocation.height - TREE_VIEW_HEADER_HEIGHT (tree_view);
- tree_view->priv->vadjustment->page_increment = (GTK_WIDGET (tree_view)->allocation.height - TREE_VIEW_HEADER_HEIGHT (tree_view)) / 2;
+ gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
+ tree_view->priv->vadjustment->page_size = allocation.height - TREE_VIEW_HEADER_HEIGHT (tree_view);
+ tree_view->priv->vadjustment->page_increment = (allocation.height - TREE_VIEW_HEADER_HEIGHT (tree_view)) / 2;
tree_view->priv->vadjustment->lower = 0;
tree_view->priv->vadjustment->upper = tree_view->priv->height;
gtk_adjustment_changed (tree_view->priv->vadjustment);
@@ -12946,6 +13045,7 @@ gtk_tree_view_get_cell_area (GtkTreeView *tree_view,
GtkTreeViewColumn *column,
GdkRectangle *rect)
{
+ GtkAllocation allocation;
GtkRBTree *tree = NULL;
GtkRBNode *node = NULL;
gint vertical_separator;
@@ -12969,8 +13069,9 @@ gtk_tree_view_get_cell_area (GtkTreeView *tree_view,
if (column)
{
- rect->x = column->button->allocation.x + horizontal_separator/2;
- rect->width = column->button->allocation.width - horizontal_separator;
+ gtk_widget_get_allocation (column->button, &allocation);
+ rect->x = allocation.x + horizontal_separator/2;
+ rect->width = allocation.width - horizontal_separator;
}
if (path)
@@ -13081,6 +13182,7 @@ void
gtk_tree_view_get_visible_rect (GtkTreeView *tree_view,
GdkRectangle *visible_rect)
{
+ GtkAllocation allocation;
GtkWidget *widget;
g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
@@ -13089,10 +13191,11 @@ gtk_tree_view_get_visible_rect (GtkTreeView *tree_view,
if (visible_rect)
{
+ gtk_widget_get_allocation (widget, &allocation);
visible_rect->x = tree_view->priv->hadjustment->value;
visible_rect->y = tree_view->priv->vadjustment->value;
- visible_rect->width = widget->allocation.width;
- visible_rect->height = widget->allocation.height - TREE_VIEW_HEADER_HEIGHT (tree_view);
+ visible_rect->width = allocation.width;
+ visible_rect->height = allocation.height - TREE_VIEW_HEADER_HEIGHT (tree_view);
}
}
@@ -13711,6 +13814,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
GtkTreeIter iter;
GtkRBTree *tree;
GtkRBNode *node;
+ GtkStyle *style;
gint cell_offset;
GList *list;
GdkRectangle background_area;
@@ -13747,7 +13851,9 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
&iter,
path))
return NULL;
-
+
+ style = gtk_widget_get_style (widget);
+
is_separator = row_is_separator (tree_view, &iter, NULL);
cell_offset = x;
@@ -13769,7 +13875,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
expose_area.height = background_area.height + 2;
cr = gdk_cairo_create (drawable);
- gdk_cairo_set_source_color (cr, &widget->style->base [gtk_widget_get_state (widget)]);
+ gdk_cairo_set_source_color (cr, &style->base [gtk_widget_get_state (widget)]);
cairo_paint (cr);
rtl = gtk_widget_get_direction (GTK_WIDGET (tree_view)) == GTK_TEXT_DIR_RTL;
@@ -13818,7 +13924,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
if (gtk_tree_view_column_cell_is_visible (column))
{
if (is_separator)
- gtk_paint_hline (widget->style,
+ gtk_paint_hline (style,
drawable,
GTK_STATE_NORMAL,
&cell_area,
@@ -14197,7 +14303,7 @@ gtk_tree_view_search_position_func (GtkTreeView *tree_view,
gint x, y;
gint tree_x, tree_y;
gint tree_width, tree_height;
- GdkWindow *tree_window = GTK_WIDGET (tree_view)->window;
+ GdkWindow *tree_window = gtk_widget_get_window (GTK_WIDGET (tree_view));
GdkScreen *screen = gdk_drawable_get_screen (tree_window);
GtkRequisition requisition;
gint monitor_num;
@@ -15119,8 +15225,9 @@ gtk_tree_view_state_changed (GtkWidget *widget,
if (gtk_widget_get_realized (widget))
{
- gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
- gdk_window_set_background (tree_view->priv->bin_window, &widget->style->base[widget->state]);
+ gdk_window_set_back_pixmap (gtk_widget_get_window (widget), NULL, FALSE);
+ gdk_window_set_background (tree_view->priv->bin_window,
+ >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]);
}
gtk_widget_queue_draw (widget);
@@ -15449,6 +15556,7 @@ gtk_tree_view_set_tooltip_cell (GtkTreeView *tree_view,
GtkTreeViewColumn *column,
GtkCellRenderer *cell)
{
+ GtkAllocation allocation;
GdkRectangle rect;
g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
@@ -15489,8 +15597,9 @@ gtk_tree_view_set_tooltip_cell (GtkTreeView *tree_view,
}
else
{
+ gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
rect.x = 0;
- rect.width = GTK_WIDGET (tree_view)->allocation.width;
+ rect.width = allocation.width;
}
/* Determine y values. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]