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