285 GtkStyleContext *context = gtk_widget_get_style_context (widget);
286 GdkRectangle toggle_rect;
287 GdkRectangle draw_rect;
288 GdkRectangle clip_rect;
296 GTK_CELL_RENDERER_CLASS (parent_class)->render (cell,
305 gtk_cell_renderer_get_size (cell, widget, cell_area,
309 &toggle_rect.height);
311 gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
312 toggle_rect.x += cell_area->x + xpad;
313 toggle_rect.y += cell_area->y + ypad;
314 toggle_rect.width -= xpad * 2;
315 toggle_rect.height -= ypad * 2;
317 if (toggle_rect.width <= 0 || toggle_rect.height <= 0)
321 gtk_cell_renderer_toggle_get_active (GTK_CELL_RENDERER_TOGGLE (cell));
323 if (!gtk_cell_renderer_get_sensitive (cell))
325 state = GTK_STATE_FLAG_INSENSITIVE;
327 else if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED)
329 if (gtk_widget_has_focus (widget))
330 state = GTK_STATE_FLAG_SELECTED;
332 state = GTK_STATE_FLAG_ACTIVE;
336 if (gtk_cell_renderer_toggle_get_activatable (GTK_CELL_RENDERER_TOGGLE (cell)))
339 state = GTK_STATE_FLAG_INSENSITIVE;
342 if ((flags & GTK_CELL_RENDERER_PRELIT) &&
343 gdk_cairo_get_clip_rectangle(cr, &clip_rect) &&
344 gdk_rectangle_intersect (&clip_rect, cell_area, &draw_rect))
347 gtk_style_context_save (context);
348 gdk_cairo_rectangle (cr, &draw_rect);
350 gtk_render_frame (context,
352 toggle_rect.x, toggle_rect.y,
353 toggle_rect.width, toggle_rect.height);
354 gtk_style_context_restore (context);
360 GdkPixbuf *insensitive = NULL;
361 GdkPixbuf *pixbuf = toggle->
pixbuf;
362 GtkBorder border = { 1, 1, 1, 1 };
369 gtk_style_context_get_border (context, state, &border);
372 toggle_rect.x += border.left;
373 toggle_rect.y += border.top;
374 toggle_rect.width -= (border.left + border.right);
375 toggle_rect.height -= (border.top + border.bottom);
377 if (state & GTK_STATE_FLAG_INSENSITIVE)
379 GtkIconSource *source;
381 source = gtk_icon_source_new ();
382 gtk_icon_source_set_pixbuf (source, pixbuf);
387 gtk_icon_source_set_size (source, GTK_ICON_SIZE_SMALL_TOOLBAR);
388 gtk_icon_source_set_size_wildcarded (source,
FALSE);
390 gtk_style_context_save (context);
391 gtk_style_context_set_state (context, GTK_STATE_FLAG_INSENSITIVE);
392 insensitive = gtk_render_icon_pixbuf (context, source, (GtkIconSize)-1);
393 gtk_style_context_restore (context);
395 gtk_icon_source_free (source);
397 pixbuf = insensitive;
400 if (gdk_rectangle_intersect (&draw_rect, &toggle_rect, &draw_rect))
402 gdk_cairo_set_source_pixbuf (cr, pixbuf, toggle_rect.x, toggle_rect.y);
403 gdk_cairo_rectangle (cr, &draw_rect);
408 g_object_unref (insensitive);