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 gtk.ActionableT;
26 
27 public  import glib.Str;
28 public  import glib.Variant;
29 public  import gtk.c.functions;
30 public  import gtk.c.types;
31 public  import gtkc.gtktypes;
32 
33 
34 /**
35  * This interface provides a convenient way of associating widgets with
36  * actions on a #GtkApplicationWindow or #GtkApplication.
37  * 
38  * It primarily consists of two properties: #GtkActionable:action-name
39  * and #GtkActionable:action-target. There are also some convenience APIs
40  * for setting these properties.
41  * 
42  * The action will be looked up in action groups that are found among
43  * the widgets ancestors. Most commonly, these will be the actions with
44  * the “win.” or “app.” prefix that are associated with the #GtkApplicationWindow
45  * or #GtkApplication, but other action groups that are added with
46  * gtk_widget_insert_action_group() will be consulted as well.
47  */
48 public template ActionableT(TStruct)
49 {
50 	/** Get the main Gtk struct */
51 	public GtkActionable* getActionableStruct(bool transferOwnership = false)
52 	{
53 		if (transferOwnership)
54 			ownedRef = false;
55 		return cast(GtkActionable*)getStruct();
56 	}
57 
58 
59 	/**
60 	 * Gets the action name for @actionable.
61 	 *
62 	 * See gtk_actionable_set_action_name() for more information.
63 	 *
64 	 * Returns: the action name, or %NULL if none is set
65 	 *
66 	 * Since: 3.4
67 	 */
68 	public string getActionName()
69 	{
70 		return Str.toString(gtk_actionable_get_action_name(getActionableStruct()));
71 	}
72 
73 	/**
74 	 * Gets the current target value of @actionable.
75 	 *
76 	 * See gtk_actionable_set_action_target_value() for more information.
77 	 *
78 	 * Returns: the current target value
79 	 *
80 	 * Since: 3.4
81 	 */
82 	public Variant getActionTargetValue()
83 	{
84 		auto p = gtk_actionable_get_action_target_value(getActionableStruct());
85 
86 		if(p is null)
87 		{
88 			return null;
89 		}
90 
91 		return new Variant(cast(GVariant*) p);
92 	}
93 
94 	/**
95 	 * Specifies the name of the action with which this widget should be
96 	 * associated.  If @action_name is %NULL then the widget will be
97 	 * unassociated from any previous action.
98 	 *
99 	 * Usually this function is used when the widget is located (or will be
100 	 * located) within the hierarchy of a #GtkApplicationWindow.
101 	 *
102 	 * Names are of the form “win.save” or “app.quit” for actions on the
103 	 * containing #GtkApplicationWindow or its associated #GtkApplication,
104 	 * respectively.  This is the same form used for actions in the #GMenu
105 	 * associated with the window.
106 	 *
107 	 * Params:
108 	 *     actionName = an action name, or %NULL
109 	 *
110 	 * Since: 3.4
111 	 */
112 	public void setActionName(string actionName)
113 	{
114 		gtk_actionable_set_action_name(getActionableStruct(), Str.toStringz(actionName));
115 	}
116 
117 	/**
118 	 * Sets the target value of an actionable widget.
119 	 *
120 	 * If @target_value is %NULL then the target value is unset.
121 	 *
122 	 * The target value has two purposes.  First, it is used as the
123 	 * parameter to activation of the action associated with the
124 	 * #GtkActionable widget. Second, it is used to determine if the widget
125 	 * should be rendered as “active” — the widget is active if the state
126 	 * is equal to the given target.
127 	 *
128 	 * Consider the example of associating a set of buttons with a #GAction
129 	 * with string state in a typical “radio button” situation.  Each button
130 	 * will be associated with the same action, but with a different target
131 	 * value for that action.  Clicking on a particular button will activate
132 	 * the action with the target of that button, which will typically cause
133 	 * the action’s state to change to that value.  Since the action’s state
134 	 * is now equal to the target value of the button, the button will now
135 	 * be rendered as active (and the other buttons, with different targets,
136 	 * rendered inactive).
137 	 *
138 	 * Params:
139 	 *     targetValue = a #GVariant to set as the target value, or %NULL
140 	 *
141 	 * Since: 3.4
142 	 */
143 	public void setActionTargetValue(Variant targetValue)
144 	{
145 		gtk_actionable_set_action_target_value(getActionableStruct(), (targetValue is null) ? null : targetValue.getVariantStruct());
146 	}
147 
148 	/**
149 	 * Sets the action-name and associated string target value of an
150 	 * actionable widget.
151 	 *
152 	 * @detailed_action_name is a string in the format accepted by
153 	 * g_action_parse_detailed_name().
154 	 *
155 	 * (Note that prior to version 3.22.25,
156 	 * this function is only usable for actions with a simple "s" target, and
157 	 * @detailed_action_name must be of the form `"action::target"` where
158 	 * `action` is the action name and `target` is the string to use
159 	 * as the target.)
160 	 *
161 	 * Params:
162 	 *     detailedActionName = the detailed action name
163 	 *
164 	 * Since: 3.4
165 	 */
166 	public void setDetailedActionName(string detailedActionName)
167 	{
168 		gtk_actionable_set_detailed_action_name(getActionableStruct(), Str.toStringz(detailedActionName));
169 	}
170 }