ruby-****@sourc*****
ruby-****@sourc*****
2012年 11月 27日 (火) 01:40:05 JST
------------------------- REMOTE_ADDR = 184.145.95.170 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-dnd-intro ------------------------- @@ -17,6 +17,11 @@ Unlike to a GUI user, to a GUI developer identification of a drag-and-drop objects is not at all that obvious. While conceptually it should be always easy to determine what is the dragging object and its source and destination locations, in reality the lines between these items may be blurry. This is mostly due to the fact, that Gtk performs many tasks for you behind the scene, and also because the objects that are to be dragged are not at all directly referenced in drag-and-drop API. Instead, the methods in Gtk::Drag module and related classes refer to them as abstract((*targets*))which you have to identify not so much in terms of graphic objects but rather as Gtk+ abstraction defined in Gtk::TargetList. Gtk::TargetList object is an array of targets (i.e. draggable items), that are specified with an ordered list or a tuple of three parameters '[target, flags, info]'. The((*'target'*))parameter is a string identifying the object to be dragged from the source and dropped onto a destination. The((*'flags'*))parameter is one of the constants defined in Gtk::Drag#TargetFlags (TARGET_SAME_APP, TARGET_SAME_WIDGET, TARGET_OTHER_APP, and TARGET_OTHER_WIDGET). The last((*'info'*))element in the targets tuple is by the application or the developer defined identification integer. + +:Note: + All widgets which have their own Gdk::Window can be set as source or destination widgets. A widget that contains its own Gdk::Window must not have Gtk::Widget::NO_WINDOW flag set. You can check for this flag with the Gtk::Widget#no_window? method. (Note that this method returns true if there is no Gdk::Window.) + + As we already mentioned another reason for a blurry view of what a drag-and-drop object is, is the fact that Gtk performs many tasks such as those defined in Gdk::DragContext#GdkDragAction behind the scene. This means that Gtk and not the programer is responsible for copying, moving and/or removing items you are dragging. However, this may may not be entirely true or not at all, depending whether you are dragging items between different widgets or within the widgets that supports dragging and dropping by design. An example of such a widget, which supports dnd by design is the Gtk::TreeView. You may also decide you want to bypass, Gtk default behaviour and implement your own drag-and-drop behaviour. In that case you will need to perform copying and removing dragging objects yourself. In that case you will need to obtain the true dragging object, such as a tree view row, or an icon residing in icon view, or perhaps a different image object all together for instance a large ima ge the icon represents. As you can see, in such situations you may need to have a true reference to the dragged object and Gtk's target abstraction may be rather useless. Fortunately these are special cases, and require a better understanding of these issues. You may find it necessary to consult the'Inter-Client Communications Conventions Manual' (ICCCM). Though, our intention here is to provide the basic coverage of the dnd in Ruby Gtk, we will look at some of the more advanced issues, enough to point you in the right direction, and perhaps to inspire developers to polish the rough edges in this areas of Gtk.