[gtk+/rendering-cleanup: 60/76] API: make gtk_icon_view_create_drag_icon() return a cairo_surface_t



commit c052ac8ca08c1c97980d2f2c6edb4094aa02dfda
Author: Benjamin Otte <otte redhat com>
Date:   Tue Aug 24 16:03:09 2010 +0200

    API: make gtk_icon_view_create_drag_icon() return a cairo_surface_t
    
    GdkPixmap is going to die!

 gtk/gtkiconview.c |   32 +++++++++++++++-----------------
 gtk/gtkiconview.h |    2 +-
 2 files changed, 16 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index eb4d6e5..22079cc 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -6810,7 +6810,7 @@ gtk_icon_view_drag_begin (GtkWidget      *widget,
 {
   GtkIconView *icon_view;
   GtkIconViewItem *item;
-  GdkPixmap *icon;
+  cairo_surface_t *icon;
   gint x, y;
   GtkTreePath *path;
 
@@ -6835,13 +6835,11 @@ gtk_icon_view_drag_begin (GtkWidget      *widget,
   icon = gtk_icon_view_create_drag_icon (icon_view, path);
   gtk_tree_path_free (path);
 
-  gtk_drag_set_icon_pixmap (context, 
-			    gdk_drawable_get_colormap (icon),
-			    icon, 
-			    NULL, 
-			    x, y);
+  cairo_surface_set_device_offset (icon, -x, -y);
 
-  g_object_unref (icon);
+  gtk_drag_set_icon_surface (context, icon);
+
+  cairo_surface_destroy (icon);
 }
 
 static void 
@@ -7412,20 +7410,20 @@ gtk_icon_view_get_dest_item_at_pos (GtkIconView              *icon_view,
  * @icon_view: a #GtkIconView
  * @path: a #GtkTreePath in @icon_view
  *
- * Creates a #GdkPixmap representation of the item at @path.  
+ * Creates a #cairo_surface_t representation of the item at @path.  
  * This image is used for a drag icon.
  *
- * Return value: a newly-allocated pixmap of the drag icon.
+ * Return value: a newly-allocated surface of the drag icon.
  * 
  * Since: 2.8
  **/
-GdkPixmap *
+cairo_surface_t *
 gtk_icon_view_create_drag_icon (GtkIconView *icon_view,
 				GtkTreePath *path)
 {
   GtkWidget *widget;
   cairo_t *cr;
-  GdkPixmap *drawable;
+  cairo_surface_t *surface;
   GList *l;
   gint index;
 
@@ -7445,12 +7443,12 @@ gtk_icon_view_create_drag_icon (GtkIconView *icon_view,
       
       if (index == item->index)
 	{
-	  drawable = gdk_pixmap_new (icon_view->priv->bin_window,
-				     item->width + 2,
-				     item->height + 2,
-				     -1);
+	  surface = gdk_window_create_similar_surface (icon_view->priv->bin_window,
+                                                       CAIRO_CONTENT_COLOR,
+                                                       item->width + 2,
+                                                       item->height + 2);
 
-	  cr = gdk_cairo_create (drawable);
+	  cr = cairo_create (surface);
 	  cairo_set_line_width (cr, 1.);
 
 	  gdk_cairo_set_source_color
@@ -7473,7 +7471,7 @@ gtk_icon_view_create_drag_icon (GtkIconView *icon_view,
 
 	  cairo_destroy (cr);
 
-	  return drawable;
+	  return surface;
 	}
     }
   
diff --git a/gtk/gtkiconview.h b/gtk/gtkiconview.h
index 5e85fc1..55a38e3 100644
--- a/gtk/gtkiconview.h
+++ b/gtk/gtkiconview.h
@@ -226,7 +226,7 @@ gboolean               gtk_icon_view_get_dest_item_at_pos     (GtkIconView
 							       gint                      drag_y,
 							       GtkTreePath             **path,
 							       GtkIconViewDropPosition  *pos);
-GdkPixmap             *gtk_icon_view_create_drag_icon         (GtkIconView              *icon_view,
+cairo_surface_t       *gtk_icon_view_create_drag_icon         (GtkIconView              *icon_view,
 							       GtkTreePath              *path);
 
 void    gtk_icon_view_convert_widget_to_bin_window_coords     (GtkIconView *icon_view,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]