[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日 (月) 10:36:17 JST


-------------------------
REMOTE_ADDR = 184.145.81.223
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-dnd-native-treev
-------------------------
@@ -30,7 +30,7 @@
 
 {{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.
+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. The only thing we did in this program is set signal handlers for all the Gtk::Widget's drag related signals.
 
 :Note:
     As you will see in the listing for this example we can use two global variables ($MONITOR, and $DEBUG) to control the behaviour of the 'prn_dnd_sig_parms' method. If you do not care for the debugging you can simply ignore these variables, (you should not set them). The difference between the two variables is in the debugging message verbosity, namely, $DEBUG prints extensive analysis of DnD signal parameters, attributes and setups, whereas $MONITOR reports only if a specified signal was caught.
@@ -45,6 +45,7 @@
 
 
 
+
  drag-begin .............................. caught.
  drag-motion ... potentially many 'drag-motion' signals were caught.
  drag-leave .............................. caught.
@@ -57,8 +58,72 @@
 
 {{br}}
 
+Let's look at he program listing:
 
+
 ((*textview-native-dnd.rb*))
+
+ #!/usr/bin/env ruby
+ $: << '~/work/HikiLib'		# replace this with your path to the tutorial modules
+ require 'hiki-gtk.rb'
+ include HikiGtk
+ require 'hiki-dnd-dbg.rb'
+ include HikiDnDdbg
+ 
+ $MONITOR=true
+ # $DEBUG=true	# $MONITOR cancels $DEBUG
+ 
+ class TextViewDND < BasicWindow
+   def initialize(title)
+     super
+     set_size_request(350, 250)
+ 
+     textview = Gtk::TextView.new
+     textview.buffer.text = "Exploring DnD in TextView widget. Try to select\n" +
+                            "some text abd drag to a new location.\n" +
+                            "line-3 abc d\nline-4 ...\nline-5 -- +++ [ ] {{}}\n" +
+                            "line-6 _____________\n" +
+                            "Last line."
+ 
+     textview.signal_connect('drag-begin')                   do |w,dc|
+       prn_dnd_sig_parms('drag-begin',         w,dc)
+     end
+     textview.signal_connect('drag-data-delete')             do |w,dc|
+       prn_dnd_sig_parms('drag-data-delete',   w,dc)
+     end
+     textview.signal_connect('drag-data-get')                do |w,dc,d,i,t|
+       prn_dnd_sig_parms('drag-data-get',      w,dc,d,i,t)
+     end
+     textview.signal_connect('drag-data-received')           do |w,dc,x,y,d,i,t|
+       prn_dnd_sig_parms('drag-data-received' ,w,dc,x,y,d,i,t)
+     end
+     textview.signal_connect('drag-drop')                    do |w,dc,x,y,t|
+       prn_dnd_sig_parms('drag-drop',         w,dc,x,y,t)
+     end
+     textview.signal_connect('drag-end')                     do |w,dc|	
+       prn_dnd_sig_parms('drag-end',          w,dc)
+     end
+     textview.signal_connect('drag-leave')                   do |w,dc,t|
+       prn_dnd_sig_parms('drag-leave',        w,dc,t)
+     end
+     textview.signal_connect('drag-motion')                  do |w,dc,x,y,t|
+       prn_dnd_sig_parms('drag-motion',       w,dc,x,y,t)
+     end
+ 
+     scrolledw = Gtk::ScrolledWindow.new
+     scrolledw.border_width = 5
+     scrolledw.add(textview)
+     scrolledw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS)
+ 
+     add(scrolledw)
+     show_all
+     Gtk.main
+ 
+   end
+ end
+
+ TextViewDND.new("Exploring Native Text-View DnD")
 
 
 




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