[gtk+] dnd: Add gtk_drag_set_icon_texture()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] dnd: Add gtk_drag_set_icon_texture()
- Date: Sat, 2 Dec 2017 15:22:46 +0000 (UTC)
commit 481c6ad99a1b1c10e3384095bd7756451690a2e1
Author: Benjamin Otte <otte redhat com>
Date: Sat Dec 2 14:28:05 2017 +0100
dnd: Add gtk_drag_set_icon_texture()
docs/reference/gtk/gtk4-sections.txt | 1 +
gtk/gtkdnd.c | 32 ++++++++++++++++++++++++++++++++
gtk/gtkdnd.h | 5 +++++
3 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index fb52430..00eb3e1 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -5317,6 +5317,7 @@ gtk_drag_begin_with_coordinates
gtk_drag_cancel
gtk_drag_set_icon_widget
gtk_drag_set_icon_surface
+gtk_drag_set_icon_texture
gtk_drag_set_icon_name
gtk_drag_set_icon_gicon
gtk_drag_set_icon_default
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index c3e6531..f0364ca 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -1620,6 +1620,38 @@ gtk_drag_set_icon_surface (GdkDragContext *context,
}
/**
+ * gtk_drag_set_icon_texture: (method)
+ * @context: the context for a drag (This must be called
+ * with a context for the source side of a drag)
+ * @texture: the #GdkTexture to use as icon
+ * @hot_x: the X offset of the hotspot within the icon
+ * @hot_y: the Y offset of the hotspot within the icon
+ *
+ * Sets @texture as the icon for a given drag. GTK+ retains
+ * references for the arguments, and will release them when
+ * they are no longer needed.
+ *
+ * To position the texture relative to the mouse, its top
+ * left will be positioned @hot_x, @hot_y pixels from the
+ * mouse cursor.
+ */
+void
+gtk_drag_set_icon_texture (GdkDragContext *context,
+ GdkTexture *texture,
+ int hot_x,
+ int hot_y)
+{
+ GtkWidget *widget;
+
+ g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
+ g_return_if_fail (GDK_IS_TEXTURE (texture));
+
+ widget = gtk_image_new_from_texture (texture);
+
+ gtk_drag_set_icon_widget_internal (context, widget, hot_x, hot_y, TRUE);
+}
+
+/**
* gtk_drag_set_icon_name: (method)
* @context: the context for a drag (This must be called
* with a context for the source side of a drag)
diff --git a/gtk/gtkdnd.h b/gtk/gtkdnd.h
index 4038ac3..7b75165 100644
--- a/gtk/gtkdnd.h
+++ b/gtk/gtkdnd.h
@@ -80,6 +80,11 @@ void gtk_drag_set_icon_widget (GdkDragContext *context,
GDK_AVAILABLE_IN_ALL
void gtk_drag_set_icon_surface(GdkDragContext *context,
cairo_surface_t *surface);
+GDK_AVAILABLE_IN_3_94
+void gtk_drag_set_icon_texture(GdkDragContext *context,
+ GdkTexture *texture,
+ int hot_x,
+ int hot_y);
GDK_AVAILABLE_IN_ALL
void gtk_drag_set_icon_name (GdkDragContext *context,
const gchar *icon_name,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]