[gtk/dnd-gestures-2: 128/242] stackswitcher: Port to GtkDropTarget
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/dnd-gestures-2: 128/242] stackswitcher: Port to GtkDropTarget
- Date: Tue, 7 Jan 2020 19:54:08 +0000 (UTC)
commit 9f72807ce7164b6af9f3a013385b0064b440b375
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jan 2 00:21:01 2020 -0500
stackswitcher: Port to GtkDropTarget
gtk/gtkstackswitcher.c | 37 +++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkstackswitcher.c b/gtk/gtkstackswitcher.c
index 07de3af617..0b5c5ff656 100644
--- a/gtk/gtkstackswitcher.c
+++ b/gtk/gtkstackswitcher.c
@@ -93,6 +93,14 @@ enum {
PROP_STACK
};
+static void gtk_stack_switcher_drag_leave (GtkDropTarget *dest,
+ GtkStackSwitcher *self);
+static gboolean gtk_stack_switcher_drag_motion (GtkDropTarget *dest,
+ int x,
+ int y,
+ GtkStackSwitcher *self);
+
+
G_DEFINE_TYPE_WITH_PRIVATE (GtkStackSwitcher, gtk_stack_switcher, GTK_TYPE_WIDGET)
static void
@@ -100,14 +108,21 @@ gtk_stack_switcher_init (GtkStackSwitcher *switcher)
{
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (switcher);
GtkStyleContext *context;
+ GdkContentFormats *formats;
+ GtkDropTarget *dest;
priv->buttons = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL);
context = gtk_widget_get_style_context (GTK_WIDGET (switcher));
gtk_style_context_add_class (context, GTK_STYLE_CLASS_LINKED);
- gtk_drag_dest_set (GTK_WIDGET (switcher), 0, NULL, 0);
- gtk_drag_dest_set_track_motion (GTK_WIDGET (switcher), TRUE);
+ formats = gdk_content_formats_new (NULL, 0);
+ dest = gtk_drop_target_new (0, formats, 0);
+ gdk_content_formats_unref (formats);
+ gtk_drop_target_set_track_motion (dest, TRUE);
+ g_signal_connect (dest, "drag-leave", G_CALLBACK (gtk_stack_switcher_drag_leave), switcher);
+ g_signal_connect (dest, "drag-motion", G_CALLBACK (gtk_stack_switcher_drag_motion), switcher);
+ gtk_drop_target_attach (dest, GTK_WIDGET (switcher));
}
static void
@@ -249,12 +264,11 @@ gtk_stack_switcher_switch_timeout (gpointer data)
}
static gboolean
-gtk_stack_switcher_drag_motion (GtkWidget *widget,
- GdkDrop *drop,
- gint x,
- gint y)
+gtk_stack_switcher_drag_motion (GtkDropTarget *dest,
+ int x,
+ int y,
+ GtkStackSwitcher *self)
{
- GtkStackSwitcher *self = GTK_STACK_SWITCHER (widget);
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (self);
GtkWidget *button;
GHashTableIter iter;
@@ -292,11 +306,9 @@ gtk_stack_switcher_drag_motion (GtkWidget *widget,
}
static void
-gtk_stack_switcher_drag_leave (GtkWidget *widget,
- GdkDrop *drop)
+gtk_stack_switcher_drag_leave (GtkDropTarget *dest,
+ GtkStackSwitcher *self)
{
- GtkStackSwitcher *self = GTK_STACK_SWITCHER (widget);
-
remove_switch_timer (self);
}
@@ -562,9 +574,6 @@ gtk_stack_switcher_class_init (GtkStackSwitcherClass *class)
object_class->dispose = gtk_stack_switcher_dispose;
object_class->finalize = gtk_stack_switcher_finalize;
- widget_class->drag_motion = gtk_stack_switcher_drag_motion;
- widget_class->drag_leave = gtk_stack_switcher_drag_leave;
-
g_object_class_install_property (object_class,
PROP_STACK,
g_param_spec_object ("stack",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]