diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-01-02 00:21:01 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-01-08 18:48:20 -0500 |
commit | 07c889c5ea7ba202ece23258a1ecc6aa32f26fff (patch) | |
tree | de934ceb0d5b37f7af332757daaf228c5f9d05fe /gtk/gtkstackswitcher.c | |
parent | b0d9a6ff2037ee4008ff6cb64bf42a0be3da0450 (diff) | |
download | gtk+-07c889c5ea7ba202ece23258a1ecc6aa32f26fff.tar.gz |
stackswitcher: Port to GtkDropTarget
Diffstat (limited to 'gtk/gtkstackswitcher.c')
-rw-r--r-- | gtk/gtkstackswitcher.c | 37 |
1 files 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", |