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

http://github.com/tybor/Liberty · Specman e · 68 lines · 55 code · 10 blank · 3 comment · 1 complexity · 20c5526dd858db22b1bd81106debe128 MD5 · raw file

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