[gtk/drag-icon: 3/7] dnd: Use GtkDragIcon
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/drag-icon: 3/7] dnd: Use GtkDragIcon
- Date: Mon, 30 Dec 2019 06:15:30 +0000 (UTC)
commit 710b8d7f40b9bcd26fa6c230e9a5c0e05ddabe47
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Dec 30 00:24:13 2019 -0500
dnd: Use GtkDragIcon
Use the new GtkDragIcon instead of a window
of type GTK_WINDOW_POPUP and
gtk_window_set_hardcoded_surface.
gtk/gtkdnd.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
---
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 8b35cef978..e9024b6442 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -39,6 +39,7 @@
#include "gtkwindowgroup.h"
#include "gtkwindowprivate.h"
#include "gtknative.h"
+#include "gtkdragiconprivate.h"
#include "gdk/gdkcontentformatsprivate.h"
#include "gdk/gdktextureprivate.h"
@@ -1045,24 +1046,15 @@ gtk_drag_set_icon_widget_internal (GdkDrag *drag,
if (!info->icon_window)
{
- GdkDisplay *display;
-
- display = gdk_drag_get_display (drag);
-
- info->icon_window = gtk_window_new (GTK_WINDOW_POPUP);
- gtk_window_set_type_hint (GTK_WINDOW (info->icon_window), GDK_SURFACE_TYPE_HINT_DND);
- gtk_window_set_display (GTK_WINDOW (info->icon_window), display);
+ info->icon_window = gtk_drag_icon_new ();
+ g_object_ref_sink (info->icon_window);
gtk_widget_set_size_request (info->icon_window, 24, 24);
- gtk_style_context_remove_class (gtk_widget_get_style_context (info->icon_window), "background");
-
- gtk_window_set_hardcoded_surface (GTK_WINDOW (info->icon_window),
- gdk_drag_get_drag_surface (drag));
+ gtk_drag_icon_set_surface (GTK_DRAG_ICON (info->icon_window),
+ gdk_drag_get_drag_surface (drag));
gtk_widget_show (info->icon_window);
}
- if (gtk_bin_get_child (GTK_BIN (info->icon_window)))
- gtk_container_remove (GTK_CONTAINER (info->icon_window), gtk_bin_get_child (GTK_BIN
(info->icon_window)));
- gtk_container_add (GTK_CONTAINER (info->icon_window), widget);
+ gtk_drag_icon_set_widget (GTK_DRAG_ICON (info->icon_window), widget);
}
/**
@@ -1268,7 +1260,7 @@ gtk_drag_remove_icon (GtkDragSourceInfo *info)
if (info->destroy_icon)
gtk_widget_destroy (widget);
else
- gtk_container_remove (GTK_CONTAINER (info->icon_window), widget);
+ gtk_drag_icon_set_widget (GTK_DRAG_ICON (info->icon_window), NULL);
g_object_unref (widget);
}
@@ -1278,7 +1270,7 @@ static void
gtk_drag_source_info_free (GtkDragSourceInfo *info)
{
gtk_drag_remove_icon (info);
- gtk_widget_destroy (info->icon_window);
+ g_object_unref (info->icon_window);
g_free (info);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]