summaryrefslogtreecommitdiff
path: root/gtk/gtktextutil.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2018-03-26 06:49:55 +0200
committerBenjamin Otte <otte@redhat.com>2018-03-26 18:16:37 +0200
commit9afbf02bc219997c0a57df2460c48604876a8d3f (patch)
treed69d1a01dd3507e1d8c53e585f164a26e758db7d /gtk/gtktextutil.c
parent3f28a6851bda996bfcdbd79b1adbf0aa4cf0ef94 (diff)
downloadgtk+-9afbf02bc219997c0a57df2460c48604876a8d3f.tar.gz
textview: Port dnd icon to be a GdkPaintable
Diffstat (limited to 'gtk/gtktextutil.c')
-rw-r--r--gtk/gtktextutil.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/gtk/gtktextutil.c b/gtk/gtktextutil.c
index 236aac5c79..ae17123e0a 100644
--- a/gtk/gtktextutil.c
+++ b/gtk/gtktextutil.c
@@ -261,14 +261,15 @@ G_GNUC_END_IGNORE_DEPRECATIONS
gtk_style_context_get (context, "font", &values->font, NULL);
}
-cairo_surface_t *
-_gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
- GtkTextBuffer *buffer,
- GtkTextIter *start,
- GtkTextIter *end)
+GdkPaintable *
+gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
+ GtkTextBuffer *buffer,
+ GtkTextIter *start,
+ GtkTextIter *end)
{
GtkAllocation allocation;
- cairo_surface_t *surface;
+ GdkPaintable *paintable;
+ GtkSnapshot *snapshot;
gint layout_width, layout_height;
GtkTextBuffer *new_buffer;
GtkTextLayout *layout;
@@ -331,11 +332,10 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
layout_width = MIN (layout_width, DRAG_ICON_MAX_WIDTH);
layout_height = MIN (layout_height, DRAG_ICON_MAX_HEIGHT);
- surface = gdk_surface_create_similar_surface (gtk_widget_get_surface (widget),
- CAIRO_CONTENT_COLOR_ALPHA,
- layout_width, layout_height);
-
- cr = cairo_create (surface);
+ snapshot = gtk_snapshot_new (FALSE, NULL, "RichTextDragIcon");
+ cr = gtk_snapshot_append_cairo (snapshot,
+ &GRAPHENE_RECT_INIT (0, 0, layout_width, layout_height),
+ "Text");
gtk_text_layout_draw (layout, widget, cr);
@@ -343,7 +343,9 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
g_object_unref (layout);
g_object_unref (new_buffer);
- return surface;
+ paintable = gtk_snapshot_free_to_paintable (snapshot);
+
+ return paintable;
}
static gint