[gtk+/treeview-refactor] Bring back _gtk_tree_view_column_get_cell_at_pos
- From: Kristian Rietveld <kristian src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/treeview-refactor] Bring back _gtk_tree_view_column_get_cell_at_pos
- Date: Sun, 5 Dec 2010 17:21:13 +0000 (UTC)
commit d28cbd6e6db15a77929719d08e014f560c73b0ba
Author: Kristian Rietveld <kris gtk org>
Date: Sun Dec 5 18:18:36 2010 +0100
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.
gtk/gtktreeview.c | 6 ++++++
gtk/gtktreeviewcolumn.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 2f2d5ce..a2f3846 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -3180,11 +3180,17 @@ gtk_tree_view_button_press (GtkWidget *widget,
*/
if (event->type == GDK_BUTTON_PRESS)
{
+ GtkCellRenderer *focus_cell;
+
if ((event->state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
tree_view->priv->ctrl_pressed = TRUE;
if ((event->state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK)
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)
{
gtk_tree_view_real_set_cursor (tree_view, path, FALSE, TRUE);
diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c
index bf1679e..429ed57 100644
--- a/gtk/gtktreeviewcolumn.c
+++ b/gtk/gtktreeviewcolumn.c
@@ -1466,6 +1466,40 @@ _gtk_tree_view_column_get_edited_cell (GtkTreeViewColumn *column)
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 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]