mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-06 10:50:08 +00:00
stackswitcher: Port to GtkDropTarget
This commit is contained in:
parent
b0d9a6ff20
commit
07c889c5ea
@ -93,6 +93,14 @@ enum {
|
|||||||
PROP_STACK
|
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)
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkStackSwitcher, gtk_stack_switcher, GTK_TYPE_WIDGET)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -100,14 +108,21 @@ gtk_stack_switcher_init (GtkStackSwitcher *switcher)
|
|||||||
{
|
{
|
||||||
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (switcher);
|
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (switcher);
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
|
GdkContentFormats *formats;
|
||||||
|
GtkDropTarget *dest;
|
||||||
|
|
||||||
priv->buttons = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL);
|
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));
|
context = gtk_widget_get_style_context (GTK_WIDGET (switcher));
|
||||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_LINKED);
|
gtk_style_context_add_class (context, GTK_STYLE_CLASS_LINKED);
|
||||||
|
|
||||||
gtk_drag_dest_set (GTK_WIDGET (switcher), 0, NULL, 0);
|
formats = gdk_content_formats_new (NULL, 0);
|
||||||
gtk_drag_dest_set_track_motion (GTK_WIDGET (switcher), TRUE);
|
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
|
static void
|
||||||
@ -249,12 +264,11 @@ gtk_stack_switcher_switch_timeout (gpointer data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gtk_stack_switcher_drag_motion (GtkWidget *widget,
|
gtk_stack_switcher_drag_motion (GtkDropTarget *dest,
|
||||||
GdkDrop *drop,
|
int x,
|
||||||
gint x,
|
int y,
|
||||||
gint y)
|
GtkStackSwitcher *self)
|
||||||
{
|
{
|
||||||
GtkStackSwitcher *self = GTK_STACK_SWITCHER (widget);
|
|
||||||
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (self);
|
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (self);
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
@ -292,11 +306,9 @@ gtk_stack_switcher_drag_motion (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_stack_switcher_drag_leave (GtkWidget *widget,
|
gtk_stack_switcher_drag_leave (GtkDropTarget *dest,
|
||||||
GdkDrop *drop)
|
GtkStackSwitcher *self)
|
||||||
{
|
{
|
||||||
GtkStackSwitcher *self = GTK_STACK_SWITCHER (widget);
|
|
||||||
|
|
||||||
remove_switch_timer (self);
|
remove_switch_timer (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -562,9 +574,6 @@ gtk_stack_switcher_class_init (GtkStackSwitcherClass *class)
|
|||||||
object_class->dispose = gtk_stack_switcher_dispose;
|
object_class->dispose = gtk_stack_switcher_dispose;
|
||||||
object_class->finalize = gtk_stack_switcher_finalize;
|
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,
|
g_object_class_install_property (object_class,
|
||||||
PROP_STACK,
|
PROP_STACK,
|
||||||
g_param_spec_object ("stack",
|
g_param_spec_object ("stack",
|
||||||
|
Loading…
Reference in New Issue
Block a user