PageRenderTime 15ms CodeModel.GetById 6ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/src/wrappers/gtk/library/gtk_toggle_action.e

http://github.com/tybor/Liberty
Specman e | 134 lines | 85 code | 26 blank | 23 comment | 2 complexity | 2328fba8c970f7951687e96d06f4f9de MD5 | raw file
  1indexing
  2	description: "GtkToggleAction รข€” An action which can be toggled between two states"
  3	copyright: "[
  4					Copyright (C) 2006 Paolo Redaelli, GTK+ team
  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
 22			-- Description: A GtkToggleAction corresponds roughly to a
 23			-- GtkCheckMenuItem. It has an "active" state specifying
 24			-- whether the action has been checked or not.
 25
 26class GTK_TOGGLE_ACTION
 27
 28inherit GTK_ACTION redefine make, struct_size end
 29
 30creation from_external_pointer
 31
 32feature {} -- Creation
 33	make (a_name, a_label, a_tooltip, a_stock_id: STRING) is
 34			-- Creates a new GtkToggleAction object. To add the action to
 35			-- a GtkActionGroup and set the accelerator for the action,
 36			-- call `GTK_ACTION_GROUP.add_action_with_accel'.
 37
 38			-- `a_name' A unique name for the action; `a_label' the label
 39			-- displayed in menu items and on buttons; `a_tooltip' a
 40			-- tooltip for the action; `a_stock_id' the stock icon to
 41			-- display in widgets representing the action
 42		do
 43			from_external_pointer (gtk_toggle_action_new (a_name.to_external, a_label.to_external,
 44																		 a_tooltip.to_external,a_stock_id.to_external))
 45		end
 46
 47feature
 48	action_toggled is
 49			-- Emits the "toggled" signal on the toggle action.
 50		do
 51			gtk_toggle_action_toggled (handle)
 52		end
 53
 54	set_active is
 55			-- Sets the checked state on the toggle action.
 56		do
 57			gtk_toggle_action_set_active (handle, 1)
 58		ensure active: is_active
 59		end
 60
 61	set_inactive is
 62			-- Sets the checked state on the toggle action to inactive.
 63		do
 64			gtk_toggle_action_set_active (handle, 0)
 65		ensure inactive: not is_active
 66		end
 67
 68	is_active: BOOLEAN is
 69			-- Is toggle action checked?
 70		do
 71			Result:=gtk_toggle_action_get_active(handle).to_boolean
 72		end
 73
 74	
 75	draw_as_radio is
 76			-- the action should have proxies like a radio action. TODO: 
 77			-- provide a better description.
 78		do
 79			gtk_toggle_action_set_draw_as_radio (handle,1)
 80		ensure drawn_as_radio: is_drawn_as_radio
 81		end
 82
 83	undraw_as_radio is
 84			-- the action should not have proxies like a radio
 85			-- action. TODO: provide a better description.
 86		do
 87			gtk_toggle_action_set_draw_as_radio (handle,0)
 88		ensure not_drawn_as_radio: not is_drawn_as_radio
 89		end
 90
 91	is_drawn_as_radio: BOOLEAN is
 92			-- Should the action have proxies like a radio action?
 93		do
 94			Result:=gtk_toggle_action_get_draw_as_radio(handle).to_boolean
 95		end
 96
 97feature -- TODO: The "toggled" signal
 98
 99-- void        user_function                  (GtkToggleAction *toggleaction,
100--                                             gpointer         user_data)         : Run first
101
102-- toggleaction : 	the object which received the signal.
103-- user_data : 	user data set when the signal handler was connected.
104feature -- struct size
105	struct_size: INTEGER is
106		external "C inline use <gtk/gtk.h>"
107		alias "sizeof(GtkToggleAction)"
108		end
109	
110feature {} -- External calls
111	gtk_toggle_action_new (name_str, label_str, tooltip_str, stock_id_str : POINTER): POINTER is --  GtkToggleAction*
112		external "C use <gtk/gtk.h>"
113		end
114
115	gtk_toggle_action_toggled (toggle_action: POINTER) is
116		external "C use <gtk/gtk.h>"
117		end
118
119	gtk_toggle_action_set_active (toggle_action: POINTER; active_bool: INTEGER) is
120		external "C use <gtk/gtk.h>"
121		end
122
123	gtk_toggle_action_get_active (toggle_action: POINTER): INTEGER is -- gboolean
124		external "C use <gtk/gtk.h>"
125		end
126
127	gtk_toggle_action_set_draw_as_radio (toggle_action: POINTER; draw_as_radio_bool: INTEGER) is
128		external "C use <gtk/gtk.h>"
129		end
130
131	gtk_toggle_action_get_draw_as_radio (toggle_action: POINTER): INTEGER is
132		external "C use <gtk/gtk.h>"
133		end
134end -- class GTK_TOGGLE_ACTION