Bring back _gtk_tree_view_column_get_cell_at_pos

The function has been re-implemented around GtkCellArea.  This commits
also brings back the invocation of this function in
gtk_tree_view_button_press().  I shouldn't have removed this.
This commit is contained in:
Kristian Rietveld 2010-12-05 18:18:36 +01:00
parent 2a6550176c
commit d28cbd6e6d
2 changed files with 40 additions and 0 deletions

View File

@ -3180,11 +3180,17 @@ gtk_tree_view_button_press (GtkWidget *widget,
*/ */
if (event->type == GDK_BUTTON_PRESS) if (event->type == GDK_BUTTON_PRESS)
{ {
GtkCellRenderer *focus_cell;
if ((event->state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK) if ((event->state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
tree_view->priv->ctrl_pressed = TRUE; tree_view->priv->ctrl_pressed = TRUE;
if ((event->state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) if ((event->state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK)
tree_view->priv->shift_pressed = TRUE; tree_view->priv->shift_pressed = TRUE;
focus_cell = _gtk_tree_view_column_get_cell_at_pos (column, event->x - background_area.x);
if (focus_cell)
gtk_tree_view_column_focus_cell (column, focus_cell);
if (event->state & GDK_CONTROL_MASK) if (event->state & GDK_CONTROL_MASK)
{ {
gtk_tree_view_real_set_cursor (tree_view, path, FALSE, TRUE); gtk_tree_view_real_set_cursor (tree_view, path, FALSE, TRUE);

View File

@ -1466,6 +1466,40 @@ _gtk_tree_view_column_get_edited_cell (GtkTreeViewColumn *column)
return gtk_cell_area_get_edited_cell (priv->cell_area); return gtk_cell_area_get_edited_cell (priv->cell_area);
} }
GtkCellRenderer *
_gtk_tree_view_column_get_cell_at_pos (GtkTreeViewColumn *column,
gint x)
{
GList *list;
GList *cell;
GtkCellRenderer *match = NULL;
GtkTreeViewColumnPrivate *priv = column->priv;
list = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column));
for (cell = list; cell; cell = cell->next)
{
GdkRectangle zero_cell_area = { 0, };
GdkRectangle allocation;
gtk_cell_area_get_cell_allocation (priv->cell_area,
priv->cell_area_context,
priv->tree_view,
cell->data,
&zero_cell_area,
&allocation);
if (allocation.x <= x && x <= allocation.x + allocation.width)
{
match = cell->data;
break;
}
}
g_list_free (list);
return match;
}
/* Public Functions */ /* Public Functions */