PageRenderTime 13ms CodeModel.GetById 11ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

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