/src/wrappers/gtk/examples/status_bar/status_bar_demo.e

http://github.com/tybor/Liberty · Specman e · 73 lines · 62 code · 9 blank · 2 comment · 1 complexity · 5f686104a6af1e04043fdf232ec8da42 MD5 · raw file

  1. class STATUS_BAR_DEMO
  2. insert GTK
  3. creation make
  4. feature -- GUI elements
  5. window: GTK_WINDOW
  6. hbox: GTK_HBOX
  7. vbox: GTK_VBOX
  8. push_button,pop_button: GTK_BUTTON
  9. statusbar: GTK_STATUS_BAR
  10. feature -- Initialisation
  11. make is
  12. do
  13. gtk.initialize
  14. create window.make
  15. window.set_title (window_title)
  16. window.connect_agent_to_destroy_signal (agent on_destroy)
  17. create push_button.with_label ("Push a message")
  18. create pop_button.with_label ("Pop last message")
  19. create statusbar.make
  20. statusbar.push (startup_message)
  21. create vbox.make(True,5)
  22. create hbox.make(True,5)
  23. -- Connect "clicked" signals of the buttons to callbacks
  24. push_button.connect_agent_to_clicked_signal (agent on_push_clicked (?))
  25. pop_button.connect_agent_to_clicked_signal (agent on_pop_clicked (?))
  26. -- Pack and show all our widgets
  27. push_button.show; pop_button.show
  28. hbox.pack_start(push_button,True,True,10)
  29. hbox.pack_start(pop_button,True,True,10)
  30. hbox.show
  31. vbox.pack_start(hbox,True,True,0)
  32. statusbar.show
  33. vbox.pack_start(statusbar,True,True,0)
  34. vbox.show
  35. window.add(vbox)
  36. window.show
  37. gtk.run_main_loop
  38. end
  39. feature counter: INTEGER
  40. feature -- Agents
  41. on_push_clicked (a_button: GTK_BUTTON) is
  42. do
  43. counter:=counter+1
  44. print ("Pushing message n."+counter.out+"%N")
  45. statusbar.push("This is message number "+counter.out)
  46. end
  47. on_pop_clicked (a_button: GTK_BUTTON) is
  48. do
  49. if statusbar.is_empty then
  50. print ("Statusbar empty: cannot pop any message%N")
  51. else
  52. print ("Popping last message%N")
  53. statusbar.pop
  54. end
  55. end
  56. on_destroy (a_gtk_object: GTK_OBJECT) is
  57. do
  58. print ("on destroy has been called%N")
  59. gtk.quit
  60. end
  61. feature -- Constants
  62. window_title: STRING is "Eiffel GTK Staturbar demo"
  63. startup_message: STRING is "Startup message"
  64. end