PIKApp/app/widgets/pikadnd.h

298 lines
14 KiB
C

/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_DND_H__
#define __PIKA_DND_H__
#define PIKA_TARGET_URI_LIST \
{ "text/uri-list", 0, PIKA_DND_TYPE_URI_LIST }
#define PIKA_TARGET_TEXT_PLAIN \
{ "text/plain", 0, PIKA_DND_TYPE_TEXT_PLAIN }
#define PIKA_TARGET_NETSCAPE_URL \
{ "_NETSCAPE_URL", 0, PIKA_DND_TYPE_NETSCAPE_URL }
#define PIKA_TARGET_XDS \
{ "XdndDirectSave0", 0, PIKA_DND_TYPE_XDS }
#define PIKA_TARGET_COLOR \
{ "application/x-color", 0, PIKA_DND_TYPE_COLOR }
#define PIKA_TARGET_SVG \
{ "image/svg", 0, PIKA_DND_TYPE_SVG }
#define PIKA_TARGET_SVG_XML \
{ "image/svg+xml", 0, PIKA_DND_TYPE_SVG_XML }
/* just here for documentation purposes, the actual list of targets
* is created dynamically from available GdkPixbuf loaders
*/
#define PIKA_TARGET_PIXBUF \
{ NULL, 0, PIKA_DND_TYPE_PIXBUF }
#define PIKA_TARGET_IMAGE \
{ "application/x-pika-image-id", GTK_TARGET_SAME_APP, PIKA_DND_TYPE_IMAGE }
#define PIKA_TARGET_COMPONENT \
{ "application/x-pika-component", GTK_TARGET_SAME_APP, PIKA_DND_TYPE_COMPONENT }
#define PIKA_TARGET_LAYER \
{ "application/x-pika-layer-id", GTK_TARGET_SAME_APP, PIKA_DND_TYPE_LAYER }
#define PIKA_TARGET_CHANNEL \
{ "application/x-pika-channel-id", GTK_TARGET_SAME_APP, PIKA_DND_TYPE_CHANNEL }
#define PIKA_TARGET_LAYER_MASK \
{ "application/x-pika-layer-mask-id", GTK_TARGET_SAME_APP, PIKA_DND_TYPE_LAYER_MASK }
#define PIKA_TARGET_VECTORS \
{ "application/x-pika-vectors-id", GTK_TARGET_SAME_APP, PIKA_DND_TYPE_VECTORS }
#define PIKA_TARGET_BRUSH \
{ "application/x-pika-brush-name", 0, PIKA_DND_TYPE_BRUSH }
#define PIKA_TARGET_PATTERN \
{ "application/x-pika-pattern-name", 0, PIKA_DND_TYPE_PATTERN }
#define PIKA_TARGET_GRADIENT \
{ "application/x-pika-gradient-name", 0, PIKA_DND_TYPE_GRADIENT }
#define PIKA_TARGET_PALETTE \
{ "application/x-pika-palette-name", 0, PIKA_DND_TYPE_PALETTE }
#define PIKA_TARGET_FONT \
{ "application/x-pika-font-name", 0, PIKA_DND_TYPE_FONT }
#define PIKA_TARGET_BUFFER \
{ "application/x-pika-buffer-name", GTK_TARGET_SAME_APP, PIKA_DND_TYPE_BUFFER }
#define PIKA_TARGET_IMAGEFILE \
{ "application/x-pika-imagefile-name", GTK_TARGET_SAME_APP, PIKA_DND_TYPE_IMAGEFILE }
#define PIKA_TARGET_TEMPLATE \
{ "application/x-pika-template-name", GTK_TARGET_SAME_APP, PIKA_DND_TYPE_TEMPLATE }
#define PIKA_TARGET_TOOL_ITEM \
{ "application/x-pika-tool-item-name", GTK_TARGET_SAME_APP, PIKA_DND_TYPE_TOOL_ITEM }
#define PIKA_TARGET_NOTEBOOK_TAB \
{ "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, PIKA_DND_TYPE_NOTEBOOK_TAB }
#define PIKA_TARGET_LAYER_LIST \
{ "application/x-pika-layer-list", GTK_TARGET_SAME_APP, PIKA_DND_TYPE_LAYER_LIST }
#define PIKA_TARGET_CHANNEL_LIST \
{ "application/x-pika-channel-list", GTK_TARGET_SAME_APP, PIKA_DND_TYPE_CHANNEL_LIST }
#define PIKA_TARGET_VECTORS_LIST \
{ "application/x-pika-vectors-list", GTK_TARGET_SAME_APP, PIKA_DND_TYPE_VECTORS_LIST }
/* dnd initialization */
void pika_dnd_init (Pika *pika);
/* uri list dnd functions */
typedef GList * (* PikaDndDragUriListFunc) (GtkWidget *widget,
gpointer data);
typedef void (* PikaDndDropUriListFunc) (GtkWidget *widget,
gint x,
gint y,
GList *uri_list,
gpointer data);
void pika_dnd_uri_list_source_add (GtkWidget *widget,
PikaDndDragUriListFunc get_uri_list_func,
gpointer data);
void pika_dnd_uri_list_source_remove (GtkWidget *widget);
void pika_dnd_uri_list_dest_add (GtkWidget *widget,
PikaDndDropUriListFunc set_uri_list_func,
gpointer data);
void pika_dnd_uri_list_dest_remove (GtkWidget *widget);
/* color dnd functions */
typedef void (* PikaDndDragColorFunc) (GtkWidget *widget,
PikaRGB *color,
gpointer data);
typedef void (* PikaDndDropColorFunc) (GtkWidget *widget,
gint x,
gint y,
const PikaRGB *color,
gpointer data);
void pika_dnd_color_source_add (GtkWidget *widget,
PikaDndDragColorFunc get_color_func,
gpointer data);
void pika_dnd_color_source_remove (GtkWidget *widget);
void pika_dnd_color_dest_add (GtkWidget *widget,
PikaDndDropColorFunc set_color_func,
gpointer data);
void pika_dnd_color_dest_remove (GtkWidget *widget);
/* stream dnd functions */
typedef guchar * (* PikaDndDragStreamFunc) (GtkWidget *widget,
gsize *stream_len,
gpointer data);
typedef void (* PikaDndDropStreamFunc) (GtkWidget *widget,
gint x,
gint y,
const guchar *stream,
gsize stream_len,
gpointer data);
void pika_dnd_svg_source_add (GtkWidget *widget,
PikaDndDragStreamFunc get_svg_func,
gpointer data);
void pika_dnd_svg_source_remove (GtkWidget *widget);
void pika_dnd_svg_dest_add (GtkWidget *widget,
PikaDndDropStreamFunc set_svg_func,
gpointer data);
void pika_dnd_svg_dest_remove (GtkWidget *widget);
/* pixbuf dnd functions */
typedef GdkPixbuf * (* PikaDndDragPixbufFunc) (GtkWidget *widget,
gpointer data);
typedef void (* PikaDndDropPixbufFunc) (GtkWidget *widget,
gint x,
gint y,
GdkPixbuf *pixbuf,
gpointer data);
void pika_dnd_pixbuf_source_add (GtkWidget *widget,
PikaDndDragPixbufFunc get_pixbuf_func,
gpointer data);
void pika_dnd_pixbuf_source_remove (GtkWidget *widget);
void pika_dnd_pixbuf_dest_add (GtkWidget *widget,
PikaDndDropPixbufFunc set_pixbuf_func,
gpointer data);
void pika_dnd_pixbuf_dest_remove (GtkWidget *widget);
/* component dnd functions */
typedef PikaImage * (* PikaDndDragComponentFunc) (GtkWidget *widget,
PikaContext **context,
PikaChannelType *channel,
gpointer data);
typedef void (* PikaDndDropComponentFunc) (GtkWidget *widget,
gint x,
gint y,
PikaImage *image,
PikaChannelType channel,
gpointer data);
void pika_dnd_component_source_add (GtkWidget *widget,
PikaDndDragComponentFunc get_comp_func,
gpointer data);
void pika_dnd_component_source_remove (GtkWidget *widget);
void pika_dnd_component_dest_add (GtkWidget *widget,
PikaDndDropComponentFunc set_comp_func,
gpointer data);
void pika_dnd_component_dest_remove (GtkWidget *widget);
/* PikaViewable (by GType) dnd functions */
typedef PikaViewable * (* PikaDndDragViewableFunc) (GtkWidget *widget,
PikaContext **context,
gpointer data);
typedef void (* PikaDndDropViewableFunc) (GtkWidget *widget,
gint x,
gint y,
PikaViewable *viewable,
gpointer data);
gboolean pika_dnd_drag_source_set_by_type (GtkWidget *widget,
GdkModifierType start_button_mask,
GType type,
GdkDragAction actions);
gboolean pika_dnd_viewable_source_add (GtkWidget *widget,
GType type,
PikaDndDragViewableFunc get_viewable_func,
gpointer data);
gboolean pika_dnd_viewable_source_remove (GtkWidget *widget,
GType type);
gboolean pika_dnd_drag_dest_set_by_type (GtkWidget *widget,
GtkDestDefaults flags,
GType type,
gboolean list_accepted,
GdkDragAction actions);
gboolean pika_dnd_viewable_dest_add (GtkWidget *widget,
GType type,
PikaDndDropViewableFunc set_viewable_func,
gpointer data);
gboolean pika_dnd_viewable_dest_remove (GtkWidget *widget,
GType type);
PikaViewable * pika_dnd_get_drag_viewable (GtkWidget *widget);
/* PikaViewable (by GType) GList dnd functions */
typedef GList * (* PikaDndDragViewableListFunc) (GtkWidget *widget,
PikaContext **context,
gpointer data);
typedef void (* PikaDndDropViewableListFunc) (GtkWidget *widget,
gint x,
gint y,
GList *viewables,
gpointer data);
gboolean pika_dnd_viewable_list_source_add (GtkWidget *widget,
GType type,
PikaDndDragViewableListFunc get_viewable_list_func,
gpointer data);
gboolean pika_dnd_viewable_list_source_remove (GtkWidget *widget,
GType type);
gboolean pika_dnd_viewable_list_dest_add (GtkWidget *widget,
GType type,
PikaDndDropViewableListFunc set_viewable_func,
gpointer data);
gboolean pika_dnd_viewable_list_dest_remove (GtkWidget *widget,
GType type);
GList * pika_dnd_get_drag_list (GtkWidget *widget);
/* Direct Save Protocol (XDS) */
void pika_dnd_xds_source_add (GtkWidget *widget,
PikaDndDragViewableFunc get_image_func,
gpointer data);
void pika_dnd_xds_source_remove (GtkWidget *widget);
#endif /* __PIKA_DND_H__ */