forked from AuroraMiddleware/gtk
Move code over
Move remaining code from gtkdnd.c to gtkdragdest.c and nuke gtkdnd.c and gtkdndprivate.h.
This commit is contained in:
parent
e9067ae2db
commit
f3be49838f
@ -97,7 +97,6 @@ private_headers = [
|
|||||||
'gtkcsswidgetnodeprivate.h',
|
'gtkcsswidgetnodeprivate.h',
|
||||||
'gtkcsswin32sizevalueprivate.h',
|
'gtkcsswin32sizevalueprivate.h',
|
||||||
'gtkdialogprivate.h',
|
'gtkdialogprivate.h',
|
||||||
'gtkdndprivate.h',
|
|
||||||
'gtkentryprivate.h',
|
'gtkentryprivate.h',
|
||||||
'gtkeventcontrollerlegacyprivate.h',
|
'gtkeventcontrollerlegacyprivate.h',
|
||||||
'gtkeventcontrollerprivate.h',
|
'gtkeventcontrollerprivate.h',
|
||||||
|
141
gtk/gtkdnd.c
141
gtk/gtkdnd.c
@ -1,141 +0,0 @@
|
|||||||
/* GTK - The GIMP Toolkit
|
|
||||||
* Copyright (C) 1995-1999 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
|
||||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
||||||
* files for a list of changes. These files are distributed with
|
|
||||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include "gtkdndprivate.h"
|
|
||||||
|
|
||||||
#include "gtkdragdestprivate.h"
|
|
||||||
#include "gtkimageprivate.h"
|
|
||||||
#include "gtkintl.h"
|
|
||||||
#include "gtkmain.h"
|
|
||||||
#include "gtkpicture.h"
|
|
||||||
#include "gtkselectionprivate.h"
|
|
||||||
#include "gtksettingsprivate.h"
|
|
||||||
#include "gtkstylecontext.h"
|
|
||||||
#include "gtktooltipprivate.h"
|
|
||||||
#include "gtkwidgetprivate.h"
|
|
||||||
#include "gtkwindowgroup.h"
|
|
||||||
#include "gtkwindowprivate.h"
|
|
||||||
#include "gtknative.h"
|
|
||||||
#include "gtkdragiconprivate.h"
|
|
||||||
|
|
||||||
#include "gdk/gdkcontentformatsprivate.h"
|
|
||||||
#include "gdk/gdktextureprivate.h"
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SECTION:gtkdnd
|
|
||||||
* @Short_description: Functions for controlling drag and drop handling
|
|
||||||
* @Title: Drag and Drop
|
|
||||||
*
|
|
||||||
* GTK+ has a rich set of functions for doing inter-process communication
|
|
||||||
* via the drag-and-drop metaphor.
|
|
||||||
*
|
|
||||||
* As well as the functions listed here, applications may need to use some
|
|
||||||
* facilities provided for [Selections][gtk3-Selections]. Also, the Drag and
|
|
||||||
* Drop API makes use of signals in the #GtkWidget class.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* gtk_drag_dest_handle_event:
|
|
||||||
* @toplevel: Toplevel widget that received the event
|
|
||||||
* @event: the event to handle
|
|
||||||
*
|
|
||||||
* Called from widget event handling code on Drag events
|
|
||||||
* for destinations. For drag-motion and drop-start events,
|
|
||||||
* this function is only called if no event handler has
|
|
||||||
* handled the event.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gtk_drag_dest_handle_event (GtkWidget *toplevel,
|
|
||||||
GdkEvent *event)
|
|
||||||
{
|
|
||||||
GtkDropTarget *dest;
|
|
||||||
GdkDrop *drop;
|
|
||||||
GdkEventType event_type;
|
|
||||||
|
|
||||||
g_return_if_fail (toplevel != NULL);
|
|
||||||
g_return_if_fail (event != NULL);
|
|
||||||
|
|
||||||
event_type = gdk_event_get_event_type (event);
|
|
||||||
drop = gdk_event_get_drop (event);
|
|
||||||
|
|
||||||
/* Find the widget for the event */
|
|
||||||
switch ((guint) event_type)
|
|
||||||
{
|
|
||||||
case GDK_DRAG_ENTER:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GDK_DRAG_LEAVE:
|
|
||||||
dest = gtk_drop_get_current_dest (drop);
|
|
||||||
if (dest)
|
|
||||||
{
|
|
||||||
gtk_drop_target_emit_drag_leave (dest, drop);
|
|
||||||
gtk_drop_set_current_dest (drop, NULL);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GDK_DRAG_MOTION:
|
|
||||||
case GDK_DROP_START:
|
|
||||||
gdk_drop_status (drop, 0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
clear_current_dest (gpointer data, GObject *former_object)
|
|
||||||
{
|
|
||||||
g_object_set_data (G_OBJECT (data), "current-dest", NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gtk_drop_set_current_dest (GdkDrop *drop,
|
|
||||||
GtkDropTarget *dest)
|
|
||||||
{
|
|
||||||
GtkDropTarget *old_dest;
|
|
||||||
|
|
||||||
old_dest = g_object_get_data (G_OBJECT (drop), "current-dest");
|
|
||||||
|
|
||||||
if (old_dest)
|
|
||||||
g_object_weak_unref (G_OBJECT (old_dest), clear_current_dest, drop);
|
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (drop), "current-dest", dest);
|
|
||||||
|
|
||||||
if (dest)
|
|
||||||
g_object_weak_ref (G_OBJECT (dest), clear_current_dest, drop);
|
|
||||||
}
|
|
||||||
|
|
||||||
GtkDropTarget *
|
|
||||||
gtk_drop_get_current_dest (GdkDrop *drop)
|
|
||||||
{
|
|
||||||
return g_object_get_data (G_OBJECT (drop), "current-dest");
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
/* -*- Mode: C; c-file-style: "gnu"; tab-width: 8 -*- */
|
|
||||||
/* GTK - The GIMP Toolkit
|
|
||||||
* Copyright (C) 2015 Red Hat, Inc.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GTK_DND_PRIVATE_H__
|
|
||||||
#define __GTK_DND_PRIVATE_H__
|
|
||||||
|
|
||||||
#include "gtkwidget.h"
|
|
||||||
#include "gtkdragdest.h"
|
|
||||||
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
void gtk_drag_dest_handle_event (GtkWidget *toplevel,
|
|
||||||
GdkEvent *event);
|
|
||||||
|
|
||||||
void gtk_drop_set_current_dest (GdkDrop *drop,
|
|
||||||
GtkDropTarget *dest);
|
|
||||||
GtkDropTarget *gtk_drop_get_current_dest (GdkDrop *drop);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* __GTK_DND_PRIVATE_H__ */
|
|
@ -27,7 +27,6 @@
|
|||||||
#include "gtkdragdest.h"
|
#include "gtkdragdest.h"
|
||||||
#include "gtkdragdestprivate.h"
|
#include "gtkdragdestprivate.h"
|
||||||
|
|
||||||
#include "gtkdndprivate.h"
|
|
||||||
#include "gtkintl.h"
|
#include "gtkintl.h"
|
||||||
#include "gtknative.h"
|
#include "gtknative.h"
|
||||||
#include "gtktypebuiltins.h"
|
#include "gtktypebuiltins.h"
|
||||||
@ -102,6 +101,10 @@ static void gtk_drop_target_set_widget (GtkEventController *controller,
|
|||||||
GtkWidget *widget);
|
GtkWidget *widget);
|
||||||
static void gtk_drop_target_unset_widget (GtkEventController *controller);
|
static void gtk_drop_target_unset_widget (GtkEventController *controller);
|
||||||
|
|
||||||
|
static gboolean gtk_drop_target_get_armed (GtkDropTarget *dest);
|
||||||
|
static void gtk_drop_target_set_armed (GtkDropTarget *dest,
|
||||||
|
gboolean armed);
|
||||||
|
|
||||||
G_DEFINE_TYPE (GtkDropTarget, gtk_drop_target, GTK_TYPE_EVENT_CONTROLLER);
|
G_DEFINE_TYPE (GtkDropTarget, gtk_drop_target, GTK_TYPE_EVENT_CONTROLLER);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -439,12 +442,6 @@ gtk_drag_dest_hierarchy_changed (GtkWidget *widget,
|
|||||||
gdk_surface_register_dnd (gtk_native_get_surface (native));
|
gdk_surface_register_dnd (gtk_native_get_surface (native));
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkDropTarget *
|
|
||||||
gtk_drop_target_get (GtkWidget *widget)
|
|
||||||
{
|
|
||||||
return g_object_get_data (G_OBJECT (widget), I_("gtk-drag-dest"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_drop_target_get_target:
|
* gtk_drop_target_get_target:
|
||||||
* @dest: a #GtkDropTarget
|
* @dest: a #GtkDropTarget
|
||||||
@ -477,7 +474,7 @@ gtk_drop_target_get_drop (GtkDropTarget *dest)
|
|||||||
return dest->drop;
|
return dest->drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
static const char *
|
||||||
gtk_drop_target_match (GtkDropTarget *dest,
|
gtk_drop_target_match (GtkDropTarget *dest,
|
||||||
GdkDrop *drop)
|
GdkDrop *drop)
|
||||||
{
|
{
|
||||||
@ -557,7 +554,7 @@ set_drop (GtkDropTarget *dest,
|
|||||||
g_object_add_weak_pointer (G_OBJECT (dest->drop), (gpointer *)&dest->drop);
|
g_object_add_weak_pointer (G_OBJECT (dest->drop), (gpointer *)&dest->drop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
gtk_drop_target_emit_drag_leave (GtkDropTarget *dest,
|
gtk_drop_target_emit_drag_leave (GtkDropTarget *dest,
|
||||||
GdkDrop *drop)
|
GdkDrop *drop)
|
||||||
{
|
{
|
||||||
@ -567,7 +564,7 @@ gtk_drop_target_emit_drag_leave (GtkDropTarget *dest,
|
|||||||
gtk_drop_target_set_armed (dest, FALSE);
|
gtk_drop_target_set_armed (dest, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
static gboolean
|
||||||
gtk_drop_target_emit_drag_motion (GtkDropTarget *dest,
|
gtk_drop_target_emit_drag_motion (GtkDropTarget *dest,
|
||||||
GdkDrop *drop,
|
GdkDrop *drop,
|
||||||
int x,
|
int x,
|
||||||
@ -586,7 +583,7 @@ gtk_drop_target_emit_drag_motion (GtkDropTarget *dest,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
static gboolean
|
||||||
gtk_drop_target_emit_drag_drop (GtkDropTarget *dest,
|
gtk_drop_target_emit_drag_drop (GtkDropTarget *dest,
|
||||||
GdkDrop *drop,
|
GdkDrop *drop,
|
||||||
int x,
|
int x,
|
||||||
@ -600,7 +597,7 @@ gtk_drop_target_emit_drag_drop (GtkDropTarget *dest,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
gtk_drop_target_set_armed (GtkDropTarget *dest,
|
gtk_drop_target_set_armed (GtkDropTarget *dest,
|
||||||
gboolean armed)
|
gboolean armed)
|
||||||
{
|
{
|
||||||
@ -623,7 +620,7 @@ gtk_drop_target_set_armed (GtkDropTarget *dest,
|
|||||||
g_object_notify_by_pspec (G_OBJECT (dest), properties[PROP_ARMED]);
|
g_object_notify_by_pspec (G_OBJECT (dest), properties[PROP_ARMED]);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
static gboolean
|
||||||
gtk_drop_target_get_armed (GtkDropTarget *dest)
|
gtk_drop_target_get_armed (GtkDropTarget *dest)
|
||||||
{
|
{
|
||||||
return dest->armed;
|
return dest->armed;
|
||||||
@ -647,6 +644,35 @@ gtk_drop_target_filter_event (GtkEventController *controller,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clear_current_dest (gpointer data, GObject *former_object)
|
||||||
|
{
|
||||||
|
g_object_set_data (G_OBJECT (data), "current-dest", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_drop_set_current_dest (GdkDrop *drop,
|
||||||
|
GtkDropTarget *dest)
|
||||||
|
{
|
||||||
|
GtkDropTarget *old_dest;
|
||||||
|
|
||||||
|
old_dest = g_object_get_data (G_OBJECT (drop), "current-dest");
|
||||||
|
|
||||||
|
if (old_dest)
|
||||||
|
g_object_weak_unref (G_OBJECT (old_dest), clear_current_dest, drop);
|
||||||
|
|
||||||
|
g_object_set_data (G_OBJECT (drop), "current-dest", dest);
|
||||||
|
|
||||||
|
if (dest)
|
||||||
|
g_object_weak_ref (G_OBJECT (dest), clear_current_dest, drop);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkDropTarget *
|
||||||
|
gtk_drop_get_current_dest (GdkDrop *drop)
|
||||||
|
{
|
||||||
|
return g_object_get_data (G_OBJECT (drop), "current-dest");
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gtk_drop_target_handle_event (GtkEventController *controller,
|
gtk_drop_target_handle_event (GtkEventController *controller,
|
||||||
const GdkEvent *event)
|
const GdkEvent *event)
|
||||||
@ -699,6 +725,48 @@ gtk_drop_target_handle_event (GtkEventController *controller,
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function is called if none of the event
|
||||||
|
* controllers has handled a drag event.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gtk_drag_dest_handle_event (GtkWidget *toplevel,
|
||||||
|
GdkEvent *event)
|
||||||
|
{
|
||||||
|
GtkDropTarget *dest;
|
||||||
|
GdkDrop *drop;
|
||||||
|
GdkEventType event_type;
|
||||||
|
|
||||||
|
g_return_if_fail (toplevel != NULL);
|
||||||
|
g_return_if_fail (event != NULL);
|
||||||
|
|
||||||
|
event_type = gdk_event_get_event_type (event);
|
||||||
|
drop = gdk_event_get_drop (event);
|
||||||
|
|
||||||
|
switch ((guint) event_type)
|
||||||
|
{
|
||||||
|
case GDK_DRAG_ENTER:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GDK_DRAG_LEAVE:
|
||||||
|
dest = gtk_drop_get_current_dest (drop);
|
||||||
|
if (dest)
|
||||||
|
{
|
||||||
|
gtk_drop_target_emit_drag_leave (dest, drop);
|
||||||
|
gtk_drop_set_current_dest (drop, NULL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GDK_DRAG_MOTION:
|
||||||
|
case GDK_DROP_START:
|
||||||
|
gdk_drop_status (drop, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_drop_target_set_widget (GtkEventController *controller,
|
gtk_drop_target_set_widget (GtkEventController *controller,
|
||||||
GtkWidget *widget)
|
GtkWidget *widget)
|
||||||
|
@ -23,27 +23,9 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
void gtk_drop_target_emit_drag_data_received (GtkDropTarget *dest,
|
|
||||||
GdkDrop *drop,
|
|
||||||
GtkSelectionData *sdata);
|
|
||||||
void gtk_drop_target_emit_drag_leave (GtkDropTarget *dest,
|
|
||||||
GdkDrop *drop);
|
|
||||||
gboolean gtk_drop_target_emit_drag_motion (GtkDropTarget *dest,
|
|
||||||
GdkDrop *drop,
|
|
||||||
int x,
|
|
||||||
int y);
|
|
||||||
gboolean gtk_drop_target_emit_drag_drop (GtkDropTarget *dest,
|
|
||||||
GdkDrop *drop,
|
|
||||||
int x,
|
|
||||||
int y);
|
|
||||||
|
|
||||||
const char * gtk_drop_target_match (GtkDropTarget *dest,
|
void gtk_drag_dest_handle_event (GtkWidget *toplevel,
|
||||||
GdkDrop *drop);
|
GdkEvent *event);
|
||||||
void gtk_drop_target_set_armed (GtkDropTarget *dest,
|
|
||||||
gboolean armed);
|
|
||||||
gboolean gtk_drop_target_get_armed (GtkDropTarget *dest);
|
|
||||||
|
|
||||||
GtkDropTarget *gtk_drop_target_get (GtkWidget *widget);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
#include "gtkdragsource.h"
|
#include "gtkdragsource.h"
|
||||||
|
|
||||||
#include "gtkdndprivate.h"
|
|
||||||
#include "gtkgesturedrag.h"
|
#include "gtkgesturedrag.h"
|
||||||
#include "gtkgesturesingleprivate.h"
|
#include "gtkgesturesingleprivate.h"
|
||||||
#include "gtkimagedefinitionprivate.h"
|
#include "gtkimagedefinitionprivate.h"
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
#include "gtkcelllayout.h"
|
#include "gtkcelllayout.h"
|
||||||
#include "gtkcssnodeprivate.h"
|
#include "gtkcssnodeprivate.h"
|
||||||
#include "gtkdebug.h"
|
#include "gtkdebug.h"
|
||||||
#include "gtkdndprivate.h"
|
|
||||||
#include "gtkeditable.h"
|
#include "gtkeditable.h"
|
||||||
#include "gtkemojichooser.h"
|
#include "gtkemojichooser.h"
|
||||||
#include "gtkemojicompletion.h"
|
#include "gtkemojicompletion.h"
|
||||||
|
@ -116,7 +116,7 @@
|
|||||||
#include "gtkaccelmapprivate.h"
|
#include "gtkaccelmapprivate.h"
|
||||||
#include "gtkbox.h"
|
#include "gtkbox.h"
|
||||||
#include "gtkdebug.h"
|
#include "gtkdebug.h"
|
||||||
#include "gtkdndprivate.h"
|
#include "gtkdragdestprivate.h"
|
||||||
#include "gtkmain.h"
|
#include "gtkmain.h"
|
||||||
#include "gtkmediafileprivate.h"
|
#include "gtkmediafileprivate.h"
|
||||||
#include "gtkmodulesprivate.h"
|
#include "gtkmodulesprivate.h"
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#include "gtkbutton.h"
|
#include "gtkbutton.h"
|
||||||
#include "gtkcssnodeprivate.h"
|
#include "gtkcssnodeprivate.h"
|
||||||
#include "gtkdebug.h"
|
#include "gtkdebug.h"
|
||||||
#include "gtkdndprivate.h"
|
|
||||||
#include "gtkeditable.h"
|
#include "gtkeditable.h"
|
||||||
#include "gtkemojichooser.h"
|
#include "gtkemojichooser.h"
|
||||||
#include "gtkemojicompletion.h"
|
#include "gtkemojicompletion.h"
|
||||||
|
@ -214,7 +214,6 @@ gtk_public_sources = files([
|
|||||||
'gtkcontainer.c',
|
'gtkcontainer.c',
|
||||||
'gtkcssprovider.c',
|
'gtkcssprovider.c',
|
||||||
'gtkdialog.c',
|
'gtkdialog.c',
|
||||||
'gtkdnd.c',
|
|
||||||
'gtkdragdest.c',
|
'gtkdragdest.c',
|
||||||
'gtkdragsource.c',
|
'gtkdragsource.c',
|
||||||
'gtkdrawingarea.c',
|
'gtkdrawingarea.c',
|
||||||
|
Loading…
Reference in New Issue
Block a user