ruby-****@sourc*****
ruby-****@sourc*****
2012年 11月 29日 (木) 03:12:36 JST
------------------------- REMOTE_ADDR = 184.145.80.128 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-dnd-intro ------------------------- @@ -30,13 +30,23 @@ The source locations and/or widgets are those in which the objects to be dragged originally reside, and the destinations are places, widgets or object onto which you wish to drop the dragged objects. These widgets or objects may be different, for instance you may plan to drag an icon from an icon view onto some other viewing area, perhaps a canvas or a text widget. Or they can be one and the same widget and indeed the same object, as is the case when you are reordering rows in a tree view, or items in the text view. In the previous chapter 9, (section: 9.6.2.2), we have already seen our toolbar 'dnd-toolbox.rb' example in which the source and destination are of the same type namely Gtk::Frame, but they are two different objects. -Normally, you have to set up source and destination widgets. There exists a plethora of methods to accomplish this. With the exception of the widgets that support dnd by design, in which you can choose the default dnd behaviour with almost no extra work, you need to register a widget as source or destination or both. When setting up a widget as source or destination widget, you have to identify the drag-object(s), or as we mentioned in previous paragraph, the 'target(s)'. During this registration you also need to specify the((*action*))the dnd system is to take for the item being dragged. This action is defined as a constant in Gdk::DragContext#GdkDragAction and conveys to the Gtk system whether the item is to be copied, moved, removed from the source, and how to react at the destination at the time the drop occurs. Following are two API examples to show what kind of arguments you may be required to supply when registering a widget as a source: +Normally, you have to set up source and destination widgets. There exists a plethora of methods to accomplish this. With the exception of the widgets that support dnd by design, in which you can choose the default dnd behaviour with almost no extra work, you need to register a widget as source or destination or both. When setting up a widget as source or destination widget, you have to identify the drag-object(s), or as we mentioned in previous paragraph, the 'target(s)'. During this registration you also need to specify the((*action*))the dnd system is to take for the item being dragged. This action is defined as a constant in Gdk::DragContext#GdkDragAction and conveys to the Gtk system whether the item is to be copied, moved, removed from the source, and how to react at the destination at the time the drop occurs. Following are few API examples to show different methods used to register source and destination widgets, and the kind of arguments you may be required to supply when registering these widgets. - # Gtk::Drag.source_set(source_widget, start_button_mask, targets, actions) +You use Gtk::Drag.source_set and Gtk::Drag.dest_set module methods, when source and destination widgets are arbitrary Gtk objects with their own Gdk::Window: + +(#1) + # Gtk::Drag.source_set(source_widget, start_button_mask, targets, actions) + # Gtk::Drag.dest_set(destination_widget, flags, targets, actions) + +When source and destination woidgets natively support dnd, you use their "enable..." instance methods: + +(#2) + # Gtk::TreeView#enable_model_drag_source(start_button_mask, targets, actions) treeview.enable_model_drag_source(Gdk::Window::BUTTON1_MASK, TVDND_TARGETS, TVDND_ACTIONS) or a less involved one: +(#3) # Gtk::TreeView#enable_model_drag_source(start_button_mask, targets, actions) treeview.enable_model_drag_dest(TVDND_TARGETS, Gdk::DragContext::ACTION_ASK)