more d'n'd testing

This commit is contained in:
fgerlits 2007-08-21 14:04:47 +00:00
parent 9681e780d7
commit 0cd232a75f
3 changed files with 47 additions and 4 deletions

View File

@ -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<Gdk::DragContext> & 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);
}

View File

@ -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<Gdk::DragContext> & context,
int x,
int y,
const Gtk::SelectionData & selectionData,
guint info,
guint time)
throw ();
/**
* The callback for the end of the drag.
*/

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.2.0 on Thu Aug 16 15:39:58 2007 by fgerlits@fgerlits-laptop-->
<!--Generated with glade3 3.2.0 on Tue Aug 21 15:45:29 2007 by fgerlits@desktop-->
<glade-interface>
<widget class="GtkWindow" id="mainWindow1">
<property name="width_request">300</property>
@ -33,7 +33,9 @@
<widget class="GtkTreeView" id="treeView1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="has_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="extension_events">GDK_EXTENSION_EVENTS_CURSOR</property>
<property name="headers_clickable">True</property>
<property name="reorderable">True</property>
<property name="rules_hint">True</property>