Re: drag and drop in gnome



Elliot Lee wrote:

> On 3 Aug 1999 23:28:12 -0400, Daniel Weber <DWEBER1@austin.rr.com> wrote:
>
> >    I'm trying to implement a sample program that accepts drag-n-drop,
> >however I'm having a serios amount of difficulty in getting it to work.
> >I'm working from the xDND specification page and the gtk source, but
> >haven't gotten anywhere, really.  Questions include:
>
> You're digging into the low-level stuff. It's really not that complicated ;-)
>
> Setting up a drag source:
>         Call gtk_drag_source_set() with appropriate params.
>         Provide an appropriate handler for the "drag_data_get" signal.
>
> Setting up a drag destination:
>         Call gtk_drag_dest_set() with the appropriate params.
>         Provide an appropriate handler for the "drag_data_received" signal.
>

I guess I"m missing what you mean by providing an appropriate handler.  In the
gtk source it's listed as "drag-data-received" (with dash instead of underscore)
and I put in a signal handler with:

  gtk_signal_connect(GTK_OBJECT(edit_control), "drag-data-received",
   GTK_SIGNAL_FUNC (drag_data_received), " drag-data-received");

The signal handler itself just prints out that it was called.  However, this
signal handler is never entered.  I am setting the drop with:

gtk_drag_dest_set(edit_control,GTK_DEST_DEFAULT_DROP, targets,2,
   GDK_ACTION_LINK);

where edit_control is a simple edit control (where I hope to open a file
someday), and targets is defined as:
   GtkTargetEntry targets[] = {
    {"text/x-c",0,1},
   {"text/url",0,2}};

I take it from the (rather incomplete) documentation at gtk.org that gtk is
doing some checking against the defined targets before signaling the
application.  However there is no mention of what form the targets description
should be in.  I assumed that they would be mime types, but since I couldn't
figure out what was in the GList in the GDragContext I couldn't even print out
what gtk was trying to drop.  Remember, the only signal I am getting is the
drag-leave.  This led me down a wild search of the source code and the Xdnd page
which has, to this point, led me precisely nowhere.  Not that I'm ready to give
up yet.  My questions now are:

1)  What goes in the target description?  mime types?  file descriptors (*.c)?
Something even more bizarre?
2)  Is there somewhere a minimum bit of code that shows how to do this?
3)  Do I have to setup source and destination or can I just setup desitination
if a control only receives drops?
4)  Why doens't my code work the first time?  I'm really much, much smarter than
my computer but it aways seems to find a way to humilate me.  This is just not
right.

Any help appreciated....



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]