Goal:
I would like to implement DragNDrop from my application onto
Icons which exist on the desktop. This would allow my app to
drop a "PATH" on an icon and start the application appropriately,
just as if the FileManager had done it.
Actions:
So far I have implemented what I believe to be standard Motif
calls (borrowed from The Programming Manual), and I have gotten
the XmNconvertProc called. This routine stuffs the return values
as follows:
Boolean
convertProc( Widget w,
Atom* selection, Atom* target, Atom* type,
XtPointer* value, unsigned long* length, int* format)
{
DragConvertPtr conv;
Boolean converted = False;
Display *display = XtDisplay(w);
Atom TARGETS = XmInternAtom( display, "TARGETS", False);
Atom SGI_ICON = XmInternAtom( display, "_SGI_ICON", False);
Atom MOTIF_DROP = XmInternAtom( display, "_MOTIF_DROP", False);
/* get the widget that initiated the drag */
XtVaGetValues( w, XmNclientData, &conv, NULL, 0);
Widget widget = (Widget) conv->widget;
/* Make sure we are doing a motif drag by checking if the widget that
* is passed in is a drag context. Make sure the widget in the client
* data is not NULL.
*/
if( !widget || !XmIsDragContext( w) || *selection != MOTIF_DROP)
return converted;
if( *target == SGI_ICON) {
const char* const name = "/usr/people/mark/string_test";
char* m_name = XtMalloc( strlen( name) + 1);
strcpy( m_name, name);
*type = SGI_ICON;
*value = (XtPointer)m_name;
*length = strlen( m_name) + 1;
*format = 8;
converted = True;
} else if (*target == TARGETS) {
printf( "got here?");
}
return converted;
Problems:Quote:}
1) The Drop looks correct in that the icon absorbes the drop, however,
the $SELECTED variable in the .ftr never seems to be set. I feel I
am missing something. Any ideas?
2) I would like this to be compliant over releases, so is the correct
behavior part of some standard, or is it going to be catch-is-catch-can
from release to release?
Thanks in advance for any insights,
mark