1 /*
2  * This file is part of d-handy.
3  *
4  * d-handy 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  * d-handy 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 d-handy; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 module handy.ActionRow;
20 
21 private import glib.ConstructionException;
22 private import glib.Str;
23 private import gobject.ObjectG;
24 private import gtk.Widget;
25 private import handy.PreferencesRow;
26 private import handy.c.functions;
27 public  import handy.c.types;
28 
29 
30 /** */
31 public class ActionRow : PreferencesRow
32 {
33 	/** the main Gtk struct */
34 	protected HdyActionRow* hdyActionRow;
35 
36 	/** Get the main Gtk struct */
37 	public HdyActionRow* getActionRowStruct(bool transferOwnership = false)
38 	{
39 		if (transferOwnership)
40 			ownedRef = false;
41 		return hdyActionRow;
42 	}
43 
44 	/** the main Gtk struct as a void* */
45 	protected override void* getStruct()
46 	{
47 		return cast(void*)hdyActionRow;
48 	}
49 
50 	/**
51 	 * Sets our main struct and passes it to the parent class.
52 	 */
53 	public this (HdyActionRow* hdyActionRow, bool ownedRef = false)
54 	{
55 		this.hdyActionRow = hdyActionRow;
56 		super(cast(HdyPreferencesRow*)hdyActionRow, ownedRef);
57 	}
58 
59 	alias activate = Widget.activate;
60 
61 	/** */
62 	public void activate()
63 	{
64 		hdy_action_row_activate(hdyActionRow);
65 	}
66 
67 	/**
68 	 */
69 
70 	/** */
71 	public static GType getType()
72 	{
73 		return hdy_action_row_get_type();
74 	}
75 
76 	/**
77 	 * Creates a new #HdyActionRow.
78 	 *
79 	 * Returns: a new #HdyActionRow
80 	 *
81 	 * Since: 0.0.6
82 	 *
83 	 * Throws: ConstructionException GTK+ fails to create the object.
84 	 */
85 	public this()
86 	{
87 		auto p = hdy_action_row_new();
88 
89 		if(p is null)
90 		{
91 			throw new ConstructionException("null returned by new");
92 		}
93 
94 		this(cast(HdyActionRow*) p);
95 	}
96 
97 	/**
98 	 * Adds an action widget to @self.
99 	 *
100 	 * Params:
101 	 *     widget = the action widget
102 	 *
103 	 * Since: 0.0.6
104 	 */
105 	public void addAction(Widget widget)
106 	{
107 		hdy_action_row_add_action(hdyActionRow, (widget is null) ? null : widget.getWidgetStruct());
108 	}
109 
110 	/**
111 	 * Adds a prefix widget to @self.
112 	 *
113 	 * Params:
114 	 *     widget = the prefix widget
115 	 *
116 	 * Since: 0.0.6
117 	 */
118 	public void addPrefix(Widget widget)
119 	{
120 		hdy_action_row_add_prefix(hdyActionRow, (widget is null) ? null : widget.getWidgetStruct());
121 	}
122 
123 	/**
124 	 * Gets the widget activated when @self is activated.
125 	 *
126 	 * Returns: the widget activated when @self is
127 	 *     activated, or %NULL if none has been set.
128 	 *
129 	 * Since: 0.0.7
130 	 */
131 	public Widget getActivatableWidget()
132 	{
133 		auto p = hdy_action_row_get_activatable_widget(hdyActionRow);
134 
135 		if(p is null)
136 		{
137 			return null;
138 		}
139 
140 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
141 	}
142 
143 	/**
144 	 * Gets the icon name for @self.
145 	 *
146 	 * Returns: the icon name for @self.
147 	 *
148 	 * Since: 0.0.6
149 	 */
150 	public string getIconName()
151 	{
152 		return Str.toString(hdy_action_row_get_icon_name(hdyActionRow));
153 	}
154 
155 	/**
156 	 * Gets the subtitle for @self.
157 	 *
158 	 * Returns: the subtitle for @self.
159 	 *
160 	 * Since: 0.0.6
161 	 */
162 	public string getSubtitle()
163 	{
164 		return Str.toString(hdy_action_row_get_subtitle(hdyActionRow));
165 	}
166 
167 	/**
168 	 * Gets the title for @self.
169 	 *
170 	 * Returns: the title for @self.
171 	 *
172 	 * Since: 0.0.6
173 	 */
174 	public override string getTitle()
175 	{
176 		return Str.toString(hdy_action_row_get_title(hdyActionRow));
177 	}
178 
179 	/**
180 	 * Gets whether an embedded underline in the text of the title and subtitle
181 	 * labels indicates a mnemonic. See hdy_action_row_set_use_underline().
182 	 *
183 	 * Returns: %TRUE if an embedded underline in the title and subtitle labels
184 	 *     indicates the mnemonic accelerator keys.
185 	 *
186 	 * Since: 0.0.6
187 	 */
188 	public override bool getUseUnderline()
189 	{
190 		return hdy_action_row_get_use_underline(hdyActionRow) != 0;
191 	}
192 
193 	/**
194 	 * Sets the widget to activate when @self is activated, either by clicking
195 	 * on it, by calling hdy_action_row_activate(), or via mnemonics in the title or
196 	 * the subtitle. See the “use_underline” property to enable mnemonics.
197 	 *
198 	 * The target widget will be activated by emitting the
199 	 * GtkWidget::mnemonic-activate signal on it.
200 	 *
201 	 * Params:
202 	 *     widget = the target #GtkWidget, or %NULL to unset
203 	 *
204 	 * Since: 0.0.7
205 	 */
206 	public void setActivatableWidget(Widget widget)
207 	{
208 		hdy_action_row_set_activatable_widget(hdyActionRow, (widget is null) ? null : widget.getWidgetStruct());
209 	}
210 
211 	/**
212 	 * Sets the icon name for @self.
213 	 *
214 	 * Params:
215 	 *     iconName = the icon name
216 	 *
217 	 * Since: 0.0.6
218 	 */
219 	public void setIconName(string iconName)
220 	{
221 		hdy_action_row_set_icon_name(hdyActionRow, Str.toStringz(iconName));
222 	}
223 
224 	/**
225 	 * Sets the subtitle for @self.
226 	 *
227 	 * Params:
228 	 *     subtitle = the subtitle
229 	 *
230 	 * Since: 0.0.6
231 	 */
232 	public void setSubtitle(string subtitle)
233 	{
234 		hdy_action_row_set_subtitle(hdyActionRow, Str.toStringz(subtitle));
235 	}
236 
237 	/**
238 	 * Sets the title for @self.
239 	 *
240 	 * Params:
241 	 *     title = the title
242 	 *
243 	 * Since: 0.0.6
244 	 */
245 	public override void setTitle(string title)
246 	{
247 		hdy_action_row_set_title(hdyActionRow, Str.toStringz(title));
248 	}
249 
250 	/**
251 	 * If true, an underline in the text of the title and subtitle labels indicates
252 	 * the next character should be used for the mnemonic accelerator key.
253 	 *
254 	 * Params:
255 	 *     useUnderline = %TRUE if underlines in the text indicate mnemonics
256 	 *
257 	 * Since: 0.0.6
258 	 */
259 	public override void setUseUnderline(bool useUnderline)
260 	{
261 		hdy_action_row_set_use_underline(hdyActionRow, useUnderline);
262 	}
263 }