+ {
+ gtk_cell_area_stop_editing (area, TRUE);
+ retval = TRUE;
+ }
+ }
+ else if (event->type == GDK_BUTTON_PRESS)
+ {
+ GdkEventButton *button_event = (GdkEventButton *)event;
+
+ if (button_event->button == GDK_BUTTON_PRIMARY)
+ {
+ GtkCellRenderer *renderer = NULL;
+ GtkCellRenderer *focus_renderer;
+ GdkRectangle alloc_area;
+ gint event_x, event_y;
+
+ /* We may need some semantics to tell us the offset of the event
+ * window we are handling events for (i.e. GtkTreeView has a bin_window) */
+ event_x = button_event->x;
+ event_y = button_event->y;
+
+ /* Dont try to search for an event coordinate that is not in the area, that will
+ * trigger a runtime warning.
+ */
+ if (event_x >= cell_area->x && event_x <= cell_area->x + cell_area->width &&
+ event_y >= cell_area->y && event_y <= cell_area->y + cell_area->height)
+ renderer =
+ gtk_cell_area_get_cell_at_position (area, context, widget,
+ cell_area, event_x, event_y,
+ &alloc_area);
+
+ if (renderer)
+ {
+ focus_renderer = gtk_cell_area_get_focus_from_sibling (area, renderer);
+ if (!focus_renderer)
+ focus_renderer = renderer;
+
+ /* If we're already editing, cancel it and set focus */
+ if (gtk_cell_area_get_edited_cell (area))
+ {
+ /* XXX Was it really canceled in this case ? */
+ gtk_cell_area_stop_editing (area, TRUE);
+ gtk_cell_area_set_focus_cell (area, focus_renderer);
+ retval = TRUE;
+ }
+ else
+ {
+ /* If we are activating via a focus sibling,
+ * we need to fetch the right cell area for the real event renderer */
+ if (focus_renderer != renderer)
+ gtk_cell_area_get_cell_allocation (area, context, widget, focus_renderer,
+ cell_area, &alloc_area);
+
+ gtk_cell_area_set_focus_cell (area, focus_renderer);
+ retval = gtk_cell_area_activate_cell (area, widget, focus_renderer,
+ event, &alloc_area, flags);
+ }
+ }
+ }
+ }
+
+ return retval;
+}
+
+static gboolean
+render_cell (GtkCellRenderer *renderer,
+ const GdkRectangle *cell_area,
+ const GdkRectangle *cell_background,
+ CellRenderData *data)
+{
+ GtkCellRenderer *focus_cell;
+ GtkCellRendererState flags;
+ GdkRectangle inner_area;
+
+ focus_cell = gtk_cell_area_get_focus_cell (data->area);
+ flags = data->render_flags;
+
+ gtk_cell_area_inner_cell_area (data->area, data->widget, cell_area, &inner_area);
+
+ if ((flags & GTK_CELL_RENDERER_FOCUSED) &&
+ (data->focus_all ||
+ (focus_cell &&
+ (renderer == focus_cell ||
+ gtk_cell_area_is_focus_sibling (data->area, focus_cell, renderer)))))
+ {
+ gint focus_line_width;
+ GdkRectangle cell_focus;
+
+ gtk_cell_renderer_get_aligned_area (renderer, data->widget, flags, &inner_area, &cell_focus);
+
+ gtk_widget_style_get (data->widget,
+ "focus-line-width", &focus_line_width,
+ NULL);
+
+ /* The focus rectangle is located around the aligned area of the cell */
+ cell_focus.x -= focus_line_width;
+ cell_focus.y -= focus_line_width;
+ cell_focus.width += 2 * focus_line_width;
+ cell_focus.height += 2 * focus_line_width;
+
+ if (data->first_focus)
+ {
+ data->first_focus = FALSE;
+ data->focus_rect = cell_focus;
+ }
+ else
+ {
+ gdk_rectangle_union (&data->focus_rect, &cell_focus, &data->focus_rect);
+ }