m_WorkPlace.set_size_request(600, 600);
//Targets:
- std::list<Gtk::TargetEntry> listTargets;
listTargets.push_back( Gtk::TargetEntry("STRING") );
listTargets.push_back( Gtk::TargetEntry("text/plain") );
+ listTargets.push_back( Gtk::TargetEntry("POINTER") );
+ listTargets.push_back( Gtk::TargetEntry("application/pointer") );
//Drag site:
{
//TODO: The gtkmm API needs to change to use a Gtk::SelectionData instead of a GtkSelectionData.
//That should happen for gtkmm 2.4.
-
- if ((selection_data->length >= 0) && (selection_data->format == 8))
- {
- CItem *a = Gtk::manage( new CItem((const char *)selection_data->data) );
/* Ajusto coordenada x e y para que caigan en un lugar de una cuadricula de
* 32x32 */
int i,j;
// separacion de 2 cuadritos
i = (x+1)/32;
j = (y+1)/32;
+
+ // El drag es de un item
+ if (selection_data->format == 10) {
+ m_WorkPlace.move(*drag_get_source_widget(context), i*32, j*32);
+ }
+
+ // El Drag es desde la barra de tareas
+ if ((selection_data->length >= 0) && (selection_data->format == 8))
+ {
+ CItem *a = Gtk::manage( new CItem((const char *)selection_data->data) );
m_WorkPlace.put(*a, i*32, j*32);
+ // Seteo la lista de tipos de drags
+ a->drag_source_set(listTargets);
+ // Conecto las señales
+ a->signal_drag_data_get().connect( SigC::slot(*this, &DnDWindow::on_item_drag_data_get));
+ a->signal_drag_begin().connect( SigC::slot(*this, &DnDWindow::on_item_drag_begin));
+
a->show();
//listaItems.push_back(a);
}
context->drag_finish(false, false, time);
}
+void DnDWindow::on_item_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
+{
+}
+
+void DnDWindow::on_item_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time)
+{
+ // El 10 creo que es el format
+ gtk_selection_data_set (selection_data, selection_data->target, 10, (const guchar*)"codo.png", 8);
+}
+
+