On Sun, 21 Apr 2002 12:15:55 +0200 (CET) Vadim Zeitlin <[EMAIL PROTECTED]> wrote:
VZ> On Sun, 21 Apr 2002 11:57:00 +0200 (CEST) Harald Gutsche VZ> <[EMAIL PROTECTED]> wrote: VZ> VZ> HG> is there any possibility to get a little switch VZ> HG> VZ> HG> "default drag&drop operation is move" VZ> HG> ? VZ> VZ> No. I've looked at this a long time ago after receiving many requestes VZ> about it and it turned out that GTK+ decides itself what to do and I VZ> found VZ> no way to influence this. Maybe this has changed with GTK+ 2.0, I VZ> haven't VZ> looked at this issue in it yet, but with 1.x I think it's simply VZ> impossible. VZ> VZ> If you find any program which uses GTK+ dnd and where the default VZ> operation is move (but copy is also allowed), please let me know - VZ> maybe we VZ> could learn something from its sources :-) VZ> VZ> Regards, VZ> VZ VZ> VZ> at http://wolfpack.twu.net/docs/gtkdnd/#s5 I found something: Specifying Default Drag Actions Unfortunatly there is no way to define the default drag action (GDK_ACTION_MOVE or GDK_ACTION_COPY amoung other things) when you set up your source and destination widgets. So the default drag action needs to be set when a drag is in progress, specifically when a drag_motion signal is sent. In your ddrag_motion signal handler, you need to call gdk_drag_status() which sets the default drag action. So here are the changes you would have to make if you were using the example source: When you set up your drag destination widget, you need to omit the GTK_DEST_DEFAULT_MOTION flag from the call to gtk_drag_dest_set(). gtk_drag_dest_set( w, GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, target_entry, 1, GDK_ACTION_COPY | GDK_ACTION_MOVE ); Next you will need to create a handler for the drag_motion signal and connect the destination widget to that signal. The drag_motion signal handler should look something like this: static gboolean DNDDragMotionCB( GtkWidget *widget, GdkDragContext *dc, gint x, gint y, guint t, gpointer data ) { gboolean same; GtkWidget *source_widget; my_prog_window_struct *pws = (my_prog_window_struct *)data; if((widget == NULL) || (pws == NULL) || (dc == NULL)) return(FALSE); /* Get source widget and check if it is the same as the * destination widget. */ source_widget = gtk_drag_get_source_widget(dc); same = ((source_widget == widget) ? TRUE : FALSE); /* Put additional checks here, perhaps if same is FALSE then * set the default drag to GDK_ACTION_COPY. */ /* Say we just want to allow GDK_ACTION_MOVE, first we check * if that is in the list of allowed actions on the dc. If * so then we set it to that. Note if the user holds down the * ctrl key then the only flag in dc->actions will be * GDK_ACTION_COPY. The constraint for dc->actions is that * specified from the given actions in gtk_drag_dest_set() and * gtk_drag_source_set(). */ if(dc->actions == GDK_ACTION_MOVE) gdk_drag_status(dc, GDK_ACTION_MOVE, t); return(TRUE); } And connect the drag_motion signal with the destination widget: gtk_signal_connect( GTK_OBJECT(widget), "drag_motion", GTK_SIGNAL_FUNC(GUIDragMotionCB), cb_data_ptr ); This will have the destination widget udpate the default drag to be a GDK_ACTION_MOVE whenever the drag pointer goes over it or when the user presses a modifier key (such as CTRL or SHIFT). Remember when a modifier key is pressed down, the drag_motion handler will be called and the dc->actions field will only have one flag set, that is the flag corresponding to the modifier key (GDK_ACTION_MOVE for the SHIFT key and GDK_ACTION_COPY for the CTRL key. _______________________________________________ Mahogany-Users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/mahogany-users
