Drawing a widget as a drag icon (without going down to C)

Daniel Boles via gtkmm-list <[email protected]>
Newsgroups gmane.comp.gnome.gtkmm
Message-ID <CAKChMKMXj+pQBjK__QpzZhEm3BQaQ1XDhaoACh6Yy8bAT3XO4g@mail.gmail.com>
I have a small widget that can be a drag/drop source/sink. When it's
dragged, I want it to be the drag-icon, so you can see that you're dragging
that particular widget (and its particular label, etc.)

However, Gtk::Widget::draw(Cairo::RefPtr<Cairo::Context> const&) is
protected in gtkmm, so it seems that in order to draw the widget onto a
surface that I can then set as drag-icon, I must do:

```
auto const allocation = m_box_label.get_allocation();
auto const surface = Cairo::ImageSurface::create(
  Cairo::FORMAT_ARGB32, allocation.get_width(), allocation.get_height() );
auto const cairoContext = Cairo::Context::create(surface);
gtk_widget_draw( reinterpret_cast<GtkWidget*>( m_box_label.gobj() ),
cairoContext->cobj() );
dragContext->set_icon(surface);
```

Is there any better way that I didn't think of, any way to make this nicer
in gtkmm, or is it just a fact of life at this point? (Since gtkmm-3 is
stable and master is probably very different here.)

_______________________________________________
gtkmm-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.