1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module atk.ActionT;
26 
27 public  import glib.Str;
28 public  import gtkc.atk;
29 public  import gtkc.atktypes;
30 
31 
32 /**
33  * #AtkAction should be implemented by instances of #AtkObject classes
34  * with which the user can interact directly, i.e. buttons,
35  * checkboxes, scrollbars, e.g. components which are not "passive"
36  * providers of UI information.
37  * 
38  * Exceptions: when the user interaction is already covered by another
39  * appropriate interface such as #AtkEditableText (insert/delete text,
40  * etc.) or #AtkValue (set value) then these actions should not be
41  * exposed by #AtkAction as well.
42  * 
43  * Though most UI interactions on components should be invocable via
44  * keyboard as well as mouse, there will generally be a close mapping
45  * between "mouse actions" that are possible on a component and the
46  * AtkActions.  Where mouse and keyboard actions are redundant in
47  * effect, #AtkAction should expose only one action rather than
48  * exposing redundant actions if possible.  By convention we have been
49  * using "mouse centric" terminology for #AtkAction names.
50  */
51 public template ActionT(TStruct)
52 {
53 	/** Get the main Gtk struct */
54 	public AtkAction* getActionStruct(bool transferOwnership = false)
55 	{
56 		if (transferOwnership)
57 			ownedRef = false;
58 		return cast(AtkAction*)getStruct();
59 	}
60 
61 
62 	/**
63 	 * Perform the specified action on the object.
64 	 *
65 	 * Params:
66 	 *     i = the action index corresponding to the action to be performed
67 	 *
68 	 * Returns: %TRUE if success, %FALSE otherwise
69 	 */
70 	public bool doAction(int i)
71 	{
72 		return atk_action_do_action(getActionStruct(), i) != 0;
73 	}
74 
75 	/**
76 	 * Returns a description of the specified action of the object.
77 	 *
78 	 * Params:
79 	 *     i = the action index corresponding to the action to be performed
80 	 *
81 	 * Returns: a description string, or %NULL if @action does
82 	 *     not implement this interface.
83 	 */
84 	public string getDescription(int i)
85 	{
86 		return Str.toString(atk_action_get_description(getActionStruct(), i));
87 	}
88 
89 	/**
90 	 * Gets the keybinding which can be used to activate this action, if one
91 	 * exists. The string returned should contain localized, human-readable,
92 	 * key sequences as they would appear when displayed on screen. It must
93 	 * be in the format "mnemonic;sequence;shortcut".
94 	 *
95 	 * - The mnemonic key activates the object if it is presently enabled onscreen.
96 	 * This typically corresponds to the underlined letter within the widget.
97 	 * Example: "n" in a traditional "New..." menu item or the "a" in "Apply" for
98 	 * a button.
99 	 * - The sequence is the full list of keys which invoke the action even if the
100 	 * relevant element is not currently shown on screen. For instance, for a menu
101 	 * item the sequence is the keybindings used to open the parent menus before
102 	 * invoking. The sequence string is colon-delimited. Example: "Alt+F:N" in a
103 	 * traditional "New..." menu item.
104 	 * - The shortcut, if it exists, will invoke the same action without showing
105 	 * the component or its enclosing menus or dialogs. Example: "Ctrl+N" in a
106 	 * traditional "New..." menu item.
107 	 *
108 	 * Example: For a traditional "New..." menu item, the expected return value
109 	 * would be: "N;Alt+F:N;Ctrl+N" for the English locale and "N;Alt+D:N;Strg+N"
110 	 * for the German locale. If, hypothetically, this menu item lacked a mnemonic,
111 	 * it would be represented by ";;Ctrl+N" and ";;Strg+N" respectively.
112 	 *
113 	 * Params:
114 	 *     i = the action index corresponding to the action to be performed
115 	 *
116 	 * Returns: the keybinding which can be used to activate
117 	 *     this action, or %NULL if there is no keybinding for this action.
118 	 */
119 	public string getKeybinding(int i)
120 	{
121 		return Str.toString(atk_action_get_keybinding(getActionStruct(), i));
122 	}
123 
124 	/**
125 	 * Returns the localized name of the specified action of the object.
126 	 *
127 	 * Params:
128 	 *     i = the action index corresponding to the action to be performed
129 	 *
130 	 * Returns: a name string, or %NULL if @action does not
131 	 *     implement this interface.
132 	 */
133 	public string getLocalizedName(int i)
134 	{
135 		return Str.toString(atk_action_get_localized_name(getActionStruct(), i));
136 	}
137 
138 	/**
139 	 * Gets the number of accessible actions available on the object.
140 	 * If there are more than one, the first one is considered the
141 	 * "default" action of the object.
142 	 *
143 	 * Returns: a the number of actions, or 0 if @action does not
144 	 *     implement this interface.
145 	 */
146 	public int getNActions()
147 	{
148 		return atk_action_get_n_actions(getActionStruct());
149 	}
150 
151 	/**
152 	 * Returns a non-localized string naming the specified action of the
153 	 * object. This name is generally not descriptive of the end result
154 	 * of the action, but instead names the 'interaction type' which the
155 	 * object supports. By convention, the above strings should be used to
156 	 * represent the actions which correspond to the common point-and-click
157 	 * interaction techniques of the same name: i.e.
158 	 * "click", "press", "release", "drag", "drop", "popup", etc.
159 	 * The "popup" action should be used to pop up a context menu for the
160 	 * object, if one exists.
161 	 *
162 	 * For technical reasons, some toolkits cannot guarantee that the
163 	 * reported action is actually 'bound' to a nontrivial user event;
164 	 * i.e. the result of some actions via atk_action_do_action() may be
165 	 * NIL.
166 	 *
167 	 * Params:
168 	 *     i = the action index corresponding to the action to be performed
169 	 *
170 	 * Returns: a name string, or %NULL if @action does not
171 	 *     implement this interface.
172 	 */
173 	public string getName(int i)
174 	{
175 		return Str.toString(atk_action_get_name(getActionStruct(), i));
176 	}
177 
178 	/**
179 	 * Sets a description of the specified action of the object.
180 	 *
181 	 * Params:
182 	 *     i = the action index corresponding to the action to be performed
183 	 *     desc = the description to be assigned to this action
184 	 *
185 	 * Returns: a gboolean representing if the description was successfully set;
186 	 */
187 	public bool setDescription(int i, string desc)
188 	{
189 		return atk_action_set_description(getActionStruct(), i, Str.toStringz(desc)) != 0;
190 	}
191 }