static void
empathy_cell_renderer_expander_render (GtkCellRenderer      *cell,
				      cairo_t *cr,
				      GtkWidget            *widget,
				      const GdkRectangle   *background_area,
				      const GdkRectangle   *cell_area,
				      GtkCellRendererState  flags)
{
	EmpathyCellRendererExpander     *expander;
	EmpathyCellRendererExpanderPriv *priv;
	gint                            x_offset, y_offset;
	guint                           xpad, ypad;
	GtkStyleContext                 *style;
	GtkStateFlags                    state;

	expander = (EmpathyCellRendererExpander *) cell;
	priv = GET_PRIV (expander);

	empathy_cell_renderer_expander_get_size (cell, widget,
						(GdkRectangle *) cell_area,
						&x_offset, &y_offset,
						NULL, NULL);

	g_object_get (cell,
		      "xpad", &xpad,
		      "ypad", &ypad,
		      NULL);

	style = gtk_widget_get_style_context (widget);

	gtk_style_context_save (style);
	gtk_style_context_add_class (style, GTK_STYLE_CLASS_EXPANDER);

	state = gtk_cell_renderer_get_state (cell, widget, flags);

	if (priv->expander_style == GTK_EXPANDER_COLLAPSED)
		state |= GTK_STATE_FLAG_NORMAL;
	else
		state |= GTK_STATE_FLAG_ACTIVE;

	gtk_style_context_set_state (style, state);

	gtk_render_expander (style,
			     cr,
			     cell_area->x + x_offset + xpad,
			     cell_area->y + y_offset + ypad,
			     priv->expander_size,
			     priv->expander_size);

	gtk_style_context_restore (style);
}
Ejemplo n.º 2
0
static void
empathy_cell_renderer_expander_render (GtkCellRenderer      *cell,
				      GdkWindow            *window,
				      GtkWidget            *widget,
				      GdkRectangle         *background_area,
				      GdkRectangle         *cell_area,
				      GdkRectangle         *expose_area,
				      GtkCellRendererState  flags)
{
	EmpathyCellRendererExpander     *expander;
	EmpathyCellRendererExpanderPriv *priv;
	GtkExpanderStyle                expander_style;
	gint                            x_offset, y_offset;

	expander = (EmpathyCellRendererExpander*) cell;
	priv = GET_PRIV (expander);

	if (priv->animation_node) {
		GtkTreePath *path;
		GdkRectangle rect;

		/* Not sure if I like this ... */
		path = gtk_tree_row_reference_get_path (priv->animation_node);
		gtk_tree_view_get_background_area (priv->animation_view, path,
						   NULL, &rect);
		gtk_tree_path_free (path);

		if (background_area->y == rect.y)
			expander_style = priv->animation_style;
		else
			expander_style = priv->expander_style;
	} else
		expander_style = priv->expander_style;

	empathy_cell_renderer_expander_get_size (cell, widget, cell_area,
						&x_offset, &y_offset,
						NULL, NULL);

	gtk_paint_expander (widget->style,
			    window,
			    GTK_STATE_NORMAL,
			    expose_area,
			    widget,
			    "treeview",
			    cell_area->x + x_offset + cell->xpad + priv->expander_size / 2,
			    cell_area->y + y_offset + cell->ypad + priv->expander_size / 2,
			    expander_style);
}