[ruby-gnome2-doc-cvs] [Ruby-GNOME2 Project Website] update - tut-gtk2-dnd-native-treev

Back to archive index

ruby-****@sourc***** ruby-****@sourc*****
2012年 12月 17日 (月) 08:40:22 JST


-------------------------
REMOTE_ADDR = 184.145.81.223
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-dnd-native-treev
-------------------------
@@ -23,8 +23,42 @@
 
 
 
-
 # (10.3.1)
+=== DnD In Text View Widget
+
+Of the three TextView, IconView, and TreeView widgets, the Gtk::TreeView widget is the list demanding to implement drag-and-drop features in your own Gtk GUI programs. Its DnD functionality is fully enabled for any Grk::TextView object you create, and users can start dragging text-view objects by selecting and dragging them to desired locations within the text-view. It is even possible to drag items external to the application with the text-view, whose contents can be converted to plain text, or replaced with the URI text. This text-view's default behaviour is quite satisfying when used on selected text within the text-view itself, but is rather limited for external items, nevertheless, it is fully functional, without any additional programming (coding) effort.  
+
+{{image_right("drag-in-txtv-colage.png")}}
+
+To demonstrate these to Gtk::TextView native drag-and-drop properties and behaviour, I included a simple example program called 'textview-native-dnd.rb', in which we use our DnD debugging module 'HikiDnDdbg' to show that all eight Gtk::Widget's drag related signals are caught, though, we have not declared neither source nor destination widget in the code. 
+
+
+Following is the output on the controlling terminal or console:
+
+
+
+
+
+
+ drag-begin .............................. caught.
+ drag-motion ... potentially many 'drag-motion' signals were caught.
+ drag-leave .............................. caught.
+ drag-drop ............................... caught.
+ drag-data-get ........................... caught.
+ drag-data-received ...................... caught.
+ drag-data-delete ........................ caught.
+ drag-end ................................ caught.
+
+
+{{br}}
+
+
+((*textview-native-dnd.rb*))
+
+
+
+
+# (10.3.2)
 === DnD Tree View Items
 
 The Gtk::TreeView widget is one of those widgets where dragged and dropped objects are strictly the items belonging to some particular data structures and/or hierarchies and must be of a rather particular format, namely, the rows of predetermined sets of columns stored in related data models or data stores. This particularity about data structure and format is best met if dragging and dropping occurs within the same widget, i.e. you should always be able to drag one row within a list or a tree view to a new location, as long as the drop occurs in the same widget in which the drag also started. Currently this is even more true for a generic Gtk library, used by languages like Ruby, Python and alike, than is for the original GTK+ C and C++ (a.k.a. gtkmm) implementations. Namely, the original C GTK+ implementation allows you to drag rows of data from one list/tree view to another, i.e. in GTK+ you are not limited to the single widget, as you are in Ruby or Python when using Gtk
 +.
@@ -34,7 +68,41 @@
 
 
 
-# (10.3.1.1)
+# (10.3.2.1)
 === Built-in DnD Tree View Mechanism
 
 
@@ -44,7 +78,41 @@
 
 
 
-# (10.3.1.1.1)
+# (10.3.2.1.1)
 :Office Supplies Array Initialization Module
 
     In the 'treeview-built-in-dnd.rb' example program we use auxiliary initialization application dependent module. If this module were useful also in many other tutorial example programs it would be wise to place it in a common directory or folder, along with our 'HikiGtk' module file (hiki-gtk.rb). However, we decided to place it in the same directory where also the example 'treeview-built-in-dnd.rb' program resides. This requires in the example program we tell Ruby interpreter to also include our current directory, from which we are going to run our example code, in the load path (look for the declarative statement ((*"$: << '.'"*)) at the beginning of the example program). Indeed, you could have as well specified the full path in the 'require' declarative instead, however, I wanted to repeat the idiom expanding the load path, so you get used to it, because it is very convenient when you use module files in other directories.
@@ -219,5 +253,39 @@
 
 
 
-# (10.3.1.2)
+# (10.3.2.2)
 === Custom DnD In Tree View




ruby-gnome2-cvs メーリングリストの案内
Back to archive index