[gtk/dnd-gestures-2: 113/242] tests: Convert to GtkDragSource
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/dnd-gestures-2: 113/242] tests: Convert to GtkDragSource
- Date: Tue, 7 Jan 2020 19:52:52 +0000 (UTC)
commit 9c6c1c76c8bd6638c9c0cb8788d5f18dbe3e4043
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Dec 31 21:10:15 2019 -0500
tests: Convert to GtkDragSource
Some tests, such as testimage did not have
anything particularly worth keeping, so
were removed instead of fixed.
tests/meson.build | 1 -
tests/testdnd.c | 43 ++-----
tests/testdnd2.c | 326 ++++++++++++++++++++----------------------------
tests/testentryicons.c | 14 ---
tests/testimage.c | 178 --------------------------
tests/testlist3.c | 35 ++----
tests/testnotebookdnd.c | 21 ----
tests/testtoolbar.c | 9 +-
8 files changed, 162 insertions(+), 465 deletions(-)
---
diff --git a/tests/meson.build b/tests/meson.build
index e6041c3627..8becf6a9f3 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -53,7 +53,6 @@ gtk_tests = [
['testiconview-keynav'],
['testicontheme'],
['testinfobar'],
- ['testimage'],
['testkineticscrolling'],
['testlist'],
['testlist2'],
diff --git a/tests/testdnd.c b/tests/testdnd.c
index dfc9bceac1..ad1c8d2ffa 100644
--- a/tests/testdnd.c
+++ b/tests/testdnd.c
@@ -313,8 +313,6 @@ target_drag_motion (GtkWidget *widget,
gint x,
gint y)
{
- GtkWidget *source_widget;
- GdkDrag *drag;
char *s;
if (!have_drag)
@@ -323,12 +321,6 @@ target_drag_motion (GtkWidget *widget,
gtk_image_set_from_pixbuf (GTK_IMAGE (widget), trashcan_open);
}
- drag = gdk_drop_get_drag (drop);
- source_widget = drag ? gtk_drag_get_source_widget (drag) : NULL;
- g_print ("motion, source %s\n", source_widget ?
- G_OBJECT_TYPE_NAME (source_widget) :
- "NULL");
-
s = gdk_content_formats_to_string (gdk_drop_get_formats (drop));
g_print ("%s\n", s);
@@ -416,20 +408,6 @@ label_drag_data_received (GtkWidget *widget,
gdk_drop_finish (drop, 0);
}
-void
-source_drag_data_get (GtkWidget *widget,
- GdkDrag *drag,
- GtkSelectionData *selection_data,
- gpointer data)
-{
- if (gtk_selection_data_get_target (selection_data) == g_intern_static_string
("application/x-rootwindow-drop"))
- g_print ("I was dropped on the rootwin\n");
- else
- gtk_selection_data_set (selection_data,
- gtk_selection_data_get_target (selection_data),
- 8, (guchar *) "I'm Data!", 9);
-}
-
/* The following is a rather elaborate example demonstrating/testing
* changing of the window hierarchy during a drag - in this case,
* via a "spring-loaded" popup window.
@@ -564,7 +542,6 @@ popsite_leave (GtkWidget *widget,
void
source_drag_data_delete (GtkWidget *widget,
- GdkDrag *drag,
gpointer data)
{
g_print ("Delete the data!\n");
@@ -587,6 +564,9 @@ main (int argc, char **argv)
GtkWidget *button;
GdkPixbuf *drag_icon;
GdkTexture *texture;
+ GdkContentProvider *content;
+ GValue value = G_VALUE_INIT;
+ GtkDragSource *source;
GdkContentFormats *targets;
test_init ();
@@ -661,12 +641,13 @@ main (int argc, char **argv)
button = gtk_button_new_with_label ("Drag Here\n");
- targets = gdk_content_formats_new (target_table, n_targets);
- gtk_drag_source_set (button, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
- targets,
- GDK_ACTION_COPY | GDK_ACTION_MOVE);
- gtk_drag_source_set_icon_paintable (button, GDK_PAINTABLE (texture));
- gdk_content_formats_unref (targets);
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_string (&value, "I'm data!");
+ content = gdk_content_provider_new_for_value (&value);
+ g_value_unset (&value);
+ source = gtk_drag_source_new (content, GDK_ACTION_COPY | GDK_ACTION_MOVE);
+ gtk_drag_source_attach (source, button, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK);
+ gtk_drag_source_set_icon (source, GDK_PAINTABLE (texture), 0, 0);
g_object_unref (texture);
@@ -674,9 +655,7 @@ main (int argc, char **argv)
gtk_widget_set_vexpand (button, TRUE);
gtk_grid_attach (GTK_GRID (grid), button, 0, 1, 1, 1);
- g_signal_connect (button, "drag-data-get",
- G_CALLBACK (source_drag_data_get), NULL);
- g_signal_connect (button, "drag-data-delete",
+ g_signal_connect (source, "drag-data-delete",
G_CALLBACK (source_drag_data_delete), NULL);
gtk_widget_show (window);
diff --git a/tests/testdnd2.c b/tests/testdnd2.c
index 5505055d0e..a33afb172e 100644
--- a/tests/testdnd2.c
+++ b/tests/testdnd2.c
@@ -37,114 +37,12 @@ enum {
BOTTOM_RIGHT
};
-static void
-image_drag_begin (GtkWidget *widget,
- GdkDrag *drag,
- gpointer data)
-{
- GdkPaintable *paintable;
- gint hotspot;
- gint hot_x, hot_y;
- gint size;
-
- paintable = get_image_paintable (GTK_IMAGE (data), &size);
- hotspot = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (data), "hotspot"));
- switch (hotspot)
- {
- default:
- case TOP_LEFT:
- hot_x = 0;
- hot_y = 0;
- break;
- case CENTER:
- hot_x = size / 2;
- hot_y = size / 2;
- break;
- case BOTTOM_RIGHT:
- hot_x = size;
- hot_y = size;
- break;
- }
- gtk_drag_set_icon_paintable (drag, paintable, hot_x, hot_y);
- g_object_unref (paintable);
-}
-
-static void
-drag_widget_destroyed (GtkWidget *image, gpointer data)
-{
- GtkWidget *widget = data;
-
- g_print ("drag widget destroyed\n");
- g_object_unref (image);
- g_object_set_data (G_OBJECT (widget), "drag widget", NULL);
-}
-
-static void
-window_drag_end (GtkWidget *widget,
- GdkDrag *drag,
- gpointer data)
-{
- GtkWidget *window = data;
-
- gtk_widget_destroy (window);
- g_signal_handlers_disconnect_by_func (widget, window_drag_end, data);
-}
-
-static void
-window_drag_begin (GtkWidget *widget,
- GdkDrag *drag,
- gpointer data)
-{
- GdkPaintable *paintable;
- GtkWidget *image;
- int hotspot;
- int size;
-
- hotspot = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (data), "hotspot"));
-
- image = g_object_get_data (G_OBJECT (widget), "drag widget");
- if (image == NULL)
- {
- g_print ("creating new drag widget\n");
- paintable = get_image_paintable (GTK_IMAGE (data), &size);
- image = gtk_image_new_from_paintable (paintable);
- g_object_unref (paintable);
- g_object_ref (image);
- g_object_set_data (G_OBJECT (widget), "drag widget", image);
- g_signal_connect (image, "destroy", G_CALLBACK (drag_widget_destroyed), widget);
- }
- else
- g_print ("reusing drag widget\n");
-
- gtk_drag_set_icon_widget (drag, image, 0, 0);
-
- if (hotspot == CENTER)
- g_signal_connect (widget, "drag-end", G_CALLBACK (window_drag_end), image);
-}
-
-static void
-update_source_target_list (GtkWidget *image)
-{
- GdkContentFormats *target_list;
-
- target_list = gdk_content_formats_new (NULL, 0);
-
- target_list = gtk_content_formats_add_image_targets (target_list, FALSE);
- if (gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_ICON_NAME)
- target_list = gtk_content_formats_add_text_targets (target_list);
-
- gtk_drag_source_set_target_list (image, target_list);
-
- gdk_content_formats_unref (target_list);
-}
-
static void
update_dest_target_list (GtkWidget *image)
{
GdkContentFormats *target_list;
target_list = gdk_content_formats_new (NULL, 0);
-
target_list = gtk_content_formats_add_image_targets (target_list, FALSE);
target_list = gtk_content_formats_add_text_targets (target_list);
@@ -191,149 +89,191 @@ image_drag_data_received (GtkWidget *widget,
GtkSelectionData *selection_data,
gpointer data)
{
+ GdkTexture *texture;
gchar *text;
if (gtk_selection_data_get_length (selection_data) == 0)
return;
- if (gtk_selection_data_targets_include_image (selection_data, FALSE))
+ texture = gtk_selection_data_get_texture (selection_data);
+ if (texture)
{
- GdkTexture *texture;
-
- texture = gtk_selection_data_get_texture (selection_data);
- gtk_image_set_from_paintable (GTK_IMAGE (data), GDK_PAINTABLE (texture));
-
+ gtk_image_set_from_paintable (GTK_IMAGE (widget), GDK_PAINTABLE (texture));
g_object_unref (texture);
+ return;
}
- else if (gtk_selection_data_targets_include_text (selection_data))
+
+ text = (gchar *)gtk_selection_data_get_text (selection_data);
+ if (text)
{
- text = (gchar *)gtk_selection_data_get_text (selection_data);
- gtk_image_set_from_icon_name (GTK_IMAGE (data), text);
+ gtk_image_set_from_icon_name (GTK_IMAGE (widget), text);
g_free (text);
}
- else
+}
+
+static void
+update_source_icon (GtkDragSource *source,
+ const char *icon_name,
+ int hotspot)
+{
+ GdkPaintable *paintable;
+ int hot_x, hot_y;
+ int size = 48;
+
+ paintable = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+ icon_name, size, 0, NULL);
+ switch (hotspot)
{
- g_assert_not_reached ();
+ default:
+ case TOP_LEFT:
+ hot_x = 0;
+ hot_y = 0;
+ break;
+ case CENTER:
+ hot_x = size / 2;
+ hot_y = size / 2;
+ break;
+ case BOTTOM_RIGHT:
+ hot_x = size;
+ hot_y = size;
+ break;
}
+ gtk_drag_source_set_icon (source, paintable, hot_x, hot_y);
+ g_object_unref (paintable);
}
-
-GtkWidget *
-make_image (const gchar *icon_name, int hotspot)
+static GBytes *
+get_data (const char *mimetype,
+ gpointer data)
{
- GtkWidget *image;
+ GtkWidget *image = data;
+ GdkContentFormats *formats;
+ gboolean want_text;
- image = gtk_image_new_from_icon_name (icon_name);
- gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
+ formats = gdk_content_formats_new (NULL, 0);
+ formats = gtk_content_formats_add_text_targets (formats);
+ want_text = gdk_content_formats_contain_mime_type (formats, mimetype);
+ gdk_content_formats_unref (formats);
- gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
- update_source_target_list (image);
+ g_print ("get data called for %s\n", mimetype);
+ if (want_text)
+ {
+ const char *text = gtk_image_get_icon_name (GTK_IMAGE (image));
- g_object_set_data (G_OBJECT (image), "hotspot", GINT_TO_POINTER (hotspot));
+ return g_bytes_new (text, strlen (text) + 1);
+ }
+ else if (strcmp (mimetype, "image/png") == 0)
+ {
+ int size;
+ GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (image), &size);
+ if (GDK_IS_TEXTURE (paintable))
+ {
+ char *name = g_strdup ("drag-data-XXXXXX");
+ int fd;
+ char *data;
+ gsize size;
- g_signal_connect (image, "drag-begin", G_CALLBACK (image_drag_begin), image);
- g_signal_connect (image, "drag-data-get", G_CALLBACK (image_drag_data_get), image);
+ // FIXME: this is horrible
- gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL, NULL, GDK_ACTION_COPY);
- g_signal_connect (image, "drag-data-received", G_CALLBACK (image_drag_data_received), image);
- update_dest_target_list (image);
+ fd = g_mkstemp (name);
+ close (fd);
- return image;
+ gdk_texture_save_to_png (GDK_TEXTURE (paintable), name);
+
+ g_file_get_contents (name, &data, &size, NULL);
+ g_free (name);
+
+ return g_bytes_new_take (data, size);
+ }
+
+ g_clear_object (&paintable);
+ }
+ return NULL;
+}
+
+static void
+drag_begin (GtkDragSource *source)
+{
+ g_print ("drag begin\n");
+}
+
+static void
+drag_end (GtkDragSource *source)
+{
+ g_print ("drag end\n");
+}
+
+static gboolean
+drag_failed (GtkDragSource *source, GdkDragCancelReason reason)
+{
+ g_print ("drag failed: %d\n", reason);
+ return FALSE;
}
GtkWidget *
-make_image2 (const gchar *icon_name, int hotspot)
+make_image (const gchar *icon_name, int hotspot)
{
GtkWidget *image;
+ GtkDragSource *source;
+ GdkContentFormats *formats;
+ GdkContentProvider *content;
image = gtk_image_new_from_icon_name (icon_name);
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
- gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
- update_source_target_list (image);
+ formats = gdk_content_formats_new (NULL, 0);
+ formats = gtk_content_formats_add_image_targets (formats, FALSE);
+ formats = gtk_content_formats_add_text_targets (formats);
- g_object_set_data (G_OBJECT (image), "hotspot", GINT_TO_POINTER (hotspot));
+ content = gdk_content_provider_new_with_formats (formats, get_data, image);
+ source = gtk_drag_source_new (content, GDK_ACTION_COPY);
+ g_object_unref (content);
+ gdk_content_formats_unref (formats);
+ update_source_icon (source, icon_name, hotspot);
- g_signal_connect (image, "drag-begin", G_CALLBACK (window_drag_begin), image);
- g_signal_connect (image, "drag-data-get", G_CALLBACK (image_drag_data_get), image);
+ g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), NULL);
+ g_signal_connect (source, "drag-end", G_CALLBACK (drag_end), NULL);
+ g_signal_connect (source, "drag-failed", G_CALLBACK (drag_failed), NULL);
+ gtk_drag_source_attach (source, image, GDK_BUTTON1_MASK);
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL, NULL, GDK_ACTION_COPY);
- g_signal_connect (image, "drag-data-received", G_CALLBACK (image_drag_data_received), image);
+ g_signal_connect (image, "drag-data-received", G_CALLBACK (image_drag_data_received), NULL);
update_dest_target_list (image);
return image;
}
static void
-spinner_drag_begin (GtkWidget *widget,
- GdkDrag *drag,
- gpointer data)
-{
- GtkWidget *spinner;
-
- g_print ("GtkWidget::drag-begin\n");
- spinner = g_object_new (GTK_TYPE_SPINNER,
- "visible", TRUE,
- "active", TRUE,
- NULL);
- gtk_drag_set_icon_widget (drag, spinner, 0, 0);
- g_object_set_data (G_OBJECT (drag), "spinner", spinner);
-}
-
-static void
-spinner_drag_end (GtkWidget *widget,
- GdkDrag *drag,
- gpointer data)
-{
- GtkWidget *spinner;
-
- g_print ("GtkWidget::drag-end\n");
- spinner = g_object_get_data (G_OBJECT (drag), "spinner");
- gtk_widget_destroy (spinner);
-}
-
-static gboolean
-spinner_drag_failed (GtkWidget *widget,
- GdkDrag *drag,
- GtkDragResult result,
- gpointer data)
+spinner_drag_begin (GtkDragSource *source,
+ GtkWidget *widget)
{
- GTypeClass *class;
- GEnumValue *value;
-
- class = g_type_class_ref (GTK_TYPE_DRAG_RESULT);
- value = g_enum_get_value (G_ENUM_CLASS (class), result);
- g_print ("GtkWidget::drag-failed %s\n", value->value_nick);
- g_type_class_unref (class);
-
- return FALSE;
-}
+ GdkPaintable *paintable;
-void
-spinner_drag_data_get (GtkWidget *widget,
- GdkDrag *drag,
- GtkSelectionData *selection_data,
- gpointer data)
-{
- g_print ("GtkWidget::drag-data-get\n");
- gtk_selection_data_set_text (selection_data, "ACTIVE", -1);
+ paintable = gtk_widget_paintable_new (widget);
+ gtk_drag_source_set_icon (source, paintable, 0, 0);
+ g_object_unref (paintable);
}
static GtkWidget *
make_spinner (void)
{
GtkWidget *spinner;
+ GtkDragSource *source;
+ GdkContentProvider *content;
+ GValue value = G_VALUE_INIT;
spinner = gtk_spinner_new ();
gtk_spinner_start (GTK_SPINNER (spinner));
- gtk_drag_source_set (spinner, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
- gtk_drag_source_add_text_targets (spinner);
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_string (&value, "ACTIVE");
+ content = gdk_content_provider_new_for_value (&value);
+ source = gtk_drag_source_new (content, GDK_ACTION_COPY);
+ g_signal_connect (source, "drag-begin", G_CALLBACK (spinner_drag_begin), spinner);
+ gtk_drag_source_attach (source, spinner, GDK_BUTTON1_MASK);
- g_signal_connect (spinner, "drag-begin", G_CALLBACK (spinner_drag_begin), spinner);
- g_signal_connect (spinner, "drag-end", G_CALLBACK (spinner_drag_end), spinner);
- g_signal_connect (spinner, "drag-failed", G_CALLBACK (spinner_drag_failed), spinner);
- g_signal_connect (spinner, "drag-data-get", G_CALLBACK (spinner_drag_data_get), spinner);
+ g_object_unref (content);
+ g_value_unset (&value);
return spinner;
}
@@ -367,9 +307,9 @@ main (int argc, char *Argv[])
gtk_grid_attach (GTK_GRID (grid), make_spinner (), 0, 2, 1, 1);
gtk_grid_attach (GTK_GRID (grid), make_image ("weather-clear", CENTER), 1, 2, 1, 1);
- gtk_grid_attach (GTK_GRID (grid), make_image2 ("dialog-question", TOP_LEFT), 0, 3, 1, 1);
+ gtk_grid_attach (GTK_GRID (grid), make_image ("dialog-question", TOP_LEFT), 0, 3, 1, 1);
- gtk_grid_attach (GTK_GRID (grid), make_image2 ("dialog-information", CENTER), 1, 3, 1, 1);
+ gtk_grid_attach (GTK_GRID (grid), make_image ("dialog-information", CENTER), 1, 3, 1, 1);
gtk_widget_show (window);
gtk_main ();
diff --git a/tests/testentryicons.c b/tests/testentryicons.c
index 6d733ef85c..e117579d2e 100644
--- a/tests/testentryicons.c
+++ b/tests/testentryicons.c
@@ -8,18 +8,6 @@ clear_pressed (GtkEntry *entry, gint icon, gpointer data)
gtk_editable_set_text (GTK_EDITABLE (entry), "");
}
-static void
-drag_begin_cb (GtkWidget *widget,
- GdkDrag *drag,
- gpointer user_data)
-{
- gint pos;
-
- pos = gtk_entry_get_current_icon_drag_source (GTK_ENTRY (widget));
- if (pos != -1)
- gtk_drag_set_icon_name (drag, "dialog-information", 2, 2);
-}
-
static void
set_blank (GtkWidget *button,
GtkEntry *entry)
@@ -172,8 +160,6 @@ main (int argc, char **argv)
gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
GTK_ENTRY_ICON_PRIMARY,
content, GDK_ACTION_COPY);
- g_signal_connect_after (entry, "drag-begin",
- G_CALLBACK (drag_begin_cb), NULL);
g_object_unref (content);
/*
diff --git a/tests/testlist3.c b/tests/testlist3.c
index 2f6aba8450..8c9036e853 100644
--- a/tests/testlist3.c
+++ b/tests/testlist3.c
@@ -5,9 +5,8 @@ static const char *entries[] = {
};
static void
-drag_begin (GtkWidget *widget,
- GdkDrag *drag,
- gpointer data)
+drag_begin (GtkDragSource *source,
+ GtkWidget *widget)
{
GtkWidget *row;
GtkAllocation alloc;
@@ -19,26 +18,11 @@ drag_begin (GtkWidget *widget,
paintable = gtk_widget_paintable_new (row);
gtk_widget_translate_coordinates (widget, row, 0, 0, &x, &y);
- gtk_drag_set_icon_paintable (drag, paintable, -x, -y);
+ gtk_drag_source_set_icon (source, paintable, -x, -y);
g_object_unref (paintable);
}
-
-void
-drag_data_get (GtkWidget *widget,
- GdkDrag *drag,
- GtkSelectionData *selection_data,
- gpointer data)
-{
- gtk_selection_data_set (selection_data,
- g_intern_static_string ("GTK_LIST_BOX_ROW"),
- 32,
- (const guchar *)&widget,
- sizeof (gpointer));
-}
-
-
static void
drag_data_received (GtkWidget *widget,
GdkDrop *drop,
@@ -69,7 +53,10 @@ static GtkWidget *
create_row (const gchar *text)
{
GtkWidget *row, *box, *label, *image;
+ GBytes *bytes;
+ GdkContentProvider *content;
GdkContentFormats *targets;
+ GtkDragSource *source;
row = gtk_list_box_row_new ();
image = gtk_image_new_from_icon_name ("open-menu-symbolic");
@@ -81,11 +68,13 @@ create_row (const gchar *text)
gtk_container_add (GTK_CONTAINER (box), label);
gtk_container_add (GTK_CONTAINER (box), image);
- targets = gdk_content_formats_new (entries, 1);
+ bytes = g_bytes_new (&row, sizeof (gpointer));
+ content = gdk_content_provider_new_for_bytes ("GTK_LIST_BOX_ROW", bytes);
+ source = gtk_drag_source_new (content, GDK_ACTION_MOVE);
+ g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
+ gtk_drag_source_attach (source, image, GDK_BUTTON1_MASK);
- gtk_drag_source_set (image, GDK_BUTTON1_MASK, targets, GDK_ACTION_MOVE);
- g_signal_connect (image, "drag-begin", G_CALLBACK (drag_begin), NULL);
- g_signal_connect (image, "drag-data-get", G_CALLBACK (drag_data_get), NULL);
+ targets = gdk_content_formats_new (entries, 1);
gtk_drag_dest_set (row, GTK_DEST_DEFAULT_ALL, targets, GDK_ACTION_MOVE);
g_signal_connect (row, "drag-data-received", G_CALLBACK (drag_data_received), NULL);
diff --git a/tests/testnotebookdnd.c b/tests/testnotebookdnd.c
index 543b8186f3..44e8f095d7 100644
--- a/tests/testnotebookdnd.c
+++ b/tests/testnotebookdnd.c
@@ -90,21 +90,6 @@ on_page_reordered (GtkNotebook *notebook, GtkWidget *child, guint page_num, gpoi
g_print ("page %d reordered\n", page_num);
}
-static void
-on_notebook_drag_begin (GtkWidget *widget,
- GdkDrag *drag,
- gpointer data)
-{
- guint page_num;
-
- page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (widget));
-
- if (page_num > 2)
- gtk_drag_set_icon_name (drag,
- (page_num % 2) ? "help-browser" : "process-stop",
- 0, 0);
-}
-
static gboolean
remove_in_idle (gpointer data)
{
@@ -186,8 +171,6 @@ create_notebook (gchar **labels,
g_signal_connect (GTK_NOTEBOOK (notebook), "page-reordered",
G_CALLBACK (on_page_reordered), NULL);
- g_signal_connect_after (G_OBJECT (notebook), "drag-begin",
- G_CALLBACK (on_notebook_drag_begin), NULL);
return notebook;
}
@@ -233,8 +216,6 @@ create_notebook_non_dragable_content (gchar **labels,
g_signal_connect (GTK_NOTEBOOK (notebook), "page-reordered",
G_CALLBACK (on_page_reordered), NULL);
- g_signal_connect_after (G_OBJECT (notebook), "drag-begin",
- G_CALLBACK (on_notebook_drag_begin), NULL);
return notebook;
}
@@ -271,8 +252,6 @@ create_notebook_with_notebooks (gchar **labels,
g_signal_connect (GTK_NOTEBOOK (notebook), "page-reordered",
G_CALLBACK (on_page_reordered), NULL);
- g_signal_connect_after (G_OBJECT (notebook), "drag-begin",
- G_CALLBACK (on_notebook_drag_begin), NULL);
return notebook;
}
diff --git a/tests/testtoolbar.c b/tests/testtoolbar.c
index a26f8a842b..3a2f7cbdb9 100644
--- a/tests/testtoolbar.c
+++ b/tests/testtoolbar.c
@@ -389,6 +389,8 @@ main (gint argc, gchar **argv)
GtkWidget *hbox, *hbox1, *hbox2, *checkbox, *option_menu, *menu;
gint i;
GdkContentFormats *targets;
+ GdkContentProvider *content;
+ GtkDragSource *source;
static const gchar *toolbar_styles[] = { "icons", "text", "both (vertical)",
"both (horizontal)" };
GtkToolItem *item;
@@ -616,9 +618,10 @@ main (gint argc, gchar **argv)
gtk_container_add (GTK_CONTAINER (hbox), checkbox);
targets = gdk_content_formats_new (target_table, G_N_ELEMENTS (target_table));
- gtk_drag_source_set (button, GDK_BUTTON1_MASK,
- targets,
- GDK_ACTION_MOVE);
+ content = gdk_content_provider_new_for_bytes (target_table[0], g_bytes_new ("", 1));
+ source = gtk_drag_source_new (content, GDK_ACTION_MOVE);
+ g_object_unref (content);
+ gtk_drag_source_attach (source, button, GDK_BUTTON1_MASK);
gtk_drag_dest_set (toolbar, GTK_DEST_DEFAULT_DROP,
targets,
GDK_ACTION_MOVE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]