[gtk/dnd-gestures-2: 50/55] testnotebookdnd: Fix, partially
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/dnd-gestures-2: 50/55] testnotebookdnd: Fix, partially
- Date: Fri, 3 Jan 2020 00:48:19 +0000 (UTC)
commit 94b4a1ab2cc2f2bc8d9f109549bc61ee4f8bdd21
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jan 2 08:51:20 2020 -0500
testnotebookdnd: Fix, partially
Make this mostly work again.
tests/testnotebookdnd.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/tests/testnotebookdnd.c b/tests/testnotebookdnd.c
index 44e8f095d7..80a196f7be 100644
--- a/tests/testnotebookdnd.c
+++ b/tests/testnotebookdnd.c
@@ -94,7 +94,7 @@ static gboolean
remove_in_idle (gpointer data)
{
GtkWidget *child = data;
- GtkWidget *parent = gtk_widget_get_parent (child);
+ GtkWidget *parent = gtk_widget_get_ancestor (child, GTK_TYPE_NOTEBOOK);
GtkWidget *tab_label;
tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (parent), child);
@@ -105,8 +105,7 @@ remove_in_idle (gpointer data)
}
static void
-on_button_drag_data_received (GtkWidget *widget,
- GdkDrop *drop,
+on_button_drag_data_received (GtkDropTarget *dest,
GtkSelectionData *data,
gpointer user_data)
{
@@ -199,12 +198,18 @@ create_notebook_non_dragable_content (gchar **labels,
while (*labels)
{
GtkWidget *button;
- button = gtk_button_new_with_label (*labels);
+ button = gtk_button_new_with_label ("example content");
/* Use GtkListBox since it bubbles up motion notify event, which can
* experience more issues than GtkBox. */
page = gtk_list_box_new ();
gtk_container_add (GTK_CONTAINER (page), button);
+ button = gtk_button_new_with_label ("row 2");
+ gtk_container_add (GTK_CONTAINER (page), button);
+
+ button = gtk_button_new_with_label ("third row");
+ gtk_container_add (GTK_CONTAINER (page), button);
+
title = gtk_label_new (*labels);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, title);
@@ -260,18 +265,16 @@ create_trash_button (void)
{
GdkContentFormats *targets;
GtkWidget *button;
+ GtkDropTarget *dest;
button = gtk_button_new_with_mnemonic ("_Delete");
targets = gdk_content_formats_new (button_targets, G_N_ELEMENTS (button_targets));
- gtk_drag_dest_set (button,
- GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
- targets,
- GDK_ACTION_MOVE);
+ dest = gtk_drop_target_new (GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, targets, GDK_ACTION_MOVE);
+ g_signal_connect (dest, "drag-data-received", G_CALLBACK (on_button_drag_data_received), NULL);
+ gtk_drop_target_attach (dest, button);
gdk_content_formats_unref (targets);
- g_signal_connect_after (G_OBJECT (button), "drag-data-received",
- G_CALLBACK (on_button_drag_data_received), NULL);
return button;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]