[gtk+] selection: Add surface based apis



commit ad00108678d6819ee2d8f864dff219a7db5b389c
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Oct 22 22:19:31 2017 +0200

    selection: Add surface based apis
    
    Add gtk_selection_data_set_surface.

 gtk/gtkselection.c |   17 +++++++++++++++++
 gtk/gtkselection.h |    3 +++
 2 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c
index 00b6f43..166e29f 100644
--- a/gtk/gtkselection.c
+++ b/gtk/gtkselection.c
@@ -1733,6 +1733,23 @@ gtk_selection_data_set_pixbuf (GtkSelectionData *selection_data,
   return FALSE;
 }
 
+gboolean
+gtk_selection_data_set_surface (GtkSelectionData *selection_data,
+                               cairo_surface_t  *surface)
+{
+  GdkPixbuf *pixbuf;
+  gboolean retval;
+
+  pixbuf = gdk_pixbuf_get_from_surface (surface,
+                                        0, 0,
+                                        cairo_image_surface_get_width (surface),
+                                        cairo_image_surface_get_height (surface));
+  retval = gtk_selection_data_set_pixbuf (selection_data, pixbuf);
+  g_object_unref (pixbuf);
+
+  return retval;
+}
+
 /**
  * gtk_selection_data_get_pixbuf:
  * @selection_data: a #GtkSelectionData
diff --git a/gtk/gtkselection.h b/gtk/gtkselection.h
index 678b3ac..e151571 100644
--- a/gtk/gtkselection.h
+++ b/gtk/gtkselection.h
@@ -224,6 +224,9 @@ guchar * gtk_selection_data_get_text (const GtkSelectionData     *selection_data
 GDK_AVAILABLE_IN_ALL
 gboolean gtk_selection_data_set_pixbuf   (GtkSelectionData  *selection_data,
                                           GdkPixbuf         *pixbuf);
+GDK_AVAILABLE_IN_3_94
+gboolean gtk_selection_data_set_surface (GtkSelectionData  *selection_data,
+                                         cairo_surface_t   *surface);
 GDK_AVAILABLE_IN_ALL
 GdkPixbuf *gtk_selection_data_get_pixbuf (const GtkSelectionData  *selection_data);
 GDK_AVAILABLE_IN_ALL


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