PageRenderTime 20ms CodeModel.GetById 14ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/src/wrappers/gtk/library/clicked_callback.e

http://github.com/tybor/Liberty
Specman e | 79 lines | 60 code | 14 blank | 5 comment | 3 complexity | b1a5b413ecc3b2e907f62d427ee1a268 MD5 | raw file
 1indexing
 2	description: "Generic callback for the clicked signal"
 3	copyright: "[
 4					Copyright (C) 2006 Paolo redaelli, eiffel-libraries team,  GTK+ team and others
 5					
 6					This library is free software; you can redistribute it and/or
 7					modify it under the terms of the GNU Lesser General Public License
 8					as published by the Free Software Foundation; either version 2.1 of
 9					the License, or (at your option) any later version.
10					
11					This library is distributed in the hope that it will be useful, but
12					WITHOUT ANY WARRANTY; without even the implied warranty of
13					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14					Lesser General Public License for more details.
15
16					You should have received a copy of the GNU Lesser General Public
17					License along with this library; if not, write to the Free Software
18					Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19					02110-1301 USA
20				]"
21	license: "LGPL v2 or later"
22	date: "$Date:$"
23	revision "$Revision:$"
24
25class CLICKED_CALLBACK [O -> GTK_WIDGET]
26
27inherit CALLBACK redefine object end
28
29insert G_OBJECT_FACTORY [O]
30
31creation make
32
33feature
34	object: O
35
36feature
37	callback (instance: POINTER) is --  a_button: GTK_BUTTON) is
38		do
39			debug
40				print ("Callback: instance=") print (instance.to_string) print ("%N")
41			end
42			-- The following is written with the implicit requirement 
43			-- that the button is actually created bu the Eiffel 
44			-- application. 
45			object := wrapper(instance)
46			-- The above line replaces "create object.from_external_pointer
47			-- (instance)" which continuosly creates new Eiffel wrappers
48			procedure.call ([object])
49		end
50
51	callback_pointer: POINTER is
52		do
53			Result := get_callback_pointer ($callback)
54		ensure
55			Result.is_not_null
56		end
57
58	connect (an_object: O; a_procedure: like procedure) is
59		do
60			debug
61				print ("CLICKED_CALLBACK.connect (an_object=") print (an_object.to_pointer.to_string)
62				print (" an_object.handle=") print (an_object.handle.to_string)
63				print (") Current=") print (to_pointer.to_string)
64				print (" Current.handle=") print (handle.to_string)
65				print ("%N")
66			end
67					 
68			handler_id := g_signal_connect_closure (an_object.handle,
69													 signal_name.to_external,
70													 handle,
71													 0 -- i.e. call it before default handler
72													 )
73			procedure := a_procedure
74		end
75
76		signal_name: STRING is "clicked"
77
78	procedure: PROCEDURE [ANY, TUPLE[O]]
79end