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



commit 34fa43c8c02e90d10225ce4fc29f0f38bd8d4741
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 c36fdbb..a0c4013 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -6862,7 +6862,7 @@ gtk_icon_view_drag_begin (GtkWidget      *widget,
 {
   GtkIconView *icon_view;
   GtkIconViewItem *item;
-  GdkPixmap *icon;
+  cairo_surface_t *icon;
   gint x, y;
   GtkTreePath *path;
 
@@ -6887,13 +6887,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 
@@ -7464,20 +7462,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;
 
@@ -7497,12 +7495,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 (cr, &gtk_widget_get_style (widget)->base[gtk_widget_get_state (widget)]);
@@ -7524,7 +7522,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 cdf79b7..f46d533 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]