summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte.benjamin@googlemail.com>2023-05-17 00:19:06 +0000
committerBenjamin Otte <otte.benjamin@googlemail.com>2023-05-17 00:19:06 +0000
commit646d1a8923d1e6508e753e70b2332a0924576a4f (patch)
tree6e1716113ca1d657c41e214949fb003771af88aa
parent1b885cc317156f215d79c415828f42db1ef143af (diff)
parent112fe063232c4066e78c5e217f3e5b6fb5c0bf8f (diff)
downloadgtk+-646d1a8923d1e6508e753e70b2332a0924576a4f.tar.gz
Merge branch 'wip/otte/ci-emergency' into 'main'
CI: Actually build our code See merge request GNOME/gtk!5980
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--gsk/gl/gskglrenderjob.c30
-rw-r--r--tests/meson.build2
-rw-r--r--tests/testclipboard2.c461
-rw-r--r--tests/testdnd.c597
5 files changed, 1 insertions, 1091 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9da8b055aa..9d22e3798d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -24,7 +24,7 @@ stages:
variables:
COMMON_MESON_FLAGS: "-Dwerror=true -Dcairo:werror=false -Dgi-docgen:werror=false -Dgraphene:werror=false -Dlibepoxy:werror=false -Dlibsass:werror=false -Dpango:werror=false -Dsassc:werror=false -Dgdk-pixbuf:werror=false -Dglib:werror=false -Dlibcloudproviders:werror=false -Dlibpng:werror=false -Dlibtiff:werror=false -Dsysprof:werror=false -Dwayland-protocols:werror=false -Dharfbuzz:werror=false -Dfreetype2:werror=false -Dfontconfig:werror=false -Dfribidi:werror=false -Dlibffi:werror=false -Dlibjpeg-turbo:werror=false -Dmutest:werror=false -Dpixman:werror=false -Dproxy-libintl:werror=false"
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
- FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Dbuild-demos=false -Dbuild-examples=false -Dbuild-tests=false -Dbuild-testsuite=true"
+ FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Dbuild-testsuite=true"
MESON_TEST_TIMEOUT_MULTIPLIER: 3
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v46"
diff --git a/gsk/gl/gskglrenderjob.c b/gsk/gl/gskglrenderjob.c
index 85ee17eac8..e5967d9f52 100644
--- a/gsk/gl/gskglrenderjob.c
+++ b/gsk/gl/gskglrenderjob.c
@@ -363,36 +363,6 @@ rect_contains_rect (const graphene_rect_t *r1,
(r2->origin.y + r2->size.height) <= (r1->origin.y + r1->size.height);
}
-static inline gboolean
-rounded_inner_rect_contains_rect (const GskRoundedRect *rounded,
- const graphene_rect_t *rect)
-{
- const graphene_rect_t *rounded_bounds = &rounded->bounds;
- graphene_rect_t inner;
- float offset_x;
- float offset_y;
-
- /* TODO: This is pretty conservative and we could go further,
- * more fine-grained checks to avoid offscreen drawing.
- */
-
- offset_x = MAX (rounded->corner[GSK_CORNER_TOP_LEFT].width,
- rounded->corner[GSK_CORNER_BOTTOM_LEFT].width);
- offset_y = MAX (rounded->corner[GSK_CORNER_TOP_LEFT].height,
- rounded->corner[GSK_CORNER_TOP_RIGHT].height);
-
- inner.origin.x = rounded_bounds->origin.x + offset_x;
- inner.origin.y = rounded_bounds->origin.y + offset_y;
- inner.size.width = rounded_bounds->size.width - offset_x -
- MAX (rounded->corner[GSK_CORNER_TOP_RIGHT].width,
- rounded->corner[GSK_CORNER_BOTTOM_RIGHT].width);
- inner.size.height = rounded_bounds->size.height - offset_y -
- MAX (rounded->corner[GSK_CORNER_BOTTOM_LEFT].height,
- rounded->corner[GSK_CORNER_BOTTOM_RIGHT].height);
-
- return rect_contains_rect (&inner, rect);
-}
-
static inline gboolean G_GNUC_PURE
rect_intersects (const graphene_rect_t *r1,
const graphene_rect_t *r2)
diff --git a/tests/meson.build b/tests/meson.build
index c9c6e6a4cd..3294b47d08 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -25,13 +25,11 @@ gtk_tests = [
['testbaseline'],
['testbaseline2'],
['testcalendar'],
- ['testclipboard2'],
['testcombo'],
['testcolumnview'],
['testcombochange'],
['testcellrenderertext'],
['testdialog'],
- ['testdnd'],
['testdnd2'],
['testdndresize'],
['testellipsise'],
diff --git a/tests/testclipboard2.c b/tests/testclipboard2.c
deleted file mode 100644
index 32df2cba95..0000000000
--- a/tests/testclipboard2.c
+++ /dev/null
@@ -1,461 +0,0 @@
-/*
- * Copyright (C) 2011 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <gtk/gtk.h>
-
-static GdkTexture *
-render_paintable_to_texture (GdkPaintable *paintable)
-{
- GtkSnapshot *snapshot;
- GskRenderNode *node;
- int width, height;
- cairo_surface_t *surface;
- cairo_t *cr;
- GdkTexture *texture;
- GBytes *bytes;
-
- width = gdk_paintable_get_intrinsic_width (paintable);
- height = gdk_paintable_get_intrinsic_height (paintable);
-
- surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
-
- snapshot = gtk_snapshot_new ();
- gdk_paintable_snapshot (paintable, snapshot, width, height);
- node = gtk_snapshot_free_to_node (snapshot);
-
- cr = cairo_create (surface);
- gsk_render_node_draw (node, cr);
- cairo_destroy (cr);
-
- gsk_render_node_unref (node);
-
- bytes = g_bytes_new_with_free_func (cairo_image_surface_get_data (surface),
- cairo_image_surface_get_height (surface)
- * cairo_image_surface_get_stride (surface),
- (GDestroyNotify) cairo_surface_destroy,
- cairo_surface_reference (surface));
- texture = gdk_memory_texture_new (cairo_image_surface_get_width (surface),
- cairo_image_surface_get_height (surface),
- GDK_MEMORY_DEFAULT,
- bytes,
- cairo_image_surface_get_stride (surface));
- g_bytes_unref (bytes);
- cairo_surface_destroy (surface);
-
- return texture;
-}
-
-static void
-clipboard_changed_cb (GdkClipboard *clipboard,
- GtkWidget *stack)
-{
- GtkWidget *child;
-
- gtk_stack_set_visible_child_name (GTK_STACK (stack), "info");
-
- child = gtk_stack_get_child_by_name (GTK_STACK (stack), "image");
- gtk_image_clear (GTK_IMAGE (child));
-
- child = gtk_stack_get_child_by_name (GTK_STACK (stack), "text");
- gtk_label_set_text (GTK_LABEL (child), "");
-}
-
-static void
-texture_loaded_cb (GObject *clipboard,
- GAsyncResult *res,
- gpointer data)
-{
- GError *error = NULL;
- GdkTexture *texture;
-
- texture = gdk_clipboard_read_texture_finish (GDK_CLIPBOARD (clipboard), res, &error);
- if (texture == NULL)
- {
- g_print ("%s\n", error->message);
- g_error_free (error);
- return;
- }
-
- gtk_image_set_from_paintable (data, GDK_PAINTABLE (texture));
- g_object_unref (texture);
-}
-
-static void
-text_loaded_cb (GObject *clipboard,
- GAsyncResult *res,
- gpointer data)
-{
- GError *error = NULL;
- char *text;
-
- text = gdk_clipboard_read_text_finish (GDK_CLIPBOARD (clipboard), res, &error);
- if (text == NULL)
- {
- g_print ("%s\n", error->message);
- g_error_free (error);
- return;
- }
-
- gtk_label_set_text (data, text);
- g_free (text);
-}
-
-static void
-visible_child_changed_cb (GtkWidget *stack,
- GParamSpec *pspec,
- GdkClipboard *clipboard)
-{
- const char *visible_child = gtk_stack_get_visible_child_name (GTK_STACK (stack));
-
- if (visible_child == NULL)
- {
- /* nothing to do here but avoiding crashes in g_str_equal() */
- }
- else if (g_str_equal (visible_child, "image"))
- {
- GtkWidget *image = gtk_stack_get_child_by_name (GTK_STACK (stack), "image");
-
- gdk_clipboard_read_texture_async (clipboard,
- NULL,
- texture_loaded_cb,
- image);
- }
- else if (g_str_equal (visible_child, "text"))
- {
- GtkWidget *label = gtk_stack_get_child_by_name (GTK_STACK (stack), "text");
-
- gdk_clipboard_read_text_async (clipboard,
- NULL,
- text_loaded_cb,
- label);
- }
-}
-
-#ifdef G_OS_UNIX /* portal usage supported on *nix only */
-
-static GSList *
-get_file_list (const char *dir)
-{
- GFileEnumerator *enumerator;
- GFile *file;
- GFileInfo *info;
- GSList *list = NULL;
-
- file = g_file_new_for_path (dir);
- enumerator = g_file_enumerate_children (file, "standard::name,standard::type", 0, NULL, NULL);
- g_object_unref (file);
- if (enumerator == NULL)
- return NULL;
-
- while (g_file_enumerator_iterate (enumerator, &info, &file, NULL, NULL) && file != NULL)
- {
- /* the portal can't handle directories */
- if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR)
- continue;
-
- list = g_slist_prepend (list, g_object_ref (file));
- }
-
- return g_slist_reverse (list);
-}
-
-#else /* G_OS_UNIX -- original non-portal-enabled code */
-
-static GList *
-get_file_list (const char *dir)
-{
- GFileEnumerator *enumerator;
- GFile *file;
- GList *list = NULL;
-
- file = g_file_new_for_path (dir);
- enumerator = g_file_enumerate_children (file, "standard::name", 0, NULL, NULL);
- g_object_unref (file);
- if (enumerator == NULL)
- return NULL;
-
- while (g_file_enumerator_iterate (enumerator, NULL, &file, NULL, NULL) && file != NULL)
- list = g_list_prepend (list, g_object_ref (file));
-
- return g_list_reverse (list);
-}
-
-#endif /* !G_OS_UNIX */
-
-static void
-format_list_add_row (GtkWidget *list,
- const char *format_name,
- GdkContentFormats *formats)
-{
- GtkWidget *box;
-
- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
- gtk_box_append (GTK_BOX (box), gtk_label_new (format_name));
-
- gdk_content_formats_unref (formats);
- gtk_list_box_insert (GTK_LIST_BOX (list), box, -1);
-}
-
-static void
-clipboard_formats_change_cb (GdkClipboard *clipboard,
- GParamSpec *pspec,
- GtkWidget *list)
-{
- GdkContentFormats *formats;
- GtkWidget *row;
- const char * const *mime_types;
- const GType *gtypes;
- gsize i, n;
-
- while ((row = GTK_WIDGET (gtk_list_box_get_row_at_index (GTK_LIST_BOX (list), 0))))
- gtk_list_box_remove (GTK_LIST_BOX (list), row);
-
- formats = gdk_clipboard_get_formats (clipboard);
-
- gtypes = gdk_content_formats_get_gtypes (formats, &n);
- for (i = 0; i < n; i++)
- {
- format_list_add_row (list,
- g_type_name (gtypes[i]),
- gdk_content_formats_new_for_gtype (gtypes[i]));
- }
-
- mime_types = gdk_content_formats_get_mime_types (formats, &n);
- for (i = 0; i < n; i++)
- {
- format_list_add_row (list,
- mime_types[i],
- gdk_content_formats_new ((const char *[2]) { mime_types[i], NULL }, 1));
- }
-}
-
-static GtkWidget *
-get_formats_list (GdkClipboard *clipboard)
-{
- GtkWidget *sw, *list;
-
- sw = gtk_scrolled_window_new ();
-
- list = gtk_list_box_new ();
- g_signal_connect_object (clipboard, "notify::formats", G_CALLBACK (clipboard_formats_change_cb), list, 0);
- clipboard_formats_change_cb (clipboard, NULL, list);
- gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
-
- return sw;
-}
-
-static GtkWidget *
-get_contents_widget (GdkClipboard *clipboard)
-{
- GtkWidget *stack, *child;
-
- stack = gtk_stack_new ();
- gtk_widget_set_hexpand (stack, TRUE);
- gtk_widget_set_vexpand (stack, TRUE);
- g_signal_connect (stack, "notify::visible-child", G_CALLBACK (visible_child_changed_cb), clipboard);
- g_signal_connect_object (clipboard, "changed", G_CALLBACK (clipboard_changed_cb), stack, 0);
-
- child = get_formats_list (clipboard);
- gtk_stack_add_titled (GTK_STACK (stack), child, "info", "Info");
-
- child = gtk_image_new ();
- gtk_stack_add_titled (GTK_STACK (stack), child, "image", "Image");
-
- child = gtk_label_new (NULL);
- gtk_label_set_wrap (GTK_LABEL (child), TRUE);
- gtk_stack_add_titled (GTK_STACK (stack), child, "text", "Text");
-
- return stack;
-}
-
-static void
-provider_button_clicked_cb (GtkWidget *button,
- GdkClipboard *clipboard)
-{
- gdk_clipboard_set_content (clipboard,
- g_object_get_data (G_OBJECT (button), "provider"));
-}
-
-static void
-add_provider_button (GtkWidget *box,
- GdkContentProvider *provider,
- GdkClipboard *clipboard,
- const char *name)
-{
- GtkWidget *button;
-
- button = gtk_button_new_with_label (name);
- g_signal_connect (button, "clicked", G_CALLBACK (provider_button_clicked_cb), clipboard);
- if (provider)
- g_object_set_data_full (G_OBJECT (button), "provider", provider, g_object_unref);
-
- gtk_box_append (GTK_BOX (box), button);
-}
-
-static GtkWidget *
-get_button_list (GdkClipboard *clipboard,
- const char *info)
-{
- static const guchar invalid_utf8[] = { 'L', 'i', 'b', 'e', 'r', 't', 0xe9, ',', ' ',
- 0xc9, 'g', 'a', 'l', 'i', 't', 0xe9, ',', ' ',
- 'F', 'r', 'a', 't', 'e', 'r', 'n', 'i', 't', 0xe9, 0 };
- GtkWidget *box;
- GtkIconPaintable *icon;
- GdkTexture *texture;
- GValue value = G_VALUE_INIT;
-
- box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-
- gtk_box_append (GTK_BOX (box), gtk_label_new (info));
-
- add_provider_button (box,
- NULL,
- clipboard,
- "Empty");
-
- g_value_init (&value, GDK_TYPE_PIXBUF);
- icon = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_for_display (gdk_clipboard_get_display (clipboard)),
- "utilities-terminal",
- NULL,
- 48, 1,
- gtk_widget_get_direction (box),
- 0);
- texture = render_paintable_to_texture (GDK_PAINTABLE (icon));
- g_value_take_object (&value, gdk_pixbuf_get_from_texture (texture));
- g_object_unref (texture);
- g_object_unref (icon);
- add_provider_button (box,
- gdk_content_provider_new_for_value (&value),
- clipboard,
- "GdkPixbuf");
- g_value_unset (&value);
-
- add_provider_button (box,
- gdk_content_provider_new_typed (G_TYPE_STRING, "Hello Clipboard ☺"),
- clipboard,
- "gchararry");
-
- add_provider_button (box,
- gdk_content_provider_new_for_bytes ("text/plain;charset=utf-8",
- g_bytes_new_static ("𝕳𝖊𝖑𝖑𝖔 𝖀𝖓𝖎𝖈𝖔𝖉𝖊",
- strlen ("𝕳𝖊𝖑𝖑𝖔 𝖀𝖓𝖎𝖈𝖔𝖉𝖊") + 1)),
- clipboard,
- "text/plain");
-
- add_provider_button (box,
- gdk_content_provider_new_for_bytes ("text/plain;charset=utf-8",
- g_bytes_new_static (invalid_utf8, sizeof(invalid_utf8))),
- clipboard,
- "Invalid UTF-8");
-
- g_value_init (&value, G_TYPE_FILE);
- g_value_take_object (&value, g_file_new_for_path (g_get_home_dir ()));
- add_provider_button (box,
- gdk_content_provider_new_for_value (&value),
- clipboard,
- "home directory");
- g_value_unset (&value);
-
- g_value_init (&value, GDK_TYPE_FILE_LIST);
- g_value_take_boxed (&value, get_file_list (g_get_home_dir ()));
- add_provider_button (box,
- gdk_content_provider_new_for_value (&value),
- clipboard,
- "files in home");
- return box;
-}
-
-static GtkWidget *
-get_clipboard_widget (GdkClipboard *clipboard,
- GdkClipboard *alt_clipboard,
- const char *name)
-{
- GtkWidget *vbox, *hbox, *stack, *switcher;
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_append (GTK_BOX (hbox), vbox);
- gtk_box_append (GTK_BOX (vbox), gtk_label_new (name));
- switcher = gtk_stack_switcher_new ();
- gtk_box_append (GTK_BOX (vbox), switcher);
- stack = get_contents_widget (clipboard);
- gtk_box_append (GTK_BOX (vbox), stack);
- gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (stack));
- gtk_box_append (GTK_BOX (hbox), get_button_list (clipboard, "Set Locally:"));
- if (clipboard != alt_clipboard)
- gtk_box_append (GTK_BOX (hbox), get_button_list (alt_clipboard, "Set Remotely:"));
-
- return hbox;
-}
-
-static GtkWidget *
-get_window_contents (GdkDisplay *display,
- GdkDisplay *alt_display)
-{
- GtkWidget *box;
-
- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_set_homogeneous (GTK_BOX (box), TRUE);
- gtk_box_append (GTK_BOX (box),
- get_clipboard_widget (gdk_display_get_clipboard (display),
- gdk_display_get_clipboard (alt_display),
- "Clipboard"));
- gtk_box_append (GTK_BOX (box),
- get_clipboard_widget (gdk_display_get_primary_clipboard (display),
- gdk_display_get_primary_clipboard (alt_display),
- "Primary Clipboard"));
-
- return box;
-}
-
-static void
-quit_cb (GtkWidget *widget,
- gpointer data)
-{
- gboolean *done = data;
-
- *done = TRUE;
-
- g_main_context_wakeup (NULL);
-}
-
-int
-main (int argc, char **argv)
-{
- GtkWidget *window;
- GdkDisplay *alt_display;
- gboolean done = FALSE;
-
- gtk_init ();
-
- alt_display = gdk_display_open (NULL);
- if (alt_display == NULL)
- alt_display = gdk_display_get_default ();
-
- window = gtk_window_new ();
- g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
- gtk_window_set_child (GTK_WINDOW (window),
- get_window_contents (gtk_widget_get_display (window),
- alt_display));
-
- gtk_window_present (GTK_WINDOW (window));
-
- while (!done)
- g_main_context_iteration (NULL, TRUE);
-
- return 0;
-}
diff --git a/tests/testdnd.c b/tests/testdnd.c
deleted file mode 100644
index 66e3c3c94a..0000000000
--- a/tests/testdnd.c
+++ /dev/null
@@ -1,597 +0,0 @@
-/* testdnd.c
- * Copyright (C) 1998 Red Hat, Inc.
- * Author: Owen Taylor
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-#include "gtk/gtk.h"
-
-/* Target side drag signals */
-
-/* XPM */
-static const char * drag_icon_xpm[] = {
-"36 48 9 1",
-" c None",
-". c #020204",
-"+ c #8F8F90",
-"@ c #D3D3D2",
-"# c #AEAEAC",
-"$ c #ECECEC",
-"% c #A2A2A4",
-"& c #FEFEFC",
-"* c #BEBEBC",
-" .....................",
-" ..&&&&&&&&&&&&&&&&&&&.",
-" ...&&&&&&&&&&&&&&&&&&&.",
-" ..&.&&&&&&&&&&&&&&&&&&&.",
-" ..&&.&&&&&&&&&&&&&&&&&&&.",
-" ..&&&.&&&&&&&&&&&&&&&&&&&.",
-" ..&&&&.&&&&&&&&&&&&&&&&&&&.",
-" ..&&&&&.&&&@&&&&&&&&&&&&&&&.",
-" ..&&&&&&.*$%$+$&&&&&&&&&&&&&.",
-" ..&&&&&&&.%$%$+&&&&&&&&&&&&&&.",
-" ..&&&&&&&&.#&#@$&&&&&&&&&&&&&&.",
-" ..&&&&&&&&&.#$**#$&&&&&&&&&&&&&.",
-" ..&&&&&&&&&&.&@%&%$&&&&&&&&&&&&&.",
-" ..&&&&&&&&&&&.&&&&&&&&&&&&&&&&&&&.",
-" ..&&&&&&&&&&&&.&&&&&&&&&&&&&&&&&&&.",
-"................&$@&&&@&&&&&&&&&&&&.",
-".&&&&&&&+&&#@%#+@#@*$%$+$&&&&&&&&&&.",
-".&&&&&&&+&&#@#@&&@*%$%$+&&&&&&&&&&&.",
-".&&&&&&&+&$%&#@&#@@#&#@$&&&&&&&&&&&.",
-".&&&&&&@#@@$&*@&@#@#$**#$&&&&&&&&&&.",
-".&&&&&&&&&&&&&&&&&&&@%&%$&&&&&&&&&&.",
-".&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&.",
-".&&&&&&&&$#@@$&&&&&&&&&&&&&&&&&&&&&.",
-".&&&&&&&&&+&$+&$&@&$@&&$@&&&&&&&&&&.",
-".&&&&&&&&&+&&#@%#+@#@*$%&+$&&&&&&&&.",
-".&&&&&&&&&+&&#@#@&&@*%$%$+&&&&&&&&&.",
-".&&&&&&&&&+&$%&#@&#@@#&#@$&&&&&&&&&.",
-".&&&&&&&&@#@@$&*@&@#@#$#*#$&&&&&&&&.",
-".&&&&&&&&&&&&&&&&&&&&&$%&%$&&&&&&&&.",
-".&&&&&&&&&&$#@@$&&&&&&&&&&&&&&&&&&&.",
-".&&&&&&&&&&&+&$%&$$@&$@&&$@&&&&&&&&.",
-".&&&&&&&&&&&+&&#@%#+@#@*$%$+$&&&&&&.",
-".&&&&&&&&&&&+&&#@#@&&@*#$%$+&&&&&&&.",
-".&&&&&&&&&&&+&$+&*@&#@@#&#@$&&&&&&&.",
-".&&&&&&&&&&$%@@&&*@&@#@#$#*#&&&&&&&.",
-".&&&&&&&&&&&&&&&&&&&&&&&$%&%$&&&&&&.",
-".&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&.",
-".&&&&&&&&&&&&&&$#@@$&&&&&&&&&&&&&&&.",
-".&&&&&&&&&&&&&&&+&$%&$$@&$@&&$@&&&&.",
-".&&&&&&&&&&&&&&&+&&#@%#+@#@*$%$+$&&.",
-".&&&&&&&&&&&&&&&+&&#@#@&&@*#$%$+&&&.",
-".&&&&&&&&&&&&&&&+&$+&*@&#@@#&#@$&&&.",
-".&&&&&&&&&&&&&&$%@@&&*@&@#@#$#*#&&&.",
-".&&&&&&&&&&&&&&&&&&&&&&&&&&&$%&%$&&.",
-".&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&.",
-".&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&.",
-".&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&.",
-"...................................."};
-
-/* XPM */
-static const char * trashcan_closed_xpm[] = {
-"64 80 17 1",
-" c None",
-". c #030304",
-"+ c #5A5A5C",
-"@ c #323231",
-"# c #888888",
-"$ c #1E1E1F",
-"% c #767677",
-"& c #494949",
-"* c #9E9E9C",
-"= c #111111",
-"- c #3C3C3D",
-"; c #6B6B6B",
-"> c #949494",
-", c #282828",
-"' c #808080",
-") c #545454",
-"! c #AEAEAC",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ==......=$$...=== ",
-" ..$------)+++++++++++++@$$... ",
-" ..=@@-------&+++++++++++++++++++-.... ",
-" =.$$@@@-&&)++++)-,$$$$=@@&+++++++++++++,..$ ",
-" .$$$$@@&+++++++&$$$@@@@-&,$,-++++++++++;;;&.. ",
-" $$$$,@--&++++++&$$)++++++++-,$&++++++;%%'%%;;$@ ",
-" .-@@-@-&++++++++-@++++++++++++,-++++++;''%;;;%*-$ ",
-" +------++++++++++++++++++++++++++++++;;%%%;;##*!. ",
-" =+----+++++++++++++++++++++++;;;;;;;;;;;;%'>>). ",
-" .=)&+++++++++++++++++;;;;;;;;;;;;;;%''>>#>#@. ",
-" =..=&++++++++++++;;;;;;;;;;;;;%###>>###+%== ",
-" .&....=-+++++%;;####''''''''''##'%%%)..#. ",
-" .+-++@....=,+%#####'%%%%%%%%%;@$-@-@*++!. ",
-" .+-++-+++-&-@$$=$=......$,,,@;&)+!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" =+-++-+++-+++++++++!++++!++++!+++!++!+++= ",
-" $.++-+++-+++++++++!++++!++++!+++!++!+.$ ",
-" =.++++++++++++++!++++!++++!+++!++.= ",
-" $..+++++++++++++++!++++++...$ ",
-" $$=.............=$$ ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" "};
-
-/* XPM */
-static const char * trashcan_open_xpm[] = {
-"64 80 17 1",
-" c None",
-". c #030304",
-"+ c #5A5A5C",
-"@ c #323231",
-"# c #888888",
-"$ c #1E1E1F",
-"% c #767677",
-"& c #494949",
-"* c #9E9E9C",
-"= c #111111",
-"- c #3C3C3D",
-"; c #6B6B6B",
-"> c #949494",
-", c #282828",
-"' c #808080",
-") c #545454",
-"! c #AEAEAC",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" .=.==.,@ ",
-" ==.,@-&&&)-= ",
-" .$@,&++;;;%>*- ",
-" $,-+)+++%%;;'#+. ",
-" =---+++++;%%%;%##@. ",
-" @)++++++++;%%%%'#%$ ",
-" $&++++++++++;%%;%##@= ",
-" ,-++++)+++++++;;;'#%) ",
-" @+++&&--&)++++;;%'#'-. ",
-" ,&++-@@,,,,-)++;;;'>'+, ",
-" =-++&@$@&&&&-&+;;;%##%+@ ",
-" =,)+)-,@@&+++++;;;;%##%&@ ",
-" @--&&,,@&)++++++;;;;'#)@ ",
-" ---&)-,@)+++++++;;;%''+, ",
-" $--&)+&$-+++++++;;;%%'';- ",
-" .,-&+++-$&++++++;;;%''%&= ",
-" $,-&)++)-@++++++;;%''%), ",
-" =,@&)++++&&+++++;%'''+$@&++++++ ",
-" .$@-++++++++++++;'#';,........=$@&++++ ",
-" =$@@&)+++++++++++'##-.................=&++ ",
-" .$$@-&)+++++++++;%#+$.....................=)+ ",
-" $$,@-)+++++++++;%;@=........................,+ ",
-" .$$@@-++++++++)-)@=............................ ",
-" $,@---)++++&)@===............................,. ",
-" $-@---&)))-$$=..............................=)!. ",
-" --&-&&,,$=,==...........................=&+++!. ",
-" =,=$..=$+)+++++&@$=.............=$@&+++++!++!. ",
-" .)-++-+++++++++++++++++++++++++++!++!++!. ",
-" .+-++-+++++++++++++++++++++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!+++!!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
-" =+-++-+++-+++++++++!++++!++++!+++!++!+++= ",
-" $.++-+++-+++++++++!++++!++++!+++!++!+.$ ",
-" =.++++++++++++++!++++!++++!+++!++.= ",
-" $..+++++++++++++++!++++++...$ ",
-" $$==...........==$$ ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" "};
-
-GdkPixbuf *trashcan_open;
-GdkPixbuf *trashcan_closed;
-
-
-static GdkDragAction
-action_make_unique (GdkDragAction action)
-{
- if (gdk_drag_action_is_unique (action))
- return action;
-
- if (action & GDK_ACTION_COPY)
- return GDK_ACTION_COPY;
-
- if (action & GDK_ACTION_MOVE)
- return GDK_ACTION_MOVE;
-
- if (action & GDK_ACTION_LINK)
- return GDK_ACTION_LINK;
-
- g_assert_not_reached ();
- return 0;
-}
-
-static GdkDragAction
-trash_drag_enter (GtkDropTarget *dest,
- GdkDrop *drop,
- double x,
- double y,
- GtkWidget *widget)
-{
- char *s;
-
- gtk_image_set_from_pixbuf (GTK_IMAGE (widget), trashcan_open);
-
- s = gdk_content_formats_to_string (gdk_drop_get_formats (drop));
- g_print ("trash enter: %s\n", s);
- g_free (s);
-
- return action_make_unique (gdk_drop_get_actions (drop));;
-}
-
-static GdkDragAction
-trash_drag_leave (GtkDropTarget *dest,
- GdkDrop *drop,
- GtkWidget *widget)
-{
- char *s;
-
- gtk_image_set_from_pixbuf (GTK_IMAGE (widget), trashcan_closed);
-
- s = gdk_content_formats_to_string (gdk_drop_get_formats (drop));
- g_print ("trash leave: %s\n", s);
- g_free (s);
-
- return action_make_unique (gdk_drop_get_actions (drop));
-}
-
-static gboolean
-trash_drag_drop (GtkDropTarget *dest,
- GdkDrop *drop,
- double x,
- double y,
- GtkWidget *widget)
-{
- char *s;
-
- s = gdk_content_formats_to_string (gdk_drop_get_formats (drop));
- g_print ("trash drop: %s\n", s);
- g_free (s);
-
- gdk_drop_finish (drop, action_make_unique (gdk_drop_get_actions (drop)));
-
- return TRUE;
-}
-
-static gboolean
-label_drag_drop (GtkDropTarget *dest,
- const GValue *value,
- int x,
- int y,
- GtkWidget *widget)
-{
- g_print ("Received \"%s\" in label\n", g_value_get_string (value));
- return TRUE;
-}
-
-/* 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.
- */
-static GtkWidget *popup_window = NULL;
-
-static gboolean popped_up = FALSE;
-static gboolean in_popup = FALSE;
-static guint popdown_timer = 0;
-static guint popup_timer = 0;
-
-static int
-popdown_cb (gpointer data)
-{
- popdown_timer = 0;
-
- gtk_widget_set_visible (popup_window, FALSE);
- popped_up = FALSE;
-
- return FALSE;
-}
-
-static void
-popup_enter (GtkDropTarget *dest)
-{
- g_print ("popup enter\n");
- if (!in_popup)
- {
- in_popup = TRUE;
- if (popdown_timer)
- {
- g_print ("removed popdown\n");
- g_source_remove (popdown_timer);
- popdown_timer = 0;
- }
- }
-}
-
-static void
-popup_leave (GtkDropTarget *dest)
-{
-g_print ("popup leave\n");
- if (in_popup)
- {
- in_popup = FALSE;
- if (!popdown_timer)
- {
- g_print ("added popdown\n");
- popdown_timer = g_timeout_add (500, popdown_cb, NULL);
- }
- }
-}
-
-static gboolean
-popup_drop (GtkDropTarget *dest)
-{
- popdown_cb (NULL);
- return TRUE;
-}
-
-static gboolean
-popup_cb (gpointer data)
-{
- if (!popped_up)
- {
- if (!popup_window)
- {
- GtkWidget *button;
- GtkWidget *grid;
- int i, j;
-
- popup_window = gtk_window_new ();
-
- grid = gtk_grid_new ();
-
- for (i=0; i<3; i++)
- for (j=0; j<3; j++)
- {
- char buffer[128];
- GtkDropTarget *dest;
-
- g_snprintf(buffer, sizeof(buffer), "%d,%d", i, j);
- button = gtk_button_new_with_label (buffer);
- gtk_widget_set_hexpand (button, TRUE);
- gtk_widget_set_vexpand (button, TRUE);
- gtk_grid_attach (GTK_GRID (grid), button, i, j, 1, 1);
-
- dest = gtk_drop_target_new (G_TYPE_STRING, GDK_ACTION_COPY | GDK_ACTION_MOVE);
- g_signal_connect (dest, "enter", G_CALLBACK (popup_enter), NULL);
- g_signal_connect (dest, "leave", G_CALLBACK (popup_leave), NULL);
- g_signal_connect (dest, "drop", G_CALLBACK (popup_drop), NULL);
- gtk_widget_add_controller (button, GTK_EVENT_CONTROLLER (dest));
- }
- gtk_window_set_child (GTK_WINDOW (popup_window), grid);
- }
- gtk_widget_set_visible (popup_window, TRUE);
- popped_up = TRUE;
- }
-
- popup_timer = FALSE;
-
- return FALSE;
-}
-
-static void
-popsite_enter (GtkDropControllerMotion *motion)
-{
- g_print ("popsite enter\n");
- if (!popup_timer)
- popup_timer = g_timeout_add (500, popup_cb, NULL);
-}
-
-static void
-popsite_leave (GtkDropControllerMotion *motion)
-{
- g_print ("popsite leave\n");
- if (popup_timer)
- {
- g_source_remove (popup_timer);
- popup_timer = 0;
- }
-}
-
-static void
-quit_cb (GtkWidget *widget,
- gpointer data)
-{
- gboolean *done = data;
-
- *done = TRUE;
-
- g_main_context_wakeup (NULL);
-}
-
-int
-main (int argc, char **argv)
-{
- GtkWidget *window;
- GtkWidget *grid;
- GtkWidget *label;
- GtkWidget *pixmap;
- GtkWidget *button;
- GdkPixbuf *drag_icon;
- GdkTexture *texture;
- GdkContentProvider *content;
- GtkDragSource *source;
- GtkDropTarget *dest;
- GtkDropTargetAsync *async;
- GtkEventController *controller;
- gboolean done = FALSE;
-
- gtk_init ();
-
- window = gtk_window_new ();
- g_signal_connect (window, "destroy",
- G_CALLBACK (quit_cb), &done);
-
-
- grid = gtk_grid_new ();
- gtk_window_set_child (GTK_WINDOW (window), grid);
-
- drag_icon = gdk_pixbuf_new_from_xpm_data (drag_icon_xpm);
- texture = gdk_texture_new_for_pixbuf (drag_icon);
- g_object_unref (drag_icon);
- trashcan_open = gdk_pixbuf_new_from_xpm_data (trashcan_open_xpm);
- trashcan_closed = gdk_pixbuf_new_from_xpm_data (trashcan_closed_xpm);
-
- label = gtk_label_new ("Drop Here\n");
-
- dest = gtk_drop_target_new (G_TYPE_STRING, GDK_ACTION_COPY | GDK_ACTION_MOVE);
- g_signal_connect (dest, "drop", G_CALLBACK (label_drag_drop), NULL);
- gtk_widget_add_controller (label, GTK_EVENT_CONTROLLER (dest));
-
- gtk_widget_set_hexpand (label, TRUE);
- gtk_widget_set_vexpand (label, TRUE);
- gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
-
- label = gtk_label_new ("Popup\n");
-
- controller = gtk_drop_controller_motion_new ();
- g_signal_connect (controller, "enter", G_CALLBACK (popsite_enter), NULL);
- g_signal_connect (controller, "leave", G_CALLBACK (popsite_leave), NULL);
- gtk_widget_add_controller (label, controller);
-
- gtk_widget_set_hexpand (label, TRUE);
- gtk_widget_set_vexpand (label, TRUE);
- gtk_grid_attach (GTK_GRID (grid), label, 1, 1, 1, 1);
-
- pixmap = gtk_image_new_from_pixbuf (trashcan_closed);
- async = gtk_drop_target_async_new (NULL, GDK_ACTION_ALL);
- g_signal_connect (async, "drag-enter", G_CALLBACK (trash_drag_enter), pixmap);
- g_signal_connect (async, "drag-leave", G_CALLBACK (trash_drag_leave), pixmap);
- g_signal_connect (async, "drop", G_CALLBACK (trash_drag_drop), pixmap);
- gtk_widget_add_controller (pixmap, GTK_EVENT_CONTROLLER (async));
-
- gtk_widget_set_hexpand (pixmap, TRUE);
- gtk_widget_set_vexpand (pixmap, TRUE);
- gtk_grid_attach (GTK_GRID (grid), pixmap, 1, 0, 1, 1);
-
-
- /* Drag site */
-
- button = gtk_label_new ("Drag Here\n");
-
- source = gtk_drag_source_new ();
- content = gdk_content_provider_new_typed (G_TYPE_STRING, "I'm data!");
- gtk_drag_source_set_content (source, content);
- g_object_unref (content);
- gtk_drag_source_set_actions (source, GDK_ACTION_COPY|GDK_ACTION_MOVE);
- gtk_widget_add_controller (button, GTK_EVENT_CONTROLLER (source));
- gtk_drag_source_set_icon (source, GDK_PAINTABLE (texture), 0, 0);
-
- g_object_unref (texture);
-
- gtk_widget_set_hexpand (button, TRUE);
- gtk_widget_set_vexpand (button, TRUE);
- gtk_grid_attach (GTK_GRID (grid), button, 0, 1, 1, 1);
-
- gtk_window_present (GTK_WINDOW (window));
-
- while (!done)
- g_main_context_iteration (NULL, TRUE);
-
- return 0;
-}