PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/gtk/examples/dnd/dnd_demo.e

http://github.com/tybor/Liberty
Specman e | 72 lines | 53 code | 16 blank | 3 comment | 0 complexity | 1a5ca1a3ec2fd912679ba3d1cbff8f84 MD5 | raw file
 1class DND_DEMO
 2
 3insert
 4	ANY
 5	GTK
 6	GTK_DEST_DEFAULTS
 7	GDK_DRAG_ACTION
 8	GDK_MODIFIER_TYPE
 9
10creation
11	make
12
13feature
14
15	on_delete_event (a_gtk_object: GTK_OBJECT) is
16		do
17			gtk.quit
18		end
19
20	on_button1_drag_begin (a_gdk_drag_context: GDK_DRAG_CONTEXT; a_gtk_widget: GTK_WIDGET) is
21		do
22			print ("Let the dragging begin! Nothing to do here...%N")
23		end
24
25	on_button1_drag_data_get (a_gdk_drag_context: GDK_DRAG_CONTEXT; a_selection: GTK_SELECTION_DATA; a_info, a_time: INTEGER; a_gtk_widget: GTK_WIDGET) is
26		do
27		end
28
29	make is
30		local
31			hbox: GTK_HBOX
32			pixbuf: GDK_PIXBUF
33		do
34			gtk.initialize
35			create window.make
36			window.set_default_size (280, 190)
37			window.set_title ("Drag me!")
38			window.connect_agent_to_destroy_signal (agent on_delete_event)
39			window.set_border_width (20)
40			create hbox.make (True, 5)
41			window.add (hbox)
42
43			-- Create First button, set up as drag source
44			create button1.with_label("Drag me!")
45			hbox.pack_start (button1, True, True, 5)
46			button1.set_drag_source (gdk_button1_mask, gdk_action_copy)
47			button1.drag_source_add_text_targets
48			create pixbuf.from_file ("icon.png")
49			button1.drag_source_set_icon_pixbuf (pixbuf)
50
51			-- Create second button, set up as drag destination
52			create button2.with_label ("Drop me :-)")
53			hbox.pack_start (button2, True, True, 5)
54			button2.set_drag_destination (gtk_dest_default_motion.bit_or (gtk_dest_default_drop),
55									gdk_action_copy)
56			button2.drag_dest_add_text_targets
57			window.show_all
58
59			-- Connect signals
60			button1.connect_agent_to_drag_begin_signal (agent on_button1_drag_begin)
61			button1.connect_agent_to_drag_data_get_signal (agent on_button1_drag_data_get)
62
63
64			gtk.run_main_loop
65
66		end
67
68	window: GTK_WINDOW
69
70	button1, button2: GTK_BUTTON
71
72end -- class STYLE_DEMO