static void
gossip_cell_renderer_expander_render (GtkCellRenderer      *cell,
				      cairo_t              *cr,
				      GtkWidget            *widget,
				      const GdkRectangle   *background_area,
				      const GdkRectangle   *cell_area,
				      GtkCellRendererState  flags)
{
	GossipCellRendererExpander     *expander;
	GossipCellRendererExpanderPriv *priv;
	GtkStyleContext                *style_context;
	gint                            x_offset, y_offset;
	gint                            xpad, ypad;

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

	gossip_cell_renderer_expander_get_size (cell, widget, cell_area,
						&x_offset, &y_offset,
						NULL, NULL);
	gtk_cell_renderer_get_padding (cell, &xpad, &ypad);

	style_context = gtk_widget_get_style_context (widget);
	gtk_style_context_set_state (style_context, priv->style_flags);

	gtk_render_expander (gtk_widget_get_style_context (widget),
			     cr,
			     cell_area->x + x_offset + xpad,
			     cell_area->y + y_offset + ypad,
			     priv->expander_size,
			     priv->expander_size);
}
Beispiel #2
0
static void
gm_cell_renderer_expander_render (GtkCellRenderer                    *cell,
				  cairo_t                            *cr,
				  GtkWidget                          *widget,
				  G_GNUC_UNUSED const GdkRectangle   *background_area,
				  const GdkRectangle                 *cell_area,
				  GtkCellRendererState               flags)
{
	GmCellRendererExpander     *expander;
	GmCellRendererExpanderPriv *priv;
	gint                            x_offset, y_offset;
	guint                           xpad, ypad;
	GtkStyleContext                 *style;
	GtkStateFlags                    state;

	expander = (GmCellRendererExpander *) cell;
	priv = expander->priv;

	gm_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);
}
Beispiel #3
0
static gboolean
draw_cb_expanders (GtkWidget *widget, cairo_t *cr)
{
  GtkStyleContext *context;

  context = gtk_widget_get_style_context (widget);

  gtk_style_context_save (context);

  gtk_style_context_add_class (context, "expander");
  gtk_style_context_set_state (context, 0);
  gtk_render_expander (context, cr, 12, 12, 12, 12);
  gtk_style_context_set_state (context, GTK_STATE_FLAG_PRELIGHT);
  gtk_render_expander (context, cr, 36, 12, 12, 12);
  gtk_style_context_set_state (context, GTK_STATE_FLAG_ACTIVE);
  gtk_render_expander (context, cr, 60, 12, 12, 12);
  gtk_style_context_set_state (context, GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_ACTIVE);
  gtk_render_expander (context, cr, 84, 12, 12, 12);

  gtk_style_context_restore (context);

  return TRUE;
}
Beispiel #4
0
static void
draw_expander (ECellTreeView *ectv,
               cairo_t *cr,
               GtkExpanderStyle expander_style,
               GtkStateType state,
               GdkRectangle *rect)
{
	GtkStyleContext *style_context;
	GtkWidget *tree;
	GtkStateFlags flags = 0;
	gint exp_size;

	tree = gtk_widget_get_parent (GTK_WIDGET (ectv->canvas));
	style_context = gtk_widget_get_style_context (tree);

	gtk_style_context_save (style_context);

	gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_EXPANDER);

	switch (state) {
		case GTK_STATE_PRELIGHT:
			flags |= GTK_STATE_FLAG_PRELIGHT;
			break;
		case GTK_STATE_SELECTED:
			flags |= GTK_STATE_FLAG_SELECTED;
			break;
		case GTK_STATE_INSENSITIVE:
			flags |= GTK_STATE_FLAG_INSENSITIVE;
			break;
		default:
			break;
	}

	/* XXX GTK 3.13.7 broke backward-compat on which state flag controls
	 *     how an expander is drawn.
	 *
	 *     Older versions used GTK_STATE_FLAG_ACTIVE, 3.13.7 and later
	 *     changed it to GTK_STATE_FLAG_CHECKED.
	 *
	 *     See https://bugzilla.gnome.org/733967 for details. */
	if (expander_style == GTK_EXPANDER_EXPANDED) {
#if GTK_CHECK_VERSION(3,13,7)
		flags |= GTK_STATE_FLAG_CHECKED;
#else
		flags |= GTK_STATE_FLAG_ACTIVE;
#endif
	}

	gtk_style_context_set_state (style_context, flags);

	gtk_widget_style_get (tree, "expander_size", &exp_size, NULL);

	cairo_save (cr);

	gtk_render_expander (
		style_context, cr,
		(gdouble) rect->x + rect->width - exp_size,
		(gdouble) (rect->y + rect->height / 2) - (exp_size / 2),
		(gdouble) exp_size,
		(gdouble) exp_size);

	cairo_restore (cr);

	gtk_style_context_restore (style_context);
}