Re: "draw" icon with string
- From: <c buhtz posteo jp>
- To: gtk-app-devel-list list <gtk-app-devel-list gnome org>
- Subject: Re: "draw" icon with string
- Date: Tue, 4 Sep 2018 01:09:33 +0200
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
<ebassi 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.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]