Re: GtkToolbar drag and drop



Am Di, 2003-09-30 um 19.42 schrieb Federico Mena Quintero:

> This would be quite a pain in the butt.  It should be possible to extend
> or completely override what a widget can take as drops.  Imagine that
> toolbars take in data of type "application/x-gtk-toolbar" by default. 
> One should be able to do something like this:
> 
>   GtkTargetEntry extra_entries[] = {
>     { "text/uri-list", 0, TEXT_URI_LIST }
>   };
> 
>   gtk_drag_dest_add_targets (toolbar, 
> 			     extra_entries, 
> 			     G_N_ELEMENTS (extra_entries));
> 
>   g_signal_connect (toolbar, "drag_motion", 
> 		    G_CALLBACK (drag_motion_cb), NULL);
> 
>   g_signal_connect (toolbar, "drag_data_received",
> 		    G_CALLBACK (drag_data_received_cb), NULL);
> 
>   ...
> 
>   static gboolean
>   drag_motion_cb (GtkWidget *widget, GdkDragContext *context,
> 		  gint x, gint y, guint time_, gpointer data)
>   {
>     if (gdk_drag_context_has_type (context, "text/uri-list")
> 	&& (context->actions & GDK_ACTION_COPY)) {
>       gdk_drag_status (context, GDK_ACTION_COPY, time_);
>       return TRUE;
>     } else
>       return FALSE; /* let the default handler deal with it */
>   }
> 
>   static void
>   drag_data_received_cb (GtkWidget *widget, GdkDragContext *context,
> 			 gint x, gint y, GtkSelectionData *sel_data,
> 			 guint info, guint time_, gpointer data)
>   {
>     if (info == TEXT_URI_LIST)
>       add_uri_to_toolbar (GTK_TOOLBAR (widget), sel_data->data);
>     else
>       return; /* Just let the parent handle it */
>   }
> 
> It should be easy to extend the types that a drag destination can
> accept.  In the drag_data_received_cb() above, we also need a way to
> say, "I already handled it; don't do anything", or "I didn't handle it;
> let the default handler deal with it".
> 

See http://bugzilla.gnome.org/show_bug.cgi?id=118100 for a discussion of
the similar concept of nested drop sites.

Matthias 




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