[gtk+/rendering-cleanup: 53/141] testview: Convert _gtk_text_util_create_rich_drag_icon() to use surfaces
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/rendering-cleanup: 53/141] testview: Convert _gtk_text_util_create_rich_drag_icon() to use surfaces
- Date: Sat, 11 Sep 2010 03:05:05 +0000 (UTC)
commit e9ebe5c460b50c0b6bb4d6043988108b2164e925
Author: Benjamin Otte <otte redhat com>
Date: Sun Aug 15 21:24:55 2010 +0200
testview: Convert _gtk_text_util_create_rich_drag_icon() to use surfaces
gtk/gtktextutil.c | 20 ++++++++++++--------
gtk/gtktextutil.h | 8 ++++----
gtk/gtktextview.c | 22 +++++++++-------------
3 files changed, 25 insertions(+), 25 deletions(-)
---
diff --git a/gtk/gtktextutil.c b/gtk/gtktextutil.c
index 262f89b..0ef71cf 100644
--- a/gtk/gtktextutil.c
+++ b/gtk/gtktextutil.c
@@ -280,14 +280,14 @@ gtk_text_view_set_attributes_from_style (GtkTextView *text_view,
values->font = pango_font_description_copy (style->font_desc);
}
-GdkPixmap *
+cairo_surface_t *
_gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
GtkTextBuffer *buffer,
GtkTextIter *start,
GtkTextIter *end)
{
GtkAllocation allocation;
- GdkDrawable *drawable = NULL;
+ cairo_surface_t *surface;
gint pixmap_height, pixmap_width;
gint layout_width, layout_height;
GtkStyle *widget_style;
@@ -303,7 +303,7 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
g_return_val_if_fail (start != NULL, NULL);
g_return_val_if_fail (end != NULL, NULL);
- widget_style = gtk_widget_get_style (widget);
+ widget_style = gtk_widget_get_style (widget);
new_buffer = gtk_text_buffer_new (gtk_text_buffer_get_tag_table (buffer));
gtk_text_buffer_get_start_iter (new_buffer, &iter);
@@ -359,12 +359,14 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
pixmap_width = layout_width + DRAG_ICON_LAYOUT_BORDER * 2;
pixmap_height = layout_height + DRAG_ICON_LAYOUT_BORDER * 2;
- drawable = gdk_pixmap_new (gtk_widget_get_window (widget),
- pixmap_width + 2, pixmap_height + 2, -1);
+ surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
+ CAIRO_CONTENT_COLOR,
+ pixmap_width + 2,
+ pixmap_height + 2);
- cr = gdk_cairo_create (drawable);
+ cr = cairo_create (surface);
- gdk_cairo_set_source_color (cr, &widget_style->base [gtk_widget_get_state (widget)]);
+ gdk_cairo_set_source_color (cr, &widget_style->base [gtk_widget_get_state (widget)]);
cairo_paint (cr);
cairo_save (cr);
@@ -383,7 +385,9 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
g_object_unref (layout);
g_object_unref (new_buffer);
- return drawable;
+ cairo_surface_set_device_offset (surface, 2, 2);
+
+ return surface;
}
diff --git a/gtk/gtktextutil.h b/gtk/gtktextutil.h
index 8aa7deb..358ead7 100644
--- a/gtk/gtktextutil.h
+++ b/gtk/gtktextutil.h
@@ -43,10 +43,10 @@ void _gtk_text_util_append_special_char_menuitems (GtkMenuShell *me
cairo_surface_t * _gtk_text_util_create_drag_icon (GtkWidget *widget,
gchar *text,
gsize len);
-GdkPixmap* _gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
- GtkTextBuffer *buffer,
- GtkTextIter *start,
- GtkTextIter *end);
+cairo_surface_t * _gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
+ GtkTextBuffer *buffer,
+ GtkTextIter *start,
+ GtkTextIter *end);
gboolean _gtk_text_util_get_block_cursor_location (PangoLayout *layout,
gint index_,
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 6ae5f1e..a34547c 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -6902,25 +6902,21 @@ drag_begin_cb (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
{
- GtkTextView *text_view = GTK_TEXT_VIEW (widget);
- GtkTextBuffer *buffer = gtk_text_view_get_buffer (text_view);
- GtkTextIter start;
- GtkTextIter end;
- GdkPixmap *pixmap = NULL;
+ GtkTextView *text_view = GTK_TEXT_VIEW (widget);
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer (text_view);
+ GtkTextIter start;
+ GtkTextIter end;
+ cairo_surface_t *surface = NULL;
g_signal_handlers_disconnect_by_func (widget, drag_begin_cb, NULL);
if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
- pixmap = _gtk_text_util_create_rich_drag_icon (widget, buffer, &start, &end);
+ surface = _gtk_text_util_create_rich_drag_icon (widget, buffer, &start, &end);
- if (pixmap)
+ if (surface)
{
- gtk_drag_set_icon_pixmap (context,
- gdk_drawable_get_colormap (pixmap),
- pixmap,
- NULL,
- -2, -2);
- g_object_unref (pixmap);
+ gtk_drag_set_icon_surface (context, surface);
+ cairo_surface_destroy (surface);
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]