m_Button_Canio.signal_drag_data_get().connect( SigC::slot(*this, &DnDWindow::on_canio_drag_data_get));
m_Button_Y.signal_drag_data_get().connect( SigC::slot(*this, &DnDWindow::on_y_drag_data_get));
m_Button_Codo.signal_drag_data_get().connect( SigC::slot(*this, &DnDWindow::on_codo_drag_data_get));
-
+ // Señales para cambiar el icono cuando empieza el drag.
+ m_Button_Canio.signal_drag_begin().connect( SigC::slot(*this, &DnDWindow::on_canio_drag_begin));
+ m_Button_Y.signal_drag_begin().connect( SigC::slot(*this, &DnDWindow::on_y_drag_begin));
+ m_Button_Codo.signal_drag_begin().connect( SigC::slot(*this, &DnDWindow::on_codo_drag_begin));
m_VBox.pack_start(m_Button_Canio);
m_VBox.pack_start(m_Button_Y);
}
-void DnDWindow::on_canio_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, GtkSelectionData* selection_data, guint, guint)
+void DnDWindow::on_canio_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint, guint)
{
//TODO: The gtkmm API needs to change to use a Gtk::SelectionData instead of a GtkSelectionData.
//That should happen for gtkmm 2.4.
+ Glib::RefPtr<Gdk::Pixbuf> image;
+ image = Gdk::Pixbuf::create_from_file("canio.png");
+ // Cambio el icono de DND seteando el "hot spot" en el centro.
+ context->set_icon(image, image->get_width() / 2, image->get_height() / 2);
gtk_selection_data_set (selection_data, selection_data->target, 8, (const guchar*)"canio.png", 9);
}
context->drag_finish(false, false, time);
}
+void DnDWindow::on_canio_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
+{
+ Glib::RefPtr<Gdk::Pixbuf> image;
+ image = Gdk::Pixbuf::create_from_file("canio.png");
+ context->set_icon(image, image->get_width() / 2, image->get_height() / 4);
+}
+
+void DnDWindow::on_y_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
+{
+ Glib::RefPtr<Gdk::Pixbuf> image;
+ image = Gdk::Pixbuf::create_from_file("y.png");
+ context->set_icon(image, image->get_width() / 4, image->get_height() / 4);
+}
+
+void DnDWindow::on_codo_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
+{
+ Glib::RefPtr<Gdk::Pixbuf> image;
+ image = Gdk::Pixbuf::create_from_file("codo.png");
+ context->set_icon(image, 0, 0);//image->get_width() / 2, image->get_height() / 2);
+}
+