PageRenderTime 26ms CodeModel.GetById 23ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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