void gtk_cell_renderer_bubble_set_show_bubble (GtkCellRendererBubble *cell, gboolean show_bubble) { g_return_if_fail (GTK_IS_CELL_RENDERER_BUBBLE (cell)); cell->priv->show_bubble = show_bubble; }
static void render (GtkCellRenderer *cell, GdkDrawable *window, GtkWidget *widget, GdkRectangle *background_area, GdkRectangle *cell_area, GdkRectangle *expose_area, GtkCellRendererState flags) { GtkCellRendererClass *klass; GtkCellRendererBubblePrivate *priv; cairo_t *cr; GdkColor color; gint radius; g_return_if_fail(GTK_IS_CELL_RENDERER_BUBBLE (cell)); priv = GTK_CELL_RENDERER_BUBBLE (cell)->priv; if (priv->show_bubble) { cr = gdk_cairo_create(GDK_DRAWABLE (window)); gdk_color_parse("#ccc", &color); gdk_cairo_set_source_color(cr, &color); radius = MIN(cell_area->width, cell_area->height) / 2; cairo_arc(cr, cell_area->x + (cell_area->width / 2), cell_area->y + (cell_area->height / 2), radius, 0, 2 * G_PI); cairo_fill(cr); cairo_destroy(cr); } klass = GTK_CELL_RENDERER_CLASS(gtk_cell_renderer_bubble_parent_class); klass->render(cell, window, widget, background_area, cell_area, expose_area, flags); }
gboolean gtk_cell_renderer_bubble_get_show_bubble (GtkCellRendererBubble *cell) { g_return_val_if_fail (GTK_IS_CELL_RENDERER_BUBBLE (cell), FALSE); return cell->priv->show_bubble; }
static void render (GtkCellRenderer *cell, GdkDrawable *window, GtkWidget *widget, GdkRectangle *background_area, GdkRectangle *cell_area, GdkRectangle *expose_area, GtkCellRendererState flags) { GtkCellRendererBubblePrivate *priv; cairo_t *cr; cairo_pattern_t *pattern; GdkColor *start; GdkColor *stop; g_return_if_fail (GTK_IS_CELL_RENDERER_BUBBLE (cell)); priv = GTK_CELL_RENDERER_BUBBLE (cell)->priv; if (priv->show_bubble) { cr = gdk_cairo_create (GDK_DRAWABLE (window)); g_assert (cr); start = &widget->style->light [GTK_STATE_SELECTED]; stop = &widget->style->mid [GTK_STATE_SELECTED]; pattern = cairo_pattern_create_linear (cell_area->x, cell_area->y, cell_area->x, cell_area->y + cell_area->height); cairo_pattern_add_color_stop_rgb (pattern, 0.3, start->red / (gdouble)G_MAXUINT16, start->green / (gdouble)G_MAXUINT16, start->blue / (gdouble)G_MAXUINT16); cairo_pattern_add_color_stop_rgb (pattern, 0.9, stop->red / (gdouble)G_MAXUINT16, stop->green / (gdouble)G_MAXUINT16, stop->blue / (gdouble)G_MAXUINT16); rounded_rectangle (cr, cell_area->x, cell_area->y + 1, cell_area->width, cell_area->height - 2, cell_area->height / 2.5, cell_area->height / 2.5); cairo_set_source (cr, pattern); cairo_fill_preserve (cr); gdk_cairo_set_source_color (cr, &widget->style->dark [GTK_STATE_SELECTED]); cairo_set_line_width (cr, 1.0); cairo_stroke (cr); rounded_rectangle (cr, cell_area->x + 1.0, cell_area->y + 2.0, cell_area->width - 2.0, cell_area->height - 4.0, cell_area->height / 2.5, cell_area->height / 2.5); gdk_cairo_set_source_color (cr, &widget->style->light [GTK_STATE_SELECTED]); cairo_stroke (cr); cairo_destroy (cr); } GTK_CELL_RENDERER_CLASS (gtk_cell_renderer_bubble_parent_class)-> render (cell, window, widget, background_area, cell_area, expose_area, flags); }