Dear Emmanuele,

you describe how to set a drag icon. I know how to do this.
https://stackoverflow.com/q/51975256/4865723

But the question is how do I create my icon?

e.g. TreeView create it's own one, too. It is based on the row content.
I can I do the same? e.g. I only want the content of the second
column/cell and not the complete row?

 On 2018-09-02 02:33 Emmanuele Bassi
<eba...@gmail.com> wrote:
> On Sat, 1 Sep 2018 at 22:20, c.buhtz--- via gtk-app-devel-list <
> gtk-app-devel-list@gnome.org> wrote:
> 
> > I want to use my own drag-icon in a Gtk.TreeView where this is set
> > as an instance of GdkPixbuf.Pixbuf.
> >
> > I can I create/draw a pixbuf and create Text, background and border
> > color in it?
> >  
> 
> Typically, GtkTreeView will call gtk_tree_view_create_row_drag_icon()
> for the default drag surface — a box with the contents of the row.
> 
> https://developer.gnome.org/gtk3/stable/GtkTreeView.html#gtk-tree-view-create-row-drag-icon
> 
> If you want to override that, you should call
> gtk_drag_set_icon_surface(), using a Cairo surface you created:
> 
> https://developer.gnome.org/gtk3/stable/gtk3-Drag-and-Drop.html#gtk-drag-set-icon-surface
> 
> The GtkTreeView uses the default handler of the GtkWidget::drag-begin
> signal to set the drag icon; you want your own handler to be called
> after that, so you can override the drag icon with your own. To do
> that, you can:
> 
>  - call gtk_tree_view_unset_model_drag_source() or
> gtk_tree_view_unset_model_drag_dest() and implement your own drag and
> drop handling
>  - call g_signal_stop_emission_by_name() in your drag-begin callback
> to stop the signal emission chain, and prevent the default handler
> from running
>  - use g_signal_connect_after() to connect your callback, and have
> your handler run after the default one
>  - subclass GtkTreeView and override the drag_begin() virtual function
> without chaining up, to implement your own handler
> 
> Ciao,
>  Emmanuele.
> 

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to