1
/* $XConsortium: convert.c /main/5 1995/07/15 20:45:16 drk $ */
3
* @OPENGROUP_COPYRIGHT@
5
* Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
6
* Copyright (c) 1996, 1997, 1998, 1999, 2000 The Open Group
7
* ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
8
* the full copyright text.
10
* This software is subject to an open license. It may only be
11
* used on, with or for operating systems which are themselves open
12
* source systems. You must contact The Open Group for a license
13
* allowing distribution and sublicensing of this software on, with,
14
* or for operating systems which are not Open Source programs.
16
* See http://www.opengroup.org/openmotif/license for full
17
* details of the license agreement. Any use, reproduction, or
18
* distribution of the program constitutes recipient's acceptance of
21
* EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
22
* PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23
* KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
24
* WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
25
* OR FITNESS FOR A PARTICULAR PURPOSE
27
* EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
28
* NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT,
29
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30
* DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED
31
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33
* ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
34
* EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
35
* POSSIBILITY OF SUCH DAMAGES.
43
#include <Xm/Container.h>
44
#include <Xm/Transfer.h>
45
#include "filemanager.h"
48
targetConvertCallback(Widget wid, XtPointer ignore,
49
XmConvertCallbackStruct *cs)
51
Atom XA_TARGETS = XInternAtom(XtDisplay(wid), XmSTARGETS, False);
52
Atom XA_FILE = XInternAtom(XtDisplay(wid), XmSFILE, False);
53
Atom XA_FILENAME = XInternAtom(XtDisplay(wid), XmSFILE_NAME, False);
54
Atom XA_MOTIF_EXPORTS =
55
XInternAtom(XtDisplay(wid), XmS_MOTIF_EXPORT_TARGETS, False);
56
Atom XA_MOTIF_REQUIRED =
57
XInternAtom(XtDisplay(wid), XmS_MOTIF_CLIPBOARD_TARGETS, False);
59
XInternAtom(XtDisplay(wid), XmS_MOTIF_DROP, False);
61
if (cs -> selection == XA_MOTIF_DROP &&
62
(cs -> target == XA_TARGETS ||
63
cs -> target == XA_MOTIF_EXPORTS ||
64
cs -> target == XA_MOTIF_REQUIRED)) {
66
targs = (Atom *) XtMalloc(sizeof(Atom) * 2);
68
targs[1] = XA_FILENAME;
69
cs -> value = (XtPointer) targs;
73
cs -> status = XmCONVERT_MERGE;
74
} else if (cs -> target == XA_FILE ||
75
cs -> target == XA_FILENAME) {
76
if (cs -> location_data == NULL) {
81
/* First get list of selected items. */
82
XtVaGetValues(fileviewer,
83
XmNselectedObjects, &selected,
84
XmNselectedObjectCount, &count,
91
for(i = 0; i < count; i++) {
95
path = getPathFromIcon(selected[i]);
96
pathlen = strlen(path) + 1;
97
rval = XtRealloc(rval, curpos + pathlen);
98
/* This will include the terminating NULL byte. Important,
99
do not remove this NULL byte, it acts as a separator */
100
strncpy(rval, path, pathlen);
104
cs -> length = curpos - 1;
105
cs -> type = XA_STRING;
106
cs -> status = XmCONVERT_DONE;
108
cs -> status = XmCONVERT_REFUSE;
113
path = getPathFromIcon(cs -> location_data);
117
cs -> length = strlen(path);
121
cs -> type = XA_STRING;
122
cs -> status = XmCONVERT_DONE;
128
targetDestinationCallback(Widget w, XtPointer ignore,
129
XmDestinationCallbackStruct *cs)