forked from AuroraMiddleware/gtk
selection: Add texture getter/setter
This commit is contained in:
parent
85b3f6d372
commit
20de4c86ad
@ -5207,6 +5207,8 @@ gtk_selection_data_set_pixbuf
|
|||||||
gtk_selection_data_get_pixbuf
|
gtk_selection_data_get_pixbuf
|
||||||
gtk_selection_data_set_surface
|
gtk_selection_data_set_surface
|
||||||
gtk_selection_data_get_surface
|
gtk_selection_data_get_surface
|
||||||
|
gtk_selection_data_set_texture
|
||||||
|
gtk_selection_data_get_texture
|
||||||
gtk_selection_data_set_uris
|
gtk_selection_data_set_uris
|
||||||
gtk_selection_data_get_uris
|
gtk_selection_data_get_uris
|
||||||
gtk_selection_data_get_targets
|
gtk_selection_data_get_targets
|
||||||
|
@ -90,6 +90,7 @@
|
|||||||
#include "gdk-pixbuf/gdk-pixbuf.h"
|
#include "gdk-pixbuf/gdk-pixbuf.h"
|
||||||
|
|
||||||
#include "gdk/gdkcontentformatsprivate.h"
|
#include "gdk/gdkcontentformatsprivate.h"
|
||||||
|
#include "gdk/gdktextureprivate.h"
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_X11
|
#ifdef GDK_WINDOWING_X11
|
||||||
#include "x11/gdkx.h"
|
#include "x11/gdkx.h"
|
||||||
@ -1555,6 +1556,69 @@ gtk_selection_data_get_pixbuf (const GtkSelectionData *selection_data)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_selection_data_set_texture:
|
||||||
|
* @selection_data: a #GtkSelectionData
|
||||||
|
* @texture: a #GdkTexture
|
||||||
|
*
|
||||||
|
* Sets the contents of the selection from a #GdkTexture.
|
||||||
|
* The surface is converted to the form determined by
|
||||||
|
* @selection_data->target.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if the selection was successfully set,
|
||||||
|
* otherwise %FALSE.
|
||||||
|
*
|
||||||
|
* Since: 3.94
|
||||||
|
**/
|
||||||
|
gboolean
|
||||||
|
gtk_selection_data_set_texture (GtkSelectionData *selection_data,
|
||||||
|
GdkTexture *texture)
|
||||||
|
{
|
||||||
|
cairo_surface_t *surface;
|
||||||
|
gboolean retval;
|
||||||
|
|
||||||
|
g_return_val_if_fail (selection_data != NULL, FALSE);
|
||||||
|
g_return_val_if_fail (GDK_IS_TEXTURE (texture), FALSE);
|
||||||
|
|
||||||
|
surface = gdk_texture_download_surface (texture);
|
||||||
|
retval = gtk_selection_data_set_surface (selection_data, surface);
|
||||||
|
cairo_surface_destroy (surface);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_selection_data_get_texture:
|
||||||
|
* @selection_data: a #GtkSelectionData
|
||||||
|
*
|
||||||
|
* Gets the contents of the selection data as a #GdkPixbuf.
|
||||||
|
*
|
||||||
|
* Returns: (nullable) (transfer full): if the selection data
|
||||||
|
* contained a recognized image type and it could be converted to a
|
||||||
|
* #GdkTexture, a newly allocated texture is returned, otherwise
|
||||||
|
* %NULL. If the result is non-%NULL it must be freed with
|
||||||
|
* g_object_unref().
|
||||||
|
*
|
||||||
|
* Since: 3.94
|
||||||
|
**/
|
||||||
|
GdkTexture *
|
||||||
|
gtk_selection_data_get_texture (const GtkSelectionData *selection_data)
|
||||||
|
{
|
||||||
|
GdkTexture *texture;
|
||||||
|
GdkPixbuf *pixbuf;
|
||||||
|
|
||||||
|
g_return_val_if_fail (selection_data != NULL, NULL);
|
||||||
|
|
||||||
|
pixbuf = gtk_selection_data_get_pixbuf (selection_data);
|
||||||
|
if (pixbuf == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||||
|
g_object_unref (pixbuf);
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_selection_data_set_uris:
|
* gtk_selection_data_set_uris:
|
||||||
* @selection_data: a #GtkSelectionData
|
* @selection_data: a #GtkSelectionData
|
||||||
|
@ -115,6 +115,11 @@ gboolean gtk_selection_data_set_surface (GtkSelectionData *selection_data,
|
|||||||
cairo_surface_t *surface);
|
cairo_surface_t *surface);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GdkPixbuf *gtk_selection_data_get_pixbuf (const GtkSelectionData *selection_data);
|
GdkPixbuf *gtk_selection_data_get_pixbuf (const GtkSelectionData *selection_data);
|
||||||
|
GDK_AVAILABLE_IN_3_94
|
||||||
|
gboolean gtk_selection_data_set_texture (GtkSelectionData *selection_data,
|
||||||
|
GdkTexture *texture);
|
||||||
|
GDK_AVAILABLE_IN_3_94
|
||||||
|
GdkTexture *gtk_selection_data_get_texture (const GtkSelectionData *selection_data);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
gboolean gtk_selection_data_set_uris (GtkSelectionData *selection_data,
|
gboolean gtk_selection_data_set_uris (GtkSelectionData *selection_data,
|
||||||
gchar **uris);
|
gchar **uris);
|
||||||
|
Loading…
Reference in New Issue
Block a user