/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

  1. class DND_DEMO
  2. insert
  3. ANY
  4. GTK
  5. GTK_DEST_DEFAULTS
  6. GDK_DRAG_ACTION
  7. GDK_MODIFIER_TYPE
  8. creation
  9. make
  10. feature
  11. on_delete_event (a_gtk_object: GTK_OBJECT) is
  12. do
  13. gtk.quit
  14. end
  15. on_button1_drag_begin (a_gdk_drag_context: GDK_DRAG_CONTEXT; a_gtk_widget: GTK_WIDGET) is
  16. do
  17. print ("Let the dragging begin! Nothing to do here...%N")
  18. end
  19. 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
  20. do
  21. end
  22. make is
  23. local
  24. hbox: GTK_HBOX
  25. pixbuf: GDK_PIXBUF
  26. do
  27. gtk.initialize
  28. create window.make
  29. window.set_default_size (280, 190)
  30. window.set_title ("Drag me!")
  31. window.connect_agent_to_destroy_signal (agent on_delete_event)
  32. window.set_border_width (20)
  33. create hbox.make (True, 5)
  34. window.add (hbox)
  35. -- Create First button, set up as drag source
  36. create button1.with_label("Drag me!")
  37. hbox.pack_start (button1, True, True, 5)
  38. button1.set_drag_source (gdk_button1_mask, gdk_action_copy)
  39. button1.drag_source_add_text_targets
  40. create pixbuf.from_file ("icon.png")
  41. button1.drag_source_set_icon_pixbuf (pixbuf)
  42. -- Create second button, set up as drag destination
  43. create button2.with_label ("Drop me :-)")
  44. hbox.pack_start (button2, True, True, 5)
  45. button2.set_drag_destination (gtk_dest_default_motion.bit_or (gtk_dest_default_drop),
  46. gdk_action_copy)
  47. button2.drag_dest_add_text_targets
  48. window.show_all
  49. -- Connect signals
  50. button1.connect_agent_to_drag_begin_signal (agent on_button1_drag_begin)
  51. button1.connect_agent_to_drag_data_get_signal (agent on_button1_drag_data_get)
  52. gtk.run_main_loop
  53. end
  54. window: GTK_WINDOW
  55. button1, button2: GTK_BUTTON
  56. end -- class STYLE_DEMO