From 0cd232a75fa23a8bc738d23ab16665bf0d6e4f8b Mon Sep 17 00:00:00 2001 From: fgerlits Date: Tue, 21 Aug 2007 14:04:47 +0000 Subject: [PATCH] more d'n'd testing --- .../src/modules/widgets/src/TestWindow.cxx | 32 +++++++++++++++++-- .../src/modules/widgets/src/TestWindow.h | 13 ++++++++ .../widgets/var/glade/TestWindow.glade | 6 ++-- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/campcaster/src/modules/widgets/src/TestWindow.cxx b/campcaster/src/modules/widgets/src/TestWindow.cxx index 7770eee94..6f57006a2 100644 --- a/campcaster/src/modules/widgets/src/TestWindow.cxx +++ b/campcaster/src/modules/widgets/src/TestWindow.cxx @@ -200,6 +200,9 @@ TestWindow :: setupDndCallbacks (void) throw () treeView->drag_source_set(targets); treeView->signal_drag_data_get().connect(sigc::mem_fun(*this, &TestWindow::onTreeViewDragDataGet)); + treeView->drag_dest_set(targets); + treeView->signal_drag_data_received().connect(sigc::mem_fun(*this, + &TestWindow::onTreeViewDragDataReceived)); label->drag_dest_set(targets); label->signal_drag_data_received().connect(sigc::mem_fun(*this, &TestWindow::onLabelDragDataReceived)); @@ -272,6 +275,31 @@ TestWindow :: onTreeViewDragDataGet( } +/*------------------------------------------------------------------------------ + * The callback for the end of the drag. + *----------------------------------------------------------------------------*/ +void +TestWindow :: onTreeViewDragDataReceived( + const Glib::RefPtr & context, + int x, + int y, + const Gtk::SelectionData & selectionData, + guint info, + guint time) + throw () +{ + if (selectionData.get_length() >= 0 && selectionData.get_format() == 8) { + Glib::ustring data = selectionData.get_data_as_string(); + std::cerr << "string '" << data << "' dropped on tree view\n"; + context->drag_finish(true, false, time); + + } else { + std::cerr << "unknown type of data dropped on tree view\n"; + context->drag_finish(false, false, time); + } +} + + /*------------------------------------------------------------------------------ * The callback for the end of the drag. *----------------------------------------------------------------------------*/ @@ -288,11 +316,11 @@ TestWindow :: onLabelDragDataReceived( if (selectionData.get_length() >= 0 && selectionData.get_format() == 8) { Glib::ustring data = selectionData.get_data_as_string(); label->set_label(data); + context->drag_finish(true, false, time); } else { label->set_label(*getResourceUstring("dropHereText")); + context->drag_finish(false, false, time); } - - context->drag_finish(false, false, time); } diff --git a/campcaster/src/modules/widgets/src/TestWindow.h b/campcaster/src/modules/widgets/src/TestWindow.h index 79ea1fd3f..f861ecf47 100644 --- a/campcaster/src/modules/widgets/src/TestWindow.h +++ b/campcaster/src/modules/widgets/src/TestWindow.h @@ -187,6 +187,19 @@ class TestWindow : public LocalizedObject guint time) throw (); + /** + * The callback for the end of the drag. + */ + virtual void + onTreeViewDragDataReceived( + const Glib::RefPtr & context, + int x, + int y, + const Gtk::SelectionData & selectionData, + guint info, + guint time) + throw (); + /** * The callback for the end of the drag. */ diff --git a/campcaster/src/modules/widgets/var/glade/TestWindow.glade b/campcaster/src/modules/widgets/var/glade/TestWindow.glade index 1607b2d1e..fafde5db4 100644 --- a/campcaster/src/modules/widgets/var/glade/TestWindow.glade +++ b/campcaster/src/modules/widgets/var/glade/TestWindow.glade @@ -1,6 +1,6 @@ - + 300 @@ -33,7 +33,9 @@ True True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GDK_EXTENSION_EVENTS_CURSOR True True True