PageRenderTime 10ms CodeModel.GetById 8ms app.highlight 0ms RepoModel.GetById 2ms app.codeStats 0ms

/src/wrappers/gtk/library/gtk_toggle_tool_button.e

http://github.com/tybor/Liberty
Specman e | 97 lines | 64 code | 20 blank | 13 comment | 2 complexity | 72a830e7c03a5e534df9893af9d9e62d MD5 | raw file
 1indexing
 2	description: "GtkToggleToolButton - A GtkToolItem containing a toggle button."
 3	copyright: "[
 4					Copyright (C) 2006 Soluciones Informaticas Libres S.A.,
 5					eiffel-libraries team, GTK+ team
 6					
 7					This library is free software; you can redistribute it and/or
 8					modify it under the terms of the GNU Lesser General Public License
 9					as published by the Free Software Foundation; either version 2.1 of
10					the License, or (at your option) any later version.
11					
12					This library is distributed in the hopeOA that it will be useful, but
13					WITHOUT ANY WARRANTY; without even the implied warranty of
14					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15					Lesser General Public License for more details.
16
17					You should have received a copy of the GNU Lesser General Public
18					License along with this library; if not, write to the Free Software
19					Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20					02110-1301 USA
21			]"
22
23class GTK_TOGGLE_TOOL_BUTTON
24
25inherit
26	GTK_TOOL_BUTTON
27		redefine 
28			make,
29			from_stock
30		end
31
32insert
33	GTK_TOGGLE_TOOL_BUTTON_EXTERNALS
34
35create
36	from_external_pointer, make
37
38feature {} -- Creation
39
40	make is
41		do
42			from_external_pointer (gtk_toggle_tool_button_new)
43		end
44	
45	from_stock (a_stock_id: STRING) is
46		do
47			from_external_pointer(gtk_toggle_tool_button_new_from_stock (a_stock_id.to_external))
48		end
49
50feature -- Operations
51
52	set_active (is_active: BOOLEAN) is
53			-- Sets the status of the toggle tool button.
54			-- Set to TRUE if you want the GtkToggleButton to be
55			-- 'pressed in', and FALSE to raise it.
56			-- This action causes the toggled signal to be emitted.
57		do
58			gtk_toggle_tool_button_set_active (handle, is_active.to_integer)
59		end
60
61	active: BOOLEAN is
62			-- Queries a GtkToggleToolButton and returns its current state.
63			-- Returns TRUE if the toggle button is pressed in
64			-- and FALSE if it is raised.
65		do
66			Result := gtk_toggle_tool_button_get_active (handle).to_boolean
67		end
68
69feature -- The "toggled" signal
70
71	toggled_signal_name: STRING is "toggled"
72		--void                user_function           (GtkToggleToolButton *toggle_tool_button,
73		--                                             gpointer user_data);
74
75	on_toggled is
76			-- Built-in toggled signal handler; empty by design; redefine it.
77		do
78		end
79
80	enable_on_toggled is
81			-- Connects "toggled" signal to `on_toggled' feature.
82
83			-- Emitted whenever the toggle tool button changes state..
84		do
85			connect (Current, toggled_signal_name, $on_toggled)
86		end
87
88	connect_agent_to_toggled_signal (a_procedure: PROCEDURE [ANY, TUPLE[GTK_TOGGLE_TOOL_BUTTON]]) is
89			-- togglebutton : 	the object which received the signal.
90		require valid_procedure: a_procedure /= Void
91		local toggled_callback: TOGGLED_CALLBACK [like Current]
92		do
93			create toggled_callback.make
94			toggled_callback.connect (Current, a_procedure)
95		end
96
97end -- class GTK_TOGGLE_TOOL_BUTTON